MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / calculate_cost

Function calculate_cost

experiments/token_cost/token_usage_tracker.py:160–163  ·  view source on GitHub ↗

计算单次调用成本

(task_type: str, model: str, input_tokens: int, output_tokens: int)

Source from the content-addressed store, hash-verified

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

Callers 1

get_usage_statsFunction · 0.85

Calls 1

getMethod · 0.80

Tested by

no test coverage detected