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
This commit is contained in:
Max 2025-03-12 17:24:36 +08:00
parent b89a39b192
commit d3734cf1d0
2 changed files with 7 additions and 0 deletions

View file

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

View file

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