fix: 1.还原6次输入 2.移除助手消息(纯噪音)

This commit is contained in:
fuzhongyun 2026-01-07 15:18:39 +08:00
parent cc0a05eb97
commit 5046e31b63
5 changed files with 27 additions and 27 deletions

View File

@ -31,7 +31,7 @@ lsxd:
sys:
session_len: 3
session_len: 6
channel_pool_len: 100
channel_pool_size: 32
llm_pool_len: 5

View File

@ -32,7 +32,7 @@ lsxd:
sys:
session_len: 3
session_len: 6
channel_pool_len: 100
channel_pool_size: 32
llm_pool_len: 5

View File

@ -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

View File

@ -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(), // 用户输入内容

View File

@ -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
// }