Skip to content

Commit c2edee9

Browse files
bug: fix broken gpt4 when tool has no args (#386)
1 parent 9e7a3ff commit c2edee9

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

pkg/openai/client.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"sort"
1111
"strings"
1212

13-
"github.com/getkin/kin-openapi/openapi3"
1413
openai "github.com/gptscript-ai/chat-completion-client"
1514
"github.com/gptscript-ai/gptscript/pkg/cache"
1615
"github.com/gptscript-ai/gptscript/pkg/counter"
@@ -330,11 +329,11 @@ func (c *Client) Call(ctx context.Context, messageRequest types.CompletionReques
330329
}
331330

332331
for _, tool := range messageRequest.Tools {
333-
params := tool.Function.Parameters
334-
if params == nil {
335-
params = &openapi3.Schema{
336-
Type: "object",
337-
Properties: openapi3.Schemas{},
332+
var params any = tool.Function.Parameters
333+
if tool.Function.Parameters == nil || len(tool.Function.Parameters.Properties) == 0 {
334+
params = map[string]any{
335+
"type": "object",
336+
"properties": map[string]any{},
338337
}
339338
}
340339

0 commit comments

Comments
 (0)