IAIChatService Interface

Interface for getting chat completions from an AI model with conversation memory.

Namespace: Radzen

Assembly: Radzen.Blazor.dll

Syntax

public interface IAIChatService

Methods

CleanupOldSessionslink

Removes old conversation sessions based on age.

Declaration
public abstract void CleanupOldSessions(int maxAgeHours)
Parameters
Type Name Description
int maxAgeHours Maximum age in hours for sessions to keep.

ClearSessionlink

Clears the conversation history for a specific session.

Declaration
public abstract void ClearSession(string sessionId)
Parameters
Type Name Description
string sessionId The session ID to clear.

GetActiveSessionslink

Gets all active conversation sessions.

Declaration
public abstract IEnumerable<ConversationSession> GetActiveSessions()
Returns
Type Description
IEnumerable<ConversationSession>A list of active conversation sessions.

GetCompletionsAsynclink

Streams chat completion responses from the AI model asynchronously with conversation memory.

Declaration
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)
Parameters
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.
Returns
Type Description
IAsyncEnumerable<string>An async enumerable that yields streaming response chunks from the AI model.

GetOrCreateSessionlink

Gets or creates a conversation session.

Declaration
public abstract ConversationSession GetOrCreateSession(string sessionId)
Parameters
Type Name Description
string sessionId The session ID. If null, a new session will be created.
Returns
Type Description
ConversationSessionThe conversation session.
In This Article
An error has occurred. This app may no longer respond until reloaded. Reload 🗙