[PR #21176] [CLOSED] fix: respect API stream parameter over model settings #41590

Closed
opened 2026-04-25 13:46:32 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/21176
Author: @konradzamojski
Created: 2/5/2026
Status: Closed

Base: devHead: fix/api-stream-parameter-priority


📝 Commits (10+)

📊 Changes

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

View changed files

📝 backend/open_webui/main.py (+2 -1)

📄 Description

Contributor License Agreement

I agree to the contributor license agreement.


Description

This PR fixes a regression introduced by commit f138be9 (issue #19154) where the stream parameter sent in API requests is always overridden by the model's stream_response setting.

Problem

While #19154 correctly ensured that model settings are applied, it unconditionally overwrites the stream parameter from API requests, breaking:

  • OpenAI API compatibility
  • LangChain integration (streaming=True/False ignored)
  • Per-request streaming control for any API client

Solution

The fix checks if stream exists in form_data before applying the model default:

# Before (always overwrites):
if model_info_params.get("stream_response") is not None:
    form_data["stream"] = model_info_params.get("stream_response")

# After (respects API parameter):
if "stream" not in form_data and model_info_params.get("stream_response") is not None:
    form_data["stream"] = model_info_params.get("stream_response")

Changes

  • Modified backend/open_webui/main.py line 1628
  • Added check for existing stream parameter before applying model default
  • Added clarifying comment

Impact

  • Maintains #19154 fix - model setting still works as default
  • Fixes regression - API parameter now has priority
  • OpenAI API compatible - respects stream parameter per-request
  • Enables LangChain - streaming=True/False now works
  • 100% backward compatible - no breaking changes

Testing

I have personally tested ALL changes in this PR

How I tested it:

  1. Deployed OpenWebUI 0.7.2 with the fix applied
  2. Tested via curl with different stream parameter combinations
  3. Verified LangChain integration with both streaming=True and streaming=False
  4. Confirmed model settings work as default when no API parameter provided

Test Results:

Test Case API Param Model Setting Expected Result
1 stream: false true No streaming (JSON) Pass
2 stream: true false Streaming (SSE) Pass
3 not provided false No streaming Pass
4 not provided true Streaming Pass

All scenarios tested and verified working correctly.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Regression fix
  • API compatibility improvement

Checklist


🔄 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/21176 **Author:** [@konradzamojski](https://github.com/konradzamojski) **Created:** 2/5/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix/api-stream-parameter-priority` --- ### 📝 Commits (10+) - [`fe6783c`](https://github.com/open-webui/open-webui/commit/fe6783c16699911c7be17392596d579333fb110c) Merge pull request #19030 from open-webui/dev - [`fc05e0a`](https://github.com/open-webui/open-webui/commit/fc05e0a6c5d39da60b603b4d520f800d6e36f748) Merge pull request #19405 from open-webui/dev - [`e3faec6`](https://github.com/open-webui/open-webui/commit/e3faec62c58e3a83d89aa3df539feacefa125e0c) Merge pull request #19416 from open-webui/dev - [`9899293`](https://github.com/open-webui/open-webui/commit/9899293f050ad50ae12024cbebee7e018acd851e) Merge pull request #19448 from open-webui/dev - [`140605e`](https://github.com/open-webui/open-webui/commit/140605e660b8186a7d5c79fb3be6ffb147a2f498) Merge pull request #19462 from open-webui/dev - [`6f1486f`](https://github.com/open-webui/open-webui/commit/6f1486ffd0cb288d0e21f41845361924e0d742b3) Merge pull request #19466 from open-webui/dev - [`d95f533`](https://github.com/open-webui/open-webui/commit/d95f533214e3fe5beb5e41ec1f349940bc4c7043) Merge pull request #19729 from open-webui/dev - [`a727153`](https://github.com/open-webui/open-webui/commit/a7271532f8a38da46785afcaa7e65f9a45e7d753) 0.6.43 (#20093) - [`6adde20`](https://github.com/open-webui/open-webui/commit/6adde203cd292a9e3af9c64a2ae36b603fed096a) Merge pull request #20394 from open-webui/dev - [`f9b0534`](https://github.com/open-webui/open-webui/commit/f9b0534e0c442631d1cb7205169588b9b6204179) Merge pull request #20522 from open-webui/dev ### 📊 Changes **1 file changed** (+2 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/main.py` (+2 -1) </details> ### 📄 Description ## Contributor License Agreement I agree to the contributor license agreement. --- ## Description This PR fixes a regression introduced by commit f138be9 (issue #19154) where the `stream` parameter sent in API requests is always overridden by the model's `stream_response` setting. ## Problem While #19154 correctly ensured that model settings are applied, it unconditionally overwrites the `stream` parameter from API requests, breaking: - OpenAI API compatibility - LangChain integration (`streaming=True/False` ignored) - Per-request streaming control for any API client ## Solution The fix checks if `stream` exists in `form_data` before applying the model default: ```python # Before (always overwrites): if model_info_params.get("stream_response") is not None: form_data["stream"] = model_info_params.get("stream_response") # After (respects API parameter): if "stream" not in form_data and model_info_params.get("stream_response") is not None: form_data["stream"] = model_info_params.get("stream_response") ``` ## Changes - Modified `backend/open_webui/main.py` line 1628 - Added check for existing `stream` parameter before applying model default - Added clarifying comment ## Impact - ✅ **Maintains #19154 fix** - model setting still works as default - ✅ **Fixes regression** - API parameter now has priority - ✅ **OpenAI API compatible** - respects stream parameter per-request - ✅ **Enables LangChain** - `streaming=True/False` now works - ✅ **100% backward compatible** - no breaking changes ## Testing ✅ I have **personally tested ALL changes** in this PR ### How I tested it: 1. Deployed OpenWebUI 0.7.2 with the fix applied 2. Tested via curl with different stream parameter combinations 3. Verified LangChain integration with both streaming=True and streaming=False 4. Confirmed model settings work as default when no API parameter provided ### Test Results: | Test Case | API Param | Model Setting | Expected | Result | |-----------|-----------|---------------|----------|---------| | 1 | `stream: false` | true | No streaming (JSON) | ✅ Pass | | 2 | `stream: true` | false | Streaming (SSE) | ✅ Pass | | 3 | not provided | `false` | No streaming | ✅ Pass | | 4 | not provided | `true` | Streaming | ✅ Pass | All scenarios tested and verified working correctly. ## Related Issues - Resolves: #21162 - Related: #19154 (original issue) - Improves: OpenAI API compatibility ## Type of Change - [x] Bug fix (non-breaking change which fixes an issue) - [x] Regression fix - [x] API compatibility improvement ## Checklist - [x] Code follows project style guidelines - [x] Changes tested thoroughly (all 4 scenarios) - [x] No breaking changes - [x] Backward compatible - [x] Maintains fix from #19154 - [x] Improves OpenAI API compatibility - [x] I have personally tested all changes - [x] Provided test evidence above --- <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 13:46:32 -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#41590