Add appSettings field and CreateQuestionAsync method

The `ChatService` class now includes a private readonly field `appSettings`, initialized via the constructor. A new method `CreateQuestionAsync` has been added to handle question creation asynchronously, leveraging chat history. Additionally, a comment has been updated for clarity regarding chunk limitations.
This commit is contained in:
Marco Minerva
2025-01-10 11:15:18 +01:00
parent b5c7ea57c3
commit 9700051942
@@ -9,6 +9,8 @@ namespace SqlDatabaseVectorSearch.Services;
public class ChatService(IChatCompletionService chatCompletionService, TokenizerService tokenizerService, HybridCache cache, IOptions<AppSettings> appSettingsOptions)
{
private readonly AppSettings appSettings = appSettingsOptions.Value;
public async Task<string> CreateQuestionAsync(Guid conversationId, string question)
{
var chat = await GetChatHistoryAsync(conversationId);
@@ -62,7 +64,7 @@ public class ChatService(IChatCompletionService chatCompletionService, Tokenizer
var tokenCount = tokenizerService.CountTokens(text);
if (tokenCount > tokensAvailable)
{
// There isn't enough space to add the text.
// There isn't enough space to add the chunks.
break;
}