Skip to content

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

@codecov
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

1 participant