完善了agent
This commit is contained in:
34
agent/tools/web/fetch.js
Normal file
34
agent/tools/web/fetch.js
Normal 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 };
|
||||
Reference in New Issue
Block a user