From 631d9ceec50928c951787d22971903aa4e5ead55 Mon Sep 17 00:00:00 2001 From: hanishkvc Date: Sat, 22 Nov 2025 22:39:08 +0530 Subject: [PATCH] SimpleChatTCRV:ToolCalls Cleanup Update the external ai tool call description to indicate that it doesnt have access to internet or tool calls. Update the sys_date_time description and avoid the confusion caused to some ai wrt the template string as to whether it is optional or required and wasting reasoning time around it. Now simply state that it is a reqd argument, and suggest the internal default template as a useful one to use. Update the msg returned by data store tool calls, to make them less verbose (ie avoid duplicating key list or got key data) while also more informative (ie num of keys, data length) Update the readme. --- tools/server/public_simplechat/readme.md | 16 +++++++++------- tools/server/public_simplechat/toolai.mjs | 2 +- tools/server/public_simplechat/tooljs.mjs | 8 ++++---- tools/server/public_simplechat/toolsdbworker.mjs | 14 +++++++------- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/tools/server/public_simplechat/readme.md b/tools/server/public_simplechat/readme.md index 2e884836e3..6d4b893e31 100644 --- a/tools/server/public_simplechat/readme.md +++ b/tools/server/public_simplechat/readme.md @@ -857,13 +857,15 @@ Cleanup in general * Allow user to load multiple images and submit to ai as part of a single user message. * Use popover ui to allow user to view larger versions of loaded images as well as remove before submitting to ai, if and when needed. -* add external_ai toolcall, user can see the response being generated by the external ai tool call, - as it is getting generated and recieved. -* maintain chat session specific DivStream elements, so that in future, if the logic is updated to allow - switching in the middle of a pending tool call or pending ai server response, things dont mess up wrt - ui, as they will be updating their respective DivStream and switching sessions will also take care of - making the right DivStream the currently active one, so that end user can see the streamed response - as it is occuring. +* Add external_ai toolcall with no access to internet or tool calls (helps avoid recursive ai tool calling). + User can see response generated by the external ai tool call, as and when it is recieved. +* Maintain chat session specific DivStream elements, and show live ai responses (through corresponding + DivStream) wrt the current chat session as well as any from the external ai tool call session. + In future, if the logic is updated to allow switching chat session ui in the middle of a pending tool call + or pending ai server response, things wont mess up ui, as they will be updating their respective DivStream. + Also switching sessions takes care of showing the right DivStream ie of currently switched to chat, so that + end user can see the streamed response from that chat session as it is occuring. +* Cleanup the tool call descriptions and verbose messages returned a bit. #### ToDo diff --git a/tools/server/public_simplechat/toolai.mjs b/tools/server/public_simplechat/toolai.mjs index 300257b60e..cffadb4a6e 100644 --- a/tools/server/public_simplechat/toolai.mjs +++ b/tools/server/public_simplechat/toolai.mjs @@ -15,7 +15,7 @@ let externalai_meta = { "type": "function", "function": { "name": "external_ai", - "description": "Delegates a task to another AI instance using a custom system prompt and user message, that you as the caller define. Useful for tasks like summarization, structured data generation, or any custom AI workflow.", + "description": "Delegates a task to another AI instance using a custom system prompt and user message, that you as the caller define. Useful for tasks like summarization, structured data generation, or any custom AI workflow. This external ai doesnt have access to internet or tool calls", "parameters": { "type": "object", "properties": { diff --git a/tools/server/public_simplechat/tooljs.mjs b/tools/server/public_simplechat/tooljs.mjs index 68a1aa3ceb..425dcfbd2e 100644 --- a/tools/server/public_simplechat/tooljs.mjs +++ b/tools/server/public_simplechat/tooljs.mjs @@ -17,7 +17,7 @@ let sysdatetime_meta = { "type": "function", "function": { "name": "sys_date_time", - "description": "Returns the current system date and time. One can optionally pass template to control what and all parts of date and time are returned", + "description": "Returns the current system date and time. The template argument helps control which parts of date and time are returned", "parameters": { "type": "object", "properties": { @@ -27,10 +27,10 @@ let sysdatetime_meta = { It can be any combination of Y,m,d,H,M,S,w. Here Y - FullYear 4 digits, m - Month 2 digits, d - Day 2 digits, H - hour 2 digits 24 hours format, M - minutes 2 digits, S - seconds 2 digits, - w - day of week (0(sunday)..6(saturday)) - any other char will be returned as is. + w - day of week (0(sunday)..6(saturday)). + Any other char will be returned as is. - If no template is given, it defaults to YmdTHMS. + YmdTHMS is a useful date time template, which includes all the key parts. Remember that the template characters are case sensitive. ` } diff --git a/tools/server/public_simplechat/toolsdbworker.mjs b/tools/server/public_simplechat/toolsdbworker.mjs index 30b58827e0..b2b6bd19eb 100644 --- a/tools/server/public_simplechat/toolsdbworker.mjs +++ b/tools/server/public_simplechat/toolsdbworker.mjs @@ -30,7 +30,7 @@ self.onmessage = async function (ev) { cid: ev.data.cid, tcid: ev.data.tcid, name: ev.data.name, - data: { 'status': 'ok', 'data': reqList.result, 'msg': `DataStoreList:Ok:${reqList.result}`} + data: { 'status': 'ok', 'data': reqList.result, 'msg': `DataStoreList:Ok:NumOfKeys:${reqList.result.length}`} }); } reqList.onerror = (evList) => { @@ -52,7 +52,7 @@ self.onmessage = async function (ev) { cid: ev.data.cid, tcid: ev.data.tcid, name: ev.data.name, - data: { 'status': 'ok', 'data': reqGet.result, 'msg': `DataStoreGet:Ok:${args['key']}:${reqGet.result}`} + data: { 'status': 'ok', 'data': reqGet.result, 'msg': `DataStoreGet:Ok:Key:${args['key']}:DataLen:${reqGet.result.length}`} }); } reqGet.onerror = (evGet) => { @@ -61,7 +61,7 @@ self.onmessage = async function (ev) { cid: ev.data.cid, tcid: ev.data.tcid, name: ev.data.name, - data: { 'status': 'error', 'msg': `DataStoreGet:Err:${args['key']}:${reqGet.error}`} + data: { 'status': 'error', 'msg': `DataStoreGet:Err:Key:${args['key']}:${reqGet.error}`} }); } break; @@ -74,7 +74,7 @@ self.onmessage = async function (ev) { cid: ev.data.cid, tcid: ev.data.tcid, name: ev.data.name, - data: { 'status': 'error', 'msg': `DataStoreSet:Err:${args['key']}:${reqSet.error}`} + data: { 'status': 'error', 'msg': `DataStoreSet:Err:Key:${args['key']}:${reqSet.error}`} }); } reqSet.onsuccess = (evSet) => { @@ -83,7 +83,7 @@ self.onmessage = async function (ev) { cid: ev.data.cid, tcid: ev.data.tcid, name: ev.data.name, - data: { 'status': 'ok', 'msg': `DataStoreSet:Ok:${args['key']}:${reqSet.result}`} + data: { 'status': 'ok', 'msg': `DataStoreSet:Ok:Key:${args['key']}:SetKey:${reqSet.result}`} }); } break; @@ -96,7 +96,7 @@ self.onmessage = async function (ev) { cid: ev.data.cid, tcid: ev.data.tcid, name: ev.data.name, - data: { 'status': 'ok', 'msg': `DataStoreDelete:Ok:${args['key']}:${reqDel.result}`} + data: { 'status': 'ok', 'msg': `DataStoreDelete:Ok:Key:${args['key']}:${reqDel.result}`} }); } reqDel.onerror = (evDel) => { @@ -105,7 +105,7 @@ self.onmessage = async function (ev) { cid: ev.data.cid, tcid: ev.data.tcid, name: ev.data.name, - data: { 'status': 'error', 'msg': `DataStoreDelete:Err:${args['key']}:${reqDel.error}`} + data: { 'status': 'error', 'msg': `DataStoreDelete:Err:Key:${args['key']}:${reqDel.error}`} }); } break;