AI-Ollama-Client

 view release on metacpan or  search on metacpan

scripts/describe-image.pl  view on Meta::CPAN

use Mojo::JSON 'decode_json';
use experimental 'signatures';
use AI::Ollama::Client;
use Future::Utils 'repeat';

my $ol = AI::Ollama::Client->new(
    server => 'http://192.168.1.97:11434/api',
);

$ol->on('request' => sub( $ol, $tx ) {
    use Data::Dumper;
    warn Dumper $tx->req;
});

$ol->on('response' => sub( $ol, $tx, $err='' ) {
    if( $err ) {
        warn $err if $err;
    } else {
        #use Data::Dumper;
        warn $tx->code;
    }
});

my $tx = $ol->pullModel(
    name => 'llava:latest',
)->catch(sub {
    use Data::Dumper; warn Dumper \@_;
})->get;

my @images = @ARGV ? @ARGV : ('t/testdata/objectdetection.jpg');

for my $image (@images) {
    my $response = $ol->generateCompletion(
        model => 'llava:latest',
        prompt => 'You are tagging images. Please list all the objects in this image as tags. Also list the location where it was taken.',
        images => [
            { filename => $image },

scripts/music-genre-json.pl  view on Meta::CPAN

    my @genres;
    my ($json) = ($chat =~ /^(\[.*\])$/msg);
    if( $json ) {
        @genres = decode_json( $json )->@*;
    };

    if( ! @genres ) {
        say "Did not find genres in:";
        say $chat;
    };
    use Data::Dumper; warn Dumper \@genres;

    #if( $code =~ /\A(.*?)<EOT>/s ) {
    #    my $insert = $1;
    #    my ($pre,$suf) = ($prompt =~ /<PRE>(.*?)<SUF>(.*?)<MID>/s);
    #    print "$pre$insert$suf";
    #}
}

xt/99-test-prerequisites.t  view on Meta::CPAN

#!perl -w

use warnings;
use strict;
use Test::More;
use Data::Dumper;
use File::Find;

=head1 DESCRIPTION

This test checks whether all tests still pass when the optional test
prerequisites for the test are not present.

This is done by using L<Test::Without::Module> to rerun the test while excluding
the optional prerequisite.



( run in 0.280 second using v1.01-cache-2.11-cpan-a5abf4f5562 )