Webui/server config defaults#18028
Conversation
|
It work |
allozaur
left a comment
There was a problem hiding this comment.
Looking good on my end
|
Also, you need to re-generate the server docs via |
|
I will apply the optimizations and rebase / test |
ngxson
left a comment
There was a problem hiding this comment.
Can be merged once you update the docs 👍
Add CLI arguments --webui-config (inline JSON) and --webui-config-file (file path) to configure WebUI default settings from server side. Backend changes: - Parse JSON once in server_context::load_model() for performance - Cache parsed config in webui_settings member (zero overhead on /props) - Add proper error handling in router mode with try/catch - Expose webui_settings in /props endpoint for both router and child modes Frontend changes: - Add 14 configurable WebUI settings via parameter sync - Add tests for webui settings extraction - Fix subpath support with base path in API calls Addresses feedback from @ngxson and @ggerganov
2977afc to
f93fee0
Compare
|
Docs regenerated. Fun fact: llama-gen-docs initializes my GPU just to write markdown😂 |
|
By the way, this works great! Thank you for implementing this and helping me finally get it through! @mashdragon you will be glad to see this! If I find the time, I can write up an example for the webui readme (in a separate PR perhaps). |
|
@ServeurpersoCom this is not working for me. I verified that the props page has the correct settings and ensured that they actually change when set via the config file. But, the settings in the web UI do not match the props, nor does the web UI behave according to what is set in the props page. b7472 |
Your previous WebUI settings can override the server defaults. Server defaults only apply when you first visit the WebUI or after resetting settings. Else can you clear your browser's localStorage/indexedDB and retry ? |
|
There is a bug! "Reset to default" works, but defaults aren't applied on first visit after clearing browser storage. I'm working on a patch |
|
Yeah, I just tried "reset to default" and the code you gave me for Firefox. Neither worked. After I cleared all browser data it worked. While I am here:
|
|
|
RE 1: I am happy to write up a feature request, but after thinking about this, it seems like this feature needs to be implemented consistently with how this issue will be handled: #18129 (comment) (Misc. bug: Web-Frontend overrides sampling parameters from models preset in router mode), and l imagine that one will be treated with high priority. I am not a UI expert, but it seems like some elegant and consistent solution could apply to both cases. Perhaps it could work thus: for a given parameter, the server (either server config defaults or router config.ini) - IF set - is the source of truth unless the parameter is manually set in Web UI. Perhaps the Web UI could show the server-set values as "greyed-out," and when they are manually overridden, they would be shown as "normal." This requires no extra JSON fields, and the UI itself would provide information about where the parameter values are being set. RE "prohibiting overrides" for enterprise-like cases: perhaps that could be considered low priority and implemented later. RE 2: Apologies, but I do not see how that addresses my question 2 above regarding how to determine the actual list of settable parameters we can set in the JSON file. |
|
@jbone1313 What you're describing is exactly the design pattern we need for #18129 (sampling params override bug). Server values as source of truth (greyed in UI), with user overrides, and placeholder show the current backend config. Same architecture for both webui settings and sampling parameters. We all independently converged on this. I've been running shared llama.cpp servers for friends for a long time and wanted this exact behavior. Now deploying more and more at work: proper server governance is critical. |
* server/webui: add server-side WebUI config support Add CLI arguments --webui-config (inline JSON) and --webui-config-file (file path) to configure WebUI default settings from server side. Backend changes: - Parse JSON once in server_context::load_model() for performance - Cache parsed config in webui_settings member (zero overhead on /props) - Add proper error handling in router mode with try/catch - Expose webui_settings in /props endpoint for both router and child modes Frontend changes: - Add 14 configurable WebUI settings via parameter sync - Add tests for webui settings extraction - Fix subpath support with base path in API calls Addresses feedback from @ngxson and @ggerganov * server: address review feedback from ngxson * server: regenerate README with llama-gen-docs
* server/webui: add server-side WebUI config support Add CLI arguments --webui-config (inline JSON) and --webui-config-file (file path) to configure WebUI default settings from server side. Backend changes: - Parse JSON once in server_context::load_model() for performance - Cache parsed config in webui_settings member (zero overhead on /props) - Add proper error handling in router mode with try/catch - Expose webui_settings in /props endpoint for both router and child modes Frontend changes: - Add 14 configurable WebUI settings via parameter sync - Add tests for webui settings extraction - Fix subpath support with base path in API calls Addresses feedback from @ngxson and @ggerganov * server: address review feedback from ngxson * server: regenerate README with llama-gen-docs


Make sure to read the contributing guidelines before submitting a PR
server/webui: add CLI support for configuring WebUI defaults
Summary
Implements issue #17940: adds '--webui-config-file' CLI argument and 'LLAMA_WEBUI_CONFIG' environment variable to configure WebUI default settings from the server side.
Problem
WebUI settings are hardcoded in the frontend with no server-side configuration. This causes problems:
Example: Issue #17940 requests ability to set 'pasteLongTextToFileLen: 0' by default, but currently every user must manually configure this in every new browser session.
The TODO that guided this implementation
While exploring the codebase, I found this intentional placeholder in 'server-models.cpp' (lines 6-16):
This empty JSON was left by the original developers as a clear signal for where webui settings should go. This PR completes that TODO.
Backend Changes (C++)
What was added
1. CLI argument ('common/arg.cpp')
2. Environment variable ('server.cpp')
3. JSON parsing logic ('server.cpp')
4. Expose in /props ('server-models.cpp' + 'server-context.cpp')
How it works
The C++ backend is completely agnostic: it doesn't know what settings exist. It just:
This means adding new WebUI settings never requires C++ changes.
Frontend Changes (TypeScript)
What was added
1. API type ('types/api.d.ts')
2. Syncable parameters ('services/parameter-sync.ts')
3. Store integration ('stores/server.svelte.ts' + 'stores/settings.svelte.ts')
4. Tests ('parameter-sync.spec.ts')
Settings intentionally excluded
These are user-specific and should NOT be server-configurable:
Priority Order
Server operators set defaults, but users keep control:
This means:
Usage Examples
Config file
Environment variable
LLAMA_WEBUI_CONFIG='{"pasteLongTextToFileLen":0}' ./llama-serverBoth (env var overrides file)
LLAMA_WEBUI_CONFIG='{"pdfAsImage":true}' \ ./llama-server --webui-config-file webui-defaults.jsonCheck it works
curl http://localhost:8080/props | jq .webui_settingsTesting
Backend
Frontend
Backward Compatibility
No breaking changes:
What this enables
Now server operators can:
And adding new configurable settings only requires TypeScript changes: no C++ recompilation needed.
Fixes #17940