Skip to main content

Overview

Ollama allows you to run large language models locally on your machine. Perfect for development, testing, and privacy-sensitive applications. Model Class: OpenAIChatModel (OpenAI-compatible API)

Authentication

export OLLAMA_BASE_URL="http://localhost:11434/v1/" # Required

Examples

from upsonic import Agent, Task
from upsonic.models.ollama import OllamaModel

model = OllamaModel(model_name="llama3.2")
agent = Agent(model=model)

task = Task("Hello, how are you?")
result = agent.do(task)
print(result)

Model Settings

You can set model parameters in two ways: on the model or on the Agent. On the model:
from upsonic import Agent, Task
from upsonic.models.ollama import OllamaModel, OllamaModelSettings

model = OllamaModel(
    model_name="llama3.2",
    settings=OllamaModelSettings(max_tokens=1024, temperature=0.7)
)
agent = Agent(model=model)
On the Agent:
from upsonic import Agent, Task
from upsonic.models.ollama import OllamaModelSettings

agent = Agent(
    model="ollama/llama3.2",
    settings=OllamaModelSettings(max_tokens=1024, temperature=0.7)
)

Parameters

ParameterTypeDescriptionDefaultSource
max_tokensintMaximum tokens to generateModel defaultBase
temperaturefloatSampling temperature0.8Base
top_pfloatNucleus sampling0.9Base
seedintRandom seedNoneBase
stop_sequenceslist[str]Stop sequencesNoneBase