AI-Anthropic
view release on metacpan or search on metacpan
lib/AI/Anthropic.pm view on Meta::CPAN
model => $args{model} // DEFAULT_MODEL,
max_tokens => $args{max_tokens} // 4096,
timeout => $args{timeout} // 120,
api_base => $args{api_base} // API_BASE,
_http => HTTP::Tiny->new(
timeout => $args{timeout} // 120,
),
_json => JSON::PP->new->utf8->allow_nonref,
};
return bless $self, $class;
}
=head2 message
Simple interface for single message:
my $response = $claude->message("Your question here");
my $response = $claude->message("Your question", system => "You are helpful");
print $response->text;
lib/AI/Anthropic.pm view on Meta::CPAN
# ============================================
package AI::Anthropic::Response;
use strict;
use warnings;
use overload '""' => \&text, fallback => 1;
sub new {
my ($class, %args) = @_;
return bless \%args, $class;
}
sub text { shift->{text} }
sub role { shift->{role} }
sub model { shift->{model} }
sub stop_reason { shift->{stop_reason} }
sub usage { shift->{usage} }
sub raw_response { shift->{raw_response} }
sub input_tokens { shift->{usage}{input_tokens} // 0 }
( run in 1.398 second using v1.01-cache-2.11-cpan-39bf76dae61 )