ollama - 💡(How to fix) Fix ollama run 交互模式无法拖拽/粘贴图片 [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
ollama/ollama#16091Fetched 2026-05-11 03:13:13
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Participants

Error Message

func (i *Instance) Readline() (string, error) {

Code Example

func (i *Instance) Readline() (string, error) {
    i.SetRawModeOn()
    defer i.SetRawModeOff()
    for {
        r, err := i.Terminal.Read()
        // 仅处理键盘字符,无文件/图片事件
    }
}
RAW_BUFFERClick to expand / collapse

问题描述

ollama run 交互式聊天中,无法通过拖拽或粘贴的方式将图片加入对话。

复现步骤

  1. 运行 ollama run llava(或其他视觉模型)
  2. 尝试拖拽一张图片到终端窗口
  3. 或使用 Ctrl+V 粘贴剪贴板中的图片
  4. 图片无法被添加到对话中

根因分析

readline/readline.goReadline() 逐字符处理键盘输入,没有任何文件拖放或图片粘贴的处理逻辑:

func (i *Instance) Readline() (string, error) {
    i.SetRawModeOn()
    defer i.SetRawModeOff()
    for {
        r, err := i.Terminal.Read()
        // 仅处理键盘字符,无文件/图片事件
    }
}

虽然启用了 bracket paste(?2004h),但仅用于多行文本粘贴,不支持二进制图片数据。

对比 Ollama 服务端 /api/chat 端点原生支持 images 字段([]ImageData 原始字节),说明模型能力是完备的,只是交互式前端缺少输入通道。

建议修复

  1. 交互模式下支持 Ctrl+V 粘贴图片(读取剪贴板图像数据,编码为 base64,作为 images 字段随消息发送)
  2. 支持通过文件路径引用图片(如 /image path/to/photo.jpg
  3. 终端支持的情况下,监听拖放事件读取图片文件

CC @rick-github

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

ollama - 💡(How to fix) Fix ollama run 交互模式无法拖拽/粘贴图片 [1 participants]