SYNOPSIS

PROPERTIES

openapi

ua

server

METHODS

checkBlob

my $res = $client->checkBlob()->get;

Check to see if a blob exists on the Ollama server which is useful when creating models.

Parameters

digest

the SHA256 digest of the blob

createBlob

my $res = $client->createBlob()->get;

Create a blob from a file. Returns the server file path.

Parameters

digest

the SHA256 digest of the blob

generateChatCompletion

use Future::Utils 'repeat';
my $responses = $client->generateChatCompletion();
repeat {
    my ($res) = $responses->shift;
    if( $res ) {
        my $str = $res->get;
        say $str;
    }

    Future::Mojo->done( defined $res );
} until => sub($done) { $done->get };

Generate the next message in a chat with a provided model.

Options

format

The format to return a response in. Currently the only accepted value is json.

Enable JSON mode by setting the format parameter to json. This will structure the response as valid JSON.

Note: it's important to instruct the model to use JSON in the prompt. Otherwise, the model may generate large amounts whitespace.

keep_alive

How long (in minutes) to keep the model loaded in memory.

-

If set to a positive duration (e.g. 20), the model will stay loaded for the provided duration.

-

If set to a negative duration (e.g. -1), the model will stay loaded indefinitely.

-

If set to 0, the model will be unloaded immediately once finished.

-

If not set, the model will stay loaded for 5 minutes by default

messages

The messages of the chat, this can be used to keep a chat memory

model

The model name.

Model names follow a model:tag format. Some examples are orca-mini:3b-q4_1 and llama2:70b. The tag is optional and, if not provided, will default to latest. The tag is used to identify a specific version.

options

Additional model parameters listed in the documentation for the Modelfile such as temperature.

stream

If false the response will be returned as a single response object, otherwise the response will be streamed as a series of objects.

Returns a AI::Ollama::GenerateChatCompletionResponse.

copyModel

my $res = $client->copyModel()->get;

Creates a model with another name from an existing model.

Options

destination

Name of the new model.

source

Name of the model to copy.

createModel

use Future::Utils 'repeat';
my $responses = $client->createModel();
repeat {
    my ($res) = $responses->shift;
    if( $res ) {
        my $str = $res->get;
        say $str;
    }

    Future::Mojo->done( defined $res );
} until => sub($done) { $done->get };

Create a model from a Modelfile.

Options

modelfile

The contents of the Modelfile.

name

The model name.

Model names follow a model:tag format. Some examples are orca-mini:3b-q4_1 and llama2:70b. The tag is optional and, if not provided, will default to latest. The tag is used to identify a specific version.

stream

If false the response will be returned as a single response object, otherwise the response will be streamed as a series of objects.

Returns a AI::Ollama::CreateModelResponse.

deleteModel

my $res = $client->deleteModel()->get;

Delete a model and its data.

Options

name

The model name.

Model names follow a model:tag format. Some examples are orca-mini:3b-q4_1 and llama2:70b. The tag is optional and, if not provided, will default to latest. The tag is used to identify a specific version.

generateEmbedding

my $res = $client->generateEmbedding()->get;

Generate embeddings from a model.

Options

model

The model name.

Model names follow a model:tag format. Some examples are orca-mini:3b-q4_1 and llama2:70b. The tag is optional and, if not provided, will default to latest. The tag is used to identify a specific version.

options

Additional model parameters listed in the documentation for the Modelfile such as temperature.

prompt

Text to generate embeddings for.

Returns a AI::Ollama::GenerateEmbeddingResponse.

generateCompletion

use Future::Utils 'repeat';
my $responses = $client->generateCompletion();
repeat {
    my ($res) = $responses->shift;
    if( $res ) {
        my $str = $res->get;
        say $str;
    }

    Future::Mojo->done( defined $res );
} until => sub($done) { $done->get };

Generate a response for a given prompt with a provided model.

Options

context

The context parameter returned from a previous request to [generateCompletion], this can be used to keep a short conversational memory.

format

The format to return a response in. Currently the only accepted value is json.

Enable JSON mode by setting the format parameter to json. This will structure the response as valid JSON.

Note: it's important to instruct the model to use JSON in the prompt. Otherwise, the model may generate large amounts whitespace.

images

(optional) a list of Base64-encoded images to include in the message (for multimodal models such as llava)

keep_alive

How long (in minutes) to keep the model loaded in memory.

-

If set to a positive duration (e.g. 20), the model will stay loaded for the provided duration.

-

If set to a negative duration (e.g. -1), the model will stay loaded indefinitely.

-

If set to 0, the model will be unloaded immediately once finished.

-

If not set, the model will stay loaded for 5 minutes by default

model

The model name.

Model names follow a model:tag format. Some examples are orca-mini:3b-q4_1 and llama2:70b. The tag is optional and, if not provided, will default to latest. The tag is used to identify a specific version.

options

Additional model parameters listed in the documentation for the Modelfile such as temperature.

prompt

The prompt to generate a response.

raw

If true no formatting will be applied to the prompt and no context will be returned.

You may choose to use the raw parameter if you are specifying a full templated prompt in your request to the API, and are managing history yourself.

stream

If false the response will be returned as a single response object, otherwise the response will be streamed as a series of objects.

system

The system prompt to (overrides what is defined in the Modelfile).

template

The full prompt or prompt template (overrides what is defined in the Modelfile).

Returns a AI::Ollama::GenerateCompletionResponse.

pullModel

my $res = $client->pullModel()->get;

Download a model from the ollama library.

Options

insecure

Allow insecure connections to the library.

Only use this if you are pulling from your own library during development.

name

The model name.

Model names follow a model:tag format. Some examples are orca-mini:3b-q4_1 and llama2:70b. The tag is optional and, if not provided, will default to latest. The tag is used to identify a specific version.

stream

If false the response will be returned as a single response object, otherwise the response will be streamed as a series of objects.

Returns a AI::Ollama::PullModelResponse.

pushModel

my $res = $client->pushModel()->get;

Upload a model to a model library.

Options

insecure

Allow insecure connections to the library.

Only use this if you are pushing to your library during development.

name

The name of the model to push in the form of /:.

stream

If false the response will be returned as a single response object, otherwise the response will be streamed as a series of objects.

Returns a AI::Ollama::PushModelResponse.

showModelInfo

my $res = $client->showModelInfo()->get;

Show details about a model including modelfile, template, parameters, license, and system prompt.

Options

name

The model name.

Model names follow a model:tag format. Some examples are orca-mini:3b-q4_1 and llama2:70b. The tag is optional and, if not provided, will default to latest. The tag is used to identify a specific version.

Returns a AI::Ollama::ModelInfo.

listModels

my $res = $client->listModels()->get;

List models that are available locally.

Returns a AI::Ollama::ModelsResponse.