71 lines
2.0 KiB
JavaScript
Raw Permalink Normal View History

2025-02-17 15:21:20 +07:00
import { tool } from "@langchain/core/tools";
import { z } from "zod";
export const approveRequiredTool1 = tool(
({ testParam, debug = false }) => {
if (debug) {
return `approveRequiredTool1 called successfully with ${testParam}`;
}
return `approveRequiredTool1 call failed with ${testParam}. User denied the requiest`;
},
{
name: "approveRequiredTool1",
description: "Call when user ask for the function approveRequiredTool1",
schema: z.object({
testParam: z
.string()
.describe("Some random string you come up with just for testing"),
debug: z
.boolean()
.default(false)
.describe("User controlled variable, you cannot control this"),
}),
},
);
export const approveRequiredTool2 = tool(
({ testParam, debug = false }) => {
if (debug) {
return `approveRequiredTool2 called successfully with ${testParam}`;
}
return `approveRequiredTool2 call failed with ${testParam}. User denied the requiest`;
},
{
name: "approveRequiredTool2",
description: "Call when user ask for the function approveRequiredTool2",
schema: z.object({
testParam: z
.string()
.describe("Some random string you come up with just for testing"),
debug: z
.boolean()
.default(false)
.describe("User controlled variable, you cannot control this"),
}),
},
);
export const regularTool1 = tool(
(_) => {
return ["regularTool1 called successfully", "artifact data"];
},
{
name: "regularTool1",
description: "Call when user ask for the function regularTool1",
schema: z.string(),
responseFormat: "content_and_artifact",
},
);
export const regularTool2 = tool(
(_) => {
return ["regularTool2 called successfully", "artifact data"];
},
{
name: "regularTool2",
description: "Call when user ask for the function regularTool2",
schema: z.string(),
responseFormat: "content_and_artifact",
},
);