Bundle Ollama local LLM client. Runs models (Llama, Mistral, Phi, etc.) locally via the Ollama server. Supports streaming completions, chat sessions, embeddings, and model management. Compile with -lib ollama.
Chat
Ollama chat client
Inherits: EndPoint
chat := Chat->New("llama3");
chat->Send("How many people like in San Pablo, CA?")->PrintLine();
chat->Send("How of the population identify as Latino??")->PrintLine();
chat->Send("Thanks, what are the major landmarks?")->PrintLine();
chat->Send("Goodbye?")->PrintLine();Operations
New # constructor
Constructor
New(model:String)Parameters
| Name | Type | Description |
|---|---|---|
| model | String | model name (i.e. llama3, llava) |
Send #
Chat response from the model given an input
method : public : Send(message:String) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| message | String | chat message |
Return
| Type | Description |
|---|---|
| String | chat response |
Example
chat := Chat->New("llama3");
chat->Send("What year did the Berlin Wall fall?")->PrintLine();
chat->Send("Who was the US president at the time?")->PrintLine();Send #
Chat response with options
method : public : Send(message:String, options:Options) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| message | String | chat message |
| options | Options | generation options |
Return
| Type | Description |
|---|---|
| String | chat response |
Example
opts := Options->New()->SetTemperature(0.5);
chat := Chat->New("llama3");
chat->Send("Write a haiku about mountains.", opts)->PrintLine();Send #
Chat response with format and options
method : public : Send(message:String, format:String, options:Options, tools:Vector<Tool>) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| message | String | chat message |
| format | String | output format ("json" or Nil) |
| options | Options | generation options |
| tools | Vector<Tool> | tool definitions for function calling |
Return
| Type | Description |
|---|---|
| String | chat response |
Example
opts := Options->New()->SetTemperature(0.0);
chat := Chat->New("llama3");
json_reply := chat->Send("List three colors as JSON.", "json", opts, Nil);
json_reply->PrintLine();Send #
Chat response from the model given an input
method : public : Send(message:String, image:File) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| message | String | chat message |
| image | File | image file |
Return
| Type | Description |
|---|---|
| String | chat response |
Example
chat := Chat->New("llava");
image := System.IO.Filesystem.File->New("diagram.png");
chat->Send("What does this diagram show?", image)->PrintLine();