Skip to content

Commit be4cbde

Browse files
committed
Fix: Ensure function params are not null
Mistral's validation is more strict than OpenAIs and will reject a function if the parameter field is set to null or completely omitted. It is strictly expecting a valid map. This change makes that so. Signed-off-by: Craig Jellick <[email protected]>
1 parent 1bf1f8b commit be4cbde

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pkg/openai/client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"strings"
1515
"sync/atomic"
1616

17+
"github.com/getkin/kin-openapi/openapi3"
1718
openai "github.com/gptscript-ai/chat-completion-client"
1819
"github.com/gptscript-ai/gptscript/pkg/cache"
1920
"github.com/gptscript-ai/gptscript/pkg/hash"
@@ -327,6 +328,9 @@ func (c *Client) Call(ctx context.Context, messageRequest types.CompletionReques
327328

328329
for _, tool := range messageRequest.Tools {
329330
params := tool.Function.Parameters
331+
if params == nil {
332+
params = &openapi3.Schema{}
333+
}
330334

331335
request.Tools = append(request.Tools, openai.Tool{
332336
Type: openai.ToolTypeFunction,

0 commit comments

Comments
 (0)