Class AgenticRagExtensions
Extension methods for enabling Agentic RAG on AIService. Registers the RAG pipeline as a callable tool within the agent's ReAct loop.
public static class AgenticRagExtensions
- Inheritance
-
AgenticRagExtensions
- Inherited Members
Methods
WithAgenticRag<TService>(TService, RagStore, string, string?)
Registers the RAG pipeline as a search tool for use with RunAgentAsync.
In Agentic RAG mode the agent autonomously decides when to search and what query to use. The RagStore's QueryRewriter is intentionally bypassed for this tool โ the agent itself is responsible for formulating a clear, self-contained query.
The configured retrieval strategy (vector-only or hybrid) and pipeline options of the RagStore are respected as-is.
public static TService WithAgenticRag<TService>(this TService service, RagStore ragStore, string toolName = "search_documents", string? toolDescription = null) where TService : IAIService, IFunctionRegisterable
Parameters
serviceTServiceThe AI service to register the RAG tool on.
ragStoreRagStoreA pre-built RAG store containing the indexed documents.
toolNamestringThe function name exposed to the LLM. Defaults to
search_documents. Must be unique among all registered functions on the service.toolDescriptionstringCustom description for the tool. When null a sensible default is used. A good description is critical: it controls when the agent decides to invoke this tool.
Returns
- TService
The same service instance for fluent chaining.
Type Parameters
TServiceA concrete AI service that implements both IAIService and IFunctionRegisterable (e.g.
AnthropicService,OpenAIService).
Examples
var ragStore = await RagStore.BuildAsync(cfg => cfg
.AddDocument("manual.pdf")
.UseOpenAIEmbedding(apiKey));
var answer = await new AnthropicService(apiKey, http)
.WithAgenticRag(ragStore)
.RunAgentAsync("ํ๋ถ ์ ์ฑ
์ ์์ฝํด ์ค");