Confirm this is an issue with the Python library and not an underlying OpenAI API
[X] This is an issue with the Python library
Describe the bug
Description:
The results returned by the moderation endpoint do not align with the expected schema.
Details:
In the Moderation.categories field (of type Categories), all fields are annotated as bool. However, when the moderation endpoint is called, the fields illicit and illicit_violent return None values instead of True or False.
The same issue occurs with the category_scores field (of type CategoryScores), where all fields are expected to be float. Yet, illicit and illicit_violent are also returned as None.
Expected Behavior:
If the None values for illicit and illicit_violent are expected behavior, these fields should be annotated as optional in the schema.
If this is not expected behavior, the API should be corrected to ensure that these fields return appropriate boolean or float values.
Additional Notes:
It is surprising that Pydantic does not throw an error for these mismatches and allows None values to be returned. I could not manually create a Categories object with any None value in it.
To Reproduce
Run the moderation endpoint and check response.results[0] categories and category_scores -> illicit field.
Confirm this is an issue with the Python library and not an underlying OpenAI API
Describe the bug
Description: The results returned by the moderation endpoint do not align with the expected schema.
Details:
Moderation.categories
field (of typeCategories
), all fields are annotated asbool
. However, when the moderation endpoint is called, the fieldsillicit
andillicit_violent
returnNone
values instead ofTrue
orFalse
.category_scores
field (of typeCategoryScores
), where all fields are expected to befloat
. Yet,illicit
andillicit_violent
are also returned asNone
.Expected Behavior:
None
values forillicit
andillicit_violent
are expected behavior, these fields should be annotated as optional in the schema.Additional Notes: It is surprising that Pydantic does not throw an error for these mismatches and allows
None
values to be returned. I could not manually create aCategories
object with anyNone
value in it.To Reproduce
Run the moderation endpoint and check
response.results[0]
categories and category_scores -> illicit field.Result I'm getting:
Code snippets
OS
macOS
Python version
Python 3.12.4
Library version
openai 1.51.2