Skip to content

fix: 查询时支持内联显示图片 (#443)#444

Open
shisonghong-git wants to merge 1 commit into
nashsu:mainfrom
shisonghong-git:fix/query-display-images
Open

fix: 查询时支持内联显示图片 (#443)#444
shisonghong-git wants to merge 1 commit into
nashsu:mainfrom
shisonghong-git:fix/query-display-images

Conversation

@shisonghong-git

Copy link
Copy Markdown

问题

查询时希望显示图片,但模型回复"非常抱歉,作为基于文本的AI知识库助手,我无法直接在对话框中渲染或展示图片文件。",并把 <think> 推理和文件路径一并吐出。

根因

问题不在渲染层——chat-message.tsxMarkdownContent 早已支持渲染 ![](...) 图片,并通过 resolveMarkdownImageSrcmedia/<slug>/img.png../media/<slug>/img.png 解析成 Tauri 可加载的 <img>。只要模型在回答里输出 ![](...) 标签,图片就会内联显示。

真正的缺口在查询的 system promptchat-panel.tsx):它从未告诉模型"你能显示图片",于是推理类模型按默认习惯自我设限、拒绝出图、改贴路径。对照之下,写 wiki 页面的 ingest prompt 本就有出图指令,查询这条漏掉了。

改动

在查询 system prompt 中新增 ## Images 段,明确告知模型:

  • 页面里的 ![](media/slug/img.png)内联渲染,它显示图片,不是纯文本助手;
  • 相关图片需原样照搬 ![](...) 标签(保持页面原始路径);
  • 不得把图片说成"需手动打开的文件路径",也不得声称无法显示。

仅改动 prompt 文案,无逻辑/渲染层改动。tsc 通过。

Fixes #443

The query system prompt never told the model it could emit images, so
reasoning models refused with "作为基于文本的AI知识库助手,我无法直接在对话框中渲染或展示图片文件"
and dumped file paths instead. The chat renderer already resolves and
displays `![](media/...)` / `![](../media/...)` markdown inline, so the
only gap was the prompt.

Add an Images section to the query system prompt telling the model it
CAN show images, and to reproduce relevant pages' `![](...)` tags
verbatim so they render inline — mirroring the existing image guidance
in the ingest prompt.

Fixes nashsu#443
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant