tmp
This commit is contained in:
@@ -77,10 +77,13 @@ export default class EscortAgent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (mode === "messages") {
|
} else if (mode === "messages") {
|
||||||
const [message] = data;
|
const [message, metadata] = data;
|
||||||
if (message.tool_call_chunks?.length) {
|
if (message.tool_call_chunks?.length) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (metadata?.lcSource === "summarization" || metadata?.lc_source === "summarization") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (AIMessageChunk.isInstance(message)) {
|
if (AIMessageChunk.isInstance(message)) {
|
||||||
if (message.text && !message.tool_call_chunks?.length) {
|
if (message.text && !message.tool_call_chunks?.length) {
|
||||||
callback(source, "ai", message.text, message.id);
|
callback(source, "ai", message.text, message.id);
|
||||||
@@ -103,20 +106,23 @@ export default class EscortAgent {
|
|||||||
return this.agent;
|
return this.agent;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.messages = [];
|
|
||||||
|
|
||||||
const rootDir = process.cwd();
|
const rootDir = process.cwd();
|
||||||
const userMemoryPath = path.join(rootDir, "data", userInfo._id, "memories");
|
this.messages = [];
|
||||||
console.log(userMemoryPath);
|
let backend = new FilesystemBackend({ rootDir });
|
||||||
const backend = new CompositeBackend(
|
|
||||||
new FilesystemBackend({ rootDir }),
|
if (userInfo) {
|
||||||
{
|
const userMemoryPath = path.join(rootDir, "data", userInfo._id, "memories");
|
||||||
"/memories/": new FilesystemBackend({
|
console.log(userMemoryPath);
|
||||||
rootDir: userMemoryPath,
|
backend = new CompositeBackend(
|
||||||
virtualMode: true
|
new FilesystemBackend({ rootDir }),
|
||||||
})
|
{
|
||||||
},
|
"/memories/": new FilesystemBackend({
|
||||||
)
|
rootDir: userMemoryPath,
|
||||||
|
virtualMode: true
|
||||||
|
})
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
this.flashModel = new ChatDeepSeek({
|
this.flashModel = new ChatDeepSeek({
|
||||||
model: 'deepseek-v4-flash',
|
model: 'deepseek-v4-flash',
|
||||||
@@ -139,13 +145,6 @@ export default class EscortAgent {
|
|||||||
getCalendarInfoTool, getLunarCalendarInfoTool, getYearHolidaysTool, getYearTermsTool,
|
getCalendarInfoTool, getLunarCalendarInfoTool, getYearHolidaysTool, getYearTermsTool,
|
||||||
createEscortRecordQueryTool(userInfo)],
|
createEscortRecordQueryTool(userInfo)],
|
||||||
skills: ["./agent/escort/skills/"],
|
skills: ["./agent/escort/skills/"],
|
||||||
middleware: [
|
|
||||||
summarizationMiddleware({
|
|
||||||
model: this.flashModel,
|
|
||||||
trigger: { tokens: 5000 },
|
|
||||||
keep: { messages: 10 },
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return this.agent;
|
return this.agent;
|
||||||
|
|||||||
29
websocket.js
29
websocket.js
@@ -134,18 +134,23 @@ export default class WebSocketServerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getUserInfo(token, userId) {
|
async getUserInfo(token, userId) {
|
||||||
if (!token && !userId) return null;
|
try {
|
||||||
|
if (!token && !userId) return null;
|
||||||
|
|
||||||
const url = "http://127.0.0.1:9010/user/userInfo";
|
const url = "http://127.0.0.1:9010/user/userInfo";
|
||||||
const res = await fetch(url, {
|
const res = await fetch(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
token,
|
token,
|
||||||
userId
|
userId
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
return data.data.user;
|
return data.data.user;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching user info:', error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user