mirror of
https://github.com/LLM-Red-Team/qwen-free-api.git
synced 2024-11-11 09:29:20 +08:00
修复qwen流出现异常字符时导致流文本分割异常-梅开二度
This commit is contained in:
parent
7ebc1d00ae
commit
41c9488e84
@ -262,9 +262,8 @@ function messagesPrepare(messages: any[]) {
|
||||
return _content + (v["text"] || "");
|
||||
}, content);
|
||||
}
|
||||
return (content += `<|im_start|>${message.role || "user"}\n${
|
||||
message.content
|
||||
}<|im_end|>\n`);
|
||||
return (content += `<|im_start|>${message.role || "user"}\n${message.content
|
||||
}<|im_end|>\n`);
|
||||
}, "");
|
||||
return [
|
||||
{
|
||||
@ -327,10 +326,7 @@ async function receiveStream(stream: any): Promise<any> {
|
||||
return str + content;
|
||||
}, "");
|
||||
const exceptCharIndex = text.indexOf('<27>');
|
||||
let chunk = text.substring(
|
||||
data.choices[0].message.content.length,
|
||||
exceptCharIndex == -1 ? text.length : exceptCharIndex
|
||||
);
|
||||
let chunk = text.substring(exceptCharIndex != -1 ? Math.min(data.choices[0].message.content.length, exceptCharIndex) : data.choices[0].message.content.length, exceptCharIndex == -1 ? text.length : exceptCharIndex);
|
||||
if (chunk && result.contentType == "text2image") {
|
||||
chunk = chunk.replace(
|
||||
/https?:\/\/[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=\,]*)/gi,
|
||||
@ -409,7 +405,7 @@ function createTransStream(stream: any, endCallback?: Function) {
|
||||
return str + content;
|
||||
}, "");
|
||||
const exceptCharIndex = text.indexOf('<27>');
|
||||
let chunk = text.substring(content.length, exceptCharIndex == -1 ? text.length : exceptCharIndex);
|
||||
let chunk = text.substring(exceptCharIndex != -1 ? Math.min(content.length, exceptCharIndex) : content.length, exceptCharIndex == -1 ? text.length : exceptCharIndex);
|
||||
if (chunk && result.contentType == "text2image") {
|
||||
chunk = chunk.replace(
|
||||
/https?:\/\/[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=\,]*)/gi,
|
||||
|
Loading…
Reference in New Issue
Block a user