mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-18 04:37:59 +00:00
Added the exact token count where the provider reports it
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c95cc5bacc
commit
0aa3b23b81
21 files changed
+598
-7
No files matched your search
@@ -456,6 +456,18 @@ public sealed class AIJobService(SettingsManager settingsManager, MessageBus mes
|
||||
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;
|
||||
}
|
||||
|
||||
if (state.Snapshot.Status is not AIJobStatus.RUNNING)
|
||||
{
|
||||
state.Snapshot = state.Snapshot with
|
||||
|
||||
Reference in new issue
Block a user