Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trying to provide a list of functions and receive an error #469

Closed
evdanil opened this issue Aug 10, 2023 · 2 comments
Closed

trying to provide a list of functions and receive an error #469

evdanil opened this issue Aug 10, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@evdanil
Copy link

evdanil commented Aug 10, 2023

Describe the bug
Attempt of sending request to completion endpoint return an error
" status code: 400, message: Invalid schema for function 'get_current_weather': None is not of type 'object' "

To Reproduce
Steps to reproduce the behavior, including any relevant code snippets.

functions := []openai.FunctionDefinition{
	{
		Name: "get_current_weather",
		Parameters: 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{"celcius", "fahrenheit"},
				},
			},
			Required: []string{"location"},
		},
	},
}

client := openai.NewClient(GPT_TOKEN)

response, err := client.CreateChatCompletion(
	context.Background(),
	openai.ChatCompletionRequest{
		Model:     openai.GPT3Dot5Turbo0613,
		Messages:  chat_context.Messages,
		Functions: functions,
	},
)

Expected behavior
API to consume functions list

Environment (please complete the following information):

  • go-openai v1.14.1
  • go version go1.20.7 linux/amd64
  • OpenAI API version: v1
  • OS: Ubuntu 20.04
@evdanil evdanil added the bug Something isn't working label Aug 10, 2023
@vvatanabe
Copy link
Collaborator

vvatanabe commented Aug 10, 2023

@evdanil This problem fixed #434.
Just to be sure, I tested with v1.14.1 using your code and it worked fine.

Environment:

  • go-openai v1.14.1
  • go version go1.20.7
  • OpenAI API version: v1
  • OS: Darwin arm64

@evdanil
Copy link
Author

evdanil commented Aug 10, 2023

Hello,

yes it is fixed indeed, for some reason, json.go I had in my code, was not up to date. Thank you for quick response.

@evdanil evdanil closed this as completed Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants