Skip to content

Commit

Permalink
fix:model param type, add moderation Model Name const. (sashabaranov#270
Browse files Browse the repository at this point in the history
)

* 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 <liudanbing@tal.com>
  • Loading branch information
aceld and Aceld authored Apr 20, 2023
1 parent c2b58e7 commit 2f008f7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
17 changes: 15 additions & 2 deletions moderation.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,23 @@ import (
"net/http"
)

// The moderation endpoint is a tool you can use to check whether content complies with OpenAI's usage policies.
// Developers can thus identify content that our usage policies prohibits and take action, for instance by filtering it.

// The default is text-moderation-latest which will be automatically upgraded over time.
// This ensures you are always using our most accurate model.
// If you use text-moderation-stable, we will provide advanced notice before updating the model.
// Accuracy of text-moderation-stable may be slightly lower than for text-moderation-latest.
const (
ModerationTextStable = "text-moderation-stable"
ModerationTextLatest = "text-moderation-latest"
ModerationText001 = "text-moderation-001"
)

// ModerationRequest represents a request structure for moderation API.
type ModerationRequest struct {
Input string `json:"input,omitempty"`
Model *string `json:"model,omitempty"`
Input string `json:"input,omitempty"`
Model string `json:"model,omitempty"`
}

// Result represents one of possible moderation results.
Expand Down
4 changes: 2 additions & 2 deletions moderation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestModerations(t *testing.T) {
// create an edit request
model := "text-moderation-stable"
moderationReq := ModerationRequest{
Model: &model,
Model: model,
Input: "I want to kill them.",
}
_, err = client.Moderations(ctx, moderationReq)
Expand Down Expand Up @@ -77,7 +77,7 @@ func handleModerationEndpoint(w http.ResponseWriter, r *http.Request) {

res := ModerationResponse{
ID: strconv.Itoa(int(time.Now().Unix())),
Model: *moderationReq.Model,
Model: moderationReq.Model,
}
res.Results = append(res.Results, result)

Expand Down

0 comments on commit 2f008f7

Please sign in to comment.