-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmoderations.go
53 lines (45 loc) · 1.43 KB
/
moderations.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package openai
import (
"context"
"net/http"
)
type ModerationRequest struct {
Input string `json:"input" form:"input"`
Model string `json:"model,omitempty" form:"model,omitempty"`
}
type ModerationResponse struct {
ID string `json:"id"`
Model string `json:"model"`
Results []Result `json:"results"`
}
type Result struct {
Categories Categories `json:"categories"`
CategoryScores CategoryScores `json:"category_scores"`
Flagged bool `json:"flagged"`
}
type Categories struct {
Hate bool `json:"hate"`
HateThreatening bool `json:"hate/threatening"`
SelfHarm bool `json:"self-harm"`
Sexual bool `json:"sexual"`
SexualMinors bool `json:"sexual/minors"`
Violence bool `json:"violence"`
ViolenceGraphic bool `json:"violence/graphic"`
}
type CategoryScores struct {
Hate float64 `json:"hate"`
HateThreatening float64 `json:"hate/threatening"`
SelfHarm float64 `json:"self-harm"`
Sexual float64 `json:"sexual"`
SexualMinors float64 `json:"sexual/minors"`
Violence float64 `json:"violence"`
ViolenceGraphic float64 `json:"violence/graphic"`
}
func (c *Client) CreateModeration(ctx context.Context, request ModerationRequest) (response ModerationResponse, err error) {
req, err := c.requestFactory.Build(ctx, http.MethodPost, fullURL(moderations), request)
if err != nil {
return
}
err = c.sendRequest(req, &response)
return
}