entity isolation and estimateTokenFix
This commit is contained in:
@@ -74,4 +74,17 @@ function getEpisodeIdsByEntities(entityIds) {
|
||||
).all(...entityIds).map(r => r.episode_id);
|
||||
}
|
||||
|
||||
module.exports = { getNeighborhood, getEntityNeighbors, getEpisodeIdsByEntities };
|
||||
//Entity IDs linked (via entity_episodes) to any episode in a given session
|
||||
//Scopes non-project entity search to the session's own entities under the "isolated chats" model.
|
||||
//Entities globally deduped
|
||||
function getEntityIdsBySession(sessionId){
|
||||
const db = getDB();
|
||||
return db.prepare(`
|
||||
SELECT DISTINCT ee.entity_id
|
||||
FROM entity_episodes ee
|
||||
JOIN episodes e on e.id = ee.episode_id
|
||||
WHERE e.session_id = ?
|
||||
`).all(sessionId).map(r => r.entity_id);
|
||||
}
|
||||
|
||||
module.exports = { getNeighborhood, getEntityNeighbors, getEpisodeIdsByEntities, getEntityIdsBySession };
|
||||
|
||||
@@ -162,6 +162,13 @@ app.get('/sessions/:id/episode-stats', (req, res) => {
|
||||
res.json(episodic.getSessionEpisodeStats(Number(req.params.id)));
|
||||
});
|
||||
|
||||
//Entity IDs linked to this session's episodes: sesion-scoped entity search
|
||||
app.get('/sessions/:id/entity-ids', (req, res) => {
|
||||
res.json({
|
||||
entityIds: graph.getEntityIdsBySession(Number(req.params.id))
|
||||
})
|
||||
})
|
||||
|
||||
// Episodes newer than :afterId, chronological — the un-summarized tail.
|
||||
app.get('/sessions/:id/episodes/since/:afterId', (req, res) => {
|
||||
const episodes = episodic.getEpisodesSince(Number(req.params.id), Number(req.params.afterId));
|
||||
|
||||
Reference in New Issue
Block a user