feat: improve execute js/py code and collect results (#117)

This commit is contained in:
sigoden
2024-10-23 17:22:11 +08:00
committed by GitHub
parent d499954dbb
commit fbeaa9cb2c
6 changed files with 14 additions and 18 deletions
+2 -4
View File
@@ -74,9 +74,7 @@ async function loadEnv(filePath) {
if (!process.env[envName]) {
let envValue = valueParts.join("=").trim();
if (envValue.startsWith('"') && envValue.endsWith('"')) {
envValue = envValue.slice(1, -1);
} else if (envValue.startsWith("'") && envValue.endsWith("'")) {
if ((envValue.startsWith('"') && envValue.endsWith('"')) || (envValue.startsWith("'") && envValue.endsWith("'"))) {
envValue = envValue.slice(1, -1);
}
envVars.set(envName, envValue);
@@ -116,7 +114,7 @@ function returnToLLM(value) {
}
const type = typeof value;
if (type === "string" || type === "number" || type === "boolean") {
writer.write(value);
writer.write(value.toString());
} else if (type === "object") {
const proto = Object.prototype.toString.call(value);
if (proto === "[object Object]" || proto === "[object Array]") {