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