AI-Chat
view release on metacpan or search on metacpan
Revision history for AI-Chat
0.6 18th August 2024
Changed default model from 'gpt-3.5-turbo-0125' to 'gpt-40-mini'
This model is cheaper, more capable and faster.
0.5 1st June 2024
Added 'chat' method to support back and forth conversations
Changed 'prompt' method to use the new 'chat' method
0.1 2nd March 2024
First version, released on an unsuspecting world.
lib/AI/Chat.pm view on Meta::CPAN
at optional I<temperature> parameter.
=head1 API KEYS
A free OpenAI API can be obtained from L<https://platform.openai.com/account/api-keys>
=head1 MODELS
Although the API Key is free, each use incurs a cost. This is dependent on the
number of tokens in the prompt and the reply. Different models have different costs.
The default model C<gpt-4o-mini> is the lowest cost of the useful models and
is a good place to start using this module. Previous versions of this module
defaulted to C<gpt-3.5-turbo-0125> but the current default is cheaper and
quicker. For most purposes, the default model should be used.
See also L<https://platform.openai.com/docs/models/overview>
=head1 METHODS
=head2 new
my $chat = AI::Chat->new(%params);
Creates a new AI::Chat object.
lib/AI/Chat.pm view on Meta::CPAN
=item key
C<required> Your API key for the chosen service.
=item api
The API to use (currently only 'OpenAI' is supported).
=item model
The language model to use (default: 'gpt-4o-mini').
See L<https://platform.openai.com/docs/models/overview>
=item role
The role to use for the bot in conversations.
This tells the bot what it's purpose when answering prompts.
For example: "You are a world class copywriter famed for
lib/AI/Chat.pm view on Meta::CPAN
=over 4
=item prompt
C<required> The prompt to send to the AI.
This is a shorthand for C<chat> when only a single response is needed.
=item temperature
The creativity level of the response (default: 1.0).
Temperature ranges from 0 to 2. The higher the temperature,
the more creative the bot will be in it's responses.
=back
=head2 chat
my $reply = $chat->prompt(\@chat, $temperature);
lib/AI/Chat.pm view on Meta::CPAN
=head3 Parameters
=over 4
=item chat
C<required> An arrayref of messages to send to the AI.
=item temperature
The creativity level of the response (default: 1.0).
Temperature ranges from 0 to 2. The higher the temperature,
the more creative the bot will be in it's responses.
=back
=head2 success
my $success = $chat->success();
( run in 0.396 second using v1.01-cache-2.11-cpan-0a6323c29d9 )