Here's the list from the discussion here:

Here's a CPAN Query for AI:: - I will go through that list at a later time and keep building this article.
https://metacpan.org/search?size=20&q=AI%3A%3A

  • Comment on Artificial Intelligence with Perl in 2023

Replies are listed 'Best First'.
Re: Artificial Intelligence with Perl in 2023
by Bod (Parson) on Mar 03, 2024 at 09:45 UTC

    Last evening I released AI::Chat which allows prompts to be sent to the OpenAI API. It makes integrating AI into Perl applications quite easy.

    AI::Image will follow soon which taps into DALL-E to generate AI images from within Perl.

      According to google, you need to fund your openai account to get an api key. Is that correct?

      Also possible small typo in your "description": "non-deterministic, that, is the same prompt" > "non-deterministic, that is, the same prompt"

      UPDATE: I was able to get an API key without paying. https://platform.openai.com/api-keys

        The API key is free but there is a charge everytime you use it. The cost is dependent on the model used and the number of tokens input and output.

        I have set the default model to the lowest price of the useful models as this is a good starting point. If you want more capable models such as ChatGPT-4, you will pay more.

        UPDATE - I'll add this to the documentation when I do an update

      When I run the script below as:
      gpt.pl "what is the meaning of life"
      $chat->prompt($prompt, $TEMP);
      is returning undefined.
      what is the meaning of life Use of uninitialized value $reply in concatenation (.) or string at /h +ome/****/com/gpt.pl line 25.
      #!/usr/bin/env perl my @BOOL = qw(false true); my $VERBOSE = 0; use warnings; use strict; use Getopt::Long; use AI::Chat; our $KEY = "my-key"; our $API = "OpenAI"; our $MODEL = "gpt-3.5-turbo-0125"; our $ROLE = undef; our $TEMP = 1.0; my ($prompt) = parseArgs(); my %h = (key => $KEY, api => $API, model => $MODEL); defined $ROLE and $h{role} = $ROLE; my $chat = AI::Chat->new(%h); my $reply = $chat->prompt($prompt, $TEMP); print "$prompt\n\n"; print "$reply\n"; sub parseArgs { my @args = qw(prompt); my $usage = qq{usage: $0 @args [options] prompt should be a quoted string. options ------- -key (default: $KEY) API key -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 c +opywriter famed for creating content that is immediately engaging with a lighth +earted, storytelling style". -temperature (default: $TEMP) The creativity level of the response (de +fault: 1.0). Temperature ranges from 0 to 2. The higher the temperature, the + more creative the bot will be in it's responses. -verbose (default: $BOOL[$VERBOSE]) }; my $result = GetOptions ( 'key=s' => \$KEY, 'role=s' => \$ROLE, 'temperature=f' => \$TEMP, 'verbose!' => \$VERBOSE, ); $result or print $usage and exit; @ARGV == @args or print $usage and exit; return @ARGV; }
        $chat->prompt($prompt, $TEMP);
        is returning undefined.

        Have you tried checking $chat->success?

        promt returns undef if no prompt parameter is supplied - or more precisely, if the prompt parameter is not a non-zero length string.

      The first version of AI::Image is now on CPAN

      Comments welcome as always...