-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Check if the model param is valid for moderations endpoint #437
Check if the model param is valid for moderations endpoint #437
Conversation
Codecov Report
@@ Coverage Diff @@
## master #437 +/- ##
==========================================
+ Coverage 97.02% 97.03% +0.01%
==========================================
Files 17 17
Lines 705 709 +4
==========================================
+ Hits 684 688 +4
Misses 15 15
Partials 6 6
|
moderation_test.go
Outdated
// TestModerationsWithIncorrectModel Tests passing an incorrect model to Moderations request. | ||
func TestModerationsWithIncorrectModel(t *testing.T) { | ||
client, server, teardown := setupOpenAITestServer() | ||
defer teardown() | ||
server.RegisterHandler("/v1/moderations", handleModerationEndpoint) | ||
_, err := client.Moderations(context.Background(), ModerationRequest{ | ||
Model: GPT3Dot5Turbo, | ||
Input: "I want to kill them.", | ||
}) | ||
checks.ErrorIs(t, err, ErrModerationInvalidModel) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MunaerYesiyan Thanks for PR! How about trying to write exhaustive tests for both valid and invalid models in table driven tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Included valid and invalid model for moderation unit testing.
e579559
Confirmed not supported just in case. 👍
|
And it's kinda confusing as the official document uses |
moderation.go
Outdated
@@ -18,6 +19,15 @@ const ( | |||
ModerationText001 = "text-moderation-001" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MunaerYesiyan I would like you to add a comment indicating that this constant is deprecated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deprecating the text-moderation-001
model in moderation.go
e579559
1b8d84d
to
1e82071
Compare
@MunaerYesiyan Thanks for the pull request! |
Currently there are only two models available for OpenAI /moderations endpoint, which are
text-moderation-stable
andtext-moderation-latest
. In the official python libraryopenai-python
. The method Moderation will check if the model param is inVALID_MODEL_NAMES
and returns an error when it's not.It would be great if we can add similar checks before passing the request to
/v1/moderations
endpoint.