[PR #15096] ui: add image generation support for image-capable models #40892

Open
opened 2026-04-23 01:40:48 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/15096
Author: @didlawowo
Created: 3/27/2026
Status: 🔄 Open

Base: mainHead: feat/image-gen-ui


📝 Commits (2)

  • fca8f74 ui: add image generation support for image-capable models
  • 98ac149 ui: extract ImageGenerationDisplay into reusable component

📊 Changes

6 files changed (+252 additions, -4 deletions)

View changed files

📝 app/ui/app/src/api.ts (+60 -3)
📝 app/ui/app/src/components/Chat.tsx (+21 -1)
app/ui/app/src/components/ImageGenerationDisplay.tsx (+56 -0)
app/ui/app/src/hooks/useImageGeneration.ts (+109 -0)
📝 app/ui/app/src/hooks/useModelCapabilities.ts (+5 -0)
📝 app/ui/ui.go (+1 -0)

📄 Description

Summary

  • When an image-capable model (e.g. flux2-klein) is selected, prompts are routed to /api/generate for image generation instead of the chat endpoint
  • Adds a progress bar with step counter during generation and displays the resulting image inline
  • Proxies /api/generate through the UI server to the Ollama backend

Changes

  • app/ui/ui.go: Add POST /api/generate proxy route
  • app/ui/app/src/api.ts: Add generateImage async generator for streaming NDJSON; use fetch directly for getModelCapabilities to access the capabilities field
  • app/ui/app/src/hooks/useImageGeneration.ts: New hook managing generation state (progress, image, error, abort)
  • app/ui/app/src/hooks/useModelCapabilities.ts: Add useHasImageCapability hook
  • app/ui/app/src/components/Chat.tsx: Route image-capable model prompts to image generation; display progress and result in both new and existing chat views

Test plan

  • Select an image-capable model (e.g. x/flux2-klein:9b)
  • Enter a prompt and submit — progress bar should appear with step counter
  • Wait for generation to complete — image should display inline
  • Verify text models still use the normal chat flow
  • Verify abort works when navigating away during generation

🔄 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/ollama/ollama/pull/15096 **Author:** [@didlawowo](https://github.com/didlawowo) **Created:** 3/27/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/image-gen-ui` --- ### 📝 Commits (2) - [`fca8f74`](https://github.com/ollama/ollama/commit/fca8f74cabac12993dc7dc0758e5792d99cda0cc) ui: add image generation support for image-capable models - [`98ac149`](https://github.com/ollama/ollama/commit/98ac1495d5416b4b3eba8a00af4012e7e2e1afd6) ui: extract ImageGenerationDisplay into reusable component ### 📊 Changes **6 files changed** (+252 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `app/ui/app/src/api.ts` (+60 -3) 📝 `app/ui/app/src/components/Chat.tsx` (+21 -1) ➕ `app/ui/app/src/components/ImageGenerationDisplay.tsx` (+56 -0) ➕ `app/ui/app/src/hooks/useImageGeneration.ts` (+109 -0) 📝 `app/ui/app/src/hooks/useModelCapabilities.ts` (+5 -0) 📝 `app/ui/ui.go` (+1 -0) </details> ### 📄 Description ## Summary - When an image-capable model (e.g. `flux2-klein`) is selected, prompts are routed to `/api/generate` for image generation instead of the chat endpoint - Adds a progress bar with step counter during generation and displays the resulting image inline - Proxies `/api/generate` through the UI server to the Ollama backend ## Changes - **`app/ui/ui.go`**: Add `POST /api/generate` proxy route - **`app/ui/app/src/api.ts`**: Add `generateImage` async generator for streaming NDJSON; use `fetch` directly for `getModelCapabilities` to access the `capabilities` field - **`app/ui/app/src/hooks/useImageGeneration.ts`**: New hook managing generation state (progress, image, error, abort) - **`app/ui/app/src/hooks/useModelCapabilities.ts`**: Add `useHasImageCapability` hook - **`app/ui/app/src/components/Chat.tsx`**: Route image-capable model prompts to image generation; display progress and result in both new and existing chat views ## Test plan - [ ] Select an image-capable model (e.g. `x/flux2-klein:9b`) - [ ] Enter a prompt and submit — progress bar should appear with step counter - [ ] Wait for generation to complete — image should display inline - [ ] Verify text models still use the normal chat flow - [ ] Verify abort works when navigating away during generation --- <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-23 01:40:48 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#40892