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 <liudanbing@tal.com>
This commit is contained in:
@@ -5,10 +5,23 @@ import (
|
|||||||
"net/http"
|
"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.
|
// ModerationRequest represents a request structure for moderation API.
|
||||||
type ModerationRequest struct {
|
type ModerationRequest struct {
|
||||||
Input string `json:"input,omitempty"`
|
Input string `json:"input,omitempty"`
|
||||||
Model *string `json:"model,omitempty"`
|
Model string `json:"model,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Result represents one of possible moderation results.
|
// Result represents one of possible moderation results.
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ func TestModerations(t *testing.T) {
|
|||||||
// create an edit request
|
// create an edit request
|
||||||
model := "text-moderation-stable"
|
model := "text-moderation-stable"
|
||||||
moderationReq := ModerationRequest{
|
moderationReq := ModerationRequest{
|
||||||
Model: &model,
|
Model: model,
|
||||||
Input: "I want to kill them.",
|
Input: "I want to kill them.",
|
||||||
}
|
}
|
||||||
_, err = client.Moderations(ctx, moderationReq)
|
_, err = client.Moderations(ctx, moderationReq)
|
||||||
@@ -77,7 +77,7 @@ func handleModerationEndpoint(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
res := ModerationResponse{
|
res := ModerationResponse{
|
||||||
ID: strconv.Itoa(int(time.Now().Unix())),
|
ID: strconv.Itoa(int(time.Now().Unix())),
|
||||||
Model: *moderationReq.Model,
|
Model: moderationReq.Model,
|
||||||
}
|
}
|
||||||
res.Results = append(res.Results, result)
|
res.Results = append(res.Results, result)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user