Class RagServiceExtensions
Extension methods for AIService to enable RAG functionality. Follows the same Fluent API style as Mythosia.AI's WithFunction, WithSystemMessage, etc.
public static class RagServiceExtensions
- Inheritance
-
RagServiceExtensions
- Inherited Members
Methods
WithRag(IAIService, RagStore)
Enables RAG on this AIService using a pre-built RagStore. Use this to share a single index across multiple AIService instances.
public static RagEnabledService WithRag(this IAIService service, RagStore ragStore)
Parameters
serviceIAIServiceragStoreRagStore
Returns
Examples
var ragStore = await RagStore.BuildAsync(config => config
.AddDocuments("./knowledge-base/")
.UseOpenAIEmbedding(apiKey)
);
var claude = new AnthropicService(claudeKey, http).WithRag(ragStore);
var gpt = new OpenAIService(gptKey, http).WithRag(ragStore);
WithRag(IAIService, Action<RagBuilder>)
Enables RAG on this AIService with the specified configuration. Documents are loaded and indexed lazily on the first query.
public static RagEnabledService WithRag(this IAIService service, Action<RagBuilder> configure)
Parameters
serviceIAIServiceconfigureAction<RagBuilder>
Returns
Examples
var service = new AnthropicService(apiKey, httpClient)
.WithRag(rag => rag
.AddDocument("manual.pdf")
.AddDocument("policy.txt")
);
var response = await service.GetCompletionAsync("ํ๋ถ ์ ์ฑ
์ด ์ด๋ป๊ฒ ๋๋์?");