mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
fix: stops stream upon conversation
This commit is contained in:
parent
79f050bac7
commit
23de688bf3
6 changed files with 218 additions and 120 deletions
|
|
@ -2,7 +2,7 @@ const { ModelOperations } = require('@vscode/vscode-languagedetection');
|
|||
const languages = require('../utils/languages.js');
|
||||
const codeRegex = /(```[\s\S]*?```)/g;
|
||||
// const languageMatch = /```(\w+)/;
|
||||
const replaceRegex = /```\w+/g;
|
||||
const replaceRegex = /```\w+\n/g;
|
||||
|
||||
const detectCode = async (input) => {
|
||||
try {
|
||||
|
|
@ -22,7 +22,7 @@ const detectCode = async (input) => {
|
|||
}
|
||||
|
||||
console.log('[detectCode.js] replacing', match, 'with', '```shell');
|
||||
text = text.replace(match, '```shell');
|
||||
text = text.replace(match, '```shell\n');
|
||||
});
|
||||
|
||||
return text;
|
||||
|
|
|
|||
11
api/server/routes/stopStream.js
Normal file
11
api/server/routes/stopStream.js
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
module.exports = (req, res, next) => {
|
||||
let { stopStream } = req.body;
|
||||
if (stopStream) {
|
||||
console.log('stopStream');
|
||||
res.write('event: stop\ndata:\n\n');
|
||||
res.end();
|
||||
return;
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue