Spaces:
Running
Running
Commit History
7 days ago
-
Add a monthly AI budget and pause at the workspace spend limit
When the Anthropic workspace reached its spend limit, every AI question failed with "Something went wrong while answering", and each one still sent a request to the API. The app knew only a daily budget. A monthly budget (ANKI_CATALOG_MONTHLY_BUDGET_USD, default $18) now stops AI search before a $20 workspace limit. If the API still reports the limit, the app pauses AI search until the time in the error and sends no more requests. In all three cases visitors see "AI search is paused until <date> because its budget is used up", and the question log records the outcome "budget". The admin usage page shows the month's spend and the pause.365ef12
-
Switch the AI model with one setting: ANKI_CATALOG_MODEL=sonnet or haiku
Prices and the refusal fallback come from a table of known models (Sonnet 5.5, Haiku 5.5 with its long-prompt price tier), so the daily budget stays right after a switch. Fixes the Sonnet 5.5 cache-read price ($0.10, was $0.20). The question log stores which model answered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G7oQmr9fvktpV3N8KDbTXi624ec75 -
Log every AI question with its trace for analysis on /admin/questions
The usage database gets a questions table (kept 90 days, no IP): question, outcome, tokens, cost, duration, answer and each model round with its tool calls. The admin pages list them, show one in detail and export all as JSON Lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G7oQmr9fvktpV3N8KDbTXi478b59a -
Keep usage stats in memory and save them as a whole file to the /data volume
A Storage Bucket mounted at /data cannot update a file in place, as SQLite does, but it can replace a whole file. The counters now live in an in-memory SQLite database restored from /data/usage.sqlite3 on start and written back every ANKI_CATALOG_USAGE_SAVE_SECONDS and on shutdown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G7oQmr9fvktpV3N8KDbTXie4d5515 -
Add a private usage statistics page
/admin/usage (HTTP Basic, password ANKI_CATALOG_ADMIN_TOKEN) shows keyword searches, AI questions by outcome, AI spend and page views per UTC day. Counters live in SQLite under /data when the Space has persistent storage, else in memory; the daily budget resumes from the persisted spend. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G7oQmr9fvktpV3N8KDbTXidca4399