mirror of
https://github.com/open-webui/open-webui.git
synced 2026-06-03 07:24:59 -05:00
[PR #20344] [CLOSED] fix: workspace models returning "Model not found" error #25577
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/20344
Author: @Classic298
Created: 1/3/2026
Status: ❌ Closed
Base:
dev← Head:fix-db📝 Commits (1)
6a17ceefix📊 Changes
2 files changed (+6 additions, -0 deletions)
View changed files
📝
backend/open_webui/routers/ollama.py(+3 -0)📝
backend/open_webui/routers/openai.py(+3 -0)📄 Description
Problem
Workspace models (custom models created via Workspace > Models) were returning "Model not found" (404) errors when attempting to chat with them.
https://github.com/open-webui/open-webui/issues/20340
Root Cause
When the generate_chat_completion functions in openai.py and ollama.py are called internally from chat.py (not via HTTP), the db parameter defaults to a Depends(get_session) object rather than an actual Session. This Depends object is truthy, so get_db_context attempted to use it as a session, causing Models.get_model_by_id to fail silently and return None.
With model_info being None, the base_model_id resolution was skipped, and the workspace model ID was passed directly to the API instead of its underlying base model.
Solution
Added a check in both openai.py and ollama.py to verify that db is an actual Session instance before using it. If not, db is set to None so get_db_context creates a fresh session.
Changes
@tjbck
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.