fix: 查询时支持内联显示图片 (#443)#444
Open
shisonghong-git wants to merge 1 commit into
Open
Conversation
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 `` / `` 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
查询时希望显示图片,但模型回复"非常抱歉,作为基于文本的AI知识库助手,我无法直接在对话框中渲染或展示图片文件。",并把
<think>推理和文件路径一并吐出。根因
问题不在渲染层——
chat-message.tsx的MarkdownContent早已支持渲染图片,并通过resolveMarkdownImageSrc把media/<slug>/img.png与../media/<slug>/img.png解析成 Tauri 可加载的<img>。只要模型在回答里输出标签,图片就会内联显示。真正的缺口在查询的 system prompt(
chat-panel.tsx):它从未告诉模型"你能显示图片",于是推理类模型按默认习惯自我设限、拒绝出图、改贴路径。对照之下,写 wiki 页面的 ingest prompt 本就有出图指令,查询这条漏掉了。改动
在查询 system prompt 中新增
## Images段,明确告知模型:会内联渲染,它能显示图片,不是纯文本助手;标签(保持页面原始路径);仅改动 prompt 文案,无逻辑/渲染层改动。
tsc通过。Fixes #443