route-to-function
v1.1.5
Published
Route the flow to nameless function under a module folder
Readme
This package allows you to route the flow to different es function under a specific folder with folder name, function name and function parameters in array. The package also returns a tools property with the schema list for all functions for ai tool calling.
Install
$ npm i route-to-functionNameless function example under your module folder:
export default async(where, who='minime') => {
return {
success: true,
name: who,
location: where
}
}Usage: Say your module structure looks like this: tools getCurrentWeather.js getInfo.js
import importModules from 'route-to-function'
const modules = await importModules('tools')
console.dir(modules, {depth: null})
const res = await modules.toFunction('getCurrentWeather', ['roseland', 'me'])
console.log(res)
const infoRes = await modules.toFunction('getInfo', ['1234'])
console.log(infoRes)