websocket接口与服务端进行连接,修改模型部分
This commit is contained in:
parent
611e027262
commit
419e2eea49
|
|
@ -12,3 +12,7 @@ type WSMessage struct {
|
||||||
SessionID int `json:"session_id"` //应用层会话id
|
SessionID int `json:"session_id"` //应用层会话id
|
||||||
ToID int `json:"to_id"` //接收者id
|
ToID int `json:"to_id"` //接收者id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ModelParam struct {
|
||||||
|
Model string `json:"model"` //模型名称
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@ func CreateGeneralMessageService(fromID, toID, msgType, sessionID int, msg strin
|
||||||
}
|
}
|
||||||
|
|
||||||
var client *api.Client
|
var client *api.Client
|
||||||
|
var actxMap map[int][]int
|
||||||
|
|
||||||
func WSReceiveMessageService(userID, sessionID int, channel string, msg proto.WSMessage) (error, uint) {
|
func WSReceiveMessageService(userID, sessionID int, channel string, msg proto.WSMessage) (error, uint) {
|
||||||
var resErr error
|
var resErr error
|
||||||
|
|
@ -91,9 +92,9 @@ 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
|
||||||
var actx []int
|
actx, _ := actxMap[sessionID]
|
||||||
req := &api.GenerateRequest{
|
req := &api.GenerateRequest{
|
||||||
Model: "qwen2.5-coder:latest",
|
Model: "qwen2.5:0.5b",
|
||||||
Context: actx,
|
Context: actx,
|
||||||
Prompt: prompt,
|
Prompt: prompt,
|
||||||
}
|
}
|
||||||
|
|
@ -107,6 +108,7 @@ func WSReceiveMessageService(userID, sessionID int, channel string, msg proto.WS
|
||||||
robotMsg += resp.Response
|
robotMsg += resp.Response
|
||||||
if resp.Done { //该消息完成
|
if resp.Done { //该消息完成
|
||||||
actx = resp.Context
|
actx = resp.Context
|
||||||
|
actxMap[sessionID] = actx
|
||||||
//创建消息
|
//创建消息
|
||||||
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 {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue