fix: delete redundant fields in plugin output data (#469)
This commit is contained in:
@@ -30,6 +30,7 @@ import (
|
||||
//go:generate mockgen -destination pluginmock/plugin_mock.go --package pluginmock -source plugin.go
|
||||
type Service interface {
|
||||
GetPluginToolsInfo(ctx context.Context, req *ToolsInfoRequest) (*ToolsInfoResponse, error)
|
||||
UnwrapArrayItemFieldsInVariable(v *vo.Variable) error
|
||||
GetPluginInvokableTools(ctx context.Context, req *ToolsInvokableRequest) (map[int64]InvokableTool, error)
|
||||
ExecutePlugin(ctx context.Context, input map[string]any, pe *Entity,
|
||||
toolID int64, cfg ExecConfig) (map[string]any, error)
|
||||
|
||||
@@ -77,8 +77,8 @@ type FunctionInfo struct {
|
||||
|
||||
type FunctionCallInfo struct {
|
||||
FunctionInfo
|
||||
CallID string `json:"-"`
|
||||
Arguments string `json:"arguments"`
|
||||
CallID string `json:"-"`
|
||||
Arguments map[string]any `json:"arguments"`
|
||||
}
|
||||
|
||||
type ToolResponseInfo struct {
|
||||
|
||||
@@ -2061,7 +2061,7 @@ func buildClauseFromParams(params []*vo.Param) (*database.Clause, error) {
|
||||
|
||||
func parseBatchMode(n *vo.Node) (
|
||||
batchN *vo.Node, // the new batch node
|
||||
enabled bool, // whether the node has enabled batch mode
|
||||
enabled bool, // whether the node has enabled batch mode
|
||||
err error) {
|
||||
if n.Data == nil || n.Data.Inputs == nil {
|
||||
return nil, false, nil
|
||||
|
||||
@@ -27,6 +27,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/sonic"
|
||||
|
||||
"github.com/cloudwego/eino/callbacks"
|
||||
"github.com/cloudwego/eino/components/tool"
|
||||
"github.com/cloudwego/eino/compose"
|
||||
@@ -1271,13 +1273,21 @@ func (t *ToolHandler) OnStart(ctx context.Context, info *callbacks.RunInfo,
|
||||
return ctx
|
||||
}
|
||||
|
||||
var args map[string]any
|
||||
if input.ArgumentsInJSON != "" {
|
||||
if err := sonic.UnmarshalString(input.ArgumentsInJSON, &args); err != nil {
|
||||
logs.Errorf("failed to unmarshal arguments: %v", err)
|
||||
return ctx
|
||||
}
|
||||
}
|
||||
|
||||
t.ch <- &Event{
|
||||
Type: FunctionCall,
|
||||
Context: GetExeCtx(ctx),
|
||||
functionCall: &entity.FunctionCallInfo{
|
||||
FunctionInfo: t.info,
|
||||
CallID: compose.GetToolCallID(ctx),
|
||||
Arguments: input.ArgumentsInJSON,
|
||||
Arguments: args,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -887,7 +887,12 @@ func getFCInfos(ctx context.Context, nodeKey vo.NodeKey) map[string]*fcInfo {
|
||||
}
|
||||
|
||||
func (f *fcInfo) inputString() string {
|
||||
if f.input == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
m, err := sonic.MarshalString(f.input)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -899,12 +904,5 @@ func (f *fcInfo) outputString() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
m := map[string]any{
|
||||
"data": f.output.Response, // TODO: traceID, code, message?
|
||||
}
|
||||
b, err := sonic.MarshalString(m)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return b
|
||||
return f.output.Response
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user