From 06f4cdc64976e06f4295f14babc4c884524ede66 Mon Sep 17 00:00:00 2001 From: RockYang Date: Fri, 19 Apr 2024 10:55:29 +0800 Subject: [PATCH] fixed bug for QWen response blank quotes --- CHANGELOG.md | 3 +++ api/handler/chatimpl/chat_handler.go | 10 ++++++---- api/handler/chatimpl/qwen_handler.go | 5 +++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3cdc2f3..d362c101 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ # 更新日志 +## v4.0.4 +* Bug修复:修复通义千问第二句不回复的问题。 + ## v4.0.3 2024-04-15 * Bug修复:修复MJ-PLUS 服务会自动删除10分钟前的任务问题 * Bug修复:修复MJ 的 U/V 操作会强制使用 Fast 模式 Bug diff --git a/api/handler/chatimpl/chat_handler.go b/api/handler/chatimpl/chat_handler.go index c60df32e..439fc36e 100644 --- a/api/handler/chatimpl/chat_handler.go +++ b/api/handler/chatimpl/chat_handler.go @@ -326,10 +326,12 @@ func (h *ChatHandler) sendMessage(ctx context.Context, session *types.ChatSessio } if session.Model.Platform == types.QWen { - req.Input = map[string]interface{}{"prompt": prompt} - if len(reqMgs) > 0 { - req.Input["messages"] = reqMgs - } + req.Input = make(map[string]interface{}) + reqMgs = append(reqMgs, types.Message{ + Role: "user", + Content: prompt, + }) + req.Input["messages"] = reqMgs } else { req.Messages = append(reqMgs, map[string]interface{}{ "role": "user", diff --git a/api/handler/chatimpl/qwen_handler.go b/api/handler/chatimpl/qwen_handler.go index 13b0156d..1c8edcad 100644 --- a/api/handler/chatimpl/qwen_handler.go +++ b/api/handler/chatimpl/qwen_handler.go @@ -82,10 +82,11 @@ func (h *ChatHandler) sendQWenMessage( continue } - if strings.HasPrefix(line, "data:") { - content = line[5:] + if !strings.HasPrefix(line, "data:") { + continue } + content = line[5:] var resp qWenResp if len(contents) == 0 { // 发送消息头 if !outPutStart {