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.
Model
Ollama model operation
Inherits: EndPoint
Example
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
Copy # function
Copy a model
function : Copy(src:String, dest:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| src | String | source name of the model to copy |
| dest | String | destination name of the model to copy |
Return
| Type | Description |
|---|---|
| Bool | true if successful, false otherwise |
Example
if(Model->Copy("llama3", "llama3-backup")) {
"Model copied."->PrintLine();
};Create # function
Create a model from a Modelfile description
function : Create(name:String, modelfile:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| name | String | name of the model to create |
| modelfile | String | contents of the Modelfile |
Return
| Type | Description |
|---|---|
| Bool | true if successful, false otherwise |
Example
modelfile := "FROM llama3\nSYSTEM \"You are a helpful assistant.\"";
if(Model->Create("my-assistant", modelfile)) {
"Custom model created."->PrintLine();
};Delete # function
Delete a model and its data.
function : Delete(name:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| name | String | name of the model to delete |
Return
| Type | Description |
|---|---|
| Bool | true if successful, false otherwise |
Example
if(Model->Delete("llama3")) {
"Model deleted."->PrintLine();
};Embeddings # function
Generate embeddings from a model
function : Embeddings(model:String, prompt:String) ~ Float[]Parameters
| Name | Type | Description |
|---|---|---|
| model | String | name of model to generate embeddings from |
| prompt | String | text to generate embeddings for |
Return
| Type | Description |
|---|---|
| Float | embedding vector as Float array |
Example
embeddings := Model->Embeddings("nomic-embed-text", "The sky is blue.");
if(embeddings <> Nil) {
"Dimensions: {$embeddings->Size()}"->PrintLine();
};GetDetails #
Get the model details
method : public : GetDetails() ~ ModelDetailsReturn
| Type | Description |
|---|---|
| ModelDetails | model details |
GetPulled #
Get the model pulled
method : public : GetPulled() ~ ModelPulledReturn
| Type | Description |
|---|---|
| ModelPulled | model pulled |
List # function
List the models available
function : List() ~ Vector<Model>Return
| Type | Description |
|---|---|
| Vector<Model> | list of models available |
Example
models := Model->List();
if(models <> Nil) {
each(m in models) {
m->GetPulled()->GetName()->PrintLine();
};
};Pull # function
Download a model from the ollama library
function : Pull(name:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| name | String | name of the model to pull |
Return
| Type | Description |
|---|---|
| Bool | true if successful, false otherwise |
Example
if(Model->Pull("llama3")) {
"Model downloaded successfully."->PrintLine();
};Show # function
Show information about a model
function : Show(name:String) ~ ModelParameters
| Name | Type | Description |
|---|---|---|
| name | String | name of the model to show |
Return
| Type | Description |
|---|---|
| Model | model |
Example
info := Model->Show("llama3");
if(info <> Nil) {
info->GetPulled()->GetName()->PrintLine();
info->GetDetails()->ToString()->PrintLine();
};