@@ -57,7 +57,7 @@ export async function initApi(key: KeyConfig) {
5757 return new OpenAI ( clientOptions )
5858}
5959
60- const processThreads : { userId : string , abort : AbortController , messageId : string } [ ] = [ ]
60+ const processThreads : { userId : string , chatUuid : number , abort : AbortController } [ ] = [ ]
6161
6262async function chatReplyProcess ( options : RequestOptions ) {
6363 const globalConfig = await getCacheConfig ( )
@@ -70,15 +70,15 @@ async function chatReplyProcess(options: RequestOptions) {
7070 if ( key == null || key === undefined )
7171 throw new Error ( '没有对应的apikeys配置。请再试一次 | No available apikeys configuration. Please try again.' )
7272
73- const { message, uploadFileKeys, parentMessageId, process, systemMessage, temperature, top_p } = options
73+ const { message, uploadFileKeys, parentMessageId, process, systemMessage, temperature, top_p, chatUuid } = options
7474
7575 try {
7676 // Initialize OpenAI client
7777 const openai = await initApi ( key )
7878
7979 // Create abort controller for cancellation
8080 const abort = new AbortController ( )
81- processThreads . push ( { userId, abort , messageId } )
81+ processThreads . push ( { userId, chatUuid , abort } )
8282
8383 // Prepare messages array for the chat completion
8484 const messages : OpenAI . Chat . ChatCompletionMessageParam [ ] = [ ]
@@ -262,14 +262,12 @@ search result: <search_result>${searchResultContent}</search_result>`,
262262 }
263263}
264264
265- export function abortChatProcess ( userId : string ) {
266- const index = processThreads . findIndex ( d => d . userId === userId )
265+ export function abortChatProcess ( userId : string , chatUuid : number ) {
266+ const index = processThreads . findIndex ( d => d . userId === userId && d . chatUuid === chatUuid )
267267 if ( index <= - 1 )
268268 return
269- const messageId = processThreads [ index ] . messageId
270269 processThreads [ index ] . abort . abort ( )
271270 processThreads . splice ( index , 1 )
272- return messageId
273271}
274272
275273export function initAuditService ( audit : AuditConfig ) {
0 commit comments