添加ai对话背景日志输出

This commit is contained in:
junleea 2025-03-22 17:30:32 +08:00
parent 1c578fb597
commit 0ab5328bab
1 changed files with 5 additions and 1 deletions

View File

@ -92,7 +92,10 @@ func WSReceiveMessageService(userID, sessionID int, channel string, msg proto.WS
log.Println("get ollama client error:", err) log.Println("get ollama client error:", err)
} }
prompt := msg.Msg prompt := msg.Msg
actx, _ := actxMap[sessionID] actx, ok := actxMap[sessionID]
if ok {
log.Println("actx has get will use:", len(actx))
}
req := &api.GenerateRequest{ req := &api.GenerateRequest{
Model: "qwen2.5:0.5b", Model: "qwen2.5:0.5b",
Context: actx, Context: actx,
@ -112,6 +115,7 @@ func WSReceiveMessageService(userID, sessionID int, channel string, msg proto.WS
actxMap = make(map[int][]int) actxMap = make(map[int][]int)
} }
actxMap[sessionID] = actx actxMap[sessionID] = actx
log.Println("actx has save:", len(actxMap[sessionID]))
//创建消息 //创建消息
err2, msgID := CreateMessage(2, sessionID, 2, userID, robotMsg, 1) //机器人id为2,消息类型为2,状态为1 err2, msgID := CreateMessage(2, sessionID, 2, userID, robotMsg, 1) //机器人id为2,消息类型为2,状态为1
if err2 != nil { if err2 != nil {