[PR #24661] [CLOSED] fix: fallback to first available model when model_id is missing or empty #115072

Closed
opened 2026-05-18 16:00:46 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/24661
Author: @yahyasaqban-lab
Created: 5/13/2026
Status: Closed

Base: mainHead: fix/auto-title-empty-model


📝 Commits (1)

  • 304d97a fix: fallback to first available model when model_id is missing or empty

📊 Changes

1 file changed (+56 additions, -32 deletions)

View changed files

📝 backend/open_webui/routers/tasks.py (+56 -32)

📄 Description

Summary

Fixes auto-title generation when the frontend sends an empty or missing model_id. Instead of returning a 404 error, the backend gracefully falls back to the first available model.

Problem

When users click the "regenerate title" icon (stars icon) on a chat that doesn't have a model assigned, the frontend sends model: "" to /api/title/completions. The backend then returns:

Model  was not found

This started happening because the frontend fallback logic at ChatItem.svelte line models.at(0) ?? ''''' evaluates to empty string when no models exist in the chat data.

Fix

Applied to all task endpoints in tasks.py:

  • If model_id is empty or missing and there are no models, still return 404
  • If model_id is not found but models exist, fall back to the first available model
  • Applied consistently across all 7 task endpoints (title, follow-up, query, image_prompt, emoji, tags, MOA)

Closes #24604


🔄 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/24661 **Author:** [@yahyasaqban-lab](https://github.com/yahyasaqban-lab) **Created:** 5/13/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/auto-title-empty-model` --- ### 📝 Commits (1) - [`304d97a`](https://github.com/open-webui/open-webui/commit/304d97a9a217e2d1bfff6eac4df1116e5fbea6a6) fix: fallback to first available model when model_id is missing or empty ### 📊 Changes **1 file changed** (+56 additions, -32 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/routers/tasks.py` (+56 -32) </details> ### 📄 Description ## Summary Fixes auto-title generation when the frontend sends an empty or missing model_id. Instead of returning a 404 error, the backend gracefully falls back to the first available model. ## Problem When users click the "regenerate title" icon (stars icon) on a chat that doesn't have a model assigned, the frontend sends `model: ""` to `/api/title/completions`. The backend then returns: ``` Model was not found ``` This started happening because the frontend fallback logic at `ChatItem.svelte` line `models.at(0) ?? '''''` evaluates to empty string when no models exist in the chat data. ## Fix Applied to all task endpoints in `tasks.py`: - If `model_id` is empty or missing and there are no models, still return 404 - If `model_id` is not found but models exist, fall back to the first available model - Applied consistently across all 7 task endpoints (title, follow-up, query, image_prompt, emoji, tags, MOA) ## Related Closes #24604 --- <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-05-18 16:00:46 -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#115072