Skip to content

Commit 2f008f7

Browse files
aceldAceld
andauthored
fix:model param type, add moderation Model Name const. (#270)
* add ImageEditRequest.ResponseFormat * add ImageEditRequest/ImageVariRequest.ResponseFormat * complete image_test * delete var prompt param * fix:model param type, add moderation Model Name const. * rename ModerationText001 --------- Co-authored-by: Aceld <[email protected]>
1 parent c2b58e7 commit 2f008f7

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

moderation.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,23 @@ import (
55
"net/http"
66
)
77

8+
// The moderation endpoint is a tool you can use to check whether content complies with OpenAI's usage policies.
9+
// Developers can thus identify content that our usage policies prohibits and take action, for instance by filtering it.
10+
11+
// The default is text-moderation-latest which will be automatically upgraded over time.
12+
// This ensures you are always using our most accurate model.
13+
// If you use text-moderation-stable, we will provide advanced notice before updating the model.
14+
// Accuracy of text-moderation-stable may be slightly lower than for text-moderation-latest.
15+
const (
16+
ModerationTextStable = "text-moderation-stable"
17+
ModerationTextLatest = "text-moderation-latest"
18+
ModerationText001 = "text-moderation-001"
19+
)
20+
821
// ModerationRequest represents a request structure for moderation API.
922
type ModerationRequest struct {
10-
Input string `json:"input,omitempty"`
11-
Model *string `json:"model,omitempty"`
23+
Input string `json:"input,omitempty"`
24+
Model string `json:"model,omitempty"`
1225
}
1326

1427
// Result represents one of possible moderation results.

moderation_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestModerations(t *testing.T) {
3434
// create an edit request
3535
model := "text-moderation-stable"
3636
moderationReq := ModerationRequest{
37-
Model: &model,
37+
Model: model,
3838
Input: "I want to kill them.",
3939
}
4040
_, err = client.Moderations(ctx, moderationReq)
@@ -77,7 +77,7 @@ func handleModerationEndpoint(w http.ResponseWriter, r *http.Request) {
7777

7878
res := ModerationResponse{
7979
ID: strconv.Itoa(int(time.Now().Unix())),
80-
Model: *moderationReq.Model,
80+
Model: moderationReq.Model,
8181
}
8282
res.Results = append(res.Results, result)
8383

0 commit comments

Comments
 (0)