mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-10 19:53:48 +00:00
Kept the reported token usage as one record on the answer
This commit is contained in:
4 files changed
+77
-58
No files matched your search
@@ -455,18 +455,7 @@ public sealed class AIJobService(SettingsManager settingsManager, MessageBus mes
|
||||
aiText.IsStreaming = true;
|
||||
aiText.Text += contentStreamChunk;
|
||||
aiText.Sources.MergeSources(contentStreamChunk.Sources);
|
||||
|
||||
//
|
||||
// Keep what the provider says the request cost. It arrives on one line of the stream,
|
||||
// usually the last one, and only where a provider reports it at all -- so a chunk
|
||||
// without it leaves what was reported before alone.
|
||||
//
|
||||
if (contentStreamChunk.Usage.IsKnown)
|
||||
{
|
||||
aiText.ReportedPromptTokens = contentStreamChunk.Usage.PromptTokens;
|
||||
aiText.ReportedCompletionTokens = contentStreamChunk.Usage.CompletionTokens;
|
||||
aiText.ReportedForModel = state.ChatGenerationRequest.ProviderSettings.Model.Id;
|
||||
}
|
||||
aiText.RecordReportedUsage(contentStreamChunk.Usage, state.ChatGenerationRequest.ProviderSettings.Model.Id);
|
||||
|
||||
if (state.Snapshot.Status is not AIJobStatus.RUNNING)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user