aboutsummaryrefslogtreecommitdiffstats
path: root/run/tool.js
diff options
context:
space:
mode:
Diffstat (limited to 'run/tool.js')
-rwxr-xr-xrun/tool.js21
1 files changed, 20 insertions, 1 deletions
diff --git a/run/tool.js b/run/tool.js
index ad7c151..3c8e966 100755
--- a/run/tool.js
+++ b/run/tool.js
@@ -1,6 +1,7 @@
#!/usr/bin/env node
const path = require("path");
+const fs = require('fs');
function parseArgv() {
let func_file = process.argv[1];
@@ -22,7 +23,7 @@ function parseArgv() {
}
function loadFunc(func_file) {
- const func_path = path.resolve(__dirname, `../tools/${func_file}`)
+ const func_path = path.resolve(process.env["LLM_FUNCTIONS_DIR"], `tools/${func_file}`)
try {
return require(func_path);
} catch {
@@ -31,6 +32,24 @@ function loadFunc(func_file) {
}
}
+function loadEnv(filePath) {
+ try {
+ const data = fs.readFileSync(filePath, 'utf-8');
+ const lines = data.split('\n');
+
+ lines.forEach(line => {
+ if (line.trim().startsWith('#') || line.trim() === '') return;
+
+ const [key, ...value] = line.split('=');
+ process.env[key.trim()] = value.join('=').trim();
+ });
+ } catch {}
+}
+
+process.env["LLM_FUNCTIONS_DIR"] = path.resolve(__dirname, "..");
+
+loadEnv(path.resolve(process.env["LLM_FUNCTIONS_DIR"], ".env"));
+
const [func_file, func_data] = parseArgv();
if (process.env["LLM_FUNCTION_ACTION"] == "declarate") {