修复模型类型问题

This commit is contained in:
junleea 2025-03-28 15:33:01 +08:00
parent b2c591cdb9
commit abd613d97a
1 changed files with 13 additions and 13 deletions

View File

@ -187,6 +187,18 @@ func subscribeAndHandleIMMessages(ws *websocket.Conn, userId int) {
} }
func doReceiveGenChatMessage(userId int, sessionID *uint, data *proto.WSMessageReq, chanel string) error { func doReceiveGenChatMessage(userId int, sessionID *uint, data *proto.WSMessageReq, chanel string) error {
var model dao.Model
//查看请求功能类型
models, funcs := service.FindFuncModelByFunction(data.Function, userId)
//log.Println("find function model by function:", models, funcs)
//log.Println("funcs:", len(funcs), "\tmodels:", len(models))
if len(funcs) == 0 {
return errors.New("function not exist")
}
if len(models) == 0 {
//log.Println("doReceiveGenChatMessage models:", models)
return errors.New("model not exist")
}
var err error var err error
if *sessionID == 0 { if *sessionID == 0 {
//创建会话 //创建会话
@ -196,18 +208,6 @@ func doReceiveGenChatMessage(userId int, sessionID *uint, data *proto.WSMessageR
log.Println("Create session error:", err) log.Println("Create session error:", err)
} }
} }
var model dao.Model
//查看请求功能类型
models, funcs := service.FindFuncModelByFunction(data.Function, userId)
log.Println("find function model by function:", models, funcs)
log.Println("funcs:", len(funcs), "\tmodels:", len(models))
if len(funcs) == 0 {
return errors.New("function not exist")
}
if len(models) == 0 {
log.Println("doReceiveGenChatMessage models:", models)
return errors.New("model not exist")
}
model = models[0] model = models[0]
//解析模型参数 //解析模型参数
var modelParam proto.ModelParam var modelParam proto.ModelParam
@ -217,7 +217,7 @@ func doReceiveGenChatMessage(userId int, sessionID *uint, data *proto.WSMessageR
} }
modelParam.Url = model.Url modelParam.Url = model.Url
modelParam.System = funcs[0].Info //系统功能 modelParam.System = funcs[0].Info //系统功能
imContext := proto.IMParamContext{UserID: userId, SessionID: int(*sessionID), FunctionID: int(funcs[0].ID), ModelID: int(model.ID), Question: data.Msg, Channel: chanel} imContext := proto.IMParamContext{UserID: userId, SessionID: int(*sessionID), FunctionID: int(funcs[0].ID), ModelID: int(model.ID), Question: data.Msg, Channel: chanel, ModelType: model.Type}
var userMsgID uint var userMsgID uint
//将消息存入数据库 //将消息存入数据库