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.
This commit is contained in:
parent
2dad246d53
commit
d80e438cfa
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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({
|
||||
|
|
|
|||
Loading…
Reference in New Issue