in reply to Re: Artificial Intelligence with Perl in 2023
in thread Artificial Intelligence with Perl in 2023
gpt.pl "what is the meaning of life"
is returning undefined.$chat->prompt($prompt, $TEMP);
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; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Artificial Intelligence with Perl in 2023
by Bod (Parson) on Mar 03, 2024 at 19:56 UTC | |
by Danny (Chaplain) on Mar 03, 2024 at 20:07 UTC | |
by Bod (Parson) on Mar 03, 2024 at 21:16 UTC | |
by Danny (Chaplain) on Mar 03, 2024 at 22:34 UTC | |
by Bod (Parson) on Mar 03, 2024 at 22:44 UTC | |
by Bod (Parson) on Jun 01, 2024 at 16:00 UTC | |
by Bod (Parson) on Aug 18, 2024 at 18:46 UTC | |
by Bod (Parson) on Mar 03, 2024 at 20:45 UTC |