fixes for summary prompt, chat route logger, QDrant orphan cleanup, llamacpp stream buffering
This commit is contained in:
@@ -62,6 +62,11 @@ function touchSession(id) {
|
||||
function deleteSession(id) {
|
||||
const db = getDB();
|
||||
db.prepare(`DELETE FROM sessions WHERE id = ?`).run(id);
|
||||
|
||||
//SQLite cascade removed episode rows, clean up QDrant vectors too
|
||||
// Fire-and-forget - payload-filter delete, so it doesn't depend on the rows existing
|
||||
semantic.deleteEpisodesBySession(id)
|
||||
.catch(err => logger.error(`[Memory] QDrant cleanup failed for session ${id}:`, err.message));
|
||||
}
|
||||
|
||||
function updateSession(id, { name, projectId } = {}) {
|
||||
|
||||
@@ -192,10 +192,14 @@ app.get('/entities/:id', (req, res) => {
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Delete an entity by ID
|
||||
app.delete('/entities/:id', (req, res) => {
|
||||
entities.deleteEntity(req.params.id);
|
||||
const id = Number(req.params.id);
|
||||
entities.deleteEntity(id);
|
||||
|
||||
semantic.deleteEntity(id) //fire-and-forget, same pattern as episode delete
|
||||
.catch(err => logger.error(`[Memory] Qdrant delete failed for entity ${id};`, err.message));
|
||||
|
||||
res.status(204).send();
|
||||
});
|
||||
|
||||
|
||||
@@ -99,6 +99,23 @@ async function deleteEpisode(id) {
|
||||
return deleteVector(COLLECTIONS.EPISODES, id);
|
||||
}
|
||||
|
||||
async function deleteEntity(id) {
|
||||
return deleteVector(COLLECTIONS.ENTITIES, id);
|
||||
}
|
||||
|
||||
//Delete ALL episode vectors associated with a session via payload filter
|
||||
//Used on session delete: SQLite cascade removes the rows,
|
||||
//Filter-based,
|
||||
async function deleteEpisodesBySession(sessionId) {
|
||||
const client = getClient();
|
||||
await client.delete(CoLLECTIONS.EPISODES, {
|
||||
wait: true,
|
||||
filter: {
|
||||
must: [{ key: 'sessionId', match: { value: sessionId } }]
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
initCollections,
|
||||
@@ -109,5 +126,7 @@ module.exports = {
|
||||
searchEntities,
|
||||
searchSummaries,
|
||||
deleteVector,
|
||||
deleteEpisode
|
||||
deleteEpisode,
|
||||
deleteEntity,
|
||||
deleteEpisodesBySession
|
||||
};
|
||||
@@ -32,6 +32,9 @@ function buildProjectSummaryPrompt(projectName, sessionSummaries) {
|
||||
'Be comprehensive but avoid padding. Do not repeat the same point twice.',
|
||||
'Write in third person. Output only the overview text, no headings or labels.',
|
||||
'',
|
||||
summaryBlock,
|
||||
'<|im_end|>',
|
||||
'<|im_start|>assistant',
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user