SimpleChatTC: Add skeleton for a javascript interpretor tool call

Define the meta that needs to be passed to the GenAi Engine.

Define the logic that implements the tool call, if called.

Implement the flow/structure such that a single tool calls
implementation file can define multiple tool calls.
This commit is contained in:
hanishkvc 2025-10-10 23:31:36 +05:30
parent 48c9f07982
commit f1aa0ee778
2 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,40 @@
//@ts-check
// Helpers to handle tools/functions calling
// by Humans for All
//
let metas = [
{
"type":"function",
"function":{
"name": "javascript",
"description":"Runs code in an javascript interpreter and returns the result of the execution after 60 seconds.",
"parameters":{
"type":"object",
"properties":{
"code":{
"type":"string",
"description":"The code to run in the javascript interpreter."
}
},
"required":["code"]
}
}
}
]
/**
* Implementation of the javascript interpretor logic. Minimal skeleton for now.
* @param {any} obj
*/
function tool_run(obj) {
let func = new Function(obj["code"])
func()
}
let tswitch = {
"javascript": tool_run,
}

View File

@ -0,0 +1,7 @@
//@ts-check
// Helpers to handle tools/functions calling
// by Humans for All
//
import * as tjs from './tooljs.mjs'