Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/crossdomain/plugin/model/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func WithAutoGenRespSchema() ExecuteToolOpt {
}
}

func WithPluginHTTPHeader(conversationID int64) ExecuteToolOpt {
func WithConversationID(conversationID int64) ExecuteToolOpt {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个场景,我看了上个提交,咱们使用了原有的的结构做了传递,正常来说我们的场景是在tool运行的时候透传header信息,是不是单独定义一个关于header的结构做option,所有的字段包含在内,这个option只对tool 透传header生效,不与原因逻辑混在一起比较好;

return func(o *ExecuteToolOption) {
o.ConversationID = conversationID
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (p *pluginInvokableTool) InvokableRun(ctx context.Context, argumentsInJSON
model.WithInvalidRespProcessStrategy(consts.InvalidResponseProcessStrategyOfReturnDefault),
model.WithToolVersion(p.toolInfo.GetVersion()),
model.WithProjectInfo(p.projectInfo),
model.WithPluginHTTPHeader(p.conversationID),
model.WithConversationID(p.conversationID),
}

resp, err := crossplugin.DefaultSVC().ExecuteTool(ctx, req, opts...)
Expand Down
8 changes: 8 additions & 0 deletions backend/domain/workflow/internal/nodes/plugin/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ func ExecutePlugin(ctx context.Context, input map[string]any, pe *vo.PluginEntit
if pe.PluginVersion != nil {
execOpts = append(execOpts, model.WithToolVersion(*pe.PluginVersion))
}
if cfg.ConversationID != nil {
execOpts = append(execOpts, model.WithConversationID(*cfg.ConversationID))
}
if cfg.AgentID != nil {
execOpts = append(execOpts, model.WithProjectInfo(&model.ProjectInfo{
ProjectID: *cfg.AgentID,
}))
}

r, err := crossplugin.DefaultSVC().ExecuteTool(ctx, req, execOpts...)
if err != nil {
Expand Down
18 changes: 16 additions & 2 deletions backend/domain/workflow/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,15 @@ func (p *pluginInvokeTool) Info(ctx context.Context) (_ *schema.ToolInfo, err er
}

func (p *pluginInvokeTool) PluginInvoke(ctx context.Context, argumentsInJSON string, cfg workflowModel.ExecuteConfig) (string, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrh997 帮忙确认下。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个我看下

var uID string
if cfg.AgentID != nil {
uID = cfg.ConnectorUID
} else {
uID = conv.Int64ToStr(cfg.Operator)
}

req := &model.ExecuteToolRequest{
UserID: conv.Int64ToStr(cfg.Operator),
UserID: uID,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cfg.ConnectorUID 与cfg.Operator 最新版本有区分;ConnectorUID 表示的是渠道UserID,Operator代表的是opencoze 的userID(创建Workflow 或者Plugin者);ConnectorUID 可能与Operator相同,或是第三方调用者的userID 。 ExecuteToolRequest 中的 UserID 必须是 Operator,后续鉴权场景需要。

Image如果按照这个说法,ConnectorUID不等于Operator 则这个值需要置为空 ;

PluginID: p.pluginEntity.PluginID,
ToolID: p.toolInfo.ID,
ExecScene: consts.ExecSceneOfWorkflow,
Expand All @@ -348,7 +355,14 @@ func (p *pluginInvokeTool) PluginInvoke(ctx context.Context, argumentsInJSON str
execOpts := []model.ExecuteToolOpt{
model.WithInvalidRespProcessStrategy(consts.InvalidResponseProcessStrategyOfReturnDefault),
}

if cfg.ConversationID != nil {
execOpts = append(execOpts, model.WithConversationID(*cfg.ConversationID))
}
if cfg.AgentID != nil {
execOpts = append(execOpts, model.WithProjectInfo(&model.ProjectInfo{
ProjectID: *cfg.AgentID,
}))
}
if p.pluginEntity.PluginVersion != nil {
execOpts = append(execOpts, model.WithToolVersion(*p.pluginEntity.PluginVersion))
}
Expand Down
Loading