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

Function Call Error Due to Nil Properties #429

Closed
vvatanabe opened this issue Jul 8, 2023 · 3 comments
Closed

Function Call Error Due to Nil Properties #429

vvatanabe opened this issue Jul 8, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@vvatanabe
Copy link
Collaborator

vvatanabe commented Jul 8, 2023

Describe the bug
An error occurs when using the Function Call feature. The relevant error message is as follows:

Completion error: error, status code: 400, message: Invalid schema for function 'func_name': None is not of type 'object'

This issue arises when the map in the Properties field of jsonschema.Definition is set to nil.

To Reproduce
This bug can be reproduced through the following steps:

  1. Use jsonschema.Definition when constructing parameters for the Function Call.
  2. Set the map in the Properties field of jsonschema.Definition to nil.
  3. Send a request using the Function Call feature.

Please note that the process works correctly if the map in the Properties field of jsonschema.Definition is initialized.

PR for reproduction:
#430

Expected behavior
Even if the map in the Properties field of jsonschema.Definition is nil, it should be possible to send a request using the Function Call feature.

Environment
go-openai version: v1.13.0

Additional context
This bug was caused by changes made in pull request #419. Specifically, omitempty was removed from the Properties field of jsonschema.Definition by pull request #419. This change caused issues when the map in the Properties field was set to nil.

For detailed reasons why omitempty was removed, please refer to the description in pull request #419.

As a bug handling measure, it seems better to initialize the map in the Properties field of jsonschema.Definition to an empty map if it is set to nil. Also, since jsonschema.Definition has a recursive structure that can have jsonschema.Definition as a child, the check for nil and initialization should also be done recursively.

@vvatanabe
Copy link
Collaborator Author

Fixed #431

@vvatanabe
Copy link
Collaborator Author

The problem recurs when Parameters is a value instead of a pointer.
Refs: #432

@vvatanabe vvatanabe reopened this Jul 10, 2023
vvatanabe added a commit to vvatanabe/go-openai that referenced this issue Jul 11, 2023
sashabaranov pushed a commit that referenced this issue Jul 11, 2023
…ject' (#429)(#432) (#434)

* fix: invalid schema for function 'func_name': None is not of type 'object' (#429)(#432)

* test: add integration test for function call (#429)(#432)

* style: remove duplicate import (#429)(#432)
@vvatanabe
Copy link
Collaborator Author

Fixed #434

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

1 participant