refactor: demo tools/agents (#67)

This commit is contained in:
sigoden
2024-07-09 21:17:12 +08:00
committed by GitHub
parent 0dbdc9e710
commit 02e335c995
11 changed files with 116 additions and 32 deletions
+24
View File
@@ -0,0 +1,24 @@
/**
* Demonstrate how to create a tool using Javascript and how to use comments.
* @typedef {Object} Args
* @property {string} string - Define a required string property
* @property {'foo'|'bar'} string_enum - Define a required string property with enum
* @property {string} [string_optional] - Define a optional string property
* @property {boolean} boolean - Define a required boolean property
* @property {Integer} integer - Define a required integer property
* @property {number} number - Define a required number property
* @property {string[]} array - Define a required string array property
* @property {string[]} [array_optional] - Define a optional string array property
* @param {Args} args
*/
exports.run = function run(args) {
for (const [key, value] of Object.entries(args)) {
console.log(`${key}: ${JSON.stringify(value)}`);
}
for (const [key, value] of Object.entries(process.env)) {
if (key.startsWith("LLM_")) {
console.log(`${key}: ${value}`);
}
}
}