This commit is contained in:
lik
2026-06-01 15:48:50 +08:00
parent 24b56b1875
commit 40c45c6db7
51 changed files with 2079 additions and 9 deletions

View File

@@ -0,0 +1,34 @@
import { TavilyExtract } from "@langchain/tavily";
import { tool } from "@langchain/core/tools";
import * as z from "zod"
const webFetchTool = tool(
async ({
extractDepth = "basic",
includeImages = false,
format = "markdown",
urls = [],
}) => {
const tavilyExtract = new TavilyExtract({
tavilyApiKey: process.env.TAVILY_API_KEY,
extractDepth,
includeImages,
format
});
return await tavilyExtract._call({ urls });
},
{
name: "web_fetch",
description: "Run a web fetch",
schema: z.object({
extractDepth: z.enum(["basic", "advanced"]).default("basic"),
includeImages: z.boolean().default(false),
format: z
.enum(["markdown", "json"])
.default("markdown"),
urls: z.array(z.string().describe("The urls")).default([]),
}),
},
);
export { webFetchTool };