This commit is contained in:
geekan 2024-02-07 16:23:54 +08:00
parent b56f1bfedd
commit 4370060802
3 changed files with 6 additions and 2 deletions

View file

@ -41,6 +41,10 @@ class CostManager(BaseModel):
"""
self.total_prompt_tokens += prompt_tokens
self.total_completion_tokens += completion_tokens
if model not in TOKEN_COSTS:
logger.warning(f"Model {model} not found in TOKEN_COSTS.")
return
cost = (
prompt_tokens * TOKEN_COSTS[model]["prompt"] + completion_tokens * TOKEN_COSTS[model]["completion"]
) / 1000