fix(дозаполнение): зайкины строки считаются по прайсу дипсика, чужие подписки не трогаем
Дозаполнение повторяет живой расчёт: пока нет цены подписки — прайс дипсика того дня. Запасной путь работает только для моделей подписки z.ai: подписке Claude чужая мерка не годится, там цену по-прежнему взять неоткуда. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RuEU1u9Rz24zmoy9TuvWc2
This commit is contained in:
@@ -44,12 +44,21 @@ def _price_row(row: dict, rate: float | None) -> dict | None:
|
||||
cost_rub, basis = 0.0, "usd"
|
||||
elif cost_usd is not None and rate:
|
||||
cost_rub, basis = round(cost_usd * rate, 4), "usd"
|
||||
elif api_usd == 0:
|
||||
cost_rub, basis = 0.0, "api"
|
||||
elif api_usd is not None and rate:
|
||||
# Тот же запасной путь, что и в живом расчёте: пока цена подписки не задана,
|
||||
# себестоимость зайки берём по её тарифам и говорим об этом основанием.
|
||||
cost_rub, basis = round(api_usd * rate, 4), "api"
|
||||
elif pricing.compute_credits(usage, row["model"] or "") is not None:
|
||||
# Тот же запасной путь, что и в живом расчёте, и ТОЛЬКО для моделей подписки:
|
||||
# чужой прайс годится как мерка для зайки, но не для подписки Claude — там цену
|
||||
# по-прежнему взять неоткуда. Пока цена подписки не задана, работу зайки оцениваем
|
||||
# по прайсу дипсика того дня — сопоставимая работа за те же токены
|
||||
# (распоряжение Хозяина 10.09.2026). Её собственные тарифы остаются справкой.
|
||||
reference = pricing.deepseek_reference(row["ts"])
|
||||
as_deepseek = pricing.compute_cost(usage, reference or "",
|
||||
pricing.tariff_for(row["ts"]), at=row["ts"])
|
||||
if as_deepseek == 0:
|
||||
cost_rub, basis = 0.0, "deepseek"
|
||||
elif as_deepseek is not None and rate:
|
||||
cost_rub, basis = round(as_deepseek * rate, 4), "deepseek"
|
||||
else:
|
||||
return None
|
||||
else:
|
||||
return None
|
||||
return {"cost_rub": cost_rub, "price_rub": round(cost_rub * markup, 4),
|
||||
@@ -66,7 +75,7 @@ def main() -> int:
|
||||
rate = billing.usd_rub_rate()
|
||||
with db._conn() as conn:
|
||||
rows = [dict(r) for r in conn.execute(
|
||||
"SELECT id, username, model, input_tokens, cache_tokens, output_tokens, "
|
||||
"SELECT id, ts, username, model, input_tokens, cache_tokens, output_tokens, "
|
||||
"cost_usd, cost_rub, price_rub FROM llm_usage "
|
||||
"WHERE price_rub IS NULL AND output_tokens IS NOT NULL ORDER BY id")]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user