From d3734cf1d044886680b0a93cd4dbfa16c9a51ff1 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 12 Mar 2025 17:24:36 +0800 Subject: [PATCH] Add support for passing arguments in assistant method calls - Extend Context struct to include Args field for storing call arguments - Modify objectCall.run to capture and store arguments in chat context - Update context mapping to include arguments when present --- neo/assistant/call.go | 1 + neo/context/context.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/neo/assistant/call.go b/neo/assistant/call.go index fd3df996..ef086cfe 100644 --- a/neo/assistant/call.go +++ b/neo/assistant/call.go @@ -247,6 +247,7 @@ func (obj *objectCall) run(info *v8go.FunctionCallbackInfo) *v8go.Value { chatCtx.AssistantID = assistantID chatCtx.ChatID = fmt.Sprintf("call_%s", uuid.New().String()) // New chat id chatCtx.Silent = options.Silent + chatCtx.Args = goArgs // Arguments for call // Define the callback function var cb func(msg *chatMessage.Message) = nil diff --git a/neo/context/context.go b/neo/context/context.go index 77d1c43f..929dfeb2 100644 --- a/neo/context/context.go +++ b/neo/context/context.go @@ -28,6 +28,7 @@ type Context struct { Upload *FileUpload `json:"upload,omitempty"` Version bool `json:"version,omitempty"` // Version support RAG bool `json:"rag,omitempty"` // RAG support + Args []interface{} `json:"args,omitempty"` // Arguments for call SharedSpace plan.Space `json:"-"` // Shared space } @@ -125,6 +126,11 @@ func (ctx *Context) Map() map[string]interface{} { data["retry"] = ctx.Retry } + // Arguments for call + if ctx.Args != nil && len(ctx.Args) > 0 { + data["args"] = ctx.Args + } + // Retry times data["retry_times"] = ctx.RetryTimes