Skip to content

Changes moderation category scores from float32 to float64 #1018

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

johnyojohn
Copy link

@johnyojohn johnyojohn commented Jun 10, 2025

Describe the change
Changes the types for moderation category scores from float32 to float64. This is because the openai api can return more significant digits than can be expressed in float32. In addition, the official openai go client uses float64 for moderation category scores (https://github.com/openai/openai-go/blob/main/moderation.go). Finally, the go's default JSON unmarshalling behavior for numbers is to store them into float64. I think these are all good reasons to change to float64.

Provide OpenAI documentation link
(https://platform.openai.com/docs/api-reference/moderations/create)

Describe your solution
Simply replacing the float32 types with float64.

Tests
N/A since float32 can be cast into float64 without losing precision.

Additional context

Copy link

codecov bot commented Jun 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.77%. Comparing base (ff9d83a) to head (5c5c2c0).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1018   +/-   ##
=======================================
  Coverage   85.77%   85.77%           
=======================================
  Files          43       43           
  Lines        2291     2291           
=======================================
  Hits         1965     1965           
  Misses        304      304           
  Partials       22       22           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@johnyojohn johnyojohn changed the title changes float32 to float64 Changes moderation category scores from float32 to float64 Jun 10, 2025
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.

1 participant