ChatClientGenerator<T>
Models & Types ยท AiDotNet.RetrievalAugmentedGeneration.Generators
A real external-LLM generator for RAG. Bridges the RAG IGenerator contract onto the
AiDotNet agentic IChatClient connectors (OpenAI, Azure OpenAI, Anthropic, Cohere,
Gemini, Mistral, Ollama), so retrieval-augmented answers are produced by a genuine chat model instead
of the local-LSTM NeuralGenerator or the StubGenerator. Supports token streaming via
IStreamingGenerator.
Inheritance: GeneratorBase<T> โ ChatClientGenerator<T>
Implements: IStreamingGenerator<T>
For Beginners
give it a chat-model connection and it writes answers with that model.
Generate returns the whole answer; GenerateStreamAsync
streams it as it is produced.
How It Works
This is the linchpin that lets the previously-stubbed LLM-powered RAG components (HyDE, LLM query
expansion, LLM/Cohere reranking, LLM context compression, multi-query retrieval) run against a real
model: construct one of these over any configured IChatClient and inject it.
Constructors
| Constructor | Summary |
|---|---|
ChatClientGenerator(IChatClient<T> chatClient, string systemPrompt, double? temperature, int? maxOutputTokens, int maxContextTokens, int maxGenerationTokens) |
Creates a generator over an existing chat-model connector. |
Methods
| Method | Summary |
|---|---|
IAsyncEnumerable<string> GenerateStreamAsync(string prompt, CancellationToken cancellationToken) |