20 lines
447 B
Go
20 lines
447 B
Go
package service
|
|
|
|
import (
|
|
"StuAcaWorksAI/dao"
|
|
"encoding/json"
|
|
"log"
|
|
)
|
|
|
|
func CreateAIStreamMsg(userID, modelID, sessionID int, msg interface{}, t string) (uint, error) {
|
|
msgStr, err := json.Marshal(msg)
|
|
if err != nil {
|
|
log.Println("ai stream msg Error parsing JSON:", err)
|
|
}
|
|
id := dao.InsertAIStreamMsgToDB(userID, sessionID, uint(modelID), string(msgStr), t)
|
|
if id == 0 {
|
|
log.Println("ai stream msg insert error")
|
|
}
|
|
return id, nil
|
|
}
|