Skip to content

Commit

Permalink
stop generating when the stop streaming button is pressed
Browse files Browse the repository at this point in the history
  • Loading branch information
anon committed May 5, 2023
1 parent 11bf850 commit eb8ccf9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,11 @@ const httpServer = http.createServer(async (req, res) => {
previousRequestResolve = resolve;
});

req.socket.on('close', () => {
abortPreviousRequest?.();
abortPreviousRequest = null;
});

try {
await getChatCompletions(req, res);
} finally {
Expand Down

0 comments on commit eb8ccf9

Please sign in to comment.