[PR #11178] Interleave text and images in interactive mode #75760

Open
opened 2026-05-05 08:11:06 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/11178
Author: @sagnikpal2004
Created: 6/24/2025
Status: 🔄 Open

Base: mainHead: fix/interleave


📝 Commits (1)

  • ecf01fa interleave images in interactive

📊 Changes

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

View changed files

📝 cmd/interactive.go (+6 -3)

📄 Description

Enables interleaving of text and images (instead of prefixing images) when prompting in the interactive mode.

Description

This PR updates the logic for replacing image file paths with [img] tokens in interactive mode. The change ensures that both normalized and original file paths, with or without quotes, are replaced consistently in the user input. This way, the ollama server is able to seamlessly assign image IDs to each of these tokens in order of the images inputted.
This works for: 'path', "path", and unquoted paths. Both normalized and original file paths

Previously, when a user entered a message in interactive mode containing an image file path (e.g., /path/to/image.jpg), the code would remove the file path from the prompt entirely, leaving the images to be prefixed into the prompt later when reconstructed at the server. This is not ideal behavior, and can reduce the quality of output.

Changes in behaviour

Prompt: Hi, tell me about this image: "C:\Users\sagnikpal2004\image1.png", and how it is related to this image folder\image2.png
Old behavior: [img-0] [img-1] Hi, tell me about this image: , and how it is related to this image 
New behavior: Hi, tell me about this image: [img-0], and how it is related to this image [img-1]

Related to: #10274


🔄 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/11178 **Author:** [@sagnikpal2004](https://github.com/sagnikpal2004) **Created:** 6/24/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/interleave` --- ### 📝 Commits (1) - [`ecf01fa`](https://github.com/ollama/ollama/commit/ecf01fab38c7fa1eb3636670a2e3a727c6c0abbc) interleave images in interactive ### 📊 Changes **1 file changed** (+6 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `cmd/interactive.go` (+6 -3) </details> ### 📄 Description Enables interleaving of text and images (instead of prefixing images) when prompting in the interactive mode. ## Description This PR updates the logic for replacing image file paths with `[img]` tokens in interactive mode. The change ensures that both normalized and original file paths, with or without quotes, are replaced consistently in the user input. This way, the ollama server is able to seamlessly assign image IDs to each of these tokens in order of the images inputted. This works for: 'path', "path", and unquoted paths. Both normalized and original file paths Previously, when a user entered a message in interactive mode containing an image file path (e.g., /path/to/image.jpg), the code would remove the file path from the prompt entirely, leaving the images to be prefixed into the prompt later when reconstructed at the server. This is not ideal behavior, and can reduce the quality of output. ## Changes in behaviour ``` Prompt: Hi, tell me about this image: "C:\Users\sagnikpal2004\image1.png", and how it is related to this image folder\image2.png Old behavior: [img-0] [img-1] Hi, tell me about this image: , and how it is related to this image New behavior: Hi, tell me about this image: [img-0], and how it is related to this image [img-1] ``` Related to: #10274 --- <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-05 08:11:06 -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#75760