Skip to content

Commit

Permalink
bug: fix broken gpt4 when tool has no args (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud authored May 23, 2024
1 parent 9e7a3ff commit c2edee9
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pkg/openai/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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{},
}
}

Expand Down

0 comments on commit c2edee9

Please sign in to comment.