API.pm

filter: Statementstmt 93.9% 31 / 33 Branchbran 50.0% 3 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 85.1% 46 / 54 SCAR 18.1
CC
6
Cov
86%
new
3.2
BEGIN
3.0
__ANON__
2.1
CRAP 6.1
« API/Request.pm ↑ Summary API/Request/Chat.pm »
1 package OpenAI::API;
2  
3 16 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 16 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 16 ▶use OpenAI::API::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 16 our $VERSION = 0.36;
9  
10 BEGIN {
11 16 ▶ my %module_dispatcher = (
Subroutine BEGIN: called CC=3 SCAR=11.1
12 chat => 'OpenAI::API::Request::Chat',
13 completions => 'OpenAI::API::Request::Completion',
14 edits => 'OpenAI::API::Request::Edit',
15 embeddings => 'OpenAI::API::Request::Embedding',
16 files => 'OpenAI::API::Request::File::List',
17 file_retrieve => 'OpenAI::API::Request::File::Retrieve',
18 image_create => 'OpenAI::API::Request::Image::Generation',
19 models => 'OpenAI::API::Request::Model::List',
20 model_retrieve => 'OpenAI::API::Request::Model::Retrieve',
21 moderations => 'OpenAI::API::Request::Moderation',
22 );
23  
24 16 for my $sub_name ( keys %module_dispatcher ) {
25 160 my $module = $module_dispatcher{$sub_name};
26  
27 160 ▶ eval "require $module" or die $@;
Branch: 1 branch
BranchTrueFalseTotal
eval "require $module" or die $@ 0 160 160
28  
29 16 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
30 160 *{"$sub_name"} = sub {
31 10 ▶ my $self = shift;
Subroutine __ANON__: called CC=2 SCAR=7.4
32 10 ▶ my %params = ref $_[0] eq 'HASH' ? %{ $_[0] } : @_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 10 10
33  
34 10 my $request = $module->new( %params, config => $self->config );
35 4 return $request->send();
36 160 };
37 }
38 }
39  
40 sub new {
41 3 ▶ my $class = shift;
Subroutine new: called CC=3 SCAR=11.6
Pod documented
42  
43 3 ▶ my %param = ref $_[0] ? %{ $_[0] } : @_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 3 3
44  
45 3 ▶ my $self = bless \%param, ref $class || $class;
Condition66%2/3
ref $class || $class
l!l&&r!l&&!r
120
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table66%2/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
46  
47 3 $self->{config} = OpenAI::API::Config->new(%param);
48  
49 2 return $self;
50 }
51  
52 sub config {
53 10 ▶ my ( $self, %param ) = @_;
Subroutine config: called CC=1 SCAR=0.0
Pod documented
54 10 return $self->{config};
55 }
56  
57 16 1;
58  
59 __END__
« API/Request.pm ↑ Summary API/Request/Chat.pm »