refactor: Enhance job state management and TTL configuration in RedisJobStore

- Updated the RedisJobStore to allow customizable TTL values for job states, improving flexibility in job management.
- Refactored the handling of job expiration and cleanup processes to align with new TTL configurations.
- Simplified the response structure in the chat status endpoint by consolidating state retrieval, enhancing clarity and performance.
- Improved comments and documentation for better understanding of the changes made.
This commit is contained in:
Danny Avila 2025-12-15 01:44:57 -05:00
parent 1ed8b8429a
commit d258297ec5
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
2 changed files with 66 additions and 23 deletions

View file

@ -133,15 +133,17 @@ router.get('/chat/status/:conversationId', async (req, res) => {
return res.status(403).json({ error: 'Unauthorized' });
}
const info = await GenerationJobManager.getStreamInfo(conversationId);
// Get resume state which contains aggregatedContent
// Avoid calling both getStreamInfo and getResumeState (both fetch content)
const resumeState = await GenerationJobManager.getResumeState(conversationId);
const isActive = job.status === 'running';
res.json({
active: info?.active ?? false,
active: isActive,
streamId: conversationId,
status: info?.status ?? job.status,
aggregatedContent: info?.aggregatedContent,
createdAt: info?.createdAt ?? job.createdAt,
status: job.status,
aggregatedContent: resumeState?.aggregatedContent ?? [],
createdAt: job.createdAt,
resumeState,
});
});