rameters (optional):
=over
=item format
the format to return a response in. Format can be json or a JSON schema
=item options
additional model parameters listed in the documentation for the Model
g"
]
);
my $json = $ollama->completion(
prompt => "What color is the sky at different times of the day? Respond using JSON",
format => "json",
)->json_response;
my $json2 = $ollama->compl
etion(
prompt => "Ollama is 22 years old and is busy saving the world. Respond using JSON",
format => {
type => "object",
properties => {
age => {
"type" => "integer"
},
ava
package WebService::Ollama::Response;
use Moo;
use JSON::Lines qw/jsonl/;
has [qw/
done
context
total_duration
load_duration
model
create_at
eval_count
eval_duration
done_reason
response
otal
completed
version
embeddings
models
/] => (
is => 'ro',
);
sub json_response {
my ($self) = shift;
my $aoa = jsonl( decode => 1, data => $self->response ? $self->response : $self->message
=head2 embeddings
=head2 models
=head1 SUBROUNTINES/METHODS
=head2 json_response
JSON decode the response.
$response->json_response;
=head1 AUTHOR
LNATION, C<< <email at lnation.org> >>
=hea
package WebService::Ollama::UA;
use Moo;
use LWP::UserAgent;
use JSON::Lines;
use MIME::Base64 qw/encode_base64/;
use WebService::Ollama::Response;
has base_url => (
is => 'ro',
);
has ua => (
i
default => sub {
LWP::UserAgent->new();
}
);
has json => (
is => 'ro',
default => sub {
JSON::Lines->new( utf8 => 1 );
}
);
sub get {
shift->request(
type => 'GET',
@_
);
}
sub post
dd_handler(response_data => sub {
my($response, $ua, $handler, $data) = @_;
$data = $self->json->decode($data);
for (@{$data}) {
$stream_cb->(WebService::Ollama::Response->new(%{$_}));