fix: delete redundant fields in plugin output data (#469)

This commit is contained in:
lvxinyu-1117
2025-08-04 16:54:30 +08:00
committed by GitHub
parent a44b4e8f7e
commit c7bf6bbdec
8 changed files with 304 additions and 15 deletions

View File

@@ -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,
},
}

View File

@@ -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
}