From: Eric Zhang Date: Thu, 18 Jul 2024 10:43:49 +0000 (+0800) Subject: server: use relative routes for static files in new UI (#8552) X-Git-Tag: upstream/0.0.4488~1073 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=0d2c7321e9678e91b760ebe57f0d063856bb018b;p=pkg%2Fggml%2Fsources%2Fllama.cpp server: use relative routes for static files in new UI (#8552) * server: public: fix api_url on non-index pages * server: public: use relative routes for static files in new UI --- diff --git a/examples/server/public/completion.js b/examples/server/public/completion.js index 987b9a3b..36818f76 100644 --- a/examples/server/public/completion.js +++ b/examples/server/public/completion.js @@ -21,7 +21,7 @@ let generation_settings = null; // export async function* llama(prompt, params = {}, config = {}) { let controller = config.controller; - const api_url = config.api_url || ""; + const api_url = config.api_url?.replace(/\/+$/, '') || ""; if (!controller) { controller = new AbortController(); @@ -196,7 +196,7 @@ export const llamaComplete = async (params, controller, callback) => { // Get the model info from the server. This is useful for getting the context window and so on. export const llamaModelInfo = async (config = {}) => { if (!generation_settings) { - const api_url = config.api_url || ""; + const api_url = config.api_url?.replace(/\/+$/, '') || ""; const props = await fetch(`${api_url}/props`).then(r => r.json()); generation_settings = props.default_generation_settings; } diff --git a/examples/server/public/index-new.html b/examples/server/public/index-new.html index 5513e912..bf2b0a3f 100644 --- a/examples/server/public/index-new.html +++ b/examples/server/public/index-new.html @@ -14,10 +14,10 @@