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

405
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -9,14 +9,14 @@ packages = [{ include = "skyvern" }, { include = "alembic" }]
[tool.poetry.dependencies]
python = "^3.11,<3.12"
python-dotenv = "^1.0.0"
openai = "<1.68"
openai = ">=1.68.2"
sqlalchemy = {extras = ["mypy"], version = "^2.0.29"}
aiohttp = "^3.8.5"
python-multipart = "^0.0.6"
toml = "^0.10.2"
jinja2 = "^3.1.2"
uvicorn = {extras = ["standard"], version = "^0.24.0.post1"}
litellm = "^1.63.12"
litellm = "1.66.1"
playwright = "1.46.0"
pillow = "^10.1.0"
starlette-context = "^0.3.6"

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)