feat: improve execute js/py code and collect results (#117)
This commit is contained in:
@@ -87,9 +87,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);
|
||||
@@ -129,7 +127,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]") {
|
||||
|
||||
@@ -77,9 +77,7 @@ def load_env(file_path):
|
||||
|
||||
if env_name not in os.environ:
|
||||
env_value = "=".join(value_parts).strip()
|
||||
if env_value.startswith('"') and env_value.endswith('"'):
|
||||
env_value = env_value[1:-1]
|
||||
elif env_value.startswith("'") and env_value.endswith("'"):
|
||||
if (env_value.startswith('"') and env_value.endswith('"')) or (env_value.startswith("'") and env_value.endswith("'")):
|
||||
env_value = env_value[1:-1]
|
||||
env_vars[env_name] = env_value
|
||||
|
||||
@@ -150,7 +148,7 @@ def return_to_llm(value):
|
||||
|
||||
value_type = type(value).__name__
|
||||
if value_type in ("str", "int", "float", "bool"):
|
||||
writer.write(value)
|
||||
writer.write(str(value))
|
||||
elif value_type == "dict" or value_type == "list":
|
||||
value_str = json.dumps(value, indent=2)
|
||||
assert value == json.loads(value_str)
|
||||
|
||||
+2
-4
@@ -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]") {
|
||||
|
||||
+2
-4
@@ -72,9 +72,7 @@ def load_env(file_path):
|
||||
|
||||
if env_name not in os.environ:
|
||||
env_value = "=".join(value_parts).strip()
|
||||
if env_value.startswith('"') and env_value.endswith('"'):
|
||||
env_value = env_value[1:-1]
|
||||
elif env_value.startswith("'") and env_value.endswith("'"):
|
||||
if (env_value.startswith('"') and env_value.endswith('"')) or (env_value.startswith("'") and env_value.endswith("'")):
|
||||
env_value = env_value[1:-1]
|
||||
env_vars[env_name] = env_value
|
||||
|
||||
@@ -110,7 +108,7 @@ def return_to_llm(value):
|
||||
|
||||
value_type = type(value).__name__
|
||||
if value_type in ("str", "int", "float", "bool"):
|
||||
writer.write(value)
|
||||
writer.write(str(value))
|
||||
elif value_type == "dict" or value_type == "list":
|
||||
value_str = json.dumps(value, indent=2)
|
||||
assert value == json.loads(value_str)
|
||||
|
||||
Reference in New Issue
Block a user