Merge branch 'SciSharp:master' into master

This commit is contained in:
hchen2020 2025-02-28 15:27:40 -06:00 committed by GitHub
commit 284c588df3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View file

@ -60,12 +60,13 @@ public class TokenStatistics : ITokenStatistics
stat.SetState("llm_total_cost", total_cost, isNeedVersion: false, source: StateSource.Application);
// Save stats
var agentId = message.CurrentAgentId ?? string.Empty;
var globalStats = _services.GetRequiredService<IBotSharpStatsService>();
var body = new BotSharpStatsInput
{
Metric = StatsMetric.AgentLlmCost,
Dimension = "agent",
DimRefVal = message.CurrentAgentId,
DimRefVal = agentId,
RecordTime = DateTime.UtcNow,
IntervalType = StatsInterval.Day,
Data = [
@ -75,7 +76,7 @@ public class TokenStatistics : ITokenStatistics
new StatsKeyValuePair("completion_cost_total", deltaCompletionCost)
]
};
globalStats.UpdateStats("global-llm-cost", body);
globalStats.UpdateStats($"global-llm-cost-{agentId}", body);
}
public void PrintStatistics()

View file

@ -25,17 +25,18 @@ public class GlobalStatsConversationHook : IContentGeneratingHook
// record agent call
var globalStats = _services.GetRequiredService<IBotSharpStatsService>();
var agentId = message.CurrentAgentId ?? string.Empty;
var body = new BotSharpStatsInput
{
Metric = StatsMetric.AgentCall,
Dimension = "agent",
DimRefVal = message.CurrentAgentId ?? string.Empty,
DimRefVal = agentId,
RecordTime = DateTime.UtcNow,
IntervalType = StatsInterval.Day,
Data = [
new StatsKeyValuePair("agent_call_count", 1)
]
};
globalStats.UpdateStats("global-agent-call", body);
globalStats.UpdateStats($"global-agent-call-{agentId}", body);
}
}