mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-19 18:00:15 +01:00
refactor: streamline agent controller and remove legacy resumable handling
- Updated the AgentController to route all requests to ResumableAgentController, simplifying the logic. - Deprecated the legacy non-resumable path, providing a clear migration path for future use. - Adjusted setHeaders middleware to remove unnecessary checks for resumable mode. - Cleaned up the useResumableSSE hook to eliminate redundant query parameters, enhancing clarity and performance.
This commit is contained in:
parent
460f60665f
commit
27e5f646d7
3 changed files with 11 additions and 14 deletions
|
|
@ -348,15 +348,19 @@ const ResumableAgentController = async (req, res, next, initializeClient, addTit
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Non-resumable Agent Controller - Uses GenerationJobManager for abort handling.
|
* Agent Controller - Routes to ResumableAgentController for all requests.
|
||||||
* Response is streamed directly to client via res, but abort state is managed centrally.
|
* The legacy non-resumable path is kept below but no longer used by default.
|
||||||
*/
|
*/
|
||||||
const AgentController = async (req, res, next, initializeClient, addTitle) => {
|
const AgentController = async (req, res, next, initializeClient, addTitle) => {
|
||||||
const isResumable = req.query.resumable === 'true';
|
return ResumableAgentController(req, res, next, initializeClient, addTitle);
|
||||||
if (isResumable) {
|
};
|
||||||
return ResumableAgentController(req, res, next, initializeClient, addTitle);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legacy Non-resumable Agent Controller - Uses GenerationJobManager for abort handling.
|
||||||
|
* Response is streamed directly to client via res, but abort state is managed centrally.
|
||||||
|
* @deprecated Use ResumableAgentController instead
|
||||||
|
*/
|
||||||
|
const _LegacyAgentController = async (req, res, next, initializeClient, addTitle) => {
|
||||||
const {
|
const {
|
||||||
text,
|
text,
|
||||||
isRegenerate,
|
isRegenerate,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,4 @@
|
||||||
function setHeaders(req, res, next) {
|
function setHeaders(req, res, next) {
|
||||||
// Skip SSE headers for resumable mode - it returns JSON first, then client subscribes separately
|
|
||||||
if (req.query.resumable === 'true') {
|
|
||||||
return next();
|
|
||||||
}
|
|
||||||
|
|
||||||
res.writeHead(200, {
|
res.writeHead(200, {
|
||||||
Connection: 'keep-alive',
|
Connection: 'keep-alive',
|
||||||
'Content-Type': 'text/event-stream',
|
'Content-Type': 'text/event-stream',
|
||||||
|
|
|
||||||
|
|
@ -498,9 +498,7 @@ export default function useResumableSSE(
|
||||||
|
|
||||||
clearStepMaps();
|
clearStepMaps();
|
||||||
|
|
||||||
const url = payloadData.server.includes('?')
|
const url = payloadData.server;
|
||||||
? `${payloadData.server}&resumable=true`
|
|
||||||
: `${payloadData.server}?resumable=true`;
|
|
||||||
|
|
||||||
const maxRetries = 3;
|
const maxRetries = 3;
|
||||||
let lastError: unknown = null;
|
let lastError: unknown = null;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue