package session import ( "ai-agent/workflow/model/entity" "gitea.redpowerfuture.com/red-future/common/beans" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gtime" ) // WebSocketConnectReq WebSocket 连接请求(query string 参数) type WebSocketConnectReq struct { g.Meta `path:"/wsExecute" method:"get" tags:"工作流执行" summary:"WebSocket执行工作流" dc:"通过WebSocket连接实时执行工作流,支持进度推送和取消"` SessionId string `p:"sessionId" dc:"会话ID"` } type WebSocketExecChatReq struct { Id int64 `json:"id" dc:"id"` ModelId int64 `json:"modelId" dc:"模型ID" v:"required#模型ID不能为空"` Question string `json:"question" dc:"用户提问" v:"required#用户提问不能为空"` SystemPrompt string `json:"systemPrompt" dc:"系统提示词"` } type WebSocketExecWorkflowReq struct { FlowId int64 `json:"flowId" dc:"用户流程ID" v:"required#用户流程ID不能为空"` FlowContent *entity.FlowInfo `json:"flowContent" dc:"用户流程内容" v:"required#用户流程内容不能为空"` } type CreateSessionReq struct { SessionId string `json:"sessionId" dc:"会话ID"` SessionName string `json:"sessionName" dc:"会话名称"` } type ListSessionReq struct { g.Meta `path:"/list" method:"get" tags:"会话管理" summary:"会话列表" dc:"会话列表"` PageNum int64 `json:"pageNum" dc:"页码,从1开始"` PageSize int64 `json:"pageSize" dc:"每页数量"` } type ListSessionRes struct { List []*VOSession `json:"list"` Total int `json:"total"` } type VOSession struct { SessionId string `json:"sessionId" dc:"会话ID"` SessionName string `json:"sessionName" dc:"会话名称"` CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"` } type DeleteSessionReq struct { g.Meta `path:"/delete" method:"delete" tags:"会话管理" summary:"删除会话" dc:"删除会话"` SessionId string `json:"sessionId" v:"required#会话ID不能为空"` } type DeleteSessionRecordReq struct { g.Meta `path:"/deleteRecord" method:"post" tags:"会话管理" summary:"删除会话记录" dc:"删除会话记录"` Ids []struct { Id int64 `json:"id" v:"required#ID不能为空"` Type string `json:"type" v:"required#类型不能为空"` } } type GetSessionInfoReq struct { g.Meta `path:"/get" method:"get" tags:"会话管理" summary:"会话内结果列表" dc:"会话内结果列表,工作流+普通对话混排按时间倒序"` PageNum int64 `json:"pageNum" dc:"页码,从1开始"` PageSize int64 `json:"pageSize" dc:"每页数量"` SessionId string `json:"sessionId" v:"required#会话ID不能为空"` } type GetSessionInfoRes struct { List []*VOSessionInfoResult `json:"list"` Total int `json:"total"` } // VOSessionInfoResult 会话内单条结果(工作流/普通对话混排) type VOSessionInfoResult struct { Id int64 `json:"id,string" dc:"结果ID"` Type string `json:"type" dc:"workflow-工作流结果,chat-普通对话结果"` Status int `json:"status" dc:"1-运行中,2-成功,3-失败"` FlowId int64 `json:"flowId,string" dc:"工作流ID(chat类型为空)"` RequestParams map[string]any `json:"requestParams" description:"请求参数"` ResultFileUrl string `json:"resultFileUrl" description:"结果文件路径(供预览/下载)"` ResultContent string `json:"resultContent" description:"结果文件内容(服务端已读取,前端直接展示)"` TotalTokens int `json:"totalTokens" dc:"总token消耗"` TotalFee float64 `json:"totalFee" dc:"模型扣费合计(各模型按次费用)"` ActualAmount float64 `json:"actualAmount" dc:"业务扣费(用户钱包实际扣除,元)"` ErrorMsg string `json:"errorMsg" dc:"错误信息(友好提示)"` Error string `json:"error" dc:"错误明细(原始错误)"` CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"` } type ListWorkflowResultReq struct { g.Meta `path:"/resultList" method:"get" tags:"会话管理" summary:"工作流执行结果树" dc:"按创建人分页查询工作流执行结果,按天分组返回树结构(日期→流程→结果文件),pageSize=每页天数,不传返回全部"` Page *beans.Page `json:"page"` } type DeleteWorkflowResultReq struct { g.Meta `path:"/resultDelete" method:"delete" tags:"会话管理" summary:"删除工作流执行结果" dc:"删除工作流执行结果"` Id int64 `json:"id" v:"required#ID不能为空"` }