diff options
Diffstat (limited to 'examples/server/public/completion.js')
-rw-r--r-- | examples/server/public/completion.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/examples/server/public/completion.js b/examples/server/public/completion.js index 835ce6e6..987b9a3b 100644 --- a/examples/server/public/completion.js +++ b/examples/server/public/completion.js @@ -21,6 +21,7 @@ let generation_settings = null; // export async function* llama(prompt, params = {}, config = {}) { let controller = config.controller; + const api_url = config.api_url || ""; if (!controller) { controller = new AbortController(); @@ -28,7 +29,7 @@ export async function* llama(prompt, params = {}, config = {}) { const completionParams = { ...paramDefaults, ...params, prompt }; - const response = await fetch("/completion", { + const response = await fetch(`${api_url}/completion`, { method: 'POST', body: JSON.stringify(completionParams), headers: { @@ -193,9 +194,10 @@ 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 () => { +export const llamaModelInfo = async (config = {}) => { if (!generation_settings) { - const props = await fetch("/props").then(r => r.json()); + const api_url = config.api_url || ""; + const props = await fetch(`${api_url}/props`).then(r => r.json()); generation_settings = props.default_generation_settings; } return generation_settings; |