openai-python
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`?
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
I have experienced the same problem. In the documentation it is stated, that the default value should be null.
However, when providing it explicitly, I'm getting the same error in the Postman as OP.
As far as I have investigated the API. It looks like providing the empty map has fixed the problem.
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.
I will have the team take a look at this later this week.
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.