fix(chat): use Markdown for LLM image context and normalize legacy XML
Chat and agent tool context now emits answer-ready Markdown images instead of internal <image> XML so copied content renders safely. The frontend also normalizes legacy XML blocks in persisted conversations during streaming.
This commit is contained in:
@@ -1247,14 +1247,10 @@ func (t *KnowledgeSearchTool) formatOutput(
|
||||
var imageInfos []types.ImageInfo
|
||||
if err := json.Unmarshal([]byte(result.ImageInfo), &imageInfos); err == nil && len(imageInfos) > 0 {
|
||||
for _, img := range imageInfos {
|
||||
ob.WriteString(fmt.Sprintf("<image url=\"%s\">\n", xmlEscape(img.URL)))
|
||||
if img.Caption != "" {
|
||||
ob.WriteString(fmt.Sprintf("<image_caption>%s</image_caption>\n", xmlEscape(img.Caption)))
|
||||
if imageMarkdown := searchutil.BuildImageInfoMarkdownWithURL(img.URL, &img); imageMarkdown != "" {
|
||||
ob.WriteString(imageMarkdown)
|
||||
ob.WriteString("\n")
|
||||
}
|
||||
if img.OCRText != "" {
|
||||
ob.WriteString(fmt.Sprintf("<image_ocr>%s</image_ocr>\n", xmlEscape(img.OCRText)))
|
||||
}
|
||||
ob.WriteString("</image>\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user