- 新增计费模块:执行开始建单、终态结算/取消/失败处理,支持按条/按秒/按token计费 - 新增执行生命周期跟踪:优雅关停时取消运行中执行并等待落库 - 新增异步任务等待/通知机制(Wait/Notify) - 重构执行记录落库与进度上报,统一失败分类与重试语义 - 重命名文件:async_task.go→async.go、flow_checkpoint_store.go→exec_checkpoint.go、flow_graph_util.go→exec_record.go - 更新 .gitignore 与数据库密码配置
111 lines
4.5 KiB
Go
111 lines
4.5 KiB
Go
package entity
|
||
|
||
import (
|
||
"ai-agent/workflow/consts/flow"
|
||
"ai-agent/workflow/consts/node"
|
||
|
||
"gitea.redpowerfuture.com/red-future/common/beans"
|
||
)
|
||
|
||
type FlowInfo struct {
|
||
Version string `json:"version"`
|
||
StartNodeId string `json:"startNodeId"`
|
||
Nodes []FlowNode `json:"nodes"`
|
||
Edges []FlowEdge `json:"edges"`
|
||
ChargeMode string `json:"chargeMode"` // 计费方式:per_item/per_second/per_token(缺省 per_item,对齐 shop-user-trade consts/pricing)
|
||
}
|
||
|
||
type FlowNode struct {
|
||
Id string `json:"id"`
|
||
NodeCode node.NodeType `json:"nodeCode"`
|
||
Name string `json:"name"`
|
||
Desc string `json:"desc"`
|
||
Config map[string]interface{} `json:"config"`
|
||
IsBatchExec bool `json:"isBatchExec"`
|
||
PreTool string `json:"preTool"`
|
||
PostTool string `json:"postTool"`
|
||
IsSaveFile bool `json:"isSaveFile"`
|
||
SubConfig *SubFlowConfig `json:"subConfig"`
|
||
ModelConfig ModelItem `json:"modelConfig"`
|
||
OutputConfig []map[string]any `json:"outputConfig"`
|
||
Prompt string `json:"prompt"`
|
||
NegativePrompt string `json:"negativePrompt"`
|
||
PatchLayout bool `json:"patchLayout"`
|
||
Templates []map[string]any `json:"templates"`
|
||
//SkillName string `json:"skillName"`
|
||
//PromptContent string `json:"promptContent"`
|
||
//InputSource []FlowNodeInputSource `json:"inputSource"` // 前端指定:来源节点ID
|
||
//FormConfig []node.NodeFormField `json:"formConfig"`
|
||
OutputResult []map[string]any `json:"outputResult" ds:"节点输出结果"`
|
||
}
|
||
|
||
type ModelItem struct {
|
||
ModelId int64 `json:"modelId,string"`
|
||
ModelName string `json:"modelName"`
|
||
ModelFormFields []map[string]any `json:"modelFormFields"`
|
||
ModelRequestParams map[string]any `json:"modelRequestParams"`
|
||
ModelRequestParamsPath []FlowModelParams `json:"modelRequestParamsPath"`
|
||
ModelResponseBodyMapping map[string]any `json:"modelResponseBodyMapping"`
|
||
}
|
||
|
||
type FlowModelParams struct {
|
||
Label string `json:"label"`
|
||
Path string `json:"path"`
|
||
Type string `json:"type"`
|
||
Required bool `json:"required"`
|
||
Value any `json:"value"`
|
||
ValueSource []ValueSource `json:"valueSource"`
|
||
RefsName string `json:"refsName"`
|
||
}
|
||
|
||
type ValueSource struct {
|
||
NodeId string `json:"nodeId"`
|
||
Field string `json:"field"`
|
||
Label string `json:"label"`
|
||
}
|
||
|
||
// SubFlowConfig 子流程节点配置
|
||
type SubFlowConfig struct {
|
||
WorkflowId int64 `json:"workflowId,string"`
|
||
WorkflowName string `json:"workflowName"`
|
||
Fields []map[string]any `json:"fields"`
|
||
MaxConcurrency int `json:"maxConcurrency"` // 子流程并发数
|
||
}
|
||
|
||
type FlowEdge struct {
|
||
Id string `json:"id"`
|
||
From string `json:"from"`
|
||
To string `json:"to"`
|
||
}
|
||
|
||
type FlowUser struct {
|
||
beans.SQLBaseDO `orm:",inherit"` // 嵌入基础字段:Id, TenantId, Creator, CreatedAt, Updater, UpdatedAt, DeletedAt
|
||
// 业务字段
|
||
FlowName string `orm:"flow_name" json:"flowName" description:"流程名称"`
|
||
Description string `orm:"description" json:"description" description:"流程描述"`
|
||
FlowContent *FlowInfo `orm:"flow_content" json:"flowContent" description:"流程内容"`
|
||
NodeInputParams []*FlowNode `orm:"node_input_params" json:"nodeInputParams" description:"节点输入参数"`
|
||
AccessLevel flow.FlowUserAccessLevel `orm:"access_level" json:"accessLevel" description:"访问权限:1私有,2团队,3公开"`
|
||
SourceFlowTemplateId int64 `orm:"source_flow_template_id" json:"sourceFlowTemplateId" description:"来源流程模板ID"`
|
||
}
|
||
|
||
type flowUserCol struct {
|
||
beans.SQLBaseCol
|
||
FlowName string
|
||
Description string
|
||
FlowContent string
|
||
NodeInputParams string
|
||
AccessLevel string
|
||
SourceFlowTemplateId string
|
||
}
|
||
|
||
var FlowUserCol = flowUserCol{
|
||
SQLBaseCol: beans.DefSQLBaseCol,
|
||
FlowName: "flow_name",
|
||
Description: "description",
|
||
FlowContent: "flow_content",
|
||
NodeInputParams: "node_input_params",
|
||
AccessLevel: "access_level",
|
||
SourceFlowTemplateId: "source_flow_template_id",
|
||
}
|