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   112 use strict;
  16         32  
  16         513  
4 16     16   84 use warnings;
  16         36  
  16         387  
5              
6 16     16   110 use Moo;
  16         41  
  16         93  
7 16     16   5792 use strictures 2;
  16         140  
  16         594  
8 16     16   2742 use namespace::clean;
  16         36  
  16         134  
9              
10             extends 'OpenAI::API::Request';
11              
12 16     16   4376 use Types::Standard qw(Bool Str Num Int Map);
  16         34  
  16         103  
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 14 sub endpoint { 'embeddings' }
20 1     1 1 8 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 food was delicious and the waiter...",
37             );
38              
39             my $res = $request->send();
40              
41             =head1 DESCRIPTION
42              
43             Get a vector representation of a given input that can be easily consumed
44             by machine learning models and algorithms.
45              
46             =head1 METHODS
47              
48             =head2 new()
49              
50             =over 4
51              
52             =item * model
53              
54             =item * input
55              
56             =item * user [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<Embeddings|https://platform.openai.com/docs/api-reference/embeddings>