| 1 | package WebService::Jina; | ||||||||||||
| 2 | |||||||||||||
| 3 | 1 | ▶ | use 5.006; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 1 | our $VERSION = '0.06'; | |||||||||||
| 8 | |||||||||||||
| 9 | 1 | ▶ | use WebService::Jina::UA; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 1 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | |||||||||||||
| 12 | 1 | has api_key => ( | |||||||||||
| 13 | is => 'ro', | ||||||||||||
| 14 | lazy => 1, | ||||||||||||
| 15 | required => 1 | ||||||||||||
| 16 | ); | ||||||||||||
| 17 | |||||||||||||
| 18 | has ua => ( | ||||||||||||
| 19 | is => 'ro', | ||||||||||||
| 20 | 0 | ▶ | default => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 21 | 0 | return WebService::Jina::UA->new( | |||||||||||
| 22 | api_key => $_[0]->api_key | ||||||||||||
| 23 | ); | ||||||||||||
| 24 | } | ||||||||||||
| 25 | 1 | ); | |||||||||||
| 26 | |||||||||||||
| 27 | 0 | ▶ | sub deepsearch { | ||||||||||
|
Subroutine
deepsearch: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||
| 28 | 0 | my ($self, %args) = @_; | |||||||||||
| 29 | |||||||||||||
| 30 | 0 | ▶ | $args{model} ||= 'jina-deepsearch-v1'; | ||||||||||
|
Condition0%0/2
$args{"model"} ||= "jina-deepsearch-v1"
MC/DC0%0/1
$args{"model"} ||= "jina-deepsearch-v1"
$args{"model"}
Truth table0%0/2
A
A= $args{"model"}
| |||||||||||||
| 31 | |||||||||||||
| 32 | 0 | ▶ | if (! $args{messages}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 33 | 0 | die 'No messages defined for deepsearch'; | |||||||||||
| 34 | } | ||||||||||||
| 35 | |||||||||||||
| 36 | 0 | ▶ | $args{stream} = $args{stream} ? \1 : \0; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 37 | |||||||||||||
| 38 | 0 | ▶ | $args{reasoning_effort} ||= "medium"; | ||||||||||
|
Condition0%0/2
$args{"reasoning_effort"} ||= "medium"
MC/DC0%0/1
$args{"reasoning_effort"} ||= "medium"
$args{"reasoning_effort"}
Truth table0%0/2
A
A= $args{"reasoning_effort"}
| |||||||||||||
| 39 | |||||||||||||
| 40 | $self->ua->post( | ||||||||||||
| 41 | url => 'https://deepsearch.jina.ai/v1/chat/completions', | ||||||||||||
| 42 | headers => delete $args{headers}, | ||||||||||||
| 43 | 0 | data => \%args | |||||||||||
| 44 | ); | ||||||||||||
| 45 | } | ||||||||||||
| 46 | |||||||||||||
| 47 | 0 | ▶ | sub reader { | ||||||||||
|
Subroutine
reader: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||
| 48 | 0 | my ($self, %args) = @_; | |||||||||||
| 49 | |||||||||||||
| 50 | 0 | ▶ | if (! $args{url}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 51 | 0 | die "no url defined for reader"; | |||||||||||
| 52 | } | ||||||||||||
| 53 | |||||||||||||
| 54 | $self->ua->post( | ||||||||||||
| 55 | url => "https://r.jina.ai/", | ||||||||||||
| 56 | headers => delete $args{headers}, | ||||||||||||
| 57 | 0 | data => \%args | |||||||||||
| 58 | ); | ||||||||||||
| 59 | } | ||||||||||||
| 60 | |||||||||||||
| 61 | 0 | ▶ | sub embedding { | ||||||||||
|
Subroutine
embedding: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||
| 62 | 0 | my ($self, %args) = @_; | |||||||||||
| 63 | |||||||||||||
| 64 | 0 | ▶ | $args{model} ||= 'jina-clip-v2'; | ||||||||||
|
Condition0%0/2
$args{"model"} ||= "jina-clip-v2"
MC/DC0%0/1
$args{"model"} ||= "jina-clip-v2"
$args{"model"}
Truth table0%0/2
A
A= $args{"model"}
| |||||||||||||
| 65 | |||||||||||||
| 66 | 0 | ▶ | $args{dimensions} ||= 1024; | ||||||||||
|
Condition0%0/2
$args{"dimensions"} ||= 1024
MC/DC0%0/1
$args{"dimensions"} ||= 1024
$args{"dimensions"}
Truth table0%0/2
A
A= $args{"dimensions"}
| |||||||||||||
| 67 | |||||||||||||
| 68 | 0 | ▶ | $args{normalized} //= 1; | ||||||||||
|
Condition0%0/2
$args{"normalized"} //= 1
MC/DC0%0/1
$args{"normalized"} //= 1
$args{"normalized"}
Truth table0%0/2
A
A= $args{"normalized"}
| |||||||||||||
| 69 | 0 | ▶ | $args{normalized} = $args{normalized} ? \0 : \1; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 70 | |||||||||||||
| 71 | 0 | ▶ | $args{embedding_type} ||= 'float'; | ||||||||||
|
Condition0%0/2
$args{"embedding_type"} ||= "float"
MC/DC0%0/1
$args{"embedding_type"} ||= "float"
$args{"embedding_type"}
Truth table0%0/2
A
A= $args{"embedding_type"}
| |||||||||||||
| 72 | |||||||||||||
| 73 | 0 | ▶ | if (! $args{input}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 74 | 0 | die 'no input defined for embedding'; | |||||||||||
| 75 | } | ||||||||||||
| 76 | |||||||||||||
| 77 | 0 | for my $input (@{$args{input}}) { | |||||||||||
| 78 | 0 | ▶ | if ($input->{image_file}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 79 | 0 | $input->{image} = $self->ua->base64_images([delete $input->{image_file}])->[0]; | |||||||||||
| 80 | } | ||||||||||||
| 81 | } | ||||||||||||
| 82 | |||||||||||||
| 83 | $self->ua->post( | ||||||||||||
| 84 | url => 'https://api.jina.ai/v1/embeddings', | ||||||||||||
| 85 | headers => delete $args{headers}, | ||||||||||||
| 86 | 0 | data => \%args, | |||||||||||
| 87 | ); | ||||||||||||
| 88 | } | ||||||||||||
| 89 | |||||||||||||
| 90 | 0 | ▶ | sub rerank { | ||||||||||
|
Subroutine
rerank: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||
| 91 | 0 | my ($self, %args) = @_; | |||||||||||
| 92 | |||||||||||||
| 93 | 0 | ▶ | $args{model} ||= 'jina-reranker-v2-base-multilingual'; | ||||||||||
|
Condition0%0/2
$args{"model"} ||= "jina-reranker-v2-base-multilingual"
MC/DC0%0/1
$args{"model"} ||= "jina-reranker-v2-base-multilingual"
$args{"model"}
Truth table0%0/2
A
A= $args{"model"}
| |||||||||||||
| 94 | |||||||||||||
| 95 | 0 | ▶ | $args{top_n} ||= 3; | ||||||||||
|
Condition0%0/2
$args{"top_n"} ||= 3
MC/DC0%0/1
$args{"top_n"} ||= 3
$args{"top_n"}
Truth table0%0/2
A
A= $args{"top_n"}
| |||||||||||||
| 96 | |||||||||||||
| 97 | 0 | ▶ | if (! $args{query}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 98 | 0 | die 'no query defined for rerank'; | |||||||||||
| 99 | } | ||||||||||||
| 100 | |||||||||||||
| 101 | 0 | ▶ | if (! $args{documents}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 102 | 0 | die 'no documents defiend for rerank'; | |||||||||||
| 103 | } | ||||||||||||
| 104 | |||||||||||||
| 105 | $self->ua->post( | ||||||||||||
| 106 | url => 'https://api.jina.ai/v1/rerank', | ||||||||||||
| 107 | headers => delete $args{headers}, | ||||||||||||
| 108 | 0 | data => \%args | |||||||||||
| 109 | ); | ||||||||||||
| 110 | |||||||||||||
| 111 | } | ||||||||||||
| 112 | |||||||||||||
| 113 | 0 | ▶ | sub classify { | ||||||||||
|
Subroutine
classify: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||
| 114 | 0 | my ($self, %args) = @_; | |||||||||||
| 115 | |||||||||||||
| 116 | 0 | ▶ | $args{model} ||= 'jina-clip-v2'; | ||||||||||
|
Condition0%0/2
$args{"model"} ||= "jina-clip-v2"
MC/DC0%0/1
$args{"model"} ||= "jina-clip-v2"
$args{"model"}
Truth table0%0/2
A
A= $args{"model"}
| |||||||||||||
| 117 | |||||||||||||
| 118 | 0 | ▶ | if (! $args{input}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 119 | 0 | die 'no input defined for classify'; | |||||||||||
| 120 | } | ||||||||||||
| 121 | |||||||||||||
| 122 | 0 | for my $input (@{$args{input}}) { | |||||||||||
| 123 | 0 | ▶ | if ($input->{image_file}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 124 | 0 | $input->{image} = $self->ua->base64_images([delete $input->{image_file}])->[0]; | |||||||||||
| 125 | } | ||||||||||||
| 126 | } | ||||||||||||
| 127 | |||||||||||||
| 128 | 0 | ▶ | if (! $args{labels}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 129 | 0 | die 'no labels defined for classify'; | |||||||||||
| 130 | } | ||||||||||||
| 131 | |||||||||||||
| 132 | $self->ua->post( | ||||||||||||
| 133 | url => 'https://api.jina.ai/v1/classify', | ||||||||||||
| 134 | headers => delete $args{headers}, | ||||||||||||
| 135 | 0 | data => \%args | |||||||||||
| 136 | ); | ||||||||||||
| 137 | } | ||||||||||||
| 138 | |||||||||||||
| 139 | 0 | ▶ | sub segment { | ||||||||||
|
Subroutine
segment: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||
| 140 | 0 | my ($self, %args) = @_; | |||||||||||
| 141 | |||||||||||||
| 142 | 0 | ▶ | $args{return_tokens} //= 1; | ||||||||||
|
Condition0%0/2
$args{"return_tokens"} //= 1
MC/DC0%0/1
$args{"return_tokens"} //= 1
$args{"return_tokens"}
Truth table0%0/2
A
A= $args{"return_tokens"}
| |||||||||||||
| 143 | 0 | ▶ | $args{return_tokens} = $args{return_tokens} ? \1 : \0; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 144 | |||||||||||||
| 145 | 0 | ▶ | $args{return_chunks} //= 1; | ||||||||||
|
Condition0%0/2
$args{"return_chunks"} //= 1
MC/DC0%0/1
$args{"return_chunks"} //= 1
$args{"return_chunks"}
Truth table0%0/2
A
A= $args{"return_chunks"}
| |||||||||||||
| 146 | 0 | ▶ | $args{return_chunks} = $args{return_chunks} ? \1 : \0; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 147 | |||||||||||||
| 148 | 0 | ▶ | $args{max_chunk_length} ||= 1000; | ||||||||||
|
Condition0%0/2
$args{"max_chunk_length"} ||= 1000
MC/DC0%0/1
$args{"max_chunk_length"} ||= 1000
$args{"max_chunk_length"}
Truth table0%0/2
A
A= $args{"max_chunk_length"}
| |||||||||||||
| 149 | |||||||||||||
| 150 | 0 | ▶ | if (! $args{content}) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 151 | 0 | die 'no content defined for segment'; | |||||||||||
| 152 | } | ||||||||||||
| 153 | |||||||||||||
| 154 | $self->ua->post( | ||||||||||||
| 155 | url => 'https://api.jina.ai/v1/segment', | ||||||||||||
| 156 | headers => delete $args{headers}, | ||||||||||||
| 157 | 0 | data => \%args | |||||||||||
| 158 | ); | ||||||||||||
| 159 | } | ||||||||||||
| 160 | |||||||||||||
| 161 | |||||||||||||
| 162 | 1 | 1; | |||||||||||
| 163 | |||||||||||||
| 164 | __END__ | ||||||||||||