go-openai
go-openai copied to clipboard
1 validation error for Request body -> tools extra fields not permitted (type=value_error.extra)
config := openai.DefaultAzureConfig(appKey, baseUrl)
config.APIVersion = "2023-07-01-preview"
config.AzureModelMapperFunc = func(model string) string {
azureModelMapping := map[string]string{
"gpt-3.5-turbo": "gpt-35-turbo",
"text-embedding-ada-002": "text-embedding-ada-002",
"gpt-4": "*",
openai.GPT4TurboPreview: "**",
}
return azureModelMapping[model]
}
client := openai.NewClientWithConfig(config)
resp, err := client.CreateChatCompletion(ctx, openai.ChatCompletionRequest{
Model: openai.GPT4TurboPreview,
Messages: dialogue,
Tools: []openai.Tool{getSimpleTool()},
})
if err != nil {
logger.Ex(ctx, tags, "CreateChatCompletion.err:[%+v]", err)
return
}
func getSimpleTool() openai.Tool {
// describe the function & its inputs
params := jsonschema.Definition{
Type: jsonschema.Object,
Properties: map[string]jsonschema.Definition{
"location": {
Type: jsonschema.String,
Description: "The city and state, e.g. San Francisco, CA",
},
"unit": {
Type: jsonschema.String,
Enum: []string{"celsius", "fahrenheit"},
},
},
Required: []string{"location"},
}
f := openai.FunctionDefinition{
Name: "get_current_weather",
Description: "Get the current weather in a given location",
Parameters: params,
}
t := openai.Tool{
Type: openai.ToolTypeFunction,
Function: f,
}
return t
}
run error
err.Code=44036064 err.Type=invalid_request_error err.Msg=1 validation error for Requestbody -> Metadata extra fields not permitted (type=value_error.extra)
go-openai version: 1.17.9
Go version: 1.18
OS: macOS 12.4
Additional context Add any other context about the problem here.