[PR #24800] [CLOSED] feat: Add Load/Preload Model button for Ollama models #131520

Closed
opened 2026-05-21 17:07:19 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/24800
Author: @Sarvind1
Created: 5/15/2026
Status: Closed

Base: devHead: feature/load-model-button


📝 Commits (1)

  • 4d2c927 feat: add Load/Preload button for Ollama models in model selector

📊 Changes

5 files changed (+141 additions, -1 deletions)

View changed files

📝 backend/open_webui/main.py (+64 -0)
📝 src/lib/apis/index.ts (+33 -0)
📝 src/lib/components/chat/ModelSelector/ModelItem.svelte (+21 -0)
📝 src/lib/components/chat/ModelSelector/Selector.svelte (+19 -1)
📝 src/lib/i18n/locales/en-US/translation.json (+4 -0)

📄 Description

Summary

Adds a Load / Preload Model button to the model selector dropdown — the missing counterpart to the existing Eject (unload) button. When an Ollama model is idle (not loaded in VRAM), admins can now preload it before starting a chat, eliminating cold-start latency.

Resolves community request in Discussion #14750 and related Issue #3987.

What changed

File Change
backend/open_webui/main.py New POST /api/models/load endpoint. Resolves the Ollama node(s) for the model and sends a keep-alive generate request (keep_alive: 5m, empty prompt) to warm the model into VRAM. Admin-only.
src/lib/apis/index.ts New loadModel() client function that calls the backend endpoint.
src/lib/components/chat/ModelSelector/Selector.svelte loadModelHandler — calls loadModel(), shows toast notifications, refreshes the model list on success.
src/lib/components/chat/ModelSelector/ModelItem.svelte Renders a download-tray icon (ArrowDownTray) for idle Ollama models visible to admins. Mirrors the existing Eject button pattern.
src/lib/i18n/locales/en-US/translation.json Added i18n keys: Load, Load model, Loading model..., Model loaded successfully.

How it works

  • Backend: POST /api/models/load accepts { "model": "<model_id>" }. It looks up the model in OLLAMA_MODELS, resolves prefix IDs and API keys per Ollama node, then sends POST /api/generate with an empty prompt and keep_alive: "5m" to warm the model. Returns { "status": true } on success or a 500 with per-node error details.
  • Frontend: The Load button appears only for admin users, only for Ollama-owned models, and only when the model is not already loaded (!item.model.loaded && item.model.owned_by === 'ollama'). Once loaded, the button disappears and the existing Eject button becomes visible instead.

Screenshots

The Load button (download icon) appears next to idle Ollama models in the selector dropdown. After loading, it's replaced by the existing Eject button (upload icon). Non-Ollama models and non-admin users see no change.

Testing

  1. Have an Ollama instance with at least one model that is not loaded (verify via ollama ps).
  2. Open the model selector in Open WebUI as an admin user.
  3. Hover over the idle Ollama model — a download-tray icon (Load) should appear.
  4. Click the Load button — a "Loading model..." toast appears, followed by "Model loaded successfully".
  5. The model now shows as loaded (green dot) and the Eject button replaces the Load button.
  6. Verify non-admin users do not see the Load button.
  7. Verify non-Ollama models do not show the Load button.

Notes

  • No new dependencies added.
  • Admin-only — follows the same permission pattern as the existing Eject button.
  • Follows existing code patterns for Ollama API interaction (mirrors unload_model endpoint structure).
  • The keep_alive: "5m" default matches Ollama's standard behavior; the model stays warm for 5 minutes after the preload request.

🔄 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/24800 **Author:** [@Sarvind1](https://github.com/Sarvind1) **Created:** 5/15/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `feature/load-model-button` --- ### 📝 Commits (1) - [`4d2c927`](https://github.com/open-webui/open-webui/commit/4d2c927712a5ee1ce3db23afde79afebf552a6cd) feat: add Load/Preload button for Ollama models in model selector ### 📊 Changes **5 files changed** (+141 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/main.py` (+64 -0) 📝 `src/lib/apis/index.ts` (+33 -0) 📝 `src/lib/components/chat/ModelSelector/ModelItem.svelte` (+21 -0) 📝 `src/lib/components/chat/ModelSelector/Selector.svelte` (+19 -1) 📝 `src/lib/i18n/locales/en-US/translation.json` (+4 -0) </details> ### 📄 Description ## Summary Adds a **Load / Preload Model** button to the model selector dropdown — the missing counterpart to the existing **Eject** (unload) button. When an Ollama model is idle (not loaded in VRAM), admins can now preload it before starting a chat, eliminating cold-start latency. Resolves community request in Discussion #14750 and related Issue #3987. ## What changed | File | Change | |------|--------| | `backend/open_webui/main.py` | New `POST /api/models/load` endpoint. Resolves the Ollama node(s) for the model and sends a keep-alive generate request (`keep_alive: 5m`, empty prompt) to warm the model into VRAM. Admin-only. | | `src/lib/apis/index.ts` | New `loadModel()` client function that calls the backend endpoint. | | `src/lib/components/chat/ModelSelector/Selector.svelte` | `loadModelHandler` — calls `loadModel()`, shows toast notifications, refreshes the model list on success. | | `src/lib/components/chat/ModelSelector/ModelItem.svelte` | Renders a download-tray icon (ArrowDownTray) for idle Ollama models visible to admins. Mirrors the existing Eject button pattern. | | `src/lib/i18n/locales/en-US/translation.json` | Added i18n keys: `Load`, `Load model`, `Loading model...`, `Model loaded successfully`. | ## How it works - **Backend**: `POST /api/models/load` accepts `{ "model": "<model_id>" }`. It looks up the model in `OLLAMA_MODELS`, resolves prefix IDs and API keys per Ollama node, then sends `POST /api/generate` with an empty prompt and `keep_alive: "5m"` to warm the model. Returns `{ "status": true }` on success or a 500 with per-node error details. - **Frontend**: The Load button appears only for admin users, only for Ollama-owned models, and only when the model is not already loaded (`!item.model.loaded && item.model.owned_by === 'ollama'`). Once loaded, the button disappears and the existing Eject button becomes visible instead. ## Screenshots The **Load** button (download icon) appears next to idle Ollama models in the selector dropdown. After loading, it's replaced by the existing **Eject** button (upload icon). Non-Ollama models and non-admin users see no change. ## Testing 1. Have an Ollama instance with at least one model that is **not** loaded (verify via `ollama ps`). 2. Open the model selector in Open WebUI as an admin user. 3. Hover over the idle Ollama model — a download-tray icon (Load) should appear. 4. Click the Load button — a "Loading model..." toast appears, followed by "Model loaded successfully". 5. The model now shows as loaded (green dot) and the Eject button replaces the Load button. 6. Verify non-admin users do not see the Load button. 7. Verify non-Ollama models do not show the Load button. ## Notes - No new dependencies added. - Admin-only — follows the same permission pattern as the existing Eject button. - Follows existing code patterns for Ollama API interaction (mirrors `unload_model` endpoint structure). - The `keep_alive: "5m"` default matches Ollama's standard behavior; the model stays warm for 5 minutes after the preload request. --- <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-21 17:07:19 -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#131520