Skip to main content

Classic RAG

RAGPipeline is the deterministic v4 orchestration API. Each request retrieves documents, optionally reranks them, and sends the resulting context to the injected LLM.

Construct a pipeline

All constructor arguments are keyword-only. reranker and config are optional. The embeddings instance is retained as part of the configured component graph; the vector store normally uses the same instance.

Generate a structured response

The response is immutable and can be converted to transport-friendly data:
Successful classic generation records retrieval, optional reranking, and generation events. Timings are expressed in milliseconds.

Reranking

Install the local Hugging Face integration:
Reranking receives the question and retrieved Document values. The final ordered documents are both supplied to generation and returned as sources.

Ingest directories

Directory ingestion is explicit and separate from construction:
The vector store must provide add_documents(). Unsupported files and symlinks are reported as skips. Discovery, processing, and indexing failures are reported per file.

Stateless history

Pass history explicitly when the caller owns state:
Enable PipelineConfig(reformulate_queries=True) to rewrite follow-up questions before retrieval. The original question and history are preserved for final generation. See Query reformulation. For managed history scoped to one conversation, create a session. See Conversation history.

Streaming

Streaming yields text chunks. The structured event envelope currently belongs to non-streaming generate() responses.

Error boundaries

RAGLight validates empty questions and configuration before provider work where possible. Provider, retrieval, and generation exceptions remain visible to the application. The framework does not silently invent fallback answers.
Keep one configured pipeline and create separate sessions per conversation. Pipelines own components, not globally shared chat history.
Inject LangfuseTracer through tracer= for native stage-level traces. See Langfuse observability.