Erstmal Deaktiviert
This commit is contained in:
@@ -112,11 +112,11 @@
|
||||
|
||||
<Color x:Key="ModuleAiControlZeiterfassungNavigationHeaderColor">#FF5C1919</Color>
|
||||
<Color x:Key="ModuleAiControlZeiterfassungNavigationContentColor">#FF993B3B</Color>
|
||||
<Color x:Key="ModuleAiControlZeiterfassungNavigationContentColor2">#FF5C1919</Color>
|
||||
<Color x:Key="ModuleAiControlZeiterfassungNavigationContentColor2">#FF893535</Color>
|
||||
|
||||
<Color x:Key="ModuleAiControlSupportConceptNavigationHeaderColor">#FF5C1919</Color>
|
||||
<Color x:Key="ModuleAiControlSupportConceptNavigationContentColor">#FF993B3B</Color>
|
||||
<Color x:Key="ModuleAiControlSupportConceptNavigationContentColor2">#FF5C1919</Color>
|
||||
<Color x:Key="ModuleAiControlSupportConceptNavigationContentColor2">#FF893535</Color>
|
||||
|
||||
<Color x:Key="ModuleAiControlCustomerNavigationHeaderColor">#FF19485C</Color>
|
||||
<Color x:Key="ModuleAiControlCustomerNavigationContentColor">#FF3B7799</Color>
|
||||
|
||||
@@ -21,7 +21,6 @@ using BS.Shared.DataContracts;
|
||||
using BS.Shared.DataContracts.Compact;
|
||||
using BS.Shared.DataContracts.Feature.AI;
|
||||
using BS.Shared.Extensions;
|
||||
using Microsoft.ML.Tokenizers;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace BeWo.Service.Plugins
|
||||
@@ -309,7 +308,10 @@ namespace BeWo.Service.Plugins
|
||||
};
|
||||
|
||||
// Check Token Size
|
||||
checkTokenSize(conv.Messages, configModelName);
|
||||
if(!checkTokenSize(conv.Messages, configModelName))
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
// Updated
|
||||
conv.Updated = DateTime.Now;
|
||||
@@ -360,28 +362,30 @@ namespace BeWo.Service.Plugins
|
||||
return new AiConversationMessageDC[] { user_msg_dc, assi_msg_dc };
|
||||
}
|
||||
|
||||
private void checkTokenSize(IList<AiConversationMessage> messages, string configModelName)
|
||||
private bool checkTokenSize(IList<AiConversationMessage> messages, string configModelName)
|
||||
{
|
||||
Tokenizer tokenizer = TiktokenTokenizer.CreateForModel(configModelName);
|
||||
|
||||
int tokens = countChatTokens(messages, tokenizer);
|
||||
return true;
|
||||
//Tokenizer tokenizer = TiktokenTokenizer.CreateForModel(configModelName);
|
||||
|
||||
//int tokens = countChatTokens(messages, tokenizer);
|
||||
}
|
||||
|
||||
private int countChatTokens(IList<AiConversationMessage> messages, Tokenizer tokenizer)
|
||||
{
|
||||
int tokensPerMessage = 4; // OpenAI Overhead
|
||||
int tokensPerReply = 2;
|
||||
//private int countChatTokens(IList<AiConversationMessage> messages, Tokenizer tokenizer)
|
||||
//{
|
||||
// int tokensPerMessage = 4; // OpenAI Overhead
|
||||
// int tokensPerReply = 2;
|
||||
|
||||
int total = 0;
|
||||
// int total = 0;
|
||||
|
||||
foreach (var msg in messages)
|
||||
{
|
||||
total += tokensPerMessage;
|
||||
total += tokenizer.CountTokens(msg.Role.ToString());
|
||||
total += tokenizer.CountTokens(msg.Message);
|
||||
}
|
||||
// foreach (var msg in messages)
|
||||
// {
|
||||
// total += tokensPerMessage;
|
||||
// total += tokenizer.CountTokens(msg.Role.ToString());
|
||||
// total += tokenizer.CountTokens(msg.Message);
|
||||
// }
|
||||
|
||||
return total + tokensPerReply;
|
||||
}
|
||||
// return total + tokensPerReply;
|
||||
//}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user