Merge pull request #917 from trheyi/main
fix: Update Assistant API to handle arguments and improve error logging
This commit is contained in:
commit
2e74595ad0
2 changed files with 9 additions and 4 deletions
|
|
@ -306,10 +306,15 @@ func (ast *Assistant) Call(c *gin.Context, payload APIPayload) (interface{}, err
|
||||||
|
|
||||||
// Check if the method exists
|
// Check if the method exists
|
||||||
if !scriptCtx.Global().Has(method) {
|
if !scriptCtx.Global().Has(method) {
|
||||||
|
color.Red("Assistant Call: %s Method %s not found", ast.ID, method)
|
||||||
return nil, fmt.Errorf(HookErrorMethodNotFound)
|
return nil, fmt.Errorf(HookErrorMethodNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
return scriptCtx.CallWith(ctx, method, payload.Payload)
|
if payload.Args == nil || len(payload.Args) == 0 {
|
||||||
|
return scriptCtx.CallWith(ctx, method)
|
||||||
|
}
|
||||||
|
|
||||||
|
return scriptCtx.CallWith(ctx, method, payload.Args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleChatStream manages the streaming chat interaction with the AI
|
// handleChatStream manages the streaming chat interaction with the AI
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,9 @@ type API interface {
|
||||||
|
|
||||||
// APIPayload the API payload
|
// APIPayload the API payload
|
||||||
type APIPayload struct {
|
type APIPayload struct {
|
||||||
Sid string `json:"sid"`
|
Sid string `json:"sid"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Payload map[string]interface{} `json:"payload"`
|
Args []interface{} `json:"args,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResHookInit the response of the init hook
|
// ResHookInit the response of the init hook
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue