summaryrefslogtreecommitdiff
path: root/htroot
diff options
context:
space:
mode:
authorMichael Peter Christen <mc@yacy.net>2026-03-28 21:33:54 +0100
committerMichael Peter Christen <mc@yacy.net>2026-03-28 21:33:54 +0100
commit1f80c6679e2fa240210cfa7a5df7441a1ba7c023 (patch)
tree3fadb671c15688d4525f936e61f7104f0ed54de1 /htroot
parente0bf6b8c68f0d141f1ee4c35a3e65108caf27615 (diff)
Add search tool backed by shared RAG search document output
Diffstat (limited to 'htroot')
-rw-r--r--htroot/yacychat.html35
1 files changed, 34 insertions, 1 deletions
diff --git a/htroot/yacychat.html b/htroot/yacychat.html
index 447293e34..3ac314d04 100644
--- a/htroot/yacychat.html
+++ b/htroot/yacychat.html
@@ -2050,6 +2050,30 @@
return base64 ? base64ToUtf8(base64) : '';
}
+ function parseStructuredToolResult(result) {
+ const raw = result?.content || result?.function?.content || '';
+ if (typeof raw !== 'string' || !raw.trim()) return null;
+ try {
+ return JSON.parse(raw);
+ } catch (err) {
+ return null;
+ }
+ }
+
+ function inferAttachmentFromToolResult(result) {
+ const payload = parseStructuredToolResult(result);
+ const name = payload?.['search-filename'];
+ const base64 = payload?.['search-text-base64'];
+ if (!name || !base64) return null;
+ return {
+ kind: 'text',
+ name,
+ dataUrl: `data:text/markdown;base64,${base64}`,
+ mime: 'text/markdown',
+ textContent: base64ToUtf8(base64)
+ };
+ }
+
function messageDisplayText(message) {
if (!message) return '';
if (typeof message.display === 'string') return message.display;
@@ -2175,9 +2199,18 @@
responseTitle.textContent = 'Response';
item.appendChild(responseTitle);
+ const attachment = inferAttachmentFromToolResult(result);
+ if (attachment) {
+ const attachmentContainer = document.createElement('div');
+ attachmentContainer.appendChild(createAttachmentChip(attachment));
+ item.appendChild(attachmentContainer);
+ }
+
const responseBody = document.createElement('pre');
responseBody.className = 'toolcall-result';
- responseBody.textContent = formatToolArguments(result?.content || result?.function?.content || '');
+ responseBody.textContent = attachment
+ ? attachmentTextContent(attachment)
+ : formatToolArguments(result?.content || result?.function?.content || '');
item.appendChild(responseBody);
}