feat(costs): Stufe 2 — geschätzte Quellen (lokaler Strom, Cartesia, Notruf)
Lokales LLM: Call-Dauer gemessen -> Stromkosten je Job ((max-idle)*load*n/ 3.6e6*Preis(EUR/kWh)*usd_per_eur), Kategorie llm_local. Cartesia-TTS: Zeichen x cartesia_usd_per_char (tts). Notruf: pro Webhook-Alarm 0,20€*usd_per_eur (alert), nur Doku, nie Sperre. Helfer in costs.py; neue Settings (GPU-Watt/Last/ Strompreis/usd_per_eur/cartesia/alert). Statistik: "exakt vs. geschätzt" (Tooltip + Summenzeile, Kategorien tts/alert/llm_local). Tests: 318. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
66d6708f59
commit
d45e2c9ae3
8 changed files with 85 additions and 5 deletions
|
|
@ -688,11 +688,14 @@ class SQLiteStore(Store):
|
|||
" WHERE w.user_id = u.user_id), 0) AS total_web_searches,"
|
||||
" COALESCE((SELECT SUM(c.amount_usd) FROM cost_usage c"
|
||||
" WHERE c.user_id = u.user_id AND c.day LIKE ?), 0) AS month_cost_usd,"
|
||||
" COALESCE((SELECT SUM(ce.amount_usd) FROM cost_usage ce"
|
||||
" WHERE ce.user_id = u.user_id AND ce.day LIKE ?"
|
||||
" AND ce.category IN ('tts','alert','llm_local')), 0) AS month_cost_estimated_usd,"
|
||||
" COALESCE((SELECT SUM(uu.requests) FROM usage uu"
|
||||
" WHERE uu.user_id = u.user_id AND uu.day LIKE ?), 0) AS month_requests"
|
||||
" FROM usage u LEFT JOIN users usr ON usr.id = u.user_id"
|
||||
" GROUP BY u.user_id ORDER BY total_requests DESC",
|
||||
(month, month),
|
||||
(month, month, month),
|
||||
).fetchall()
|
||||
return [dict(r) for r in rows]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue