// src/middleware/create-memory.ts
export const createMemoryFromInput: AgentMiddleware = async (
req,
res,
next
) => {
await prisma.memory.create({
data: {
userId: req.input.userId,
agentId: req.input.agentId,
roomId: req.input.roomId,
type: req.input.type,
generator: "external",
content: JSON.stringify(req.input),
},
});
await next();
};
// Creating LLM response memories
await prisma.memory.create({
data: {
userId: req.input.userId,
agentId: req.input.agentId,
roomId: req.input.roomId,
type: "agent",
generator: "llm",
content: JSON.stringify({ text: response }),
},
});