feat: remove default timeout for both nodes and workflow (#585)
This commit is contained in:
parent
90b561c3df
commit
4b3042359c
|
|
@ -1552,7 +1552,6 @@ func (w *ApplicationService) OpenAPIRun(ctx context.Context, req *workflow.OpenA
|
||||||
AgentID: agentID,
|
AgentID: agentID,
|
||||||
ConnectorID: connectorID,
|
ConnectorID: connectorID,
|
||||||
ConnectorUID: strconv.FormatInt(userID, 10),
|
ConnectorUID: strconv.FormatInt(userID, 10),
|
||||||
TaskType: vo.TaskTypeForeground,
|
|
||||||
InputFailFast: true,
|
InputFailFast: true,
|
||||||
BizType: vo.BizTypeWorkflow,
|
BizType: vo.BizTypeWorkflow,
|
||||||
}
|
}
|
||||||
|
|
@ -1563,6 +1562,7 @@ func (w *ApplicationService) OpenAPIRun(ctx context.Context, req *workflow.OpenA
|
||||||
|
|
||||||
if req.GetIsAsync() {
|
if req.GetIsAsync() {
|
||||||
exeCfg.SyncPattern = vo.SyncPatternAsync
|
exeCfg.SyncPattern = vo.SyncPatternAsync
|
||||||
|
exeCfg.TaskType = vo.TaskTypeBackground
|
||||||
exeID, err := GetWorkflowDomainSVC().AsyncExecute(ctx, exeCfg, parameters)
|
exeID, err := GetWorkflowDomainSVC().AsyncExecute(ctx, exeCfg, parameters)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -1575,6 +1575,7 @@ func (w *ApplicationService) OpenAPIRun(ctx context.Context, req *workflow.OpenA
|
||||||
}
|
}
|
||||||
|
|
||||||
exeCfg.SyncPattern = vo.SyncPatternSync
|
exeCfg.SyncPattern = vo.SyncPatternSync
|
||||||
|
exeCfg.TaskType = vo.TaskTypeForeground
|
||||||
wfExe, tPlan, err := GetWorkflowDomainSVC().SyncExecute(ctx, exeCfg, parameters)
|
wfExe, tPlan, err := GetWorkflowDomainSVC().SyncExecute(ctx, exeCfg, parameters)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
|
|
@ -268,7 +268,6 @@ var NodeTypeMetas = map[NodeType]*NodeTypeMeta{
|
||||||
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-LLM-v2.jpg",
|
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-LLM-v2.jpg",
|
||||||
SupportBatch: true,
|
SupportBatch: true,
|
||||||
ExecutableMeta: ExecutableMeta{
|
ExecutableMeta: ExecutableMeta{
|
||||||
DefaultTimeoutMS: 3 * 60 * 1000, // 3 minutes
|
|
||||||
PreFillZero: true,
|
PreFillZero: true,
|
||||||
PostFillNil: true,
|
PostFillNil: true,
|
||||||
InputSourceAware: true,
|
InputSourceAware: true,
|
||||||
|
|
@ -288,9 +287,8 @@ var NodeTypeMetas = map[NodeType]*NodeTypeMeta{
|
||||||
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Plugin-v2.jpg",
|
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Plugin-v2.jpg",
|
||||||
SupportBatch: true,
|
SupportBatch: true,
|
||||||
ExecutableMeta: ExecutableMeta{
|
ExecutableMeta: ExecutableMeta{
|
||||||
DefaultTimeoutMS: 3 * 60 * 1000, // 3 minutes
|
PreFillZero: true,
|
||||||
PreFillZero: true,
|
PostFillNil: true,
|
||||||
PostFillNil: true,
|
|
||||||
},
|
},
|
||||||
EnUSName: "Plugin",
|
EnUSName: "Plugin",
|
||||||
EnUSDescription: "Used to access external real-time data and perform operations",
|
EnUSDescription: "Used to access external real-time data and perform operations",
|
||||||
|
|
@ -306,10 +304,9 @@ var NodeTypeMetas = map[NodeType]*NodeTypeMeta{
|
||||||
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Code-v2.jpg",
|
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Code-v2.jpg",
|
||||||
SupportBatch: false,
|
SupportBatch: false,
|
||||||
ExecutableMeta: ExecutableMeta{
|
ExecutableMeta: ExecutableMeta{
|
||||||
DefaultTimeoutMS: 60 * 1000, // 1 minute
|
PreFillZero: true,
|
||||||
PreFillZero: true,
|
PostFillNil: true,
|
||||||
PostFillNil: true,
|
UseCtxCache: true,
|
||||||
UseCtxCache: true,
|
|
||||||
},
|
},
|
||||||
EnUSName: "Code",
|
EnUSName: "Code",
|
||||||
EnUSDescription: "Write code to process input variables to generate return values.",
|
EnUSDescription: "Write code to process input variables to generate return values.",
|
||||||
|
|
@ -325,9 +322,8 @@ var NodeTypeMetas = map[NodeType]*NodeTypeMeta{
|
||||||
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-KnowledgeQuery-v2.jpg",
|
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-KnowledgeQuery-v2.jpg",
|
||||||
SupportBatch: false,
|
SupportBatch: false,
|
||||||
ExecutableMeta: ExecutableMeta{
|
ExecutableMeta: ExecutableMeta{
|
||||||
DefaultTimeoutMS: 60 * 1000, // 1 minute
|
PreFillZero: true,
|
||||||
PreFillZero: true,
|
PostFillNil: true,
|
||||||
PostFillNil: true,
|
|
||||||
},
|
},
|
||||||
EnUSName: "Knowledge retrieval",
|
EnUSName: "Knowledge retrieval",
|
||||||
EnUSDescription: "In the selected knowledge, the best matching information is recalled based on the input variable and returned as an Array.",
|
EnUSDescription: "In the selected knowledge, the best matching information is recalled based on the input variable and returned as an Array.",
|
||||||
|
|
@ -371,9 +367,8 @@ var NodeTypeMetas = map[NodeType]*NodeTypeMeta{
|
||||||
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Database-v2.jpg",
|
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Database-v2.jpg",
|
||||||
SupportBatch: false,
|
SupportBatch: false,
|
||||||
ExecutableMeta: ExecutableMeta{
|
ExecutableMeta: ExecutableMeta{
|
||||||
DefaultTimeoutMS: 60 * 1000, // 1 minute
|
PreFillZero: true,
|
||||||
PreFillZero: true,
|
PostFillNil: true,
|
||||||
PostFillNil: true,
|
|
||||||
},
|
},
|
||||||
EnUSName: "SQL Customization",
|
EnUSName: "SQL Customization",
|
||||||
EnUSDescription: "Complete the operations of adding, deleting, modifying and querying the database based on user-defined SQL",
|
EnUSDescription: "Complete the operations of adding, deleting, modifying and querying the database based on user-defined SQL",
|
||||||
|
|
@ -425,10 +420,9 @@ var NodeTypeMetas = map[NodeType]*NodeTypeMeta{
|
||||||
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Direct-Question-v2.jpg",
|
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Direct-Question-v2.jpg",
|
||||||
SupportBatch: false,
|
SupportBatch: false,
|
||||||
ExecutableMeta: ExecutableMeta{
|
ExecutableMeta: ExecutableMeta{
|
||||||
DefaultTimeoutMS: 60 * 1000, // 1 minute
|
PreFillZero: true,
|
||||||
PreFillZero: true,
|
PostFillNil: true,
|
||||||
PostFillNil: true,
|
MayUseChatModel: true,
|
||||||
MayUseChatModel: true,
|
|
||||||
},
|
},
|
||||||
EnUSName: "Question",
|
EnUSName: "Question",
|
||||||
EnUSDescription: "Support asking questions to the user in the middle of the conversation, with both preset options and open-ended questions",
|
EnUSDescription: "Support asking questions to the user in the middle of the conversation, with both preset options and open-ended questions",
|
||||||
|
|
@ -472,10 +466,9 @@ var NodeTypeMetas = map[NodeType]*NodeTypeMeta{
|
||||||
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Loop-v2.jpg",
|
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Loop-v2.jpg",
|
||||||
SupportBatch: false,
|
SupportBatch: false,
|
||||||
ExecutableMeta: ExecutableMeta{
|
ExecutableMeta: ExecutableMeta{
|
||||||
IsComposite: true,
|
IsComposite: true,
|
||||||
DefaultTimeoutMS: 60 * 1000, // 1 minute
|
PreFillZero: true,
|
||||||
PreFillZero: true,
|
PostFillNil: true,
|
||||||
PostFillNil: true,
|
|
||||||
},
|
},
|
||||||
EnUSName: "Loop",
|
EnUSName: "Loop",
|
||||||
EnUSDescription: "Used to repeatedly execute a series of tasks by setting the number of iterations and logic",
|
EnUSDescription: "Used to repeatedly execute a series of tasks by setting the number of iterations and logic",
|
||||||
|
|
@ -491,10 +484,9 @@ var NodeTypeMetas = map[NodeType]*NodeTypeMeta{
|
||||||
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Intent-v2.jpg",
|
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Intent-v2.jpg",
|
||||||
SupportBatch: false,
|
SupportBatch: false,
|
||||||
ExecutableMeta: ExecutableMeta{
|
ExecutableMeta: ExecutableMeta{
|
||||||
DefaultTimeoutMS: 60 * 1000, // 1 minute
|
PreFillZero: true,
|
||||||
PreFillZero: true,
|
PostFillNil: true,
|
||||||
PostFillNil: true,
|
MayUseChatModel: true,
|
||||||
MayUseChatModel: true,
|
|
||||||
},
|
},
|
||||||
EnUSName: "Intent recognition",
|
EnUSName: "Intent recognition",
|
||||||
EnUSDescription: "Used for recognizing the intent in user input and matching it with preset intent options.",
|
EnUSDescription: "Used for recognizing the intent in user input and matching it with preset intent options.",
|
||||||
|
|
@ -510,9 +502,8 @@ var NodeTypeMetas = map[NodeType]*NodeTypeMeta{
|
||||||
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-KnowledgeWriting-v2.jpg",
|
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-KnowledgeWriting-v2.jpg",
|
||||||
SupportBatch: false,
|
SupportBatch: false,
|
||||||
ExecutableMeta: ExecutableMeta{
|
ExecutableMeta: ExecutableMeta{
|
||||||
DefaultTimeoutMS: 60 * 1000, // 1 minute
|
PreFillZero: true,
|
||||||
PreFillZero: true,
|
PostFillNil: true,
|
||||||
PostFillNil: true,
|
|
||||||
},
|
},
|
||||||
EnUSName: "Knowledge writing",
|
EnUSName: "Knowledge writing",
|
||||||
EnUSDescription: "The write node can add a knowledge base of type text. Only one knowledge base can be added.",
|
EnUSDescription: "The write node can add a knowledge base of type text. Only one knowledge base can be added.",
|
||||||
|
|
@ -528,10 +519,9 @@ var NodeTypeMetas = map[NodeType]*NodeTypeMeta{
|
||||||
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Batch-v2.jpg",
|
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-Batch-v2.jpg",
|
||||||
SupportBatch: false,
|
SupportBatch: false,
|
||||||
ExecutableMeta: ExecutableMeta{
|
ExecutableMeta: ExecutableMeta{
|
||||||
IsComposite: true,
|
IsComposite: true,
|
||||||
DefaultTimeoutMS: 60 * 1000, // 1 minute
|
PreFillZero: true,
|
||||||
PreFillZero: true,
|
PostFillNil: true,
|
||||||
PostFillNil: true,
|
|
||||||
},
|
},
|
||||||
EnUSName: "Batch",
|
EnUSName: "Batch",
|
||||||
EnUSDescription: "By setting the number of batch runs and logic, run the tasks in the batch body.",
|
EnUSDescription: "By setting the number of batch runs and logic, run the tasks in the batch body.",
|
||||||
|
|
@ -670,8 +660,7 @@ var NodeTypeMetas = map[NodeType]*NodeTypeMeta{
|
||||||
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-database-update.jpg",
|
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-database-update.jpg",
|
||||||
SupportBatch: false,
|
SupportBatch: false,
|
||||||
ExecutableMeta: ExecutableMeta{
|
ExecutableMeta: ExecutableMeta{
|
||||||
DefaultTimeoutMS: 60 * 1000, // 1 minute
|
PreFillZero: true,
|
||||||
PreFillZero: true,
|
|
||||||
},
|
},
|
||||||
EnUSName: "Update Data",
|
EnUSName: "Update Data",
|
||||||
EnUSDescription: "Modify the existing data records in the table, and the user specifies the update conditions and contents to update the data",
|
EnUSDescription: "Modify the existing data records in the table, and the user specifies the update conditions and contents to update the data",
|
||||||
|
|
@ -687,8 +676,7 @@ var NodeTypeMetas = map[NodeType]*NodeTypeMeta{
|
||||||
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icaon-database-select.jpg",
|
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icaon-database-select.jpg",
|
||||||
SupportBatch: false,
|
SupportBatch: false,
|
||||||
ExecutableMeta: ExecutableMeta{
|
ExecutableMeta: ExecutableMeta{
|
||||||
DefaultTimeoutMS: 60 * 1000, // 1 minute
|
PreFillZero: true,
|
||||||
PreFillZero: true,
|
|
||||||
},
|
},
|
||||||
EnUSName: "Query Data",
|
EnUSName: "Query Data",
|
||||||
EnUSDescription: "Query data from the table, and the user can define query conditions, select columns, etc., and output the data that meets the conditions",
|
EnUSDescription: "Query data from the table, and the user can define query conditions, select columns, etc., and output the data that meets the conditions",
|
||||||
|
|
@ -704,8 +692,7 @@ var NodeTypeMetas = map[NodeType]*NodeTypeMeta{
|
||||||
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-database-delete.jpg",
|
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-database-delete.jpg",
|
||||||
SupportBatch: false,
|
SupportBatch: false,
|
||||||
ExecutableMeta: ExecutableMeta{
|
ExecutableMeta: ExecutableMeta{
|
||||||
DefaultTimeoutMS: 60 * 1000, // 1 minute
|
PreFillZero: true,
|
||||||
PreFillZero: true,
|
|
||||||
},
|
},
|
||||||
EnUSName: "Delete Data",
|
EnUSName: "Delete Data",
|
||||||
EnUSDescription: "Delete data records from the table, and the user specifies the deletion conditions to delete the records that meet the conditions",
|
EnUSDescription: "Delete data records from the table, and the user specifies the deletion conditions to delete the records that meet the conditions",
|
||||||
|
|
@ -721,9 +708,8 @@ var NodeTypeMetas = map[NodeType]*NodeTypeMeta{
|
||||||
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-HTTP.png",
|
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-HTTP.png",
|
||||||
SupportBatch: false,
|
SupportBatch: false,
|
||||||
ExecutableMeta: ExecutableMeta{
|
ExecutableMeta: ExecutableMeta{
|
||||||
DefaultTimeoutMS: 60 * 1000, // 1 minute
|
PreFillZero: true,
|
||||||
PreFillZero: true,
|
PostFillNil: true,
|
||||||
PostFillNil: true,
|
|
||||||
},
|
},
|
||||||
EnUSName: "HTTP request",
|
EnUSName: "HTTP request",
|
||||||
EnUSDescription: "It is used to send API requests and return data from the interface.",
|
EnUSDescription: "It is used to send API requests and return data from the interface.",
|
||||||
|
|
@ -739,8 +725,7 @@ var NodeTypeMetas = map[NodeType]*NodeTypeMeta{
|
||||||
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-database-insert.jpg",
|
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-database-insert.jpg",
|
||||||
SupportBatch: false,
|
SupportBatch: false,
|
||||||
ExecutableMeta: ExecutableMeta{
|
ExecutableMeta: ExecutableMeta{
|
||||||
DefaultTimeoutMS: 60 * 1000, // 1 minute
|
PreFillZero: true,
|
||||||
PreFillZero: true,
|
|
||||||
},
|
},
|
||||||
EnUSName: "Add Data",
|
EnUSName: "Add Data",
|
||||||
EnUSDescription: "Add new data records to the table, and insert them into the database after the user enters the data content",
|
EnUSDescription: "Add new data records to the table, and insert them into the database after the user enters the data content",
|
||||||
|
|
@ -780,8 +765,6 @@ var NodeTypeMetas = map[NodeType]*NodeTypeMeta{
|
||||||
|
|
||||||
// ExecutableMeta configures certain common aspects of request-time behaviors for this node.
|
// ExecutableMeta configures certain common aspects of request-time behaviors for this node.
|
||||||
ExecutableMeta: ExecutableMeta{
|
ExecutableMeta: ExecutableMeta{
|
||||||
// DefaultTimeoutMS configures the default timeout for this node, in milliseconds. 0 means no timeout.
|
|
||||||
DefaultTimeoutMS: 60 * 1000, // 1 minute
|
|
||||||
// PreFillZero decides whether to pre-fill zero value for any missing fields in input.
|
// PreFillZero decides whether to pre-fill zero value for any missing fields in input.
|
||||||
PreFillZero: true,
|
PreFillZero: true,
|
||||||
// PostFillNil decides whether to post-fill nil value for any missing fields in output.
|
// PostFillNil decides whether to post-fill nil value for any missing fields in output.
|
||||||
|
|
@ -803,10 +786,9 @@ var NodeTypeMetas = map[NodeType]*NodeTypeMeta{
|
||||||
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-from_json.png",
|
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icon-from_json.png",
|
||||||
SupportBatch: false,
|
SupportBatch: false,
|
||||||
ExecutableMeta: ExecutableMeta{
|
ExecutableMeta: ExecutableMeta{
|
||||||
DefaultTimeoutMS: 60 * 1000, // 1 minute
|
PreFillZero: true,
|
||||||
PreFillZero: true,
|
PostFillNil: true,
|
||||||
PostFillNil: true,
|
UseCtxCache: true,
|
||||||
UseCtxCache: true,
|
|
||||||
},
|
},
|
||||||
EnUSName: "JSON deserialization",
|
EnUSName: "JSON deserialization",
|
||||||
EnUSDescription: "Parse JSON string to variable",
|
EnUSDescription: "Parse JSON string to variable",
|
||||||
|
|
@ -822,9 +804,8 @@ var NodeTypeMetas = map[NodeType]*NodeTypeMeta{
|
||||||
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icons-dataset-delete.png",
|
IconURL: "https://lf3-static.bytednsdoc.com/obj/eden-cn/dvsmryvd_avi_dvsm/ljhwZthlaukjlkulzlp/icon/icons-dataset-delete.png",
|
||||||
SupportBatch: false,
|
SupportBatch: false,
|
||||||
ExecutableMeta: ExecutableMeta{
|
ExecutableMeta: ExecutableMeta{
|
||||||
DefaultTimeoutMS: 60 * 1000, // 1 minute
|
PreFillZero: true,
|
||||||
PreFillZero: true,
|
PostFillNil: true,
|
||||||
PostFillNil: true,
|
|
||||||
},
|
},
|
||||||
EnUSName: "Knowledge delete",
|
EnUSName: "Knowledge delete",
|
||||||
EnUSDescription: "The delete node can delete a document in knowledge base.",
|
EnUSDescription: "The delete node can delete a document in knowledge base.",
|
||||||
|
|
|
||||||
|
|
@ -124,13 +124,15 @@ func newNodeRunConfig[O any](ns *schema2.NodeSchema,
|
||||||
}, opts.init...)
|
}, opts.init...)
|
||||||
}
|
}
|
||||||
|
|
||||||
opts.init = append(opts.init, func(ctx context.Context) (context.Context, error) {
|
if execute.GetStaticConfig().MaxNodeCountPerExecution > 0 {
|
||||||
current, exceeded := execute.IncrAndCheckExecutedNodes(ctx)
|
opts.init = append(opts.init, func(ctx context.Context) (context.Context, error) {
|
||||||
if exceeded {
|
current, exceeded := execute.IncrementAndCheckExecutedNodes(ctx)
|
||||||
return nil, fmt.Errorf("exceeded max executed node count: %d, current: %d", execute.GetStaticConfig().MaxNodeCountPerExecution, current)
|
if exceeded {
|
||||||
}
|
return nil, fmt.Errorf("exceeded max executed node count: %d, current: %d", execute.GetStaticConfig().MaxNodeCountPerExecution, current)
|
||||||
return ctx, nil
|
}
|
||||||
})
|
return ctx, nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return &nodeRunConfig[O]{
|
return &nodeRunConfig[O]{
|
||||||
nodeKey: ns.Key,
|
nodeKey: ns.Key,
|
||||||
|
|
@ -325,12 +327,23 @@ func (nc *nodeRunConfig[O]) invoke() func(ctx context.Context, input map[string]
|
||||||
}()
|
}()
|
||||||
|
|
||||||
for _, i := range runner.init {
|
for _, i := range runner.init {
|
||||||
if ctx, err = i(ctx); err != nil {
|
var newCtx context.Context
|
||||||
|
if newCtx, err = i(ctx); err != nil {
|
||||||
|
var err1 error
|
||||||
|
if ctx, err1 = runner.onStart(ctx, input); err1 != nil {
|
||||||
|
return nil, err1
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
|
} else {
|
||||||
|
ctx = newCtx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if input, err = runner.preProcess(ctx, input); err != nil {
|
if input, err = runner.preProcess(ctx, input); err != nil {
|
||||||
|
var err1 error
|
||||||
|
if ctx, err1 = runner.onStart(ctx, input); err1 != nil {
|
||||||
|
return nil, err1
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -373,12 +386,23 @@ func (nc *nodeRunConfig[O]) stream() func(ctx context.Context, input map[string]
|
||||||
}()
|
}()
|
||||||
|
|
||||||
for _, i := range runner.init {
|
for _, i := range runner.init {
|
||||||
if ctx, err = i(ctx); err != nil {
|
var newCtx context.Context
|
||||||
|
if newCtx, err = i(ctx); err != nil {
|
||||||
|
var err1 error
|
||||||
|
if ctx, err1 = runner.onStart(ctx, input); err1 != nil {
|
||||||
|
return nil, err1
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
|
} else {
|
||||||
|
ctx = newCtx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if input, err = runner.preProcess(ctx, input); err != nil {
|
if input, err = runner.preProcess(ctx, input); err != nil {
|
||||||
|
var err1 error
|
||||||
|
if ctx, err1 = runner.onStart(ctx, input); err1 != nil {
|
||||||
|
return nil, err1
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -390,6 +414,60 @@ func (nc *nodeRunConfig[O]) stream() func(ctx context.Context, input map[string]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (nc *nodeRunConfig[O]) collect() func(ctx context.Context, input *schema.StreamReader[map[string]any], opts ...O) (output map[string]any, err error) {
|
||||||
|
if nc.c == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return func(ctx context.Context, input *schema.StreamReader[map[string]any], opts ...O) (output map[string]any, err error) {
|
||||||
|
ctx, runner := newNodeRunner(ctx, nc)
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if panicErr := recover(); panicErr != nil {
|
||||||
|
err = safego.NewPanicErr(panicErr, debug.Stack())
|
||||||
|
}
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
err = runner.onEnd(ctx, output)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
errOutput, hasErrOutput := runner.onError(ctx, err)
|
||||||
|
if hasErrOutput {
|
||||||
|
output = errOutput
|
||||||
|
err = nil
|
||||||
|
if output, err = runner.postProcess(ctx, output); err != nil {
|
||||||
|
logs.CtxErrorf(ctx, "postProcess failed after returning error output: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
for _, i := range runner.init {
|
||||||
|
var newCtx context.Context
|
||||||
|
if newCtx, err = i(ctx); err != nil {
|
||||||
|
var err1 error
|
||||||
|
if ctx, _, err1 = runner.onStartStream(ctx, input); err1 != nil {
|
||||||
|
return nil, err1
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
} else {
|
||||||
|
ctx = newCtx
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, p := range runner.streamPreProcessors {
|
||||||
|
input = p(ctx, input)
|
||||||
|
}
|
||||||
|
|
||||||
|
if ctx, input, err = runner.onStartStream(ctx, input); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return runner.collect(ctx, input, opts...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (nc *nodeRunConfig[O]) transform() func(ctx context.Context, input *schema.StreamReader[map[string]any], opts ...O) (output *schema.StreamReader[map[string]any], err error) {
|
func (nc *nodeRunConfig[O]) transform() func(ctx context.Context, input *schema.StreamReader[map[string]any], opts ...O) (output *schema.StreamReader[map[string]any], err error) {
|
||||||
if nc.t == nil {
|
if nc.t == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -417,8 +495,15 @@ func (nc *nodeRunConfig[O]) transform() func(ctx context.Context, input *schema.
|
||||||
}()
|
}()
|
||||||
|
|
||||||
for _, i := range runner.init {
|
for _, i := range runner.init {
|
||||||
if ctx, err = i(ctx); err != nil {
|
var newCtx context.Context
|
||||||
|
if newCtx, err = i(ctx); err != nil {
|
||||||
|
var err1 error
|
||||||
|
if ctx, _, err1 = runner.onStartStream(ctx, input); err1 != nil {
|
||||||
|
return nil, err1
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
|
} else {
|
||||||
|
ctx = newCtx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -439,7 +524,7 @@ func (nc *nodeRunConfig[O]) toNode() *Node {
|
||||||
opts = append(opts, compose.WithLambdaType(string(nc.nodeType)))
|
opts = append(opts, compose.WithLambdaType(string(nc.nodeType)))
|
||||||
opts = append(opts, compose.WithLambdaCallbackEnable(true))
|
opts = append(opts, compose.WithLambdaCallbackEnable(true))
|
||||||
|
|
||||||
l, err := compose.AnyLambda(nc.invoke(), nc.stream(), nil, nc.transform(), opts...)
|
l, err := compose.AnyLambda(nc.invoke(), nc.stream(), nc.collect(), nc.transform(), opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("failed to create lambda for node %s, err: %v", nc.nodeName, err))
|
panic(fmt.Sprintf("failed to create lambda for node %s, err: %v", nc.nodeName, err))
|
||||||
}
|
}
|
||||||
|
|
@ -589,6 +674,49 @@ func (r *nodeRunner[O]) stream(ctx context.Context, input map[string]any, opts .
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *nodeRunner[O]) collect(ctx context.Context, input *schema.StreamReader[map[string]any], opts ...O) (output map[string]any, err error) {
|
||||||
|
if r.maxRetry == 0 {
|
||||||
|
return r.c(ctx, input, opts...)
|
||||||
|
}
|
||||||
|
|
||||||
|
copied := input.Copy(int(r.maxRetry))
|
||||||
|
|
||||||
|
var n int64
|
||||||
|
defer func() {
|
||||||
|
for i := n + 1; i < r.maxRetry; i++ {
|
||||||
|
copied[i].Close()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return nil, ctx.Err()
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
output, err = r.c(ctx, copied[n], opts...)
|
||||||
|
if err != nil {
|
||||||
|
if _, ok := compose.IsInterruptRerunError(err); ok { // interrupt, won't retry
|
||||||
|
r.interrupted = true
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
logs.CtxErrorf(ctx, "[invoke] node %s ID %s failed on %d attempt, err: %v", r.nodeName, r.nodeKey, n, err)
|
||||||
|
if r.maxRetry > n {
|
||||||
|
n++
|
||||||
|
if exeCtx := execute.GetExeCtx(ctx); exeCtx != nil && exeCtx.NodeCtx != nil {
|
||||||
|
exeCtx.CurrentRetryCount++
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return output, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (r *nodeRunner[O]) transform(ctx context.Context, input *schema.StreamReader[map[string]any], opts ...O) (output *schema.StreamReader[map[string]any], err error) {
|
func (r *nodeRunner[O]) transform(ctx context.Context, input *schema.StreamReader[map[string]any], opts ...O) (output *schema.StreamReader[map[string]any], err error) {
|
||||||
if r.maxRetry == 0 {
|
if r.maxRetry == 0 {
|
||||||
return r.t(ctx, input, opts...)
|
return r.t(ctx, input, opts...)
|
||||||
|
|
|
||||||
|
|
@ -268,8 +268,6 @@ func (r *WorkflowRunner) Prepare(ctx context.Context) (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelCtx = execute.InitExecutedNodesCounter(cancelCtx)
|
|
||||||
|
|
||||||
lastEventChan := make(chan *execute.Event, 1)
|
lastEventChan := make(chan *execute.Event, 1)
|
||||||
go func() {
|
go func() {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|
|
||||||
|
|
@ -18,17 +18,14 @@ package execute
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"sync/atomic"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/coze-dev/coze-studio/backend/pkg/ctxcache"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
foregroundRunTimeout = 10 * time.Minute
|
foregroundRunTimeout = 0 // timeout for workflow execution in foreground mode, 0 means no timeout
|
||||||
backgroundRunTimeout = 24 * time.Hour
|
backgroundRunTimeout = 0 // timeout for workflow execution in background mode, 0 means no timeout
|
||||||
maxNodeCountPerWorkflow = 1000
|
maxNodeCountPerWorkflow = 0 // maximum node count for a workflow, 0 means no limit
|
||||||
maxNodeCountPerExecution = 1000
|
maxNodeCountPerExecution = 0 // maximum node count for a workflow execution, 0 means no limit
|
||||||
cancelCheckInterval = 200 * time.Millisecond
|
cancelCheckInterval = 200 * time.Millisecond
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -52,17 +49,17 @@ const (
|
||||||
executedNodeCountKey = "executed_node_count"
|
executedNodeCountKey = "executed_node_count"
|
||||||
)
|
)
|
||||||
|
|
||||||
func IncrAndCheckExecutedNodes(ctx context.Context) (int64, bool) {
|
func IncrementAndCheckExecutedNodes(ctx context.Context) (int64, bool) {
|
||||||
counter, ok := ctxcache.Get[atomic.Int64](ctx, executedNodeCountKey)
|
exeCtx := GetExeCtx(ctx)
|
||||||
if !ok {
|
if exeCtx == nil {
|
||||||
return 0, false
|
return 0, false
|
||||||
}
|
}
|
||||||
|
|
||||||
current := counter.Add(1)
|
counter := exeCtx.executed
|
||||||
|
if counter == nil {
|
||||||
|
return 0, false
|
||||||
|
}
|
||||||
|
|
||||||
|
current := (*counter).Add(1)
|
||||||
return current, current > maxNodeCountPerExecution
|
return current, current > maxNodeCountPerExecution
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitExecutedNodesCounter(ctx context.Context) context.Context {
|
|
||||||
ctxcache.Store(ctx, executedNodeCountKey, atomic.Int64{})
|
|
||||||
return ctx
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/cloudwego/eino/compose"
|
"github.com/cloudwego/eino/compose"
|
||||||
|
|
@ -30,6 +31,7 @@ import (
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||||
|
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Context struct {
|
type Context struct {
|
||||||
|
|
@ -48,6 +50,8 @@ type Context struct {
|
||||||
CheckPointID string
|
CheckPointID string
|
||||||
|
|
||||||
AppVarStore *AppVariables
|
AppVarStore *AppVariables
|
||||||
|
|
||||||
|
executed *atomic.Int64
|
||||||
}
|
}
|
||||||
|
|
||||||
type RootCtx struct {
|
type RootCtx struct {
|
||||||
|
|
@ -118,6 +122,7 @@ func restoreWorkflowCtx(ctx context.Context, h *WorkflowHandler) (context.Contex
|
||||||
}
|
}
|
||||||
|
|
||||||
storedCtx.AppVarStore = currentC.AppVarStore
|
storedCtx.AppVarStore = currentC.AppVarStore
|
||||||
|
storedCtx.executed = currentC.executed
|
||||||
}
|
}
|
||||||
|
|
||||||
return context.WithValue(ctx, contextKey{}, storedCtx), nil
|
return context.WithValue(ctx, contextKey{}, storedCtx), nil
|
||||||
|
|
@ -158,13 +163,16 @@ func restoreNodeCtx(ctx context.Context, nodeKey vo.NodeKey, resumeEvent *entity
|
||||||
|
|
||||||
currentC := GetExeCtx(ctx)
|
currentC := GetExeCtx(ctx)
|
||||||
|
|
||||||
// restore the parent-child relationship between token collectors
|
if currentC != nil {
|
||||||
if storedCtx.TokenCollector != nil && storedCtx.TokenCollector.Parent != nil {
|
// restore the parent-child relationship between token collectors
|
||||||
currentTokenCollector := currentC.TokenCollector
|
if storedCtx.TokenCollector != nil && storedCtx.TokenCollector.Parent != nil {
|
||||||
storedCtx.TokenCollector.Parent = currentTokenCollector
|
currentTokenCollector := currentC.TokenCollector
|
||||||
}
|
storedCtx.TokenCollector.Parent = currentTokenCollector
|
||||||
|
}
|
||||||
|
|
||||||
storedCtx.AppVarStore = currentC.AppVarStore
|
storedCtx.AppVarStore = currentC.AppVarStore
|
||||||
|
storedCtx.executed = currentC.executed
|
||||||
|
}
|
||||||
|
|
||||||
storedCtx.NodeCtx.CurrentRetryCount = 0
|
storedCtx.NodeCtx.CurrentRetryCount = 0
|
||||||
|
|
||||||
|
|
@ -200,6 +208,9 @@ func tryRestoreNodeCtx(ctx context.Context, nodeKey vo.NodeKey) (context.Context
|
||||||
if storedCtx.TokenCollector != nil && storedCtx.TokenCollector.Parent != nil && existingC != nil {
|
if storedCtx.TokenCollector != nil && storedCtx.TokenCollector.Parent != nil && existingC != nil {
|
||||||
currentTokenCollector := existingC.TokenCollector
|
currentTokenCollector := existingC.TokenCollector
|
||||||
storedCtx.TokenCollector.Parent = currentTokenCollector
|
storedCtx.TokenCollector.Parent = currentTokenCollector
|
||||||
|
|
||||||
|
storedCtx.AppVarStore = existingC.AppVarStore
|
||||||
|
storedCtx.executed = existingC.executed
|
||||||
}
|
}
|
||||||
|
|
||||||
storedCtx.NodeCtx.CurrentRetryCount = 0
|
storedCtx.NodeCtx.CurrentRetryCount = 0
|
||||||
|
|
@ -224,6 +235,7 @@ func PrepareRootExeCtx(ctx context.Context, h *WorkflowHandler) (context.Context
|
||||||
TokenCollector: newTokenCollector(fmt.Sprintf("wf_%d", h.rootWorkflowBasic.ID), parentTokenCollector),
|
TokenCollector: newTokenCollector(fmt.Sprintf("wf_%d", h.rootWorkflowBasic.ID), parentTokenCollector),
|
||||||
StartTime: time.Now().UnixMilli(),
|
StartTime: time.Now().UnixMilli(),
|
||||||
AppVarStore: NewAppVariables(),
|
AppVarStore: NewAppVariables(),
|
||||||
|
executed: ptr.Of(atomic.Int64{}),
|
||||||
}
|
}
|
||||||
|
|
||||||
if h.requireCheckpoint {
|
if h.requireCheckpoint {
|
||||||
|
|
@ -278,6 +290,7 @@ func PrepareSubExeCtx(ctx context.Context, wb *entity.WorkflowBasic, requireChec
|
||||||
CheckPointID: newCheckpointID,
|
CheckPointID: newCheckpointID,
|
||||||
StartTime: time.Now().UnixMilli(),
|
StartTime: time.Now().UnixMilli(),
|
||||||
AppVarStore: c.AppVarStore,
|
AppVarStore: c.AppVarStore,
|
||||||
|
executed: c.executed,
|
||||||
}
|
}
|
||||||
|
|
||||||
if requireCheckpoint {
|
if requireCheckpoint {
|
||||||
|
|
@ -321,6 +334,7 @@ func PrepareNodeExeCtx(ctx context.Context, nodeKey vo.NodeKey, nodeName string,
|
||||||
StartTime: time.Now().UnixMilli(),
|
StartTime: time.Now().UnixMilli(),
|
||||||
CheckPointID: c.CheckPointID,
|
CheckPointID: c.CheckPointID,
|
||||||
AppVarStore: c.AppVarStore,
|
AppVarStore: c.AppVarStore,
|
||||||
|
executed: c.executed,
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.NodeCtx == nil { // node within top level workflow, also not under composite node
|
if c.NodeCtx == nil { // node within top level workflow, also not under composite node
|
||||||
|
|
@ -368,6 +382,7 @@ func InheritExeCtxWithBatchInfo(ctx context.Context, index int, items map[string
|
||||||
},
|
},
|
||||||
CheckPointID: newCheckpointID,
|
CheckPointID: newCheckpointID,
|
||||||
AppVarStore: c.AppVarStore,
|
AppVarStore: c.AppVarStore,
|
||||||
|
executed: c.executed,
|
||||||
}), newCheckpointID
|
}), newCheckpointID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue