[PR #22584] [CLOSED] fix: skip Ollama-only Advanced Parameters when forwarding to non-Ollama endpoints #42398

Closed
opened 2026-04-25 14:18:28 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/22584
Author: @NIK-TIGER-BILL
Created: 3/11/2026
Status: Closed

Base: mainHead: fix/ollama-params-leak-to-openai


📝 Commits (1)

  • a59e5b9 fix: skip Ollama-only params when forwarding to OpenAI-compatible endpoints

📊 Changes

1 file changed (+21 additions, -1 deletions)

View changed files

📝 backend/open_webui/utils/middleware.py (+21 -1)

📄 Description

Problem

Advanced Parameters like num_ctx, mirostat, mirostat_eta, num_batch, num_gpu, etc. are Ollama-specific. When a user sets them for an Ollama model, they are stored in params. Later, if any non-Ollama model is used in the same session (or the user has mixed models), these params land directly in the request body of the OpenAI-compatible endpoint, causing errors (fixes #22557):

litellm.llms.bedrock.chat.invoke_handler.py: '>' not supported between NoneType and int

Root cause

In utils/middleware.py, the else-branch for non-Ollama models does:

for key, value in params.items():
    if value is not None:
        form_data[key] = value   # ← no Ollama filter!

All params — including Ollama-only ones — are forwarded.

Fix

Define OLLAMA_ONLY_PARAMS (the set of keys only meaningful to Ollama's /api/chat options field) and skip them in the non-Ollama path:

OLLAMA_ONLY_PARAMS = {"mirostat", "mirostat_eta", "num_ctx", "num_batch", ...}

for key, value in params.items():
    if value is not None and key not in OLLAMA_ONLY_PARAMS:
        form_data[key] = value

Ollama models are unaffected — they still receive all params via form_data['options'].

Fixes #22557


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/22584 **Author:** [@NIK-TIGER-BILL](https://github.com/NIK-TIGER-BILL) **Created:** 3/11/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/ollama-params-leak-to-openai` --- ### 📝 Commits (1) - [`a59e5b9`](https://github.com/open-webui/open-webui/commit/a59e5b95da5a5385738702f05f0734105433ecc9) fix: skip Ollama-only params when forwarding to OpenAI-compatible endpoints ### 📊 Changes **1 file changed** (+21 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/middleware.py` (+21 -1) </details> ### 📄 Description ## Problem Advanced Parameters like `num_ctx`, `mirostat`, `mirostat_eta`, `num_batch`, `num_gpu`, etc. are Ollama-specific. When a user sets them for an Ollama model, they are stored in `params`. Later, if any non-Ollama model is used in the same session (or the user has mixed models), these params land directly in the request body of the OpenAI-compatible endpoint, causing errors (fixes #22557): ``` litellm.llms.bedrock.chat.invoke_handler.py: '>' not supported between NoneType and int ``` ## Root cause In `utils/middleware.py`, the `else`-branch for non-Ollama models does: ```python for key, value in params.items(): if value is not None: form_data[key] = value # ← no Ollama filter! ``` All params — including Ollama-only ones — are forwarded. ## Fix Define `OLLAMA_ONLY_PARAMS` (the set of keys only meaningful to Ollama's `/api/chat` `options` field) and skip them in the non-Ollama path: ```python OLLAMA_ONLY_PARAMS = {"mirostat", "mirostat_eta", "num_ctx", "num_batch", ...} for key, value in params.items(): if value is not None and key not in OLLAMA_ONLY_PARAMS: form_data[key] = value ``` Ollama models are unaffected — they still receive all params via `form_data['options']`. Fixes #22557 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-25 14:18:28 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#42398