Merge pull request #905 from iceljc/master
add agent id in resource key
This commit is contained in:
commit
5c90f2cd8a
|
|
@ -60,12 +60,13 @@ public class TokenStatistics : ITokenStatistics
|
||||||
stat.SetState("llm_total_cost", total_cost, isNeedVersion: false, source: StateSource.Application);
|
stat.SetState("llm_total_cost", total_cost, isNeedVersion: false, source: StateSource.Application);
|
||||||
|
|
||||||
// Save stats
|
// Save stats
|
||||||
|
var agentId = message.CurrentAgentId ?? string.Empty;
|
||||||
var globalStats = _services.GetRequiredService<IBotSharpStatsService>();
|
var globalStats = _services.GetRequiredService<IBotSharpStatsService>();
|
||||||
var body = new BotSharpStatsInput
|
var body = new BotSharpStatsInput
|
||||||
{
|
{
|
||||||
Metric = StatsMetric.AgentLlmCost,
|
Metric = StatsMetric.AgentLlmCost,
|
||||||
Dimension = "agent",
|
Dimension = "agent",
|
||||||
DimRefVal = message.CurrentAgentId,
|
DimRefVal = agentId,
|
||||||
RecordTime = DateTime.UtcNow,
|
RecordTime = DateTime.UtcNow,
|
||||||
IntervalType = StatsInterval.Day,
|
IntervalType = StatsInterval.Day,
|
||||||
Data = [
|
Data = [
|
||||||
|
|
@ -75,7 +76,7 @@ public class TokenStatistics : ITokenStatistics
|
||||||
new StatsKeyValuePair("completion_cost_total", deltaCompletionCost)
|
new StatsKeyValuePair("completion_cost_total", deltaCompletionCost)
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
globalStats.UpdateStats("global-llm-cost", body);
|
globalStats.UpdateStats($"global-llm-cost-{agentId}", body);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PrintStatistics()
|
public void PrintStatistics()
|
||||||
|
|
|
||||||
|
|
@ -25,17 +25,18 @@ public class GlobalStatsConversationHook : IContentGeneratingHook
|
||||||
// record agent call
|
// record agent call
|
||||||
var globalStats = _services.GetRequiredService<IBotSharpStatsService>();
|
var globalStats = _services.GetRequiredService<IBotSharpStatsService>();
|
||||||
|
|
||||||
|
var agentId = message.CurrentAgentId ?? string.Empty;
|
||||||
var body = new BotSharpStatsInput
|
var body = new BotSharpStatsInput
|
||||||
{
|
{
|
||||||
Metric = StatsMetric.AgentCall,
|
Metric = StatsMetric.AgentCall,
|
||||||
Dimension = "agent",
|
Dimension = "agent",
|
||||||
DimRefVal = message.CurrentAgentId ?? string.Empty,
|
DimRefVal = agentId,
|
||||||
RecordTime = DateTime.UtcNow,
|
RecordTime = DateTime.UtcNow,
|
||||||
IntervalType = StatsInterval.Day,
|
IntervalType = StatsInterval.Day,
|
||||||
Data = [
|
Data = [
|
||||||
new StatsKeyValuePair("agent_call_count", 1)
|
new StatsKeyValuePair("agent_call_count", 1)
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
globalStats.UpdateStats("global-agent-call", body);
|
globalStats.UpdateStats($"global-agent-call-{agentId}", body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue