结构修改
This commit is contained in:
parent
d277ce1afb
commit
6b9b4e992f
|
@ -73,7 +73,7 @@ func (r *AiRouterBiz) RouteWithSocket(c *websocket.Conn, req *entitys.ChatSockRe
|
|||
requireData.Ch = make(chan entitys.Response)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
// 启动独立的消息处理协程
|
||||
done := r.startMessageHandler(ctx, c, &requireData)
|
||||
done := r.startMessageHandler(ctx, c, &requireData, req.Text)
|
||||
defer func() {
|
||||
close(requireData.Ch) //关闭主通道
|
||||
<-done // 等待消息处理完成
|
||||
|
@ -113,6 +113,7 @@ func (r *AiRouterBiz) startMessageHandler(
|
|||
ctx context.Context,
|
||||
c *websocket.Conn,
|
||||
requireData *entitys.RequireData,
|
||||
userInput string,
|
||||
) <-chan struct{} {
|
||||
done := make(chan struct{})
|
||||
var chat []string
|
||||
|
@ -125,7 +126,7 @@ func (r *AiRouterBiz) startMessageHandler(
|
|||
{
|
||||
SessionID: requireData.Session,
|
||||
Role: "user",
|
||||
Content: "", // 用户输入在外部处理
|
||||
Content: userInput, // 用户输入在外部处理
|
||||
},
|
||||
}
|
||||
if len(chat) > 0 {
|
||||
|
|
|
@ -62,6 +62,7 @@ func (s *SessionBiz) SessionInit(ctx context.Context, req *entitys.SessionInitRe
|
|||
SysID: sysConfig.SysID,
|
||||
SessionID: utils.UUID(),
|
||||
UserID: req.UserId,
|
||||
UserName: req.UserName,
|
||||
}
|
||||
err = s.sessionRepo.Create(&session)
|
||||
if err != nil {
|
||||
|
|
|
@ -21,6 +21,7 @@ type AiSession struct {
|
|||
Status int32 `gorm:"column:status;not null" json:"status"`
|
||||
DeleteAt *time.Time `gorm:"column:delete_at" json:"delete_at"`
|
||||
UserID string `gorm:"column:user_id;comment:用户id" json:"user_id"` // 用户id
|
||||
UserName string `gorm:"column:user_name;comment:用户名称" json:"user_name"` // 用户id
|
||||
}
|
||||
|
||||
// TableName AiSession's table name
|
||||
|
|
|
@ -3,6 +3,7 @@ package entitys
|
|||
type SessionInitRequest struct {
|
||||
SysId string `json:"sys_id"`
|
||||
UserId string `json:"user_id"`
|
||||
UserName string `json:"user_name"`
|
||||
}
|
||||
|
||||
type SessionInitResponse struct {
|
||||
|
|
Loading…
Reference in New Issue