-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
ChatCompletionAssistantMessageParam
is incorrectly typed
#1433
Comments
Sorry, I believe this is working as intended. You aren't supposed to send Perhaps @RobertCraigie has an idea on how to better handle the pydantic issue you mention. |
The main reason I brought this up is that the documentation shows inserting Of course, the downstream effect here is that when using Pydantic it fails with a ValidationError unless I manually remove |
Gotcha, thanks. Okay so I think the backend has actually changed recently to allow this to be On the Pydantic side, you may want to use our static |
For me the issue is that I have my own Pydantic model with the message as a field, so the validation fails on my own object (and I want to validation to make sure I'm sending the right message structure). |
The |
Confirm this is an issue with the Python library and not an underlying OpenAI API
Describe the bug
The
ChatCompletionAssistantMessageParam
has the incorrect types for thefunction_call
,name
, andtool_calls
fields. All of these fields should be markedOptional[...]
but they are not.While this doesn't break the type itself, downstream it prevents the use of
pydantic
with these types.To Reproduce
Run the code in the snippet below.
pydantic
will try to validateChatCompletionAssistantMessageParam
and fail becausefunction_call
is None (as returned by the API). I would expect either (1) that the returned message does not include thefunction_call
field like it excludes thename
field or (2) for theChatCompletionAssistantMessageParam
type to allow forfunction_call
to beNone
in it's type definition.Code snippets
OS
14.2.1
Python version
3.9.16
Library version
1.30.1
The text was updated successfully, but these errors were encountered: