Package com.tnsai.intelligence.rag
Class RAGPipeline
java.lang.Object
com.tnsai.intelligence.rag.RAGPipeline
Orchestrates the full RAG flow: preprocess query, retrieve, rerank, format context.
The pipeline executes these phases in order:
- Preprocess — optional query transformation (e.g., expansion, reformulation)
- Retrieve — delegates to the configured
RAGStrategy - Rerank — optional reranking of retrieved documents
- Format — converts documents into a context string for LLM injection
Each phase is pluggable via builder methods. The default pipeline performs retrieval with identity preprocessing, no reranking, and simple numbered formatting.
Thread-safe if the underlying strategy and operators are thread-safe.
- Since:
- 0.2.4
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic RAGPipeline.Builderbuilder(RAGStrategy strategy) Creates a new builder for constructing a pipeline.Returns the default context used when none is specified.Executes the full RAG pipeline and returns the formatted context string.execute(String query, RAGContext context) Executes the full RAG pipeline with a custom context and returns the formatted context string.retrieveDocuments(String query, RAGContext context) Executes the pipeline and returns the raw retrieved documents (after reranking).strategy()Returns the strategy used by this pipeline.
-
Method Details
-
execute
Executes the full RAG pipeline and returns the formatted context string.- Parameters:
query- the user query- Returns:
- the formatted context string ready for LLM injection
-
execute
Executes the full RAG pipeline with a custom context and returns the formatted context string.- Parameters:
query- the user querycontext- retrieval parameters- Returns:
- the formatted context string ready for LLM injection
-
retrieveDocuments
Executes the pipeline and returns the raw retrieved documents (after reranking).- Parameters:
query- the user querycontext- retrieval parameters- Returns:
- the retrieved and optionally reranked documents
-
strategy
Returns the strategy used by this pipeline.- Returns:
- the RAG strategy
-
defaultContext
Returns the default context used when none is specified.- Returns:
- the default RAG context
-
builder
Creates a new builder for constructing a pipeline.- Parameters:
strategy- the retrieval strategy to use- Returns:
- a new builder
-