Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat(OpenAI): Add category applied input types to moderation response #572

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

Conversation

Mcainson
Copy link
Contributor

@Mcainson Mcainson commented Apr 30, 2025

What:

  • Bug Fix
  • New Feature

Description:

This PR adds support for category_applied_input_types to the Moderations endpoint, enabling users to identify which input types (e.g., text, image) were flagged for specific categories in moderation results.

Changes

  • Added category_applied_input_types to the Moderations endpoint response structure.
  • Updated Moderations::create method to handle and parse category_applied_input_types from the API response.
  • Added tests to verify the correct parsing and handling of category_applied_input_types in moderation results.
  • Added unit tests for multi-modal (image/text) input handling in Moderations.

Related:

@abikali
Copy link
Contributor

abikali commented Apr 30, 2025

Nowhere in the documentation https://platform.openai.com/docs/api-reference/moderations/object they mentioned that category_applied_input_types is nullable (optional), unless I missed it.

@iBotPeaches
Copy link
Collaborator

iBotPeaches commented Apr 30, 2025

Nowhere in the documentation https://platform.openai.com/docs/api-reference/moderations/object they mentioned that category_applied_input_types is nullable (optional), unless I missed it.

I was running some tests just now. It appears the legacy model - text-moderation-latest does not return it, but the new one - omni-moderation-latest does.

EDIT: Found in docs

Screenshot 2025-04-30 at 9 59 41 AM

Copy link
Collaborator

@iBotPeaches iBotPeaches left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I did make some changes for context to remove all the unneeded code churn to random spacing/docblocks. Generally want to reduce any change but the newly added stuff to make it easier to review diff.

I tested this for real with this sample: iBotPeaches/openai-php-laravel-test@87313ad on both the legacy and new model to confirm the nullable aspect of category_applied_input_types and works as I expect.

+1

@iBotPeaches iBotPeaches changed the title Add category input types to moderation response feat:(OpenAI) - Add category applied input types to moderation response Apr 30, 2025
@iBotPeaches iBotPeaches changed the title feat:(OpenAI) - Add category applied input types to moderation response feat(OpenAI): - Add category applied input types to moderation response Apr 30, 2025
@iBotPeaches iBotPeaches changed the title feat(OpenAI): - Add category applied input types to moderation response feat(OpenAI): Add category applied input types to moderation response Apr 30, 2025
@iBotPeaches iBotPeaches merged commit 62e9822 into openai-php:main Apr 30, 2025
10 checks passed
@iBotPeaches iBotPeaches deleted the add-category-input-types-to-moderation-response branch April 30, 2025 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.