openai-python icon indicating copy to clipboard operation
openai-python copied to clipboard

Why do we get a `openai.error.InvalidRequestError` if we pass `None` to `logit_bias` even if it defaults to `null`?

Open nbro10 opened this issue 1 year ago • 3 comments

Describe the bug

According to the docs, logit_bias defaults to null, but if we pass None to this parameter we get openai.error.InvalidRequestError

openai.error.InvalidRequestError: None is not of type 'object' - 'logit_bias'

So, I suppose this is a bug in this package, as None should correspond to what the docs refer to as null, or the documentation is wrong.

To Reproduce

Use the script below

Code snippets

import openai

completions = openai.Completion.create(model="text-davinci-003",
                                       prompt="hello",
                                       logit_bias=None)
print(completions)

OS

macos monterey (12.5.1)

Python version

Python 3.8.13

Library version

0.27.0

nbro10 avatar Mar 08 '23 14:03 nbro10

I have experienced the same problem. In the documentation it is stated, that the default value should be null. image However, when providing it explicitly, I'm getting the same error in the Postman as OP. image

reactiveclown avatar Mar 10 '23 13:03 reactiveclown

As far as I have investigated the API. It looks like providing the empty map has fixed the problem. image So I believe, that there are two solutions here. First one would be changing the documentation and providing the "Defaults to empty map". Second one would be changing the API so it can accept the null value as logit_bias parameter.

Looking forward for any updates on this case and decided solution from the developers.

reactiveclown avatar Mar 10 '23 13:03 reactiveclown

I will have the team take a look at this later this week.

logankilpatrick avatar Mar 13 '23 16:03 logankilpatrick

Closing because this is an API issue rather than an SDK issue.

If this continues to be a problem for you, please file at community.openai.com.

rattrayalex avatar Nov 10 '23 03:11 rattrayalex