From fa885c33465433bbdb31cd90390a43d6f3617630 Mon Sep 17 00:00:00 2001 From: ferret99gt Date: Wed, 19 Feb 2025 09:25:47 -0500 Subject: [PATCH] Update remapping logic We copy the params from from the original key to the new key, then delete it. This is to ensure Ollama only gets valid options. (Add a comment as well) --- backend/open_webui/utils/payload.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/utils/payload.py b/backend/open_webui/utils/payload.py index d2a55ce19..0628b8552 100644 --- a/backend/open_webui/utils/payload.py +++ b/backend/open_webui/utils/payload.py @@ -66,13 +66,16 @@ def apply_model_params_to_body_openai(params: dict, form_data: dict) -> dict: def apply_model_params_to_body_ollama(params: dict, form_data: dict) -> dict: + # Convert OpenAI parameter names to Ollama parameter names if needed. name_differences = { "max_tokens": "num_predict", } - + for key, value in name_differences.items(): if (param := params.get(key, None)) is not None: - form_data[value] = param + # Copy the parameter to new name then delete it, to prevent Ollama warning of invalid option provided + params[value] = params[key] + del params[key] opts = [ "temperature",