SimpleChatTC:DataStore:Cleanup:Msg, duplicate on routing side
Avoid the duplicate plumbing code and use a common ops plumbing helper. Remove args[key] oversight from DataStoreList msg on webworkr
This commit is contained in:
parent
57dd228512
commit
5935ecceca
|
|
@ -28,19 +28,6 @@ let dsget_meta = {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of the data store get logic. Minimal skeleton for now.
|
||||
* NOTE: Has access to the javascript web worker environment and can mess with it and beyond
|
||||
* @param {string} chatid
|
||||
* @param {string} toolcallid
|
||||
* @param {string} toolname
|
||||
* @param {any} obj
|
||||
*/
|
||||
function dsget_run(chatid, toolcallid, toolname, obj) {
|
||||
gToolsDBWorker.postMessage({ cid: chatid, tcid: toolcallid, name: toolname, args: obj})
|
||||
}
|
||||
|
||||
|
||||
let dsset_meta = {
|
||||
"type": "function",
|
||||
"function": {
|
||||
|
|
@ -64,19 +51,6 @@ let dsset_meta = {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of the data store set logic. Minimal skeleton for now.
|
||||
* NOTE: Has access to the javascript web worker environment and can mess with it and beyond
|
||||
* @param {string} chatid
|
||||
* @param {string} toolcallid
|
||||
* @param {string} toolname
|
||||
* @param {any} obj
|
||||
*/
|
||||
function dsset_run(chatid, toolcallid, toolname, obj) {
|
||||
gToolsDBWorker.postMessage({ cid: chatid, tcid: toolcallid, name: toolname, args: obj})
|
||||
}
|
||||
|
||||
|
||||
let dsdel_meta = {
|
||||
"type": "function",
|
||||
"function": {
|
||||
|
|
@ -96,19 +70,6 @@ let dsdel_meta = {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implementation of the data store delete logic. Minimal skeleton for now.
|
||||
* NOTE: Has access to the javascript web worker environment and can mess with it and beyond
|
||||
* @param {string} chatid
|
||||
* @param {string} toolcallid
|
||||
* @param {string} toolname
|
||||
* @param {any} obj
|
||||
*/
|
||||
function dsdel_run(chatid, toolcallid, toolname, obj) {
|
||||
gToolsDBWorker.postMessage({ cid: chatid, tcid: toolcallid, name: toolname, args: obj})
|
||||
}
|
||||
|
||||
|
||||
let dslist_meta = {
|
||||
"type": "function",
|
||||
"function": {
|
||||
|
|
@ -124,14 +85,14 @@ let dslist_meta = {
|
|||
|
||||
|
||||
/**
|
||||
* Implementation of the data store list logic. Minimal skeleton for now.
|
||||
* Implementation of the minimal needed plumbing for data store related ops triggering.
|
||||
* NOTE: Has access to the javascript web worker environment and can mess with it and beyond
|
||||
* @param {string} chatid
|
||||
* @param {string} toolcallid
|
||||
* @param {string} toolname
|
||||
* @param {any} obj
|
||||
*/
|
||||
function dslist_run(chatid, toolcallid, toolname, obj) {
|
||||
function dsops_run(chatid, toolcallid, toolname, obj) {
|
||||
gToolsDBWorker.postMessage({ cid: chatid, tcid: toolcallid, name: toolname, args: obj})
|
||||
}
|
||||
|
||||
|
|
@ -142,22 +103,22 @@ function dslist_run(chatid, toolcallid, toolname, obj) {
|
|||
*/
|
||||
export let tc_switch = {
|
||||
"data_store_get": {
|
||||
"handler": dsget_run,
|
||||
"handler": dsops_run,
|
||||
"meta": dsget_meta,
|
||||
"result": ""
|
||||
},
|
||||
"data_store_set": {
|
||||
"handler": dsset_run,
|
||||
"handler": dsops_run,
|
||||
"meta": dsset_meta,
|
||||
"result": ""
|
||||
},
|
||||
"data_store_delete": {
|
||||
"handler": dsdel_run,
|
||||
"handler": dsops_run,
|
||||
"meta": dsdel_meta,
|
||||
"result": ""
|
||||
},
|
||||
"data_store_list": {
|
||||
"handler": dslist_run,
|
||||
"handler": dsops_run,
|
||||
"meta": dslist_meta,
|
||||
"result": ""
|
||||
},
|
||||
|
|
|
|||
|
|
@ -53,7 +53,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:${args['key']}:${reqList.result}`}
|
||||
data: { 'status': 'ok', 'data': reqList.result, 'msg': `DataStoreList:Ok:${reqList.result}`}
|
||||
});
|
||||
}
|
||||
reqList.onerror = (evList) => {
|
||||
|
|
@ -62,7 +62,7 @@ self.onmessage = async function (ev) {
|
|||
cid: ev.data.cid,
|
||||
tcid: ev.data.tcid,
|
||||
name: ev.data.name,
|
||||
data: { 'status': 'error', 'msg': `DataStoreList:Err:${args['key']}:${reqList.error}`}
|
||||
data: { 'status': 'error', 'msg': `DataStoreList:Err:${reqList.error}`}
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in New Issue