minor change
This commit is contained in:
parent
ba12125a1e
commit
bdc1529686
|
|
@ -6,7 +6,7 @@ public class TokenStatsModel
|
|||
public string Model { get; set; }
|
||||
public string Prompt { get; set; }
|
||||
public int PromptCount { get; set; }
|
||||
public int CachedTokenCount { get; set; }
|
||||
public int CachedPromptCount { get; set; }
|
||||
public int CompletionCount { get; set; }
|
||||
public AgentLlmConfig LlmConfig { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ public class TokenStatistics : ITokenStatistics
|
|||
var settingsService = _services.GetRequiredService<ILlmProviderService>();
|
||||
var settings = settingsService.GetSetting(stats.Provider, _model);
|
||||
|
||||
var deltaPromptCost = (stats.PromptCount - stats.CachedTokenCount) / 1000f * settings.PromptCost;
|
||||
var deltaCachedPromptCost = stats.CachedTokenCount / 1000f * (settings.AdditionalCost?.CachedPromptCost ?? 0f);
|
||||
var deltaPromptCost = (stats.PromptCount - stats.CachedPromptCount) / 1000f * settings.PromptCost;
|
||||
var deltaCachedPromptCost = stats.CachedPromptCount / 1000f * (settings.AdditionalCost?.CachedPromptCost ?? 0f);
|
||||
var deltaCompletionCost = stats.CompletionCount / 1000f * settings.CompletionCost;
|
||||
|
||||
var deltaTotal = deltaPromptCost + deltaCachedPromptCost + deltaCompletionCost;
|
||||
|
|
@ -55,8 +55,8 @@ public class TokenStatistics : ITokenStatistics
|
|||
stat.SetState("prompt_total", stats.PromptCount + inputCount, isNeedVersion: false, source: StateSource.Application);
|
||||
var outputCount = int.Parse(stat.GetState("completion_total", "0"));
|
||||
stat.SetState("completion_total", stats.CompletionCount + outputCount, isNeedVersion: false, source: StateSource.Application);
|
||||
var cachedCount = int.Parse(stat.GetState("cached_token_total", "0"));
|
||||
stat.SetState("cached_token_total", stats.CachedTokenCount + cachedCount, isNeedVersion: false, source: StateSource.Application);
|
||||
var cachedCount = int.Parse(stat.GetState("cached_prompt_total", "0"));
|
||||
stat.SetState("cached_prompt_total", stats.CachedPromptCount + cachedCount, isNeedVersion: false, source: StateSource.Application);
|
||||
|
||||
// Total cost
|
||||
var total_cost = float.Parse(stat.GetState("llm_total_cost", "0"));
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public class ChatCompletionProvider : IChatCompletion
|
|||
Provider = Provider,
|
||||
Model = _model,
|
||||
PromptCount = response.Value?.Usage?.InputTokenCount ?? 0,
|
||||
CachedTokenCount = response.Value?.Usage?.InputTokenDetails?.CachedTokenCount ?? 0,
|
||||
CachedPromptCount = response.Value?.Usage?.InputTokenDetails?.CachedTokenCount ?? 0,
|
||||
CompletionCount = response.Value?.Usage?.OutputTokenCount ?? 0
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue