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

View File

@@ -1,10 +1,14 @@
import 'dotenv/config';
import { createDeepAgent } from "deepagents";
import { createDeepAgent, FilesystemBackend } from "deepagents";
import { ChatOpenAI } from "@langchain/openai";
import { AIMessageChunk, ToolMessage } from "langchain";
import { SystemMessage, HumanMessage, AIMessage } from "@langchain/core/messages";
import { ChatDeepSeek } from "@langchain/deepseek";
import Prompts from "./prompts.js";
import { getEnvTool,webFetchTool, webSearchTool, getCalendarInfoTool,
getLunarCalendarInfoTool, getYearHolidaysTool, getYearTermsTool, getLatLngTool,
httpGetTool, httpPostTool
} from "./tools/index.js";
export default class EscortAgent {
constructor() {
@@ -25,7 +29,7 @@ export default class EscortAgent {
if (msg.type === "clear") {
this.messages = [];
} else {
this.messages.push(new HumanMessage(msg.content));
this.messages.push(new HumanMessage(`${msg.ts} - ${msg.content}`));
}
});
@@ -99,6 +103,9 @@ export default class EscortAgent {
this.messages = [];
const rootDir = process.cwd();
const backend = new FilesystemBackend({ rootDir });
this.model = new ChatDeepSeek({
model: 'deepseek-v4-pro',
apiKey: 'sk-a58ccd82b7ba4ce3ac176a88c9381095',
@@ -108,7 +115,11 @@ export default class EscortAgent {
this.agent = createDeepAgent({
name: "deep-agent",
model: this.model,
systemPrompt: Prompts.buildSystemPrompt(userInfo)
systemPrompt: Prompts.buildSystemPrompt(userInfo),
backend,
tools: [getEnvTool, webFetchTool, webSearchTool, getLatLngTool, httpGetTool, httpPostTool,
getCalendarInfoTool, getLunarCalendarInfoTool, getYearHolidaysTool, getYearTermsTool],
skills: ["./agent/skills/"]
});
return this.agent;