Interface for getting chat completions from an AI model with conversation memory.
Namespace: Radzen
Assembly: Radzen.Blazor.dll
public interface IAIChatServiceRemoves old conversation sessions based on age.
public abstract void CleanupOldSessions(int maxAgeHours)
| Type | Name | Description |
|---|---|---|
| int | maxAgeHours | Maximum age in hours for sessions to keep. |
Clears the conversation history for a specific session.
public abstract void ClearSession(string sessionId)
| Type | Name | Description |
|---|---|---|
| string | sessionId | The session ID to clear. |
Gets all active conversation sessions.
public abstract IEnumerable<ConversationSession> GetActiveSessions()
| Type | Description |
|---|---|
| IEnumerable<ConversationSession> | A list of active conversation sessions. |
Streams chat completion responses from the AI model asynchronously with conversation memory.
public abstract IAsyncEnumerable<string> GetCompletionsAsync(string userInput, string sessionId, Threading.CancellationToken cancellationToken, string model, string systemPrompt, double? temperature, int? maxTokens, string endpoint, string proxy, string apiKey, string apiKeyHeader)
| Type | Name | Description |
|---|---|---|
| string | userInput | The user's input message to send to the AI model. |
| string | sessionId | Optional session ID to maintain conversation context. If null, a new session will be created. |
| Threading.CancellationToken | cancellationToken | A cancellation token that can be used to cancel the operation. |
| string | model | Optional model name to override the configured model. |
| string | systemPrompt | Optional system prompt to override the configured system prompt. |
| double? | temperature | Optional temperature to override the configured temperature. |
| int? | maxTokens | Optional maximum tokens to override the configured max tokens. |
| string | endpoint | Optional endpoint URL to override the configured endpoint. |
| string | proxy | Optional proxy URL to override the configured proxy. |
| string | apiKey | Optional API key to override the configured API key. |
| string | apiKeyHeader | Optional API key header name to override the configured header. |
| Type | Description |
|---|---|
| IAsyncEnumerable<string> | An async enumerable that yields streaming response chunks from the AI model. |
Gets or creates a conversation session.
public abstract ConversationSession GetOrCreateSession(string sessionId)
| Type | Name | Description |
|---|---|---|
| string | sessionId | The session ID. If null, a new session will be created. |
| Type | Description |
|---|---|
| ConversationSession | The conversation session. |