mirror of
https://github.com/baptisteArno/typebot.io.git
synced 2026-06-13 21:02:56 +08:00
🚑️ Make executeFunction return any type of output to make it work with setVariable
This commit is contained in:
parent
caa397d255
commit
2d876ad160
@ -1,4 +1,5 @@
|
||||
import type { VariableStore } from "@typebot.io/forge/types";
|
||||
import { safeStringify } from "@typebot.io/lib/safeStringify";
|
||||
import { isNotEmpty } from "@typebot.io/lib/utils";
|
||||
import { executeFunction } from "@typebot.io/variables/executeFunction";
|
||||
import type { Variable } from "@typebot.io/variables/schemas";
|
||||
@ -27,7 +28,7 @@ export const parseTools = ({
|
||||
body: tool.code!,
|
||||
});
|
||||
newVariables?.forEach((v) => variables.set(v.id, v.value));
|
||||
return output;
|
||||
return safeStringify(output) ?? "";
|
||||
},
|
||||
} satisfies CoreTool;
|
||||
return acc;
|
||||
|
||||
@ -4,6 +4,7 @@ import type {
|
||||
LogsStore,
|
||||
VariableStore,
|
||||
} from "@typebot.io/forge/types";
|
||||
import { safeStringify } from "@typebot.io/lib/safeStringify";
|
||||
import { isDefined, isEmpty, isNotEmpty } from "@typebot.io/lib/utils";
|
||||
import { executeFunction } from "@typebot.io/variables/executeFunction";
|
||||
import { readDataStream } from "ai";
|
||||
@ -339,7 +340,7 @@ const createAssistantStream = async ({
|
||||
|
||||
return {
|
||||
tool_call_id: toolCall.id,
|
||||
output,
|
||||
output: safeStringify(output) ?? "",
|
||||
};
|
||||
},
|
||||
),
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { safeStringify } from "@typebot.io/lib/safeStringify";
|
||||
import { stringifyError } from "@typebot.io/lib/stringifyError";
|
||||
import { isDefined } from "@typebot.io/lib/utils";
|
||||
import ivm from "isolated-vm";
|
||||
@ -74,9 +73,9 @@ export const executeFunction = async ({
|
||||
);
|
||||
|
||||
try {
|
||||
const output = await run(parsedBody);
|
||||
const output: unknown = await run(parsedBody);
|
||||
return {
|
||||
output: safeStringify(output) ?? "",
|
||||
output,
|
||||
newVariables: Object.entries(updatedVariables)
|
||||
.map(([name, value]) => {
|
||||
const existingVariable = variables.find((v) => v.name === name);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user