feat: 新增主动拉取与多类型回调功能
- 新增 ActivePull 实体、DAO、DTO 及 Service,支持主动拉取任务管理 - 新增 ComposeCallback、VideoCallback、HttpNodeCallback 多类型回调接口 - FlowExecution 增加 NodeGroupId 和 TotalTokens 字段,支持节点组追踪与 Token 统计 - ExecutedNodes 结构由字符串列表改为包含执行状态的节点对象列表 - 重构回调通知机制,统一 Notify 函数调用 - 优化输出项类型判断逻辑,新增文件类型标识
This commit is contained in:
28
workflow/model/entity/active_pull.go
Normal file
28
workflow/model/entity/active_pull.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package entity
|
||||
|
||||
import "gitea.com/red-future/common/beans"
|
||||
|
||||
type ActivePull struct {
|
||||
beans.SQLBaseDO `orm:",inherit"` // 嵌入基础字段:Id, TenantId, Creator, CreatedAt, Updater, UpdatedAt, DeletedAt
|
||||
|
||||
Type string `orm:"type" json:"type"`
|
||||
RequestParament map[string]any `orm:"request_parament" json:"requestParament"`
|
||||
ResponseParament map[string]any `orm:"response_parament" json:"responseParament"`
|
||||
Extension map[string]any `orm:"extension" json:"extension"`
|
||||
}
|
||||
|
||||
type activePullCol struct {
|
||||
beans.SQLBaseCol
|
||||
Type string
|
||||
RequestParament string
|
||||
ResponseParament string
|
||||
Extension string
|
||||
}
|
||||
|
||||
var ActivePullCol = activePullCol{
|
||||
SQLBaseCol: beans.DefSQLBaseCol,
|
||||
Type: "type",
|
||||
RequestParament: "request_parament",
|
||||
ResponseParament: "response_parament",
|
||||
Extension: "extension",
|
||||
}
|
||||
@@ -11,6 +11,7 @@ type FlowExecution struct {
|
||||
// 业务字段
|
||||
FlowUserId int64 `orm:"flow_user_id" json:"flowUserId" description:"流程ID"`
|
||||
FlowName string `orm:"flow_name" json:"flowName" description:"流程名称"`
|
||||
NodeGroupId string `orm:"node_group_id" json:"nodeGroupId" description:"节点组ID"`
|
||||
TriggerType flow.FlowExecutionTriggerType `orm:"trigger_type" json:"triggerType" description:"触发类型"`
|
||||
DurationMs int64 `orm:"duration_ms" json:"durationMs" description:"执行时长(毫秒)"`
|
||||
Status flow.FlowExecutionStatus `orm:"status" json:"status" description:"状态:1-运行中,2-成功,3-失败"`
|
||||
@@ -20,12 +21,14 @@ type FlowExecution struct {
|
||||
ErrorMessage string `orm:"error_message" json:"errorMessage" description:"错误信息"`
|
||||
TraceId string `orm:"trace_id" json:"traceId" description:"跟踪ID"`
|
||||
SessionId string `orm:"session_id" json:"sessionId" description:"会话ID"`
|
||||
TotalTokens int `orm:"total_tokens" json:"totalTokens" description:"总token消耗"`
|
||||
}
|
||||
|
||||
type flowExecutionCol struct {
|
||||
beans.SQLBaseCol
|
||||
FlowUserId string
|
||||
FlowName string
|
||||
NodeGroupId string
|
||||
TriggerType string
|
||||
DurationMs string
|
||||
Status string
|
||||
@@ -35,12 +38,14 @@ type flowExecutionCol struct {
|
||||
ErrorMessage string
|
||||
TraceId string
|
||||
SessionId string
|
||||
TotalTokens string
|
||||
}
|
||||
|
||||
var FlowExecutionCol = flowExecutionCol{
|
||||
SQLBaseCol: beans.DefSQLBaseCol,
|
||||
FlowUserId: "flow_user_id",
|
||||
FlowName: "flow_name",
|
||||
NodeGroupId: "node_group_id",
|
||||
TriggerType: "trigger_type",
|
||||
DurationMs: "duration_ms",
|
||||
Status: "status",
|
||||
@@ -50,4 +55,5 @@ var FlowExecutionCol = flowExecutionCol{
|
||||
ErrorMessage: "error_message",
|
||||
TraceId: "trace_id",
|
||||
SessionId: "session_id",
|
||||
TotalTokens: "total_tokens",
|
||||
}
|
||||
|
||||
@@ -15,15 +15,18 @@ type FlowInfo struct {
|
||||
}
|
||||
|
||||
type FlowNode struct {
|
||||
Id string `json:"id"`
|
||||
NodeCode node.NodeType `json:"nodeCode"`
|
||||
Name string `json:"name"`
|
||||
Config map[string]interface{} `json:"config"`
|
||||
SkillName string `json:"skillName"`
|
||||
InputSource []FlowNodeInputSource `json:"inputSource"` // 前端指定:来源节点ID
|
||||
FormConfig []node.NodeFormField `json:"formConfig"`
|
||||
ModelConfig node.ModelItem `json:"modelConfig"`
|
||||
OutputResult []node.NodeFormField `json:"outputResult" ds:"节点输出结果"`
|
||||
Id string `json:"id"`
|
||||
NodeCode node.NodeType `json:"nodeCode"`
|
||||
Name string `json:"name"`
|
||||
Config map[string]interface{} `json:"config"`
|
||||
SkillName string `json:"skillName"`
|
||||
PromptContent string `json:"promptContent"`
|
||||
IsSaveFile bool `json:"isSaveFile"`
|
||||
InputSource []FlowNodeInputSource `json:"inputSource"` // 前端指定:来源节点ID
|
||||
FormConfig []node.NodeFormField `json:"formConfig"`
|
||||
ModelConfig node.ModelItem `json:"modelConfig"`
|
||||
OutputConfig []node.NodeFormField `json:"outputConfig"`
|
||||
OutputResult []node.NodeFormField `json:"outputResult" ds:"节点输出结果"`
|
||||
}
|
||||
|
||||
type FlowNodeInputSource struct {
|
||||
|
||||
58
workflow/model/entity/node_execution.go
Normal file
58
workflow/model/entity/node_execution.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"ai-agent/workflow/consts/node"
|
||||
|
||||
"gitea.com/red-future/common/beans"
|
||||
)
|
||||
|
||||
// NodeExecution 节点执行记录
|
||||
// 记录每个节点的入参、出参、token消耗、执行状态等信息
|
||||
type NodeExecution struct {
|
||||
beans.SQLBaseDO `orm:",inherit"` // 嵌入基础字段:Id, TenantId, Creator, CreatedAt, Updater, UpdatedAt, DeletedAt
|
||||
|
||||
FlowExecutionId int64 `orm:"flow_execution_id" json:"flowExecutionId" description:"流程执行ID"`
|
||||
NodeId string `orm:"node_id" json:"nodeId" description:"节点ID"`
|
||||
NodeName string `orm:"node_name" json:"nodeName" description:"节点名称"`
|
||||
NodeGroupId string `orm:"node_group_id" json:"nodeGroupId" description:"节点组ID"`
|
||||
InputParams map[string]interface{} `orm:"input_params" json:"inputParams" description:"节点输入参数"`
|
||||
OutputParams map[string]interface{} `orm:"output_params" json:"outputParams" description:"节点输出参数"`
|
||||
PromptTokens int `orm:"prompt_tokens" json:"promptTokens" description:"提示词token消耗"`
|
||||
CompletionTokens int `orm:"completion_tokens" json:"completionTokens" description:"补全token消耗"`
|
||||
TotalTokens int `orm:"total_tokens" json:"totalTokens" description:"总token消耗"`
|
||||
Status node.NodeExecutionStatus `orm:"status" json:"status" description:"执行状态:1-运行中,2-成功,3-失败,4-暂停,5-等待执行"`
|
||||
DurationMs int64 `orm:"duration_ms" json:"durationMs" description:"执行时长(毫秒)"`
|
||||
ErrorMessage string `orm:"error_message" json:"errorMessage" description:"错误信息"`
|
||||
}
|
||||
|
||||
type nodeExecutionCol struct {
|
||||
beans.SQLBaseCol
|
||||
FlowExecutionId string
|
||||
NodeId string
|
||||
NodeName string
|
||||
NodeGroupId string
|
||||
InputParams string
|
||||
OutputParams string
|
||||
PromptTokens string
|
||||
CompletionTokens string
|
||||
TotalTokens string
|
||||
Status string
|
||||
DurationMs string
|
||||
ErrorMessage string
|
||||
}
|
||||
|
||||
var NodeExecutionCol = nodeExecutionCol{
|
||||
SQLBaseCol: beans.DefSQLBaseCol,
|
||||
FlowExecutionId: "flow_execution_id",
|
||||
NodeId: "node_id",
|
||||
NodeName: "node_name",
|
||||
NodeGroupId: "node_group_id",
|
||||
InputParams: "input_params",
|
||||
OutputParams: "output_params",
|
||||
PromptTokens: "prompt_tokens",
|
||||
CompletionTokens: "completion_tokens",
|
||||
TotalTokens: "total_tokens",
|
||||
Status: "status",
|
||||
DurationMs: "duration_ms",
|
||||
ErrorMessage: "error_message",
|
||||
}
|
||||
29
workflow/model/entity/node_prompt.go
Normal file
29
workflow/model/entity/node_prompt.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"ai-agent/workflow/consts/node"
|
||||
|
||||
"gitea.com/red-future/common/beans"
|
||||
)
|
||||
|
||||
type NodePrompt struct {
|
||||
beans.SQLBaseDO `orm:",inherit"` // 嵌入基础字段:Id, TenantId, Creator, CreatedAt, Updater, UpdatedAt, DeletedAt
|
||||
|
||||
NodeType node.NodeType `orm:"node_type" json:"nodeType"`
|
||||
Prompt string `orm:"prompt" json:"prompt"`
|
||||
SourceType node.SourceType `orm:"source_type" json:"sourceType"`
|
||||
}
|
||||
|
||||
type nodePromptCol struct {
|
||||
beans.SQLBaseCol
|
||||
NodeType string
|
||||
Prompt string
|
||||
SourceType string
|
||||
}
|
||||
|
||||
var NodePromptCol = nodePromptCol{
|
||||
SQLBaseCol: beans.DefSQLBaseCol,
|
||||
NodeType: "node_type",
|
||||
Prompt: "prompt",
|
||||
SourceType: "source_type",
|
||||
}
|
||||
Reference in New Issue
Block a user