diff --git a/src/gateway/chat/reply-content.ts b/src/gateway/chat/reply-content.ts index 97863aa..9339347 100644 --- a/src/gateway/chat/reply-content.ts +++ b/src/gateway/chat/reply-content.ts @@ -62,12 +62,16 @@ export function appendGeneratedChartImages( ): string { if (!toolResults?.length) return finalText; const missing: string[] = []; + let text = finalText; for (const r of toolResults) { if (r?.name !== 'python_eval' || r.error || !r.result) continue; for (const md of r.result.match(FILES_IMG_MD_G) || []) { - const url = md.slice(md.indexOf('](') + 2, -1); - if (!finalText.includes(url) && !missing.includes(md)) missing.push(md); + const url = md.slice(md.indexOf('](') + 2, -1); // /api/files/ + const bare = url.replace(/^\/api\/files\//, ''); + // 모델이 `![설명](squares.png)`처럼 /api/files/ 없이 쓰면 브라우저가 못 찾아 "불러올 수 없습니다"가 뜬다 — 주소만 고친다. + if (bare) text = text.split(`](${bare})`).join(`](${url})`).split(`](./${bare})`).join(`](${url})`); + if (!text.includes(url) && !missing.includes(md)) missing.push(md); } } - return missing.length ? `${finalText}\n\n${missing.join('\n\n')}`.trim() : finalText; + return missing.length ? `${text}\n\n${missing.join('\n\n')}`.trim() : text; }