Spaces:
Running
Running
SilverElixir commited on
Commit ·
965ba13
1
Parent(s): 2ae6891
Count model attempts and failures in daily stats
Browse files- lumen_chat_state.py +4 -0
- lumen_commands.py +3 -1
- tests/test_bot_state.py +1 -1
lumen_chat_state.py
CHANGED
|
@@ -1000,6 +1000,10 @@ _STATS_FIELDS = (
|
|
| 1000 |
"all_failed",
|
| 1001 |
"fallbacks",
|
| 1002 |
"daily_limit_denials",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1003 |
)
|
| 1004 |
|
| 1005 |
|
|
|
|
| 1000 |
"all_failed",
|
| 1001 |
"fallbacks",
|
| 1002 |
"daily_limit_denials",
|
| 1003 |
+
# 08.10.2026: каждая попытка к модели и каждая пустая (исключение/пусто до
|
| 1004 |
+
# показа) — по ним считается реальный КПД маршрута, а не гадается по логам.
|
| 1005 |
+
"model_attempts",
|
| 1006 |
+
"model_failures",
|
| 1007 |
)
|
| 1008 |
|
| 1009 |
|
lumen_commands.py
CHANGED
|
@@ -668,7 +668,9 @@ async def cmd_stats(message: Message) -> None:
|
|
| 668 |
f"Сообщений получено: {_day_stats.get('messages_received', 0)}, ответов отправлено: {_day_stats.get('answers_sent', 0)}\n"
|
| 669 |
f"Все модели отказали: {_day_stats.get('all_failed', 0)}, "
|
| 670 |
f"переключений на резерв: {_day_stats.get('fallbacks', 0)}, "
|
| 671 |
-
f"отказов по лимиту: {_day_stats.get('daily_limit_denials', 0)}\n
|
|
|
|
|
|
|
| 672 |
f"<b>Gemini — запросов по моделям:</b>\n{gemini_text}\n\n"
|
| 673 |
f"<b>OpenRouter — запросов по моделям:</b>\n{or_text}\n\n"
|
| 674 |
f"<b>Groq — запросов по моделям:</b>\n{groq_text}\n\n"
|
|
|
|
| 668 |
f"Сообщений получено: {_day_stats.get('messages_received', 0)}, ответов отправлено: {_day_stats.get('answers_sent', 0)}\n"
|
| 669 |
f"Все модели отказали: {_day_stats.get('all_failed', 0)}, "
|
| 670 |
f"переключений на резерв: {_day_stats.get('fallbacks', 0)}, "
|
| 671 |
+
f"отказов по лимиту: {_day_stats.get('daily_limit_denials', 0)}\n"
|
| 672 |
+
f"Попыток к моделям: {_day_stats.get('model_attempts', 0)}, "
|
| 673 |
+
f"пустых: {_day_stats.get('model_failures', 0)}\n\n"
|
| 674 |
f"<b>Gemini — запросов по моделям:</b>\n{gemini_text}\n\n"
|
| 675 |
f"<b>OpenRouter — запросов по моделям:</b>\n{or_text}\n\n"
|
| 676 |
f"<b>Groq — запросов по моделям:</b>\n{groq_text}\n\n"
|
tests/test_bot_state.py
CHANGED
|
@@ -1806,7 +1806,7 @@ def test_stats_counters_reset_on_new_day():
|
|
| 1806 |
bot.GLOBAL_QUOTA["quota_day"] = "2020-01-01"
|
| 1807 |
lcs._last_quota_check_monotonic = time.monotonic() - bot._QUOTA_CHECK_THROTTLE_SEC - 10.0
|
| 1808 |
bot._reset_quota_if_new_day()
|
| 1809 |
-
assert bot._stats_entry() == {"messages_received": 0, "answers_sent": 0, "all_failed": 0, "fallbacks": 0, "daily_limit_denials": 0}
|
| 1810 |
finally:
|
| 1811 |
if had_stats:
|
| 1812 |
bot.GLOBAL_QUOTA["stats"] = old_stats
|
|
|
|
| 1806 |
bot.GLOBAL_QUOTA["quota_day"] = "2020-01-01"
|
| 1807 |
lcs._last_quota_check_monotonic = time.monotonic() - bot._QUOTA_CHECK_THROTTLE_SEC - 10.0
|
| 1808 |
bot._reset_quota_if_new_day()
|
| 1809 |
+
assert bot._stats_entry() == {"messages_received": 0, "answers_sent": 0, "all_failed": 0, "fallbacks": 0, "daily_limit_denials": 0, "model_attempts": 0, "model_failures": 0}
|
| 1810 |
finally:
|
| 1811 |
if had_stats:
|
| 1812 |
bot.GLOBAL_QUOTA["stats"] = old_stats
|