From 21544eaf87555cfa4fd36ecc9d3c2dc8d8bef0a2 Mon Sep 17 00:00:00 2001 From: hanishkvc Date: Sat, 1 Nov 2025 23:52:42 +0530 Subject: [PATCH] SimpleChatTC:ResultMaxDataLength, Desc Allow user to limit the max amount of result data returned to ai after a tool call. Inturn it is set by default to 2K. Update the pdf2text tool description to try make the local file path support more explicit --- tools/server/public_simplechat/simplechat.js | 11 ++++++++++- tools/server/public_simplechat/toolweb.mjs | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/server/public_simplechat/simplechat.js b/tools/server/public_simplechat/simplechat.js index 6e6ffdd581..1af93e2b20 100644 --- a/tools/server/public_simplechat/simplechat.js +++ b/tools/server/public_simplechat/simplechat.js @@ -1091,7 +1091,11 @@ class MultiChatUI { clearTimeout(this.timers.toolcallResponseTimeout) this.timers.toolcallResponseTimeout = undefined let chat = this.simpleChats[cid]; - chat.add(new ChatMessageEx(Roles.ToolTemp, ChatMessageEx.createToolCallResultAllInOne(tcid, name, data))) + let limitedData = data + if (gMe.tools.iResultMaxDataLength > 0) { + limitedData = data.slice(0, gMe.tools.iResultMaxDataLength) + `\n\n\nALERT: Data too long, was chopped ....` + } + chat.add(new ChatMessageEx(Roles.ToolTemp, ChatMessageEx.createToolCallResultAllInOne(tcid, name, limitedData))) if (this.chat_show(cid)) { if (gMe.tools.auto > 0) { this.timers.toolcallResponseSubmitClick = setTimeout(()=>{ @@ -1336,6 +1340,11 @@ class Me { proxyAuthInsecure: "NeverSecure", searchUrl: SearchURLS.duckduckgo, toolNames: /** @type {Array} */([]), + /** + * Control the length of the tool call result data returned to ai after tool call. + * A value of 0 is treated as unlimited data. + */ + iResultMaxDataLength: 2048, /** * Control how many milliseconds to wait for tool call to respond, before generating a timed out * error response and giving control back to end user. diff --git a/tools/server/public_simplechat/toolweb.mjs b/tools/server/public_simplechat/toolweb.mjs index f2cac18967..518ccd6f90 100644 --- a/tools/server/public_simplechat/toolweb.mjs +++ b/tools/server/public_simplechat/toolweb.mjs @@ -278,13 +278,13 @@ let pdf2text_meta = { "type": "function", "function": { "name": "pdf2text", - "description": "Fetch pdf from requested web / file path url through a proxy server and return its text content after converting pdf to text, in few seconds", + "description": "Read pdf from requested local file / web url through a proxy server and return its text content after converting pdf to text, in few seconds", "parameters": { "type": "object", "properties": { "url":{ "type":"string", - "description":"local file / web (http/https) based url of the pdf that will be got and inturn converted to text to an extent" + "description":"local file path / web (http/https) based url of the pdf that will be got and inturn converted to text to an extent" } }, "required": ["url"]