[PR #22316] [CLOSED] fix: make prompt optional in /api/generate for Ollama model unload #42238

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

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/22316
Author: @atian8179
Created: 3/6/2026
Status: Closed

Base: mainHead: fix/ollama-generate-optional-prompt


📝 Commits (1)

  • b824dba fix: make prompt optional in /api/generate for model unload support

📊 Changes

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

View changed files

📝 backend/open_webui/routers/ollama.py (+1 -1)

📄 Description

Problem

Sending keep_alive: 0 to /ollama/api/generate through the Open WebUI proxy fails with:

{"detail":[{"type":"missing","loc":["body","prompt"],"msg":"Field required"}]}

The same request works when sent directly to Ollama.

Root Cause

GenerateCompletionForm defines prompt: str as required, but Ollama's /api/generate API allows omitting prompt for model management operations (load/unload via keep_alive).

Fix

One-line change: prompt: strprompt: Optional[str] = None

Fixes #22260


🔄 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/22316 **Author:** [@atian8179](https://github.com/atian8179) **Created:** 3/6/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/ollama-generate-optional-prompt` --- ### 📝 Commits (1) - [`b824dba`](https://github.com/open-webui/open-webui/commit/b824dba1c6edde5ff0894fd116cdabb62e70c3d5) fix: make prompt optional in /api/generate for model unload support ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/routers/ollama.py` (+1 -1) </details> ### 📄 Description ## Problem Sending `keep_alive: 0` to `/ollama/api/generate` through the Open WebUI proxy fails with: ```json {"detail":[{"type":"missing","loc":["body","prompt"],"msg":"Field required"}]} ``` The same request works when sent directly to Ollama. ## Root Cause `GenerateCompletionForm` defines `prompt: str` as required, but Ollama's `/api/generate` API allows omitting `prompt` for model management operations (load/unload via `keep_alive`). ## Fix One-line change: `prompt: str` → `prompt: Optional[str] = None` Fixes #22260 --- <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 14:13:14 -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#42238