Repository navigation
feat(server): ✨ change AI settings from the status page - #135
Merged
Merged
Conversation
Issue #102, phase 3. The /quire-admin page gains an "AI settings" form, and PUT /quire-admin/v1/settings does the same for scripts. Six settings can change without editing .env or restarting: both AI time limits, the lookup sources, the rate limit and the two daily quotas. The value in force is the environment's if it sets one (shown locked on the page), else a value saved on the page (new server_settings table, migration ai_008), else the default. The orchestrator takes new values through apply_tunables, and raising the rate wakes requests already waiting under the old one. The AI router refreshes saved values before each request, re-reading the table at most every 30 s, so other processes follow; the saving process applies its change even if the read-back fails. Writes are all or nothing, bounded (time limits up to 3600 s, counts up to 1000000), and sit behind the same admin allowlist and same-origin guard as the probe. The form sends the values it showed, so only fields the admin edited count as changes and an old page cannot undo another admin's save. The model, provider address and API key stay environment-only.
vitofico
force-pushed
the
feat/admin-settings-panel
branch
from
September 28, 2026 13:53
6383734 to
6d3522e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #102.
Stacked on #123: the base is
feat/admin-status-page, so this diff shows only this change. Once #123 merges, this branch gets rebased ontomainand retargeted.The story
Phillip's AI setup failed on a CPU-only Ollama: the model needed longer than the 120-second limit, and looking books up on Wikipedia and Open Library made every prompt longer still. The fix was two lines in
.env,QUIRE_SERVER_AI_TIMEOUT_SandQUIRE_SERVER_AI_SOURCES=. Getting there meant finding the variables in the docs, editing a file on the server and recreating the container, because a plaindocker compose restartkeeps the old values. #123 added a page that shows what the server is running with. This lets the same page change the AI settings people actually tune, and they apply to the next request.What changes in practice
/quire-adminwith six settings: the insight time limit, the Reader Profile time limit, which sites to look books up on, generations per minute, generations per reader per day, and regenerations per reader per day. Press Save and the next AI request uses the new values, with no.envedit and no restart. Raising the insight limit to 285 seconds for a CPU model is typing 285 and pressing Save. The app follows on its own: it sizes its wait fromgeneration_timeout_sinGET /ai/v1/config, which now reports the value in force..envor a Kubernetes manifest sets one of the six, the page shows that field greyed out with "Set in the server's environment", because a value saved on the page would silently disagree with the file the server is managed from. Otherwise a saved value wins over the built-in default. Each saved value says who saved it and when, and a Use default button removes it.server_settingstable (migrationai_008on theaibranch), so they survive restarts and upgrades. The process that saves applies the change at once. Any other server process re-reads the table within 30 seconds, at its next AI request.PUT /quire-admin/v1/settingswith{"QUIRE_SERVER_AI_TIMEOUT_S": 285}, wherenullbrings back the default. It saves every change or none: one refused value and the answer is a 422 naming each variable and the rule it broke, for example "QUIRE_SERVER_AI_TIMEOUT_S must be a number of seconds above 0, at most 3600." The ceilings (3600 seconds, and 1000000 for the counts) only keep out typos; the environment has none.QUIRE_SERVER_ADMIN_USERS, and requests the browser marks as coming from another site are refused, so a page you visit cannot use your saved login to change settings..env, next to the provider address and the API key. The server decides at startup, from the model and the address, whether AI is configured at all, and stored insights are filed under the model that wrote them, so changing it at runtime needs that startup decision moved first, which is a change of its own. The Reader Profile time limit is added: the configuration guide says to raise it together with the insight limit, and a page that could change only one of the pair would invite the mismatch the guide warns about.What does not change
Until an admin saves something, every setting behaves exactly as before. A server without
QUIRE_SERVER_ADMIN_USERShas no page and no endpoint. With AI switched off there is no form, the endpoint answers 404, and the table is never read, since it lives on theaimigration branch like the other AI tables.GET /ai/v1/configkeeps its shape. The guide (docs/configuration.md, "Changing AI settings on the page"), the server README and the endpoint table indocs/sync-api.mddescribe the form and the precedence; each of the six settings' entries points to it.How it was checked
/ai/v1/configand the insight service, a second app instance picking it up, the environment winning and staying locked, all-or-nothing refusals,nullresetting, non-admins and cross-site requests refused on both the API and the form, AI switched off, the form saving only what changed, and a timeout message quoting the limit saved on the page, and a save that holds even when reading it back fails./ai/v1/configreading the environment, locked settings accepted, the form saving untouched fields, a zero time limit accepted, the timeout message quoting the startup value, and one for each review fix below), and each time a test failed.Infinityin the JSON body gave a 500; raising the rate left requests already waiting asleep for their old, longer wait; and a save could report success but not apply if reading it back failed right after the write.In short: the AI settings people actually tune can now be changed from the status page and apply to the next request, while anything the environment sets stays in charge.