This commit is contained in:
lik
2026-06-04 10:00:59 +08:00
parent 2b28b46aed
commit 1fce05cbfb
2 changed files with 38 additions and 34 deletions

View File

@@ -77,10 +77,13 @@ export default class EscortAgent {
}
}
} else if (mode === "messages") {
const [message] = data;
const [message, metadata] = data;
if (message.tool_call_chunks?.length) {
continue;
}
if (metadata?.lcSource === "summarization" || metadata?.lc_source === "summarization") {
continue;
}
if (AIMessageChunk.isInstance(message)) {
if (message.text && !message.tool_call_chunks?.length) {
callback(source, "ai", message.text, message.id);
@@ -103,20 +106,23 @@ export default class EscortAgent {
return this.agent;
}
this.messages = [];
const rootDir = process.cwd();
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.messages = [];
let backend = new FilesystemBackend({ rootDir });
if (userInfo) {
const userMemoryPath = path.join(rootDir, "data", userInfo._id, "memories");
console.log(userMemoryPath);
backend = new CompositeBackend(
new FilesystemBackend({ rootDir }),
{
"/memories/": new FilesystemBackend({
rootDir: userMemoryPath,
virtualMode: true
})
},
)
}
this.flashModel = new ChatDeepSeek({
model: 'deepseek-v4-flash',
@@ -139,13 +145,6 @@ export default class EscortAgent {
getCalendarInfoTool, getLunarCalendarInfoTool, getYearHolidaysTool, getYearTermsTool,
createEscortRecordQueryTool(userInfo)],
skills: ["./agent/escort/skills/"],
middleware: [
summarizationMiddleware({
model: this.flashModel,
trigger: { tokens: 5000 },
keep: { messages: 10 },
}),
],
});
return this.agent;