v2026.11.2
All Bundles
Bundle

Ollama local LLM client. Runs models (Llama, Mistral, Phi, Qwen, etc.) locally via the Ollama server. Supports text generation, chat sessions with tool calling, structured (JSON schema) output, thinking models, images, batch embeddings and model management. Every request completes before returning -- responses are not streamed, so a long generation produces nothing until it finishes. Compile with -lib ollama.

Reply

A complete reply from /api/generate or /api/chat: the text, any thinking and tool calls, and the timing and token counts. Durations are in nanoseconds.

Example

reply := Completion->GenerateReply("llama3", "Why is the sky blue?", Nil);
if(reply <> Nil) {
  reply->GetText()->PrintLine();
  "tokens: {$reply->GetEvalCount()}, done: {$reply->GetDoneReason()}"->PrintLine();
};

Operations

GetDoneReason #

Get why generation stopped (e.g. "stop", "length", "load")

method : public : GetDoneReason() ~ String

Return

TypeDescription
Stringdone reason, or Nil

GetEvalCount #

Get the number of tokens generated

method : public : GetEvalCount() ~ Int

Return

TypeDescription
Inttoken count

GetEvalDuration #

Get the time spent generating

method : public : GetEvalDuration() ~ Int

Return

TypeDescription
Intnanoseconds

GetLoadDuration #

Get the time spent loading the model

method : public : GetLoadDuration() ~ Int

Return

TypeDescription
Intnanoseconds

GetModel #

Get the model that replied

method : public : GetModel() ~ String

Return

TypeDescription
Stringmodel name

GetPromptEvalCount #

Get the number of prompt tokens evaluated

method : public : GetPromptEvalCount() ~ Int

Return

TypeDescription
Inttoken count

GetPromptEvalDuration #

Get the time spent evaluating the prompt

method : public : GetPromptEvalDuration() ~ Int

Return

TypeDescription
Intnanoseconds

GetRole #

Get the role of the reply message

method : public : GetRole() ~ String

Return

TypeDescription
Stringrole (normally "assistant")

GetText #

Get the generated text (empty when the model only called tools)

method : public : GetText() ~ String

Return

TypeDescription
Stringtext

GetThinking #

Get the model's reasoning, for thinking models with think enabled

method : public : GetThinking() ~ String

Return

TypeDescription
Stringthinking text, or Nil

GetTokensPerSecond #

Get the generation speed

method : public : GetTokensPerSecond() ~ Float

Return

TypeDescription
Floattokens per second, or 0.0 if no timing was reported

GetToolCalls #

Get the tool calls the model made (chat with tools only)

method : public : GetToolCalls() ~ Vector<ToolCall>

Return

TypeDescription
Vector<ToolCall>tool calls, empty if none

GetTotalDuration #

Get the total request time

method : public : GetTotalDuration() ~ Int

Return

TypeDescription
Intnanoseconds

HasToolCalls #

Checks for tool calls

method : public : HasToolCalls() ~ Bool

Return

TypeDescription
Booltrue if the model called one or more tools

IsDone #

Checks whether generation finished

method : public : IsDone() ~ Bool

Return

TypeDescription
Booltrue if done

Parse # function

Parses a /api/generate or /api/chat response body.

function : Parse(body:String) ~ Reply

Parameters

NameTypeDescription
bodyStringresponse text

Return

TypeDescription
Replyreply, or Nil with the last error set (EndPoint->GetLastError) for an error body or one that is not a reply