File Coverage

blib/lib/OpenAI/API/Request/Edit.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::Edit;
2              
3 16     16   150 use strict;
  16         37  
  16         521  
4 16     16   110 use warnings;
  16         61  
  16         430  
5              
6 16     16   91 use Moo;
  16         40  
  16         98  
7 16     16   5835 use strictures 2;
  16         123  
  16         611  
8 16     16   2870 use namespace::clean;
  16         54  
  16         134  
9              
10             extends 'OpenAI::API::Request';
11              
12 16     16   4589 use Types::Standard qw(Bool Str Num Int Map);
  16         52  
  16         139  
13              
14             has model => ( is => 'rw', isa => Str, required => 1, );
15             has instruction => ( is => 'rw', isa => Str, required => 1, );
16              
17             has input => ( is => 'rw', isa => Str, );
18             has temperature => ( is => 'rw', isa => Num, );
19             has top_p => ( is => 'rw', isa => Num, );
20             has n => ( is => 'rw', isa => Int, );
21              
22 1     1 1 16 sub endpoint { 'edits' }
23 1     1 1 8 sub method { 'POST' }
24              
25             1;
26              
27             __END__
28              
29             =head1 NAME
30              
31             OpenAI::API::Request::Edit - Request class for OpenAI API content editing
32              
33             =head1 SYNOPSIS
34              
35             use OpenAI::API::Request::Edit;
36              
37             my $request = OpenAI::API::Request::Edit->new(
38             model => "text-davinci-edit-001",
39             instruction => 'Correct the grammar in the following text:',
40             input => 'the cat sat on teh mat.',
41             );
42              
43             my $res = $request->send(); # or: my $res = $request->send(%args)
44             my $text = $res->{choices}[0]{text}; # or: my $text = "$res";
45              
46             =head1 DESCRIPTION
47              
48             This module provides a request class for interacting with the OpenAI
49             API's content editing endpoint. It inherits from L<OpenAI::API::Request>.
50              
51             =head1 ATTRIBUTES
52              
53             =head2 model
54              
55             ID of the model to use. You can use the text-davinci-edit-001 or
56             code-davinci-edit-001 model with this endpoint.
57              
58             =head2 input [optional]
59              
60             The input text to use as a starting point for the edit.
61              
62             =head2 instruction
63              
64             The instruction that tells the model how to edit the prompt.
65              
66             =head2 n [optional]
67              
68             How many edits to generate for the input and instruction.
69              
70             =head2 temperature [optional]
71              
72             What sampling temperature to use, between 0 and 2.
73              
74             =head2 top_p [optional]
75              
76             An alternative to sampling with temperature.
77              
78             =head1 INHERITED METHODS
79              
80             This module inherits the following methods from L<OpenAI::API::Request>:
81              
82             =head2 send(%args)
83              
84             =head2 send_async(%args)
85              
86             =head1 SEE ALSO
87              
88             L<OpenAI::API::Request>, L<OpenAI::API::Config>