Skip to main content
Namespace: Numa.Services
Related Interfaces: IChatService.cs

Fields

Field NameTypeDescription
_aoaiEndpointUriAzure OpenAI endpoint
_aoaiKeyAzureKeyCredentialAzure OpenAI key
_aaisEndpointUriAzure AI Search endpoint
_aaisKeyAzureKeyCredentialAzure AI Search key
_aoaiClientAzureOpenAIClientAzure OpenAI client

Constructor

public ChatService( string azureOpenAiEndpoint, string azureOpenAiKey, string azureAiSearchEndpoint, string azureAiSearchKey )
{
    _aoaiEndpoint = new Uri( azureOpenAiEndpoint );
    _aoaiKey = new AzureKeyCredential( azureOpenAiKey );
    _aaisEndpoint = new Uri( azureAiSearchEndpoint );
    _aaisKey = new AzureKeyCredential( azureAiSearchKey );
    _aoaiClient = new AzureOpenAIClient( _aoaiEndpoint, _aoaiKey );
}

Properties

ChatService does not have any properties.

Methods

Method NameDescriptionParametersReturn Type
GetChatClientGets a ChatClient for a specific model deployment in Azure OpenAIstringChatClient
GetChatOptionsBuilds a ChatCompletionOptions object to set MaxOutputTokenCount, Temperature, IndexName, TopNDocuments, and QueryTypestring,int,int,floatChatCompletionOptions
GetChatMessagesBuilds a list of ChatMessage to provide system prompt & previous message contextstring,List<Message>,intList<ChatMessage>
GetTitleForNewConversationGenerates a 3-5 word title for a conversationstring,stringTask<string>

IChatService.cs

using Numa.Models;
using OpenAI.Chat;

namespace Numa.Interfaces
{
    public interface IChatService
    {
        ChatClient GetChatClient( string deploymentName );
        ChatCompletionOptions GetChatOptions( string indexName, int topN, int maxTokens, float temp );
        List<ChatMessage> GetChatMessages( string systemPrompt, List<Message> currentChatMessages, int numMessages );
        Task<string> GetTitleForNewConversation( string inputMessage, string deploymentName );
    }
}