refactor: 清理 litellm 冗余代码并锁定依赖版本

This commit is contained in:
zl-q
2026-03-25 20:08:34 +08:00
parent 96fc4a1e77
commit b765b9e3e1
9 changed files with 54 additions and 71 deletions
-5
View File
@@ -1,5 +0,0 @@
from __future__ import annotations
from services.litellm.service import LiteLLMService
__all__ = ["LiteLLMService"]
@@ -0,0 +1,5 @@
from __future__ import annotations
from services.llm_pricing.service import LlmPricingService
__all__ = ["LlmPricingService"]
@@ -14,7 +14,7 @@ class PricingTier:
cache_hit_cost_per_token: float
class LiteLLMService:
class LlmPricingService:
_pricing_by_model: dict[str, tuple[PricingTier, ...]]
def __init__(self) -> None:
@@ -28,7 +28,6 @@ class LiteLLMService:
if not isinstance(model, dict):
continue
model_code = str(model.get("model_code", "")).strip().lower()
litellm_model = str(model.get("litellm_model", "")).strip().lower()
raw_tiers = model.get("pricing_tiers")
if not isinstance(raw_tiers, list) or not raw_tiers:
continue
@@ -56,8 +55,6 @@ class LiteLLMService:
)
if model_code:
pricing_by_model[model_code] = ordered_tiers
if litellm_model:
pricing_by_model[litellm_model] = ordered_tiers
return pricing_by_model
def calculate_cost(