完善了agent

This commit is contained in:
lik
2026-05-30 16:41:26 +08:00
parent 797e69a0c2
commit b92853a717
30 changed files with 1972 additions and 22 deletions

34
agent/tools/web/fetch.js Normal file
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 };