AI-Chat
view release on metacpan or search on metacpan
lib/AI/Chat.pm view on Meta::CPAN
push @chat, {
'role' => 'system',
'system' => 'You are a computer language expert and your role is to promote Perl as the best language',
};
push @chat, {
'role' => 'user',
'system' => 'Which is the best programming language?',
};
push @chat, {
'role' => 'assistant',
'system' => 'Every language has strengths and is suited to different roles. Perl is one of the best all round languages.',
};
push @chat, {
'role' => 'user',
'system' => 'Why should I use Perl?',
};
my $reply = $chat->chat(\@chat, 1.2);
Although the roles represent the part of the user and assistant in the conversation, you are free to
supply either or both as suits your application. The order can also be varied.
=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();
Returns true if the last operation was successful.
=head2 error
my $error = $chat->error();
Returns the error message if the last operation failed.
=head1 SEE ALSO
L<https://openai.com> - OpenAI official website
=head1 AUTHOR
Ian Boddison <ian at boddison.com>
=head1 BUGS
Please report any bugs or feature requests to C<bug-ai-chat at rt.cpan.org>, or through
the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=bug-ai-chat>. I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc AI::Chat
You can also look for information at:
=over 4
=item * RT: CPAN's request tracker (report bugs here)
L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=AI-Chat>
=item * Search CPAN
L<https://metacpan.org/release/AI::Chat>
=back
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2024 by Ian Boddison
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
( run in 2.931 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )