fix llm cost for gpt4.1 (#2172)

This commit is contained in:
Shuchang Zheng
2025-04-16 15:32:51 -07:00
committed by GitHub
parent e28f769010
commit 3154a9ce10
3 changed files with 348 additions and 65 deletions

View File

@@ -160,7 +160,7 @@ class LLMAPIHandlerFactory:
try:
llm_cost = litellm.completion_cost(completion_response=response)
except Exception as e:
LOG.exception("Failed to calculate LLM cost", error=str(e))
LOG.debug("Failed to calculate LLM cost", error=str(e), exc_info=True)
llm_cost = 0
prompt_tokens = response.get("usage", {}).get("prompt_tokens", 0)
completion_tokens = response.get("usage", {}).get("completion_tokens", 0)
@@ -350,7 +350,7 @@ class LLMAPIHandlerFactory:
try:
llm_cost = litellm.completion_cost(completion_response=response)
except Exception as e:
LOG.exception("Failed to calculate LLM cost", error=str(e))
LOG.debug("Failed to calculate LLM cost", error=str(e), exc_info=True)
llm_cost = 0
prompt_tokens = response.get("usage", {}).get("prompt_tokens", 0)
completion_tokens = response.get("usage", {}).get("completion_tokens", 0)