[PR #21175] [CLOSED] fix: respect API stream parameter over model settings #49007

Closed
opened 2026-04-30 01:18:30 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

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

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


📝 Commits (1)

  • ed568c4 fix: respect API stream parameter over model settings

📊 Changes

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

View changed files

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

📄 Description

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

Tested all scenarios:

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

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/21175 **Author:** [@konradzamojski](https://github.com/konradzamojski) **Created:** 2/5/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/api-stream-parameter-priority` --- ### 📝 Commits (1) - [`ed568c4`](https://github.com/open-webui/open-webui/commit/ed568c485dba120c39b459daf82ebdc6c393de54) fix: respect API stream parameter over model settings ### 📊 Changes **1 file changed** (+2 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/main.py` (+2 -1) </details> ### 📄 Description ## 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 Tested all scenarios: | Test Case | API Param | Model Setting | Expected | Result | |-----------|-----------|---------------|----------|---------| | 1 | `stream: false` | any | No streaming | ✅ Pass | | 2 | `stream: true` | any | Streaming | ✅ Pass | | 3 | not provided | `false` | No streaming | ✅ Pass | | 4 | not provided | `true` | Streaming | ✅ Pass | ## 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 --- <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-30 01:18:30 -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#49007