NAME
OpenAITests
DESCRIPTION
Using this modul is equivalent to:
use Data::Dumper;
use JSON;
use OpenAPI::Client::OpenAI;
use Test::Most;
use Test::RequiresInternet;
use utf8;
use experimental 'signatures';
run_test_cases
my @test_cases = (
{
method => 'createCompletion',
description => 'createCompletion with an instruct model',
params => {
model => 'gpt-3.5-turbo-instruct',
prompt => 'What is the capital of France?',
},
expected_response => qr{\bParis\b},
},
{
method => 'createCompletion',
description => 'createCompletion with an instruct model, using `stop`',
params => {
model => 'gpt-3.5-turbo-instruct',
prompt => 'What is the capital of France?',
stop => 'aris',
},
expected_response => qr{P$},
},
);
run_test_cases( \@test_cases );
Runs a set of test cases. The following keys are used for each test case:
method
The name of the OpenAI method to call.
description
What are we testing? This will be used as the name of the test. If omitted, we use the
methodargument instead, but it's recommended that you not omit this.params
The parameters which will be passed to the method.
expected_response
A regular expression that should match the response outout.
against
An optional subreference. It will be passed the OpenAI response as its only argument. Typically, we test the
expected_responseagainst$response->{choices}[0]{message}, but you may want to check something else in the response. For example, to testexpected_responseagainst the entire response:against => sub ($response) {$response},