tmp
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
import 'dotenv/config';
|
||||
import { createDeepAgent, FilesystemBackend } from "deepagents";
|
||||
import path from 'path';
|
||||
import { createDeepAgent, FilesystemBackend, CompositeBackend, StoreBackend } from "deepagents";
|
||||
import { ChatOpenAI } from "@langchain/openai";
|
||||
import { AIMessageChunk, ToolMessage } from "langchain";
|
||||
import { AIMessageChunk, ToolMessage, summarizationMiddleware } 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,
|
||||
import {
|
||||
getEnvTool, webFetchTool, webSearchTool, getCalendarInfoTool,
|
||||
getLunarCalendarInfoTool, getYearHolidaysTool, getYearTermsTool, getLatLngTool,
|
||||
httpGetTool, httpPostTool
|
||||
} from "./tools/index.js";
|
||||
httpGetTool, httpPostTool, createEscortRecordQueryTool
|
||||
} from "./tools/index.js";
|
||||
|
||||
export default class EscortAgent {
|
||||
constructor() {
|
||||
@@ -44,7 +46,7 @@ export default class EscortAgent {
|
||||
recursion_limit: 50,
|
||||
streamMode: ["updates", "messages", "custom"], subgraphs: true,
|
||||
configurable: {
|
||||
thread_id: 'default-session'
|
||||
thread_id: msgs[0].userId || msgs[0].appId
|
||||
}
|
||||
})) {
|
||||
const isSubagent = namespace.some(s => s.startsWith("tools:"));
|
||||
@@ -104,22 +106,46 @@ export default class EscortAgent {
|
||||
this.messages = [];
|
||||
|
||||
const rootDir = process.cwd();
|
||||
const backend = new FilesystemBackend({ rootDir });
|
||||
const userMemoryPath = path.join(rootDir, "data", userInfo._id, "memories");
|
||||
console.log(userMemoryPath);
|
||||
const backend = new CompositeBackend(
|
||||
new FilesystemBackend({ rootDir }),
|
||||
{
|
||||
"/memories/": new FilesystemBackend({
|
||||
rootDir: userMemoryPath,
|
||||
virtualMode: true
|
||||
})
|
||||
},
|
||||
)
|
||||
|
||||
this.model = new ChatDeepSeek({
|
||||
this.flashModel = new ChatDeepSeek({
|
||||
model: 'deepseek-v4-flash',
|
||||
apiKey: 'sk-a58ccd82b7ba4ce3ac176a88c9381095',
|
||||
temperature: 0.0
|
||||
});
|
||||
this.proModel = new ChatDeepSeek({
|
||||
model: 'deepseek-v4-pro',
|
||||
apiKey: 'sk-a58ccd82b7ba4ce3ac176a88c9381095',
|
||||
temperature: 0.3
|
||||
});
|
||||
|
||||
this.agent = createDeepAgent({
|
||||
name: "deep-agent",
|
||||
model: this.model,
|
||||
model: this.flashModel,
|
||||
systemPrompt: Prompts.buildSystemPrompt(userInfo),
|
||||
memory: ["./agent/escort/AGENTS.md"],
|
||||
backend,
|
||||
tools: [getEnvTool, webFetchTool, webSearchTool, getLatLngTool, httpGetTool, httpPostTool,
|
||||
getCalendarInfoTool, getLunarCalendarInfoTool, getYearHolidaysTool, getYearTermsTool],
|
||||
skills: ["./agent/escort/skills/"]
|
||||
getCalendarInfoTool, getLunarCalendarInfoTool, getYearHolidaysTool, getYearTermsTool,
|
||||
createEscortRecordQueryTool(userInfo)],
|
||||
skills: ["./agent/escort/skills/"],
|
||||
middleware: [
|
||||
summarizationMiddleware({
|
||||
model: this.flashModel,
|
||||
trigger: { tokens: 5000 },
|
||||
keep: { messages: 10 },
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
return this.agent;
|
||||
|
||||
Reference in New Issue
Block a user