mirror of
https://github.com/jihe520/MathModelAgent.git
synced 2026-10-19 05:40:21 +08:00
22 lines
662 B
Python
22 lines
662 B
Python
from litellm.integrations.custom_logger import CustomLogger
|
|
import litellm
|
|
|
|
|
|
class AgentMetrics(CustomLogger):
|
|
#### ASYNC ####
|
|
|
|
async def async_log_success_event(self, kwargs, response_obj, start_time, end_time):
|
|
try:
|
|
# response_cost = kwargs.get("response_cost", 0)
|
|
# print("streaming response_cost", response_cost)
|
|
print("agent_name", kwargs["litellm_params"]["metadata"]["agent_name"])
|
|
except:
|
|
pass
|
|
|
|
async def async_log_failure_event(self, kwargs, response_obj, start_time, end_time):
|
|
print(f"On Async Failure")
|
|
|
|
|
|
# 全局指标收集器实例
|
|
agent_metrics = AgentMetrics()
|