AI-Ollama-Client

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

# Normalize version strings like 6.30_02 to 6.3002,
# so that we can do numerical comparisons on it.
my $eumm_version = $ExtUtils::MakeMaker::VERSION;
$eumm_version =~ s/_//;

my $module = 'AI::Ollama::Client';
(my $main_file = "lib/$module.pm" ) =~ s!::!/!g;
(my $distbase = $module) =~ s!::!-!g;
my $distlink = $distbase;

my @tests = map { glob $_ } 't/*.t', 't/*/*.t';

my %module = (
    NAME                => $module,
    AUTHOR              => q{Max Maischein <corion@cpan.org>},
    VERSION_FROM        => $main_file,
    ABSTRACT_FROM       => $main_file,
    META_MERGE => {
        "meta-spec" => { version => 2 },
        resources => {
            repository => {

Makefile.PL  view on Meta::CPAN

    if( @section ) {
        pop @section if $section[-1] =~ /^=/;
        shift @section if $remove_heading;

        pop @section
            while @section and $section[-1] =~ /^\s*$/;
        shift @section
            while @section and $section[0] =~ /^\s*$/;
    };

    @section = map { $_ =~ s!^=\w+\s+!!; $_ } @section;
    return join "", @section;
}

sub regen_EXAMPLES {
    my $perl = $^X;
    if ($perl =~/\s/) {
        $perl = qq{"$perl"};
    };
    (my $example_file = $main_file) =~ s!\.pm$!/Examples.pm!;
    my $examples = `$perl -w examples/gen_examples_pod.pl`;

lib/AI/Ollama/Client.pm  view on Meta::CPAN


=cut

around 'generateCompletion' => sub ( $super, $self, %options ) {
    # Encode images as base64, if images exist:
    # (but create a copy so we don't over write the input array)
    if (my $images = $options{images}) {

        # Allow { filename => '/etc/passwd' }
        $options{images} = [
            map {
                my $item = $_;
                if( ref($item) eq 'HASH' ) {
                    $item = Mojo::File->new($item->{filename})->slurp();
                };
                encode_base64($item)
            } @$images ];
    }
    return $super->($self, %options);
};

lib/AI/Ollama/RequestOptions.pm  view on Meta::CPAN

=head2 C<< use_mlock >>

Enable mlock. (Default: false)

=cut

has 'use_mlock' => (
    is       => 'ro',
);

=head2 C<< use_mmap >>

Enable mmap. (Default: false)

=cut

has 'use_mmap' => (
    is       => 'ro',
);

=head2 C<< vocab_only >>

Enable vocab only. (Default: false)

=cut

has 'vocab_only' => (

ollama/ollama-curated.json  view on Meta::CPAN

{"openapi":"3.0.3","components":{"schemas":{"PushModelResponse":{"properties":{"total":{"type":"integer","description":"total size of the model","example":"2142590208"},"status":{"$ref":"#/components/schemas/PushModelStatus"},"digest":{"example":"sha...

ollama/ollama-curated.yaml  view on Meta::CPAN

          description: |
            Enable f16 key/value. (Default: false)
        logits_all:
          type: boolean
          description: |
            Enable logits all. (Default: false)
        vocab_only:
          type: boolean
          description: |
            Enable vocab only. (Default: false)
        use_mmap:
          type: boolean
          description: |
            Enable mmap. (Default: false)
        use_mlock:
          type: boolean
          description: |
            Enable mlock. (Default: false)
        embedding_only:
          type: boolean
          description: |
            Enable embedding only. (Default: false)
        rope_frequency_base:
          type: number

t/generate.request  view on Meta::CPAN

    "numa": true,
    "num_ctx": 0,
    "num_batch": 0,
    "num_gqa": 0,
    "num_gpu": 0,
    "main_gpu": 0,
    "low_vram": true,
    "f16_kv": true,
    "logits_all": true,
    "vocab_only": true,
    "use_mmap": true,
    "use_mlock": true,
    "embedding_only": true,
    "rope_frequency_base": 0,
    "rope_frequency_scale": 0,
    "num_thread": 0
  },
  "format": "json",
  "raw": true,
  "stream": false,
  "keep_alive": 0

xt/99-synopsis.t  view on Meta::CPAN

sub wanted {
    push @files, $File::Find::name if /\.p(l|m|od)$/
        and $_ !~ /\bDSL\.pm$/; # we skip that one as it initializes immediately
}

sub synopsis_file_ok {
    my( $file ) = @_;
    my $name = "SYNOPSIS in $file compiles";
    open my $fh, '<', $file
        or die "Couldn't read '$file': $!";
    my @synopsis = map  { s!^\s\s!!; $_ } # outdent all code for here-docs
                   grep { /^\s\s/ } # extract all verbatim (=code) stuff
                   grep { /^=head1\s+SYNOPSIS$/.../^=/ } # extract Pod synopsis
                   <$fh>;
    if( @synopsis ) {
        my($tmpfh,$tempname) = tempfile();
        print {$tmpfh} join '', @synopsis;
        close $tmpfh; # flush it
        my $output = `$^X -Ilib -c $tempname 2>&1`;
        if( $output =~ /\ssyntax OK$/ ) {
            pass $name;

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

        exit 0;
    };
};

my @tests;
if( @ARGV ) {
    @tests = @ARGV;
} else {
    open my $manifest, '<', 'MANIFEST'
        or die "Couldn't read MANIFEST: $!";
    @tests = grep { -f $_ } grep { m!^(t/.*\.t|scripts/.*\.pl)$! } map { s!\s*$!!; $_ } <$manifest>
}
plan tests => 0+@tests;

my $meta = Parse::CPAN::Meta->load_file('META.json');

# Find what META.* declares
my $explicit_test_prereqs = CPAN::Meta::Prereqs->new( $meta->{prereqs} )->merged_requirements->as_string_hash;
my $minimum_perl = $meta->{prereqs}->{runtime}->{requires}->{perl} || 5.006;

sub distributed_packages {
    my @modules;
    for( @_ ) {
        dir($_)->recurse( callback => sub {
            my( $child ) = @_;
            if( !$child->is_dir and $child =~ /\.pm$/) {
                push @modules, ((scalar $child->slurp()) =~ m/^\s*package\s+(?:#.*?\n\s+)*(\w+(?:::\w+)*)\b/msg);
            }
        });
    };
    map { $_ => $_ } @modules;
}

# Find what we distribute:
my %distribution = distributed_packages('blib','t');

my $scanner = Perl::PrereqScanner::Lite->new;
for my $test_file (@tests) {
    my $implicit_test_prereqs = $scanner->scan_file($test_file)->as_string_hash;
    my %missing = %{ $implicit_test_prereqs };
    #warn Dumper \%missing;

xt/99-unix-text.t  view on Meta::CPAN


sub unix_file_ok {
  my ($filename) = @_;
  local $/;
  open my $fh, '<', $filename
    or die "Couldn't open '$filename' : $!\n";
  binmode $fh;
  my $content = <$fh>;

  my $i;
  my @lines = grep { /\x0D\x0A$/sm } map { sprintf "%s: %s\x0A", $i++, $_ } split /\x0A/, $content;
  unless (is(scalar @lines, 0,"'$filename' contains no windows newlines")) {
    diag $_ for @lines;
  };
  close $fh;
};

xt/copyright.t  view on Meta::CPAN


    my $modified_year;
    if( $modified_ts ) {
        $modified_year = strftime('%Y', localtime($modified_ts));
    } else {
        $modified_year = 1970;
    };

    open my $fh, '<', $file
        or die "Couldn't read $file: $!";
    my @copyright = map {
                        /\bcopyright\b.*?\d{4}-(\d{4})\b/i
                        ? [ $_ => $1 ]
                        : ()
                    }
                    <$fh>;
    my $copyright = 0;
    for (@copyright) {
        $copyright = $_->[1] > $copyright ? $_->[1] : $copyright;
    };

xt/copyright.t  view on Meta::CPAN

                          : $last_modified_year;
};

note "Distribution was last modified in $last_modified_year";

my @out_of_date = grep { $_->{copyright} and $_->{copyright} < $last_modified_year } @results;

if(! is 0+@out_of_date, 0, "All files have a current copyright year ($last_modified_year)") {
    for my $file (@out_of_date) {
        diag sprintf "%s modified %d, but copyright is %d", $file->{file}, $file->{modified}, $file->{copyright};
        diag $_ for map {@$_} @{ $file->{copyright_lines}};
    };
    diag q{To fix (in a rough way, please review) run};
    diag sprintf q{    perl -i -ple 's!(\bcopyright\b.*?\d{4}-)(\d{4})\b!${1}%s!i' %s},
        $this_year,
        join ' ',
        map { $_->{file} } @out_of_date;
};



( run in 0.336 second using v1.01-cache-2.11-cpan-49f99fa48dc )