mirror of
https://github.com/LLM-Red-Team/qwen-free-api.git
synced 2024-12-23 08:49:21 +08:00
修复消息中出现插件调用失败内容的问题
This commit is contained in:
parent
6abc2d760f
commit
3bb2a93211
@ -323,9 +323,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 [
|
||||||
{
|
{
|
||||||
@ -383,7 +382,9 @@ async function receiveStream(stream: any): Promise<any> {
|
|||||||
throw new Error(`Stream response invalid: ${event.data}`);
|
throw new Error(`Stream response invalid: ${event.data}`);
|
||||||
if (!data.id && result.sessionId) data.id = result.sessionId;
|
if (!data.id && result.sessionId) data.id = result.sessionId;
|
||||||
const text = (result.contents || []).reduce((str, part) => {
|
const text = (result.contents || []).reduce((str, part) => {
|
||||||
const { role, content } = part;
|
const { contentType, role, content } = part;
|
||||||
|
console.log(part);
|
||||||
|
if (contentType != 'text' && contentType != 'text2image') return str;
|
||||||
if (role != "assistant" && !_.isString(content)) return str;
|
if (role != "assistant" && !_.isString(content)) return str;
|
||||||
return str + content;
|
return str + content;
|
||||||
}, "");
|
}, "");
|
||||||
@ -467,7 +468,8 @@ function createTransStream(stream: any, endCallback?: Function) {
|
|||||||
if (_.isError(result))
|
if (_.isError(result))
|
||||||
throw new Error(`Stream response invalid: ${event.data}`);
|
throw new Error(`Stream response invalid: ${event.data}`);
|
||||||
const text = (result.contents || []).reduce((str, part) => {
|
const text = (result.contents || []).reduce((str, part) => {
|
||||||
const { role, content } = part;
|
const { contentType, role, content } = part;
|
||||||
|
if (contentType != 'text' && contentType != 'text2image') return str;
|
||||||
if (role != "assistant" && !_.isString(content)) return str;
|
if (role != "assistant" && !_.isString(content)) return str;
|
||||||
return str + content;
|
return str + content;
|
||||||
}, "");
|
}, "");
|
||||||
|
Loading…
Reference in New Issue
Block a user