From c2edee987a073e2d5b2d83ffc98c794411c117dc Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Thu, 23 May 2024 16:47:40 -0700 Subject: [PATCH] bug: fix broken gpt4 when tool has no args (#386) --- pkg/openai/client.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pkg/openai/client.go b/pkg/openai/client.go index dce75dfc..46d1a3da 100644 --- a/pkg/openai/client.go +++ b/pkg/openai/client.go @@ -10,7 +10,6 @@ import ( "sort" "strings" - "github.com/getkin/kin-openapi/openapi3" openai "github.com/gptscript-ai/chat-completion-client" "github.com/gptscript-ai/gptscript/pkg/cache" "github.com/gptscript-ai/gptscript/pkg/counter" @@ -330,11 +329,11 @@ func (c *Client) Call(ctx context.Context, messageRequest types.CompletionReques } for _, tool := range messageRequest.Tools { - params := tool.Function.Parameters - if params == nil { - params = &openapi3.Schema{ - Type: "object", - Properties: openapi3.Schemas{}, + var params any = tool.Function.Parameters + if tool.Function.Parameters == nil || len(tool.Function.Parameters.Properties) == 0 { + params = map[string]any{ + "type": "object", + "properties": map[string]any{}, } }