project summaries addition
This commit is contained in:
@@ -3,6 +3,28 @@ const memory = require('../services/memory');
|
||||
|
||||
const router = Router();
|
||||
|
||||
// Trigger on-demand project summary generation
|
||||
router.post('/project/:projectId/generate', async (req, res) => {
|
||||
try {
|
||||
const summary = await memory.generateProjectSummary(req.params.projectId);
|
||||
res.status(201).json(summary);
|
||||
} catch (err) {
|
||||
// Pass through 422 from memory-service ("no session summaries yet")
|
||||
const status = err.message.includes('422') ? 422 : 500;
|
||||
res.status(status).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
// Get current project overview summary
|
||||
router.get('/project/:projectId/overview', async (req, res) => {
|
||||
try {
|
||||
const summary = await memory.getProjectOverviewSummary(req.params.projectId);
|
||||
res.json(summary);
|
||||
} catch (err) {
|
||||
res.status(500).json({ error: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/session/:sessionId', async (req, res) => {
|
||||
try {
|
||||
const session = await memory.getSessionByExternalId(req.params.sessionId);
|
||||
|
||||
@@ -181,7 +181,20 @@ async function getSummariesByProject(projectId) {
|
||||
if (!res.ok) throw new Error(`Failed to fetch summaries: ${res.status}`);
|
||||
return res.json();
|
||||
}
|
||||
// add to module.exports too
|
||||
|
||||
async function generateProjectSummary(projectId) {
|
||||
const res = await fetch(`${BASE_URL}/projects/${projectId}/summarize`, {
|
||||
method: 'POST',
|
||||
});
|
||||
if (!res.ok) throw new Error(`Failed to generate project summary: ${res.status}`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async function getProjectOverviewSummary(projectId) {
|
||||
const res = await fetch(`${BASE_URL}/projects/${projectId}/overview`);
|
||||
if (!res.ok) throw new Error(`Failed to fetch project overview: ${res.status}`);
|
||||
return res.json(); // null if none exists yet
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getSessionByExternalId,
|
||||
@@ -205,4 +218,6 @@ module.exports = {
|
||||
createSummary,
|
||||
updateSummary,
|
||||
getSummariesByProject,
|
||||
generateProjectSummary,
|
||||
getProjectOverviewSummary,
|
||||
}
|
||||
Reference in New Issue
Block a user