[PR #10015] [CLOSED] fix: Ollama payload.py handling for num_predict and other options #22453

Closed
opened 2026-04-20 04:09:38 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/10015
Author: @ferret99gt
Created: 2/14/2025
Status: Closed

Base: devHead: fix-ollama-option-handling-in-payload


📝 Commits (5)

  • 2017856 Merge pull request #9945 from open-webui/dev
  • 19fecc1 Update apply_model_params_to_body_ollama with all valid Ollama options and castings
  • b77842a Update convert_messages_openai_to_ollama to use the "options" subdict instead of the parent payload.
  • ec8c460 Fix bug due to typo, added num_predict to the mapping, and remove two personal comments
  • 2b246f7 Whitespace fix

📊 Changes

1 file changed (+47 additions, -52 deletions)

View changed files

📝 backend/open_webui/utils/payload.py (+47 -52)

📄 Description

0.5.12

Pull Request Checklist

Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.

Before submitting, make sure you've checked the following:

  • Target branch: Please verify that the pull request targets the dev branch.
  • Description: Provide a concise description of the changes made in this pull request.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: Have you updated relevant documentation Open WebUI Docs, or other documentation sources?
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Have you written and run sufficient tests for validating the changes?
  • Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
  • Prefix: To cleary categorize this pull request, prefix the pull request title, using one of the following:
    • BREAKING CHANGE: Significant changes that may affect compatibility
    • build: Changes that affect the build system or external dependencies
    • ci: Changes to our continuous integration processes or workflows
    • chore: Refactor, cleanup, or other non-functional code changes
    • docs: Documentation update or addition
    • feat: Introduces a new feature or enhancement to the codebase
    • fix: Bug fix or error correction
    • i18n: Internationalization or localization changes
    • perf: Performance improvement
    • refactor: Code restructuring for better maintainability, readability, or scalability
    • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)
    • test: Adding missing tests or correcting existing tests
    • WIP: Work in progress, a temporary label for incomplete or ongoing work

Changelog Entry

Description

  • Detailed in #9770 - Update payload.py to include all supported options and fix conversion from OpenAI format to Ollama format. Options are currently being set directly in the payload dict rather than the options sub-dict.

Changed

  • Updated apply_model_params_to_body_ollama with full list of Ollama options with proper casting, and bring it in line with apply_model_params_to_body_openai so they are consist.

Removed

  • Remove mapping of frequency_penalty to repeat_penalty. Ollama has frequency_penalty.

Fixed

  • Updated convert_payload_openai_to_ollama to set options in ollama_payload["options"] rather than ollama_payload directly. This was the core fix.
  • Ensure max_tokens (OpenAI) is remapped as num_predict (Ollama) and delete max_tokens afterwards (to stop Ollama error message)
  • Move the "system" prompt option from ollama_payload["options"] to ollama_payload and delete it from options (Per Ollama documentation, and to stop Ollama error message)

Additional Information

  • I do not know what part of the UI causes calls to apply_model_params_to_body_ollama, and have not tested it. All of my testing with chats in Open-Webui were going through convert_payload_openai_to_ollama. If someone can tell me when/how to call through apply_model_params_to_body_ollama I will test.
  • Please see [PR #12567] [MERGED] fix: Make Microsoft SSO work even when custom signing keys. #12475 (#9770)
  • In theory, it looks like Open-Webui stops setting repeat_penalty in calls to Ollama, which might change results as it shifts to using Ollama's frequency_penalty instead. However, because frequency_penalty was being set in the payload, not the options, it was not being used, and Ollama has been using frequency_penalty all along.

🔄 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/10015 **Author:** [@ferret99gt](https://github.com/ferret99gt) **Created:** 2/14/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix-ollama-option-handling-in-payload` --- ### 📝 Commits (5) - [`2017856`](https://github.com/open-webui/open-webui/commit/2017856791b666fac5f1c2f80a3bc7916439438b) Merge pull request #9945 from open-webui/dev - [`19fecc1`](https://github.com/open-webui/open-webui/commit/19fecc1ce5fe000e4af250d0d55219a9cf719473) Update apply_model_params_to_body_ollama with all valid Ollama options and castings - [`b77842a`](https://github.com/open-webui/open-webui/commit/b77842ab1c50bf99c66300020a7f59ae34b56d58) Update convert_messages_openai_to_ollama to use the "options" subdict instead of the parent payload. - [`ec8c460`](https://github.com/open-webui/open-webui/commit/ec8c4601a72f7633dc63a0bb29a2e57e8e50b00a) Fix bug due to typo, added num_predict to the mapping, and remove two personal comments - [`2b246f7`](https://github.com/open-webui/open-webui/commit/2b246f75c1e8ae3608e1d3fc7429d153a57d2be8) Whitespace fix ### 📊 Changes **1 file changed** (+47 additions, -52 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/payload.py` (+47 -52) </details> ### 📄 Description 0.5.12 # Pull Request Checklist ### Note to first-time contributors: Please open a discussion post in [Discussions](https://github.com/open-webui/open-webui/discussions) and describe your changes before submitting a pull request. **Before submitting, make sure you've checked the following:** - [X] **Target branch:** Please verify that the pull request targets the `dev` branch. - [X] **Description:** Provide a concise description of the changes made in this pull request. - [X] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [X] **Documentation:** Have you updated relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs), or other documentation sources? - [X] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [X] **Testing:** Have you written and run sufficient tests for validating the changes? - [X] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards? - [X] **Prefix:** To cleary categorize this pull request, prefix the pull request title, using one of the following: - **BREAKING CHANGE**: Significant changes that may affect compatibility - **build**: Changes that affect the build system or external dependencies - **ci**: Changes to our continuous integration processes or workflows - **chore**: Refactor, cleanup, or other non-functional code changes - **docs**: Documentation update or addition - **feat**: Introduces a new feature or enhancement to the codebase - **fix**: Bug fix or error correction - **i18n**: Internationalization or localization changes - **perf**: Performance improvement - **refactor**: Code restructuring for better maintainability, readability, or scalability - **style**: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.) - **test**: Adding missing tests or correcting existing tests - **WIP**: Work in progress, a temporary label for incomplete or ongoing work # Changelog Entry ### Description - Detailed in #9770 - Update payload.py to include all supported options and fix conversion from OpenAI format to Ollama format. Options are currently being set directly in the payload dict rather than the options sub-dict. ### Changed - Updated apply_model_params_to_body_ollama with full list of Ollama options with proper casting, and bring it in line with apply_model_params_to_body_openai so they are consist. ### Removed - Remove mapping of frequency_penalty to repeat_penalty. Ollama has frequency_penalty. ### Fixed - Updated convert_payload_openai_to_ollama to set options in ollama_payload["options"] rather than ollama_payload directly. This was the core fix. - Ensure max_tokens (OpenAI) is remapped as num_predict (Ollama) and delete max_tokens afterwards (to stop Ollama error message) - Move the "system" prompt option from ollama_payload["options"] to ollama_payload and delete it from options (Per Ollama documentation, and to stop Ollama error message) --- ### Additional Information - I do not know what part of the UI causes calls to apply_model_params_to_body_ollama, and have not tested it. All of my testing with chats in Open-Webui were going through convert_payload_openai_to_ollama. If someone can tell me when/how to call through apply_model_params_to_body_ollama I will test. - Please see #9770 - In theory, it looks like Open-Webui stops setting repeat_penalty in calls to Ollama, which might change results as it shifts to using Ollama's frequency_penalty instead. However, because frequency_penalty was being set in the payload, not the options, it was not being used, and Ollama has been using frequency_penalty all along. --- <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-20 04:09:38 -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#22453