Skip to content

Commit 7b8e574

Browse files
committed
serve from /props endpoint
1 parent 91df8bf commit 7b8e574

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

tools/server/public/index.html.gz

-26 Bytes
Binary file not shown.

tools/server/server.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3862,11 +3862,6 @@ int main(int argc, char ** argv) {
38623862
res_ok(res, health);
38633863
};
38643864

3865-
const auto handle_default_config = [&](const httplib::Request &, httplib::Response & res) {
3866-
// default client-side config
3867-
res_ok(res, ctx_server.default_client_config);
3868-
};
3869-
38703865
const auto handle_slots = [&](const httplib::Request & req, httplib::Response & res) {
38713866
if (!params.endpoint_slots) {
38723867
res_error(res, format_error_response("This server does not support slots endpoint. Start it with `--slots`", ERROR_TYPE_NOT_SUPPORTED));
@@ -4134,6 +4129,7 @@ int main(int argc, char ** argv) {
41344129
{ "bos_token", common_token_to_piece(ctx_server.ctx, llama_vocab_bos(ctx_server.vocab), /* special= */ true)},
41354130
{ "eos_token", common_token_to_piece(ctx_server.ctx, llama_vocab_eos(ctx_server.vocab), /* special= */ true)},
41364131
{ "build_info", build_info },
4132+
{ "default_client_config", ctx_server.default_client_config },
41374133
};
41384134
if (ctx_server.params_base.use_jinja) {
41394135
if (auto tool_use_src = common_chat_templates_source(ctx_server.chat_templates.get(), "tool_use")) {
@@ -4846,7 +4842,6 @@ int main(int argc, char ** argv) {
48464842

48474843
// register API routes
48484844
svr->Get ("/health", handle_health); // public endpoint (no API key check)
4849-
svr->Get ("/defaultConfig.json", handle_default_config); // public endpoint (no API key check)
48504845
svr->Get ("/metrics", handle_metrics);
48514846
svr->Get ("/props", handle_props);
48524847
svr->Post("/props", handle_props_change);

tools/server/webui/src/components/SettingDialog.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ export default function SettingDialog({
276276
show: boolean;
277277
onClose: () => void;
278278
}) {
279-
const { config, saveConfig } = useAppContext();
279+
const { config, saveConfig, serverProps } = useAppContext();
280280
const [sectionIdx, setSectionIdx] = useState(0);
281281

282282
// clone the config object to prevent direct mutation
@@ -287,15 +287,22 @@ export default function SettingDialog({
287287

288288
// get default client settings
289289
useEffect(() => {
290-
StorageUtils.setDefaultConfig().then((wasChanged: boolean) => {
291-
if (wasChanged) {
292-
console.log('Setting default config');
290+
if (
291+
serverProps &&
292+
serverProps.default_client_config &&
293+
Object.keys(serverProps.default_client_config).length > 0
294+
) {
295+
if (StorageUtils.setDefaultConfig(serverProps.default_client_config)) {
296+
console.log(
297+
'Setting default config:',
298+
serverProps.default_client_config
299+
);
293300
const newConfig = StorageUtils.getConfig();
294301
saveConfig(newConfig);
295302
setLocalConfig(JSON.parse(JSON.stringify(newConfig)));
296303
}
297-
});
298-
}, []);
304+
}
305+
}, [serverProps, saveConfig]);
299306

300307
const resetConfig = async () => {
301308
if (await showConfirm('Are you sure you want to reset all settings?')) {

tools/server/webui/src/utils/storage.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,9 @@ const StorageUtils = {
213213
localStorage.setItem('theme', theme);
214214
}
215215
},
216-
async setDefaultConfig(): Promise<boolean> {
216+
setDefaultConfig(defaultConfig: object | null | undefined): boolean {
217217
if (localStorage.getItem('config') === null) {
218218
try {
219-
const response = await fetch('/defaultConfig.json');
220-
const defaultConfig = await response.json();
221-
222219
// Ensure there still is no config when we overwrite it
223220
if (localStorage.getItem('config') === null) {
224221
localStorage.setItem('config', JSON.stringify(defaultConfig));

tools/server/webui/src/utils/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,6 @@ export interface LlamaCppServerProps {
134134
vision: boolean;
135135
audio: boolean;
136136
};
137+
default_client_config: Record<string, number | string | boolean>;
137138
// TODO: support params
138139
}

0 commit comments

Comments
 (0)