mirror of
https://github.com/marcominerva/SqlDatabaseVectorSearch.git
synced 2026-06-20 12:23:10 +00:00
Rename tokensAvailable to availableTokens for clarity
Updated variable names and references for improved readability and consistency in token calculations and checks.
This commit is contained in:
@@ -128,7 +128,7 @@ public class ChatService(IChatCompletionService chatCompletionService, Tokenizer
|
|||||||
|
|
||||||
""");
|
""");
|
||||||
|
|
||||||
var tokensAvailable = appSettings.MaxInputTokens
|
var availableTokens = appSettings.MaxInputTokens
|
||||||
- tokenizerService.CountChatCompletionTokens(chat[0].ToString()) // System prompt.
|
- tokenizerService.CountChatCompletionTokens(chat[0].ToString()) // System prompt.
|
||||||
- tokenizerService.CountChatCompletionTokens(prompt.ToString()) // Initial user prompt.
|
- tokenizerService.CountChatCompletionTokens(prompt.ToString()) // Initial user prompt.
|
||||||
- appSettings.MaxOutputTokens; // To ensure there is enough space for the answer.
|
- appSettings.MaxOutputTokens; // To ensure there is enough space for the answer.
|
||||||
@@ -138,7 +138,7 @@ public class ChatService(IChatCompletionService chatCompletionService, Tokenizer
|
|||||||
var text = $"---{Environment.NewLine}{chunk}";
|
var text = $"---{Environment.NewLine}{chunk}";
|
||||||
|
|
||||||
var tokenCount = tokenizerService.CountChatCompletionTokens(text);
|
var tokenCount = tokenizerService.CountChatCompletionTokens(text);
|
||||||
if (tokenCount > tokensAvailable)
|
if (tokenCount > availableTokens)
|
||||||
{
|
{
|
||||||
// There isn't enough space to add the current chunk.
|
// There isn't enough space to add the current chunk.
|
||||||
break;
|
break;
|
||||||
@@ -146,8 +146,8 @@ public class ChatService(IChatCompletionService chatCompletionService, Tokenizer
|
|||||||
|
|
||||||
prompt.Append(text);
|
prompt.Append(text);
|
||||||
|
|
||||||
tokensAvailable -= tokenCount;
|
availableTokens -= tokenCount;
|
||||||
if (tokensAvailable <= 0)
|
if (availableTokens <= 0)
|
||||||
{
|
{
|
||||||
// There isn't enough space to add more chunks.
|
// There isn't enough space to add more chunks.
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user