Note: pipeline
Context
The pipeline module (src/attune_rag/pipeline.py) is a lightweight, LLM-agnostic RAG pipeline. It coordinates four optional components — a corpus, a retriever, a query expander, and a reranker — to retrieve grounding context, assemble a prompt, and optionally call an LLM, all in a single method call.
Content
Two public types form the core of the module:
-
RagPipeline— accepts aCorpusProtocol, aRetrieverProtocol, an optionalQueryExpander, and an optionalLLMRerankerat construction time. Its two main methods are:run(query, k, prompt_variant)— retrieves up tokdocuments, assembles an augmented prompt, and returns aRagResultwithout calling an LLM.run_and_generate(query, provider, ...)— does the same, then calls the specifiedLLMProviderand returns(answer_str, RagResult).
-
RagResult— the dataclass returned by both methods. Key fields includeaugmented_prompt,citation(CitationRecord),confidence,fallback_used,elapsed_ms,context,claim_citations, andused_native_citations. When the retriever finds no grounding context,fallback_usedisTrueand the pipeline substitutesFALLBACK_PROMPT_TEMPLATE, which instructs the LLM not to invent APIs, workflow names, or CLI commands.
The prompt_variant parameter selects from the named templates in PROMPT_VARIANTS. The default variant is 'citation'.
Source files
src/attune_rag/pipeline.pysrc/attune_rag/__init__.py
Tags: pipeline, orchestration, rag, result