File Coverage

blib/lib/OpenAI/API/Request/Embedding.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 2 2 100.0
total 30 30 100.0


line stmt bran cond sub pod time code
1             package OpenAI::API::Request::Embedding;
2              
3 16     16   123 use strict;
  16         38  
  16         540  
4 16     16   98 use warnings;
  16         32  
  16         409  
5              
6 16     16   99 use Moo;
  16         58  
  16         100  
7 16     16   6173 use strictures 2;
  16         157  
  16         754  
8 16     16   3133 use namespace::clean;
  16         65  
  16         147  
9              
10             extends 'OpenAI::API::Request';
11              
12 16     16   4794 use Types::Standard qw(Bool Str Num Int Map);
  16         37  
  16         182  
13              
14             has model => ( is => 'rw', isa => Str, required => 1, );
15             has input => ( is => 'rw', isa => Str, required => 1, );
16              
17             has user => ( is => 'rw', isa => Str, );
18              
19 1     1 1 18 sub endpoint { 'embeddings' }
20 1     1 1 10 sub method { 'POST' }
21              
22             1;
23              
24             __END__
25              
26             =head1 NAME
27              
28             OpenAI::API::Request::Embedding - embeddings endpoint
29              
30             =head1 SYNOPSIS
31              
32             use OpenAI::API::Request::Embedding;
33              
34             my $request = OpenAI::API::Request::Embedding->new(
35             model => "text-embedding-ada-002",
36             input => 'The quick brown fox jumps over the lazy dog.',
37             );
38              
39             my $res = $request->send(); # or: my $res = $request->send(%args);
40              
41             =head1 DESCRIPTION
42              
43             This module provides a request class for interacting with the OpenAI
44             API's embedding endpoint. It inherits from L<OpenAI::API::Request>.
45              
46             Get a vector representation of a given input that can be easily consumed
47             by machine learning models and algorithms.
48              
49             =head1 ATTRIBUTES
50              
51             =head2 model
52              
53             The model to use for generating embeddings.
54              
55             =head2 input
56              
57             The input content for which to generate embeddings.
58              
59             =head2 user [optional]
60              
61             The user identifier for the request.
62              
63             =head1 INHERITED METHODS
64              
65             This module inherits the following methods from L<OpenAI::API::Request>:
66              
67             =head2 send
68              
69             =head2 send_async
70              
71             =head1 SEE ALSO
72              
73             L<OpenAI::API::Request>, L<OpenAI::API::Config>