浏览代码

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)
ferret99gt 2 月之前
父节点
当前提交
fa885c3346
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      backend/open_webui/utils/payload.py

+ 5 - 2
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:
 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 = {
     name_differences = {
         "max_tokens": "num_predict",
         "max_tokens": "num_predict",
     }
     }
-
+    
     for key, value in name_differences.items():
     for key, value in name_differences.items():
         if (param := params.get(key, None)) is not None:
         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 = [
     opts = [
         "temperature",
         "temperature",