mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
feat: cancellable api request
This commit is contained in:
parent
66ad54168a
commit
ef9f1ee1cf
11 changed files with 93 additions and 67 deletions
|
|
@ -84,6 +84,14 @@ const ask = async ({
|
|||
|
||||
try {
|
||||
const progressCallback = createOnProgress();
|
||||
|
||||
const abortController = new AbortController();
|
||||
res.on('close', () => {
|
||||
console.log('The client has disconnected.');
|
||||
// 执行其他操作
|
||||
abortController.abort();
|
||||
})
|
||||
|
||||
let response = await askSydney({
|
||||
text,
|
||||
onProgress: progressCallback.call(null, model, {
|
||||
|
|
@ -95,7 +103,8 @@ const ask = async ({
|
|||
parentMessageId: userParentMessageId,
|
||||
conversationId,
|
||||
...convo
|
||||
}
|
||||
},
|
||||
abortController
|
||||
});
|
||||
|
||||
console.log('SYDNEY RESPONSE', response);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue