File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 13911391 }
13921392 };
13931393
1394+ let processingQueueChats = new Set <string >();
1395+
13941396 const processNextInQueue = async (targetChatId : string ) => {
1397+ if (processingQueueChats .has (targetChatId )) return ;
1398+
13951399 const queue = $chatRequestQueues [targetChatId ];
13961400 if (! queue || queue .length === 0 ) return ;
13971401
1398- const combinedPrompt = queue .map ((m ) => m .prompt ).join (' \n\n ' );
1399- const combinedFiles = queue .flatMap ((m ) => m .files );
1402+ processingQueueChats .add (targetChatId );
1403+ try {
1404+ const combinedPrompt = queue .map ((m ) => m .prompt ).join (' \n\n ' );
1405+ const combinedFiles = queue .flatMap ((m ) => m .files );
14001406
1401- chatRequestQueues .update ((q ) => {
1402- const { [targetChatId ]: _, ... rest } = q ;
1403- return rest ;
1404- });
1407+ chatRequestQueues .update ((q ) => {
1408+ const { [targetChatId ]: _, ... rest } = q ;
1409+ return rest ;
1410+ });
14051411
1406- await submitPrompt (combinedPrompt , combinedFiles );
1412+ await submitPrompt (combinedPrompt , combinedFiles );
1413+ } finally {
1414+ processingQueueChats .delete (targetChatId );
1415+ }
14071416 };
14081417
14091418 const chatCompletedHandler = async (_chatId , modelId , responseMessageId , messages ) => {
You can’t perform that action at this time.
0 commit comments