添加腾讯混元大模型支持,修改openai循环引用问题

This commit is contained in:
junleea 2025-05-12 12:16:36 +08:00
parent de7ed81607
commit 785714fc46
1 changed files with 6 additions and 2 deletions

View File

@ -3,7 +3,6 @@ package generalModel
import ( import (
"StuAcaWorksAI/dao" "StuAcaWorksAI/dao"
"StuAcaWorksAI/proto" "StuAcaWorksAI/proto"
"StuAcaWorksAI/service"
"StuAcaWorksAI/worker" "StuAcaWorksAI/worker"
"context" "context"
"encoding/json" "encoding/json"
@ -47,7 +46,12 @@ func OpenAI(modelParam proto.ModelParam, imCtx *proto.IMParamContext, platform s
for stream.Next() { for stream.Next() {
chunk := stream.Current() chunk := stream.Current()
go service.CreateAIStreamMsg(imCtx.UserID, imCtx.ModelID, imCtx.SessionID, chunk, modelParam.Model) msgStr, err3 := json.Marshal(chunk)
if err3 != nil {
log.Println("openai stream msg Error parsing JSON:", err)
}
//go service.CreateAIStreamMsg(imCtx.UserID, imCtx.ModelID, imCtx.SessionID, chunk, modelParam.Model)
go dao.InsertAIStreamMsgToDB(imCtx.UserID, imCtx.SessionID, uint(imCtx.ModelID), string(msgStr), modelParam.Model) //存入数据库
acc.AddChunk(chunk) acc.AddChunk(chunk)
if _, ok := acc.JustFinishedToolCall(); ok { if _, ok := acc.JustFinishedToolCall(); ok {
chunk.Created = -1 // 这里由于没有返回结束标志,所以用该字段来判断 chunk.Created = -1 // 这里由于没有返回结束标志,所以用该字段来判断