From 5046e31b63a8779deb9c7510148465f2b3c6cea9 Mon Sep 17 00:00:00 2001 From: fuzhongyun <15339891972@163.com> Date: Wed, 7 Jan 2026 15:18:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=201.=E8=BF=98=E5=8E=9F6=E6=AC=A1=E8=BE=93?= =?UTF-8?q?=E5=85=A5=202.=E7=A7=BB=E9=99=A4=E5=8A=A9=E6=89=8B=E6=B6=88?= =?UTF-8?q?=E6=81=AF=EF=BC=88=E7=BA=AF=E5=99=AA=E9=9F=B3=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config.yaml | 2 +- config/config_env.yaml | 2 +- config/config_test.yaml | 2 +- internal/biz/do/prompt.go | 6 +++--- internal/biz/router.go | 42 +++++++++++++++++++-------------------- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/config/config.yaml b/config/config.yaml index 5e45ce9..33fa025 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -31,7 +31,7 @@ lsxd: sys: - session_len: 3 + session_len: 6 channel_pool_len: 100 channel_pool_size: 32 llm_pool_len: 5 diff --git a/config/config_env.yaml b/config/config_env.yaml index 0e002e0..b571f51 100644 --- a/config/config_env.yaml +++ b/config/config_env.yaml @@ -32,7 +32,7 @@ lsxd: sys: - session_len: 3 + session_len: 6 channel_pool_len: 100 channel_pool_size: 32 llm_pool_len: 5 diff --git a/config/config_test.yaml b/config/config_test.yaml index 873eb42..ec63488 100644 --- a/config/config_test.yaml +++ b/config/config_test.yaml @@ -32,7 +32,7 @@ lsxd: check_token_url: "https://api.user.1688sup.com/v1/user/welcome" sys: - session_len: 3 + session_len: 6 channel_pool_len: 100 channel_pool_size: 32 llm_pool_len: 5 diff --git a/internal/biz/do/prompt.go b/internal/biz/do/prompt.go index a27d698..b94d235 100644 --- a/internal/biz/do/prompt.go +++ b/internal/biz/do/prompt.go @@ -36,9 +36,9 @@ func (f *WithSys) CreatePrompt(ctx context.Context, rec *entitys.Recognize) (mes mes = append(prompt, api.Message{ Role: "system", // 系统角色 Content: rec.SystemPrompt, // 系统提示内容 - }, api.Message{ - Role: "assistant", // 助手角色 - Content: "### 聊天记录:" + pkg.JsonStringIgonErr(rec.ChatHis), // 助手回复内容 + // }, api.Message{ // 助手回复无需 + // Role: "assistant", // 助手角色 + // Content: "### 聊天记录:" + pkg.JsonStringIgonErr(rec.ChatHis), // 助手回复内容 }, api.Message{ Role: "user", // 用户角色 Content: content.String(), // 用户输入内容 diff --git a/internal/biz/router.go b/internal/biz/router.go index 2d827dc..3069ab0 100644 --- a/internal/biz/router.go +++ b/internal/biz/router.go @@ -178,13 +178,13 @@ func (r *AiRouterBiz) buildChatHistory(requireData *entitys.RequireData) entitys Timestamp: h.CreateAt.Format(time.DateTime), }) - // 助手消息 - ansStr := r.ansNoiseReduction(h.Ans) // 助手回复降噪 - messages = append(messages, entitys.HisMessage{ - Role: constants.RoleAssistant, // 助手角色 - Content: ansStr, // 助手回复内容 - Timestamp: h.CreateAt.Format(time.DateTime), - }) + // 助手消息 - 助手回复噪音太大且无需,pass + // ansStr := r.ansNoiseReduction(h.Ans) // 助手回复降噪 + // messages = append(messages, entitys.HisMessage{ + // Role: constants.RoleAssistant, // 助手角色 + // Content: ansStr, // 助手回复内容 + // Timestamp: h.CreateAt.Format(time.DateTime), + // }) } // 构建聊天历史上下文 @@ -199,18 +199,18 @@ func (r *AiRouterBiz) buildChatHistory(requireData *entitys.RequireData) entitys } // ansNoiseReduction 助手回复降噪 -func (r *AiRouterBiz) ansNoiseReduction(ansJson string) string { - // 使用anw统一类型解析 - ansStruct := make([]*entitys.Response, 0) - err := json.Unmarshal([]byte(ansJson), &ansStruct) - if err != nil { - log.Errorf("解析助手回复失败: %s", err.Error()) - return ansJson - } - var ansStr string - for _, item := range ansStruct { - ansStr += item.Content - } +// func (r *AiRouterBiz) ansNoiseReduction(ansJson string) string { +// // 使用anw统一类型解析 +// ansStruct := make([]*entitys.Response, 0) +// err := json.Unmarshal([]byte(ansJson), &ansStruct) +// if err != nil { +// log.Errorf("解析助手回复失败: %s", err.Error()) +// return ansJson +// } +// var ansStr string +// for _, item := range ansStruct { +// ansStr += item.Content +// } - return ansStr -} +// return ansStr +// }