line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenAI::API::Request::Moderation; |
2
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
116
|
use strict; |
|
16
|
|
|
|
|
45
|
|
|
16
|
|
|
|
|
468
|
|
4
|
16
|
|
|
16
|
|
93
|
use warnings; |
|
16
|
|
|
|
|
34
|
|
|
16
|
|
|
|
|
372
|
|
5
|
|
|
|
|
|
|
|
6
|
16
|
|
|
16
|
|
90
|
use Moo; |
|
16
|
|
|
|
|
38
|
|
|
16
|
|
|
|
|
110
|
|
7
|
16
|
|
|
16
|
|
5825
|
use strictures 2; |
|
16
|
|
|
|
|
174
|
|
|
16
|
|
|
|
|
690
|
|
8
|
16
|
|
|
16
|
|
2921
|
use namespace::clean; |
|
16
|
|
|
|
|
31
|
|
|
16
|
|
|
|
|
123
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
extends 'OpenAI::API::Request'; |
11
|
|
|
|
|
|
|
|
12
|
16
|
|
|
16
|
|
4306
|
use Types::Standard qw(Bool Str Num Int Map); |
|
16
|
|
|
|
|
44
|
|
|
16
|
|
|
|
|
129
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has input => ( is => 'rw', isa => Str, required => 1, ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has model => ( is => 'rw', isa => Str, ); |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
1
|
16
|
sub endpoint { 'moderations' } |
19
|
1
|
|
|
1
|
1
|
7
|
sub method { 'POST' } |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
1; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
__END__ |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 NAME |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
OpenAI::API::Request::Moderation - moderations endpoint |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
use OpenAI::API::Request::Moderation; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $request = OpenAI::API::Request::Moderation->new( |
34
|
|
|
|
|
|
|
input => "I like turtles", |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $res = $request->send(); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
if ( $res->{results}[0]{flagged} ) { |
40
|
|
|
|
|
|
|
die "Input violates our Content Policy"; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 DESCRIPTION |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Given a input text, outputs if the model classifies it as violating |
46
|
|
|
|
|
|
|
OpenAI's content policy. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 METHODS |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 new() |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=over 4 |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item * input |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item * model [optional] |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=back |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 send() |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Sends the request and returns a data structured similar to the one |
63
|
|
|
|
|
|
|
documented in the API reference. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 send_async() |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Send a request asynchronously. Returns a L<Promises> promise that will |
68
|
|
|
|
|
|
|
be resolved with the decoded JSON response. See L<OpenAI::API::Request> |
69
|
|
|
|
|
|
|
for an example. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 SEE ALSO |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
OpenAI API Reference: L<Moderations|https://platform.openai.com/docs/api-reference/moderations> |