fix cost calculation
This commit is contained in:
parent
aef830deba
commit
80df2555fe
|
|
@ -42,7 +42,8 @@ public class TokenStatistics : ITokenStatistics
|
|||
var settings = settingsService.GetSetting(stats.Provider, _model);
|
||||
|
||||
var deltaPromptCost = stats.PromptCount / 1000f * settings.PromptCost;
|
||||
var deltaCompletionCost = stats.CompletionCount / 1000 * settings.CompletionCost;
|
||||
var deltaCompletionCost = stats.CompletionCount / 1000f * settings.CompletionCost;
|
||||
var deltaTotal = deltaPromptCost + deltaCompletionCost;
|
||||
_promptCost += deltaPromptCost;
|
||||
_completionCost += deltaCompletionCost;
|
||||
|
||||
|
|
@ -55,10 +56,10 @@ public class TokenStatistics : ITokenStatistics
|
|||
|
||||
// Total cost
|
||||
var total_cost = float.Parse(stat.GetState("llm_total_cost", "0"));
|
||||
total_cost += Cost;
|
||||
total_cost += deltaTotal;
|
||||
stat.SetState("llm_total_cost", total_cost, isNeedVersion: false, source: StateSource.Application);
|
||||
|
||||
|
||||
// Save stats
|
||||
var globalStats = _services.GetRequiredService<IBotSharpStatsService>();
|
||||
var body = new BotSharpStatsInput
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue