diff --git a/tools/server/public_simplechat/readme.md b/tools/server/public_simplechat/readme.md index e506837450..cb7b26058c 100644 --- a/tools/server/public_simplechat/readme.md +++ b/tools/server/public_simplechat/readme.md @@ -102,6 +102,8 @@ remember to * the white list of allowed.domains * the shared bearer token between server and client ui +* other builtin tool / function calls like calcultor, javascript runner, DataStore dont require simpleproxy.py + ### using the front end @@ -178,6 +180,8 @@ Once inside This also helps if you had forgotten to start the bundled simpleproxy.py server before hand. Start the simpleproxy.py server and refresh the client ui page, to get access to web access related tool calls. + * if you refreshed unknowingly, you can use the Restore feature to try load the previous chat + session and resume that session. This uses a basic local auto save logic that is in there. * Using NewChat one can start independent chat sessions. * two independent chat sessions are setup by default. @@ -406,6 +410,8 @@ The following tools/functions are currently provided by default * run_javascript_function_code - which can be used to run some javascript code in the browser context. +* data_store_get/set - allows for a basic data store to be used. + Currently the ai generated code / expression is run through a simple minded eval inside a web worker mechanism. Use of WebWorker helps avoid exposing browser global scope to the generated code directly. However any shared web worker scope isnt isolated. Either way always remember to cross check the tool @@ -450,7 +456,7 @@ The bundled simple proxy a non-browser entity. In future it can be further extended to help with other relatively simple yet useful tool calls like -data / documents_store, fetch_rss and so. +data / documents_store [wip], fetch_rss and so. * for now fetch_rss can be indirectly achieved using fetch_web_url_raw. diff --git a/tools/server/public_simplechat/tooldb.mjs b/tools/server/public_simplechat/tooldb.mjs index 0c348fc4b8..c6bf47e7c8 100644 --- a/tools/server/public_simplechat/tooldb.mjs +++ b/tools/server/public_simplechat/tooldb.mjs @@ -13,7 +13,7 @@ let dsget_meta = { "type": "function", "function": { "name": "data_store_get", - "description": "Retrieve the value associated with a given key, in few seconds", + "description": "Retrieve the value associated with a given key, in few seconds using a web worker. If key doesnt exist, then __UNDEFINED__ is returned as the value.", "parameters": { "type": "object", "properties": { @@ -45,7 +45,7 @@ let dsset_meta = { "type": "function", "function": { "name": "data_store_set", - "description": "Store a value under a given key, in few seconds using a web worker", + "description": "Store a value under a given key, in few seconds using a web worker. If the key already exists, its value will be updated to the new value", "parameters": { "type": "object", "properties": { diff --git a/tools/server/public_simplechat/tools.mjs b/tools/server/public_simplechat/tools.mjs index b63e94ab34..e4f66ea7f3 100644 --- a/tools/server/public_simplechat/tools.mjs +++ b/tools/server/public_simplechat/tools.mjs @@ -64,7 +64,9 @@ export function setup(cb) { cb(ev.data.cid, ev.data.tcid, ev.data.name, ev.data.data) } gToolsDBWorker.onmessage = function (ev) { - cb(ev.data.cid, ev.data.tcid, ev.data.name, JSON.stringify(ev.data.data)) + cb(ev.data.cid, ev.data.tcid, ev.data.name, JSON.stringify(ev.data.data, (k,v)=>{ + return (v === undefined) ? '__UNDEFINED__' : v; + })); } } diff --git a/tools/server/public_simplechat/toolsdbworker.mjs b/tools/server/public_simplechat/toolsdbworker.mjs index b0a6b5a73d..6e17ec4a3b 100644 --- a/tools/server/public_simplechat/toolsdbworker.mjs +++ b/tools/server/public_simplechat/toolsdbworker.mjs @@ -66,7 +66,7 @@ self.onmessage = async function (ev) { } break; case 'data_store_set': - let reqSet = dbOS.add(args['value'], args['key']); + let reqSet = dbOS.put(args['value'], args['key']); reqSet.onerror = (evSet) => { console.info(`ERRR:WWDb:${ev.data.name}:transact failed:${reqSet.error}`) self.postMessage({