refactor(workflow): Move the plugin component in the Workflow package into the common crossdomain package (#717)
This commit is contained in:
@@ -25,8 +25,9 @@ import (
|
||||
einoCompose "github.com/cloudwego/eino/compose"
|
||||
"github.com/cloudwego/eino/schema"
|
||||
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
crossplugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin"
|
||||
workflow2 "github.com/coze-dev/coze-studio/backend/domain/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/plugin"
|
||||
"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/internal/execute"
|
||||
@@ -242,9 +243,9 @@ func llmToolCallbackOptions(ctx context.Context, ns *schema2.NodeSchema, eventCh
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid workflow id: %s", wfIDStr)
|
||||
}
|
||||
locator := vo.FromDraft
|
||||
locator := model.FromDraft
|
||||
if wf.WorkflowVersion != "" {
|
||||
locator = vo.FromSpecificVersion
|
||||
locator = model.FromSpecificVersion
|
||||
}
|
||||
|
||||
wfTool, err := workflow2.GetRepository().WorkflowAsTool(ctx, vo.GetPolicy{
|
||||
@@ -290,8 +291,8 @@ func llmToolCallbackOptions(ctx context.Context, ns *schema2.NodeSchema, eventCh
|
||||
return nil, err
|
||||
}
|
||||
|
||||
toolInfoResponse, err := plugin.GetPluginService().GetPluginToolsInfo(ctx, &plugin.ToolsInfoRequest{
|
||||
PluginEntity: plugin.Entity{
|
||||
toolInfoResponse, err := crossplugin.DefaultSVC().GetPluginToolsInfo(ctx, &model.ToolsInfoRequest{
|
||||
PluginEntity: model.PluginEntity{
|
||||
PluginID: pluginID,
|
||||
PluginVersion: ptr.Of(p.PluginVersion),
|
||||
},
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
"github.com/cloudwego/eino/compose"
|
||||
"github.com/cloudwego/eino/schema"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
workflow2 "github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/variable"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||
@@ -79,12 +80,12 @@ func init() {
|
||||
_ = compose.RegisterSerializableType[*entity.WorkflowBasic]("workflow_basic")
|
||||
_ = compose.RegisterSerializableType[vo.TerminatePlan]("terminate_plan")
|
||||
_ = compose.RegisterSerializableType[*entity.ToolInterruptEvent]("tool_interrupt_event")
|
||||
_ = compose.RegisterSerializableType[vo.ExecuteConfig]("execute_config")
|
||||
_ = compose.RegisterSerializableType[vo.ExecuteMode]("execute_mode")
|
||||
_ = compose.RegisterSerializableType[vo.TaskType]("task_type")
|
||||
_ = compose.RegisterSerializableType[vo.SyncPattern]("sync_pattern")
|
||||
_ = compose.RegisterSerializableType[vo.Locator]("wf_locator")
|
||||
_ = compose.RegisterSerializableType[vo.BizType]("biz_type")
|
||||
_ = compose.RegisterSerializableType[plugin.ExecuteConfig]("execute_config")
|
||||
_ = compose.RegisterSerializableType[plugin.ExecuteMode]("execute_mode")
|
||||
_ = compose.RegisterSerializableType[plugin.TaskType]("task_type")
|
||||
_ = compose.RegisterSerializableType[plugin.SyncPattern]("sync_pattern")
|
||||
_ = compose.RegisterSerializableType[plugin.Locator]("wf_locator")
|
||||
_ = compose.RegisterSerializableType[plugin.BizType]("biz_type")
|
||||
_ = compose.RegisterSerializableType[*execute.AppVariables]("app_variables")
|
||||
}
|
||||
|
||||
@@ -905,12 +906,12 @@ func streamStatePostHandlerForVars(s *schema2.NodeSchema) compose.StreamStatePos
|
||||
func GenStateModifierByEventType(e entity.InterruptEventType,
|
||||
nodeKey vo.NodeKey,
|
||||
resumeData string,
|
||||
exeCfg vo.ExecuteConfig) (stateModifier compose.StateModifier) {
|
||||
exeCfg plugin.ExecuteConfig) (stateModifier compose.StateModifier) {
|
||||
// TODO: can we unify them all to a map[NodeKey]resumeData?
|
||||
switch e {
|
||||
case entity.InterruptEventInput:
|
||||
stateModifier = func(ctx context.Context, path compose.NodePath, state any) (err error) {
|
||||
if exeCfg.BizType == vo.BizTypeAgent {
|
||||
if exeCfg.BizType == plugin.BizTypeAgent {
|
||||
m := make(map[string]any)
|
||||
sList := strings.Split(resumeData, "\n")
|
||||
for _, s := range sList {
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
einoCompose "github.com/cloudwego/eino/compose"
|
||||
"github.com/cloudwego/eino/schema"
|
||||
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
wf "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/vo"
|
||||
@@ -45,7 +46,7 @@ type WorkflowRunner struct {
|
||||
resumeReq *entity.ResumeRequest
|
||||
schema *schema2.WorkflowSchema
|
||||
streamWriter *schema.StreamWriter[*entity.Message]
|
||||
config vo.ExecuteConfig
|
||||
config model.ExecuteConfig
|
||||
|
||||
executeID int64
|
||||
eventChan chan *execute.Event
|
||||
@@ -77,7 +78,7 @@ func WithStreamWriter(sw *schema.StreamWriter[*entity.Message]) WorkflowRunnerOp
|
||||
}
|
||||
}
|
||||
|
||||
func NewWorkflowRunner(b *entity.WorkflowBasic, sc *schema2.WorkflowSchema, config vo.ExecuteConfig, opts ...WorkflowRunnerOption) *WorkflowRunner {
|
||||
func NewWorkflowRunner(b *entity.WorkflowBasic, sc *schema2.WorkflowSchema, config model.ExecuteConfig, opts ...WorkflowRunnerOption) *WorkflowRunner {
|
||||
options := &workflowRunOptions{}
|
||||
for _, opt := range opts {
|
||||
opt(options)
|
||||
@@ -262,7 +263,7 @@ func (r *WorkflowRunner) Prepare(ctx context.Context) (
|
||||
cancelCtx, cancelFn := context.WithCancel(ctx)
|
||||
var timeoutFn context.CancelFunc
|
||||
if s := execute.GetStaticConfig(); s != nil {
|
||||
timeout := ternary.IFElse(config.TaskType == vo.TaskTypeBackground, s.BackgroundRunTimeout, s.ForegroundRunTimeout)
|
||||
timeout := ternary.IFElse(config.TaskType == model.TaskTypeBackground, s.BackgroundRunTimeout, s.ForegroundRunTimeout)
|
||||
if timeout > 0 {
|
||||
cancelCtx, timeoutFn = context.WithTimeout(cancelCtx, timeout)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user