2026-05-12 13:34:28 +08:00
|
|
|
|
package flow
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"ai-agent/workflow/consts/flow"
|
2026-06-10 14:23:55 +08:00
|
|
|
|
"ai-agent/workflow/consts/node"
|
2026-05-12 13:34:28 +08:00
|
|
|
|
"ai-agent/workflow/model/entity"
|
|
|
|
|
|
|
2026-06-11 09:16:53 +08:00
|
|
|
|
"gitea.redpowerfuture.com/red-future/common/beans"
|
2026-05-12 13:34:28 +08:00
|
|
|
|
"github.com/gogf/gf/v2/frame/g"
|
|
|
|
|
|
"github.com/gogf/gf/v2/os/gtime"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// NodeExecutionInput 节点执行入参(包含配置+表单架构)
|
|
|
|
|
|
type NodeExecutionInput struct {
|
2026-06-10 14:23:55 +08:00
|
|
|
|
Config *entity.FlowNode `json:"config"` // 节点配置
|
|
|
|
|
|
Global *FlowExecutionInput `json:"global"`
|
|
|
|
|
|
NodeExecutionId int64 `json:"nodeExecutionId"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ExecutedNode 已执行节点记录,包含节点ID和执行状态
|
|
|
|
|
|
type ExecutedNode struct {
|
|
|
|
|
|
NodeId string `json:"nodeId"`
|
|
|
|
|
|
Status node.NodeExecutionStatus `json:"status"` // 执行状态:成功/失败
|
2026-05-12 13:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// FlowExecutionInput 工作流执行入参(全程不变)
|
|
|
|
|
|
type FlowExecutionInput struct {
|
2026-06-10 14:23:55 +08:00
|
|
|
|
NodeGroupId string `json:"nodeGroupId"`
|
2026-05-15 09:37:23 +08:00
|
|
|
|
IsDialogue bool `json:"isDialogue"`
|
2026-05-12 13:34:28 +08:00
|
|
|
|
ExecutionId int64 `json:"executionId"`
|
|
|
|
|
|
ConfigMap map[string]*entity.FlowNode `json:"configMap"`
|
|
|
|
|
|
SessionId string `json:"sessionId" dc:"会话ID"`
|
|
|
|
|
|
Desc string `json:"desc"`
|
|
|
|
|
|
SkillName string `json:"skillName"`
|
|
|
|
|
|
FileUrl []string `json:"fileUrl"`
|
2026-06-10 14:23:55 +08:00
|
|
|
|
ExecutedNodes []ExecutedNode `json:"executedNodes"` // 已执行节点列表,包含执行状态
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type GetIsChatModelRes struct {
|
|
|
|
|
|
Model struct {
|
|
|
|
|
|
ModelName string `json:"modelName"`
|
|
|
|
|
|
ResponseBody map[string]any `json:"responseBody"`
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type GetModelInfoReq struct {
|
|
|
|
|
|
ModelName string `json:"modelName"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type GetModelInfoRes struct {
|
|
|
|
|
|
Model struct {
|
|
|
|
|
|
LastFrame string `json:"lastFrame"`
|
|
|
|
|
|
ResponseTokenField string `json:"responseTokenField"`
|
|
|
|
|
|
ResponseMapping map[string]any `json:"responseMapping"`
|
|
|
|
|
|
ResponseBody string `json:"responseBody"`
|
|
|
|
|
|
//QueryConfig struct {
|
|
|
|
|
|
// ResponseType string `json:"responseType"`
|
|
|
|
|
|
// CallbackUrl string `json:"callbackUrl"`
|
|
|
|
|
|
// Method string `json:"method"`
|
|
|
|
|
|
// Url string `json:"url"`
|
|
|
|
|
|
// Headers map[string]any `json:"headers"`
|
|
|
|
|
|
// Body map[string]any `json:"body"`
|
|
|
|
|
|
// Response []map[string]any `json:"response"`
|
|
|
|
|
|
// ResponseBody string `json:"responseBody"`
|
|
|
|
|
|
// ResponseTokenField string `json:"responseTokenField"`
|
|
|
|
|
|
//} `json:"queryConfig"`
|
|
|
|
|
|
} `json:"model"`
|
2026-05-12 13:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type ComposeMessagesReq struct {
|
2026-06-10 14:23:55 +08:00
|
|
|
|
BuildType int `json:"buildType"`
|
|
|
|
|
|
ModelName string `json:"modelName"`
|
|
|
|
|
|
SkillName string `json:"skillName"`
|
|
|
|
|
|
CallbackUrl string `json:"callbackUrl"`
|
|
|
|
|
|
Form []map[string]any `json:"form"`
|
|
|
|
|
|
UserForm []map[string]any `json:"userForm"`
|
|
|
|
|
|
Consult []Consult `json:"consult"`
|
|
|
|
|
|
SessionId string `json:"sessionId" dc:"会话ID"`
|
|
|
|
|
|
NodeId string `json:"nodeId"`
|
|
|
|
|
|
Cause string `json:"cause"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type Consult struct {
|
|
|
|
|
|
Type string `json:"type"`
|
|
|
|
|
|
Url string `json:"url"`
|
2026-05-12 13:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type ComposeMessagesRes struct {
|
2026-06-10 14:23:55 +08:00
|
|
|
|
TaskId string `json:"taskId"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type VideoConcatReq struct {
|
|
|
|
|
|
VideoUrls []string `json:"video_urls"`
|
|
|
|
|
|
Method string `json:"method"`
|
|
|
|
|
|
Upload bool `json:"upload"`
|
|
|
|
|
|
CallbackUrl string `json:"callback_url"`
|
2026-05-12 13:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-10 14:23:55 +08:00
|
|
|
|
type VideoConcatRes struct {
|
|
|
|
|
|
TaskId string `json:"taskId"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type ModelGatewayReq struct {
|
2026-05-12 13:34:28 +08:00
|
|
|
|
ModelName string `json:"modelName"`
|
|
|
|
|
|
ModelKey string `json:"modelKey"`
|
|
|
|
|
|
BizName string `json:"bizName"`
|
|
|
|
|
|
CallbackUrl string `json:"callbackUrl"`
|
|
|
|
|
|
InputRef string `json:"inputRef"`
|
|
|
|
|
|
RequestPayload map[string]any `json:"requestPayload"`
|
|
|
|
|
|
EpicycleId int64 `json:"epicycleId" dc:"轮次ID"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-10 14:23:55 +08:00
|
|
|
|
type ModelGatewayRes struct {
|
2026-05-12 13:34:28 +08:00
|
|
|
|
TaskId string `json:"taskId"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-10 14:23:55 +08:00
|
|
|
|
type ComposeCallbackReq struct {
|
|
|
|
|
|
g.Meta `path:"/composeCallBack" method:"post" tags:"提示词处理" summary:"提示词 回调" dc:"提示词 成功后 GET 回调:callbackUrl/{bizName}"`
|
|
|
|
|
|
TaskId string `json:"taskId"`
|
|
|
|
|
|
Status string `json:"status"`
|
|
|
|
|
|
Messages struct {
|
|
|
|
|
|
TotalRounds int `json:"total_rounds"` // 总轮数
|
|
|
|
|
|
Rounds []map[string]any `json:"rounds"` // 每轮详情(动态类型)
|
|
|
|
|
|
} `json:"messages,omitempty"`
|
|
|
|
|
|
EpicycleId int64 `json:"epicycleId"`
|
|
|
|
|
|
ErrorMsg string `json:"errorMsg,omitempty"`
|
2026-05-12 13:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type ModelCallbackReq struct {
|
|
|
|
|
|
g.Meta `path:"/modelCallback" method:"post" tags:"提示词处理" summary:"model-gateway 回调" dc:"model-gateway 成功后 GET 回调:callbackUrl/{bizName}"`
|
2026-06-10 14:23:55 +08:00
|
|
|
|
TaskId string `p:"task_id" json:"task_id" v:"required#task_id不能为空" dc:"网关任务ID"`
|
|
|
|
|
|
State int `p:"state" json:"state" dc:"网关任务状态"`
|
|
|
|
|
|
OssFile string `p:"oss_file" json:"oss_file" dc:"结果文件地址"`
|
|
|
|
|
|
FileType string `p:"file_type" json:"file_type" dc:"结果文件类型"`
|
|
|
|
|
|
Messages map[string]any `json:"messages"`
|
|
|
|
|
|
ErrorMsg string `json:"error_msg"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type VideoCallbackReq struct {
|
|
|
|
|
|
g.Meta `path:"/videoCallback" method:"post" tags:"视频处理" summary:"media 回调" dc:"media 成功后 GET 回调:callbackUrl/{bizName}"`
|
|
|
|
|
|
TaskId string `json:"taskId"`
|
|
|
|
|
|
FileURL string `json:"fileUrl"`
|
2026-05-12 13:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
2026-06-10 14:23:55 +08:00
|
|
|
|
// 原始入参结构体
|
|
|
|
|
|
type Word struct {
|
|
|
|
|
|
Confidence float64 `json:"confidence"`
|
|
|
|
|
|
StartTime float64 `json:"startTime"`
|
|
|
|
|
|
EndTime float64 `json:"endTime"`
|
|
|
|
|
|
Word string `json:"word"`
|
|
|
|
|
|
}
|
|
|
|
|
|
type Sentence struct {
|
|
|
|
|
|
EndTime float64 `json:"endTime"`
|
|
|
|
|
|
StartTime float64 `json:"startTime"`
|
|
|
|
|
|
Text string `json:"text"`
|
|
|
|
|
|
Words []Word `json:"words"`
|
|
|
|
|
|
}
|
|
|
|
|
|
type InputData struct {
|
|
|
|
|
|
Data struct {
|
|
|
|
|
|
Sentences []Sentence `json:"sentences"`
|
|
|
|
|
|
} `json:"data"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 输出目标结构体(对应截图subtitles格式)
|
|
|
|
|
|
type Subtitle struct {
|
|
|
|
|
|
Start float64 `json:"start"`
|
|
|
|
|
|
End float64 `json:"end"`
|
|
|
|
|
|
Text string `json:"text"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
|
2026-05-12 13:34:28 +08:00
|
|
|
|
type ExecuteReq struct {
|
|
|
|
|
|
g.Meta `path:"/execute" method:"post" tags:"任务管理" summary:"执行任务" dc:"执行任务"`
|
|
|
|
|
|
|
|
|
|
|
|
FlowId int64 `json:"flowId" dc:"用户流程ID"`
|
|
|
|
|
|
FlowName string `json:"flowName"`
|
2026-06-10 14:23:55 +08:00
|
|
|
|
NodeGroupId string `json:"nodeGroupId"`
|
2026-05-12 13:34:28 +08:00
|
|
|
|
FlowContent *entity.FlowInfo `json:"flowContent" description:"流程内容"`
|
|
|
|
|
|
NodeInputParams []*entity.FlowNode `json:"nodeInputParams" description:"节点输入参数"`
|
|
|
|
|
|
SessionId string `json:"sessionId" dc:"会话ID"`
|
|
|
|
|
|
Desc string `json:"desc"`
|
|
|
|
|
|
SkillName string `json:"skillName"`
|
|
|
|
|
|
FileUrl []string `json:"fileUrl"`
|
2026-05-15 18:30:44 +08:00
|
|
|
|
ResultUrl string `json:"resultUrl"`
|
2026-05-12 13:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type ExecuteRes struct {
|
|
|
|
|
|
Id int64 `json:"id,string" dc:"执行记录ID,用于查询执行状态和结果"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type CancelReq struct {
|
2026-05-15 09:37:23 +08:00
|
|
|
|
g.Meta `path:"/cancel" method:"post" tags:"任务管理" summary:"取消任务" dc:"取消任务"`
|
2026-05-12 13:34:28 +08:00
|
|
|
|
|
2026-05-15 09:37:23 +08:00
|
|
|
|
SessionId string `json:"sessionId" dc:"会话ID"`
|
2026-05-12 13:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type CreateFlowExecutionReq struct {
|
|
|
|
|
|
FlowUserId int64 `json:"flowUserId" description:"流程ID"`
|
|
|
|
|
|
FlowName string `json:"flowName"`
|
2026-06-10 14:23:55 +08:00
|
|
|
|
NodeGroupId string `json:"nodeGroupId"`
|
2026-05-12 13:34:28 +08:00
|
|
|
|
TriggerType flow.FlowExecutionTriggerType `json:"triggerType" description:"触发类型"`
|
|
|
|
|
|
DurationMs int64 `json:"durationMs" description:"执行时长(毫秒)"`
|
|
|
|
|
|
Status flow.FlowExecutionStatus `json:"status" description:"状态:1-运行中,2-成功,3-失败"`
|
|
|
|
|
|
FlowContent *entity.FlowInfo `json:"flowContent" description:"流程内容"`
|
|
|
|
|
|
NodeInputParams []*entity.FlowNode `json:"nodeInputParams" description:"节点输入参数"`
|
|
|
|
|
|
OutputParams []map[string]interface{} `json:"outputParams" description:"输出参数"`
|
|
|
|
|
|
ErrorMessage string `json:"errorMessage" description:"错误信息"`
|
|
|
|
|
|
TraceId string `json:"traceId" description:"跟踪ID"`
|
|
|
|
|
|
SessionId string `json:"sessionId" dc:"会话ID"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type CreateFlowExecutionRes struct {
|
|
|
|
|
|
Id int64 `json:"id,string"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type UpdateFlowExecutionReq struct {
|
|
|
|
|
|
Id int64 `json:"id" v:"required#ID不能为空"`
|
2026-06-10 14:23:55 +08:00
|
|
|
|
NodeGroupId string `json:"nodeGroupId"`
|
2026-05-12 13:34:28 +08:00
|
|
|
|
DurationMs int64 `json:"durationMs" description:"执行时长(毫秒)"`
|
|
|
|
|
|
Status flow.FlowExecutionStatus `json:"status" description:"状态:1-运行中,2-成功,3-失败"`
|
|
|
|
|
|
OutputParams []map[string]interface{} `json:"outputParams" description:"输出参数"`
|
|
|
|
|
|
ErrorMessage string `json:"errorMessage" description:"错误信息"`
|
|
|
|
|
|
TraceId string `json:"traceId" description:"跟踪ID"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type GetFlowExecutionReq struct {
|
|
|
|
|
|
g.Meta `path:"/get" method:"get" tags:"任务管理" summary:"获取任务详情" dc:"获取任务详情"`
|
|
|
|
|
|
|
|
|
|
|
|
Id int64 `json:"id" v:"required#ID不能为空"`
|
|
|
|
|
|
SessionId string `json:"sessionId" dc:"会话ID"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type ListFlowExecutionReq struct {
|
|
|
|
|
|
g.Meta `path:"/list" method:"get" tags:"任务管理" summary:"任务列表" dc:"任务列表"`
|
|
|
|
|
|
|
|
|
|
|
|
Page *beans.Page `json:"page"`
|
|
|
|
|
|
Creator string `json:"creator"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type ListFlowExecutionRes struct {
|
|
|
|
|
|
List []*VOFlowExecution `json:"list"`
|
|
|
|
|
|
Total int `json:"total"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type VOFlowExecution struct {
|
2026-05-15 09:37:23 +08:00
|
|
|
|
Id int64 `json:"id,string" dc:"id"`
|
|
|
|
|
|
FlowUserId int64 `json:"flowUserId,string" description:"流程ID"`
|
|
|
|
|
|
FlowName string `json:"flowName"`
|
|
|
|
|
|
TriggerType flow.FlowExecutionTriggerType `json:"triggerType" description:"触发类型"`
|
|
|
|
|
|
DurationMs int64 `json:"durationMs" description:"执行时长(毫秒)"`
|
|
|
|
|
|
Status flow.FlowExecutionStatus `json:"status" description:"状态:1-运行中,2-成功,3-失败"`
|
|
|
|
|
|
FlowContent *entity.FlowInfo `json:"flowContent" description:"流程内容"`
|
|
|
|
|
|
NodeInputParams []*entity.FlowNode `json:"nodeInputParams" description:"节点输入参数"`
|
|
|
|
|
|
OutputParams []map[string]interface{} `json:"outputParams" description:"输出参数"`
|
|
|
|
|
|
ErrorMessage string `json:"errorMessage" description:"错误信息"`
|
|
|
|
|
|
TraceId string `json:"traceId" description:"跟踪ID"`
|
|
|
|
|
|
SessionId string `json:"sessionId" dc:"会话ID"`
|
|
|
|
|
|
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
|
|
|
|
|
|
UpdatedAt *gtime.Time `json:"updatedAt" dc:"更新时间"`
|
|
|
|
|
|
ImgAddressPrefix string `json:"imgAddressPrefix"`
|
2026-05-12 13:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ========== 核心:构建树状结构 ==========
|
|
|
|
|
|
// 定义树结构
|
|
|
|
|
|
type OutputItem struct {
|
|
|
|
|
|
Timestamp string `json:"timestamp" description:"时间戳key"`
|
|
|
|
|
|
Content string `json:"content" description:"内容值"`
|
2026-06-10 14:23:55 +08:00
|
|
|
|
Type string `json:"type" description:"类型"`
|
2026-05-12 13:34:28 +08:00
|
|
|
|
Label string `json:"label" description:"后缀+数字标号"`
|
|
|
|
|
|
}
|
|
|
|
|
|
type FlowNode struct {
|
|
|
|
|
|
FlowName string `json:"flowName" description:"流程名称"`
|
2026-05-12 14:31:51 +08:00
|
|
|
|
Id int64 `json:"Id,string" description:"任务ID"`
|
2026-05-12 13:34:28 +08:00
|
|
|
|
SessionId string `json:"sessionId" description:"会话ID"`
|
|
|
|
|
|
Items []OutputItem `json:"items" description:"输出项列表"`
|
|
|
|
|
|
}
|
|
|
|
|
|
type DateNode struct {
|
|
|
|
|
|
CreateDate string `json:"createDate" description:"创建日期"`
|
|
|
|
|
|
Flows []FlowNode `json:"flows" description:"流程列表"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type ListFlowExecutionTreeRes struct {
|
|
|
|
|
|
Tree []DateNode `json:"tree"`
|
|
|
|
|
|
ImgAddressPrefix string `json:"imgAddressPrefix"`
|
|
|
|
|
|
}
|