计算单次调用成本
(task_type: str, model: str, input_tokens: int, output_tokens: int)
| 158 | |
| 159 | |
| 160 | def calculate_cost(task_type: str, model: str, input_tokens: int, output_tokens: int) -> float: |
| 161 | """计算单次调用成本""" |
| 162 | pricing = MODEL_PRICES.get(model, {"input": 0, "output": 0}) |
| 163 | return (input_tokens * pricing["input"] + output_tokens * pricing["output"]) / 1000 |
| 164 | |
| 165 | |
| 166 | def get_usage_stats( |