line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenAI::API::Request::Moderation; |
2
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
120
|
use strict; |
|
16
|
|
|
|
|
35
|
|
|
16
|
|
|
|
|
493
|
|
4
|
16
|
|
|
16
|
|
85
|
use warnings; |
|
16
|
|
|
|
|
35
|
|
|
16
|
|
|
|
|
374
|
|
5
|
|
|
|
|
|
|
|
6
|
16
|
|
|
16
|
|
82
|
use Moo; |
|
16
|
|
|
|
|
34
|
|
|
16
|
|
|
|
|
105
|
|
7
|
16
|
|
|
16
|
|
5834
|
use strictures 2; |
|
16
|
|
|
|
|
112
|
|
|
16
|
|
|
|
|
630
|
|
8
|
16
|
|
|
16
|
|
2873
|
use namespace::clean; |
|
16
|
|
|
|
|
37
|
|
|
16
|
|
|
|
|
128
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
extends 'OpenAI::API::Request'; |
11
|
|
|
|
|
|
|
|
12
|
16
|
|
|
16
|
|
4692
|
use Types::Standard qw(Bool Str Num Int Map); |
|
16
|
|
|
|
|
39
|
|
|
16
|
|
|
|
|
131
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has input => ( is => 'rw', isa => Str, required => 1, ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has model => ( is => 'rw', isa => Str, ); |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
1
|
19
|
sub endpoint { 'moderations' } |
19
|
1
|
|
|
1
|
1
|
11
|
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<future|IO::Async::Future> 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> |