完善了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

35
agent/tools/web/search.js Normal file
View File

@@ -0,0 +1,35 @@
import { TavilySearch } from "@langchain/tavily";
import { tool } from "@langchain/core/tools";
import * as z from "zod"
const webSearchTool = tool(
async ({
query,
maxResults = 5,
topic = "general",
includeRawContent = false,
}) => {
const tavilySearch = new TavilySearch({
maxResults,
tavilyApiKey: process.env.TAVILY_API_KEY,
includeRawContent,
topic,
});
return await tavilySearch._call({ query });
},
{
name: "internet_search",
description: "Run a web search",
schema: z.object({
query: z.string().describe("The search query"),
maxResults: z.number().optional().default(5),
topic: z
.enum(["general", "news", "finance"])
.optional()
.default("general"),
includeRawContent: z.boolean().optional().default(false),
}),
},
);
export { webSearchTool };