Skip to content

Commit ccdefe5

Browse files
committed
SimpleChatTC:DataStore:Put, stringify undefined, readme
Update the descriptions of set and get to indicate the possible corner cases or rather semantic in such situations. Update the readme also a bit. The auto save and restore mentioned has nothing to do with the new data store mechanism.
1 parent 8bb0597 commit ccdefe5

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

tools/server/public_simplechat/readme.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ remember to
102102
* the white list of allowed.domains
103103
* the shared bearer token between server and client ui
104104

105+
* other builtin tool / function calls like calcultor, javascript runner, DataStore dont require simpleproxy.py
106+
105107

106108

107109
### using the front end
@@ -178,6 +180,8 @@ Once inside
178180
This also helps if you had forgotten to start the bundled simpleproxy.py server before hand.
179181
Start the simpleproxy.py server and refresh the client ui page, to get access to web access
180182
related tool calls.
183+
* if you refreshed unknowingly, you can use the Restore feature to try load the previous chat
184+
session and resume that session. This uses a basic local auto save logic that is in there.
181185

182186
* Using NewChat one can start independent chat sessions.
183187
* two independent chat sessions are setup by default.
@@ -406,6 +410,8 @@ The following tools/functions are currently provided by default
406410
* run_javascript_function_code - which can be used to run some javascript code in the browser
407411
context.
408412

413+
* data_store_get/set - allows for a basic data store to be used.
414+
409415
Currently the ai generated code / expression is run through a simple minded eval inside a web worker
410416
mechanism. Use of WebWorker helps avoid exposing browser global scope to the generated code directly.
411417
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
450456
a non-browser entity.
451457

452458
In future it can be further extended to help with other relatively simple yet useful tool calls like
453-
data / documents_store, fetch_rss and so.
459+
data / documents_store [wip], fetch_rss and so.
454460

455461
* for now fetch_rss can be indirectly achieved using fetch_web_url_raw.
456462

tools/server/public_simplechat/tooldb.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ let dsget_meta = {
1313
"type": "function",
1414
"function": {
1515
"name": "data_store_get",
16-
"description": "Retrieve the value associated with a given key, in few seconds",
16+
"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.",
1717
"parameters": {
1818
"type": "object",
1919
"properties": {
@@ -45,7 +45,7 @@ let dsset_meta = {
4545
"type": "function",
4646
"function": {
4747
"name": "data_store_set",
48-
"description": "Store a value under a given key, in few seconds using a web worker",
48+
"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",
4949
"parameters": {
5050
"type": "object",
5151
"properties": {

tools/server/public_simplechat/tools.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ export function setup(cb) {
6464
cb(ev.data.cid, ev.data.tcid, ev.data.name, ev.data.data)
6565
}
6666
gToolsDBWorker.onmessage = function (ev) {
67-
cb(ev.data.cid, ev.data.tcid, ev.data.name, JSON.stringify(ev.data.data))
67+
cb(ev.data.cid, ev.data.tcid, ev.data.name, JSON.stringify(ev.data.data, (k,v)=>{
68+
return (v === undefined) ? '__UNDEFINED__' : v;
69+
}));
6870
}
6971
}
7072

tools/server/public_simplechat/toolsdbworker.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ self.onmessage = async function (ev) {
6666
}
6767
break;
6868
case 'data_store_set':
69-
let reqSet = dbOS.add(args['value'], args['key']);
69+
let reqSet = dbOS.put(args['value'], args['key']);
7070
reqSet.onerror = (evSet) => {
7171
console.info(`ERRR:WWDb:${ev.data.name}:transact failed:${reqSet.error}`)
7272
self.postMessage({

0 commit comments

Comments
 (0)