Ollama

Step 1: Install and Start Ollama

Go to Ollama and follow the installation instructions for your platform.

For Linux & WSL2:

# Install Ollama
curl https://ollama.ai/install.sh | sh

# Start the Ollama server
ollama serve

For Windows/Mac: Download and install from the Ollama website.

Step 2: Pull and Test a Model

Open a new terminal and pull a model:

# Pull a model (e.g., llama2)
ollama pull llama2

# Test the model
ollama run llama2

By default, Ollama starts a server at http://localhost:11434, which will be used as the API base in your configuration.

Step 3: Configure Agent Settings

Configure the HOST_AGENT and APP_AGENT in the config/ufo/agents.yaml file to use Ollama.

If the file doesn't exist, copy it from the template:

Copy-Item config\ufo\agents.yaml.template config\ufo\agents.yaml

Edit config/ufo/agents.yaml with your Ollama configuration:

HOST_AGENT:
  VISUAL_MODE: True  # Enable if model supports vision (e.g., llava)
  API_TYPE: "ollama"  # Use Ollama API
  API_BASE: "http://localhost:11434"  # Ollama server endpoint
  API_KEY: "ollama"  # Placeholder (not used but required)
  API_MODEL: "llama2"  # Model name (must match pulled model)

APP_AGENT:
  VISUAL_MODE: True
  API_TYPE: "ollama"
  API_BASE: "http://localhost:11434"
  API_KEY: "ollama"
  API_MODEL: "llama2"

Configuration Fields:

  • VISUAL_MODE: Set to True only for vision-capable models like llava
  • API_TYPE: Use "ollama" for Ollama API (case-sensitive in code: lowercase)
  • API_BASE: Ollama server URL (default: http://localhost:11434)
  • API_KEY: Placeholder value (not used but required in config)
  • API_MODEL: Model name matching your pulled model

Important: Increase Context Length

UFO requires at least 20,000 tokens to function properly. Ollama's default context length is 2048 tokens, which is insufficient. You must create a custom model with increased context:

  1. Create a Modelfile:
FROM llama2
PARAMETER num_ctx 32768
  1. Build the custom model:
ollama create llama2-max-ctx -f Modelfile
  1. Use the custom model in your config:
API_MODEL: "llama2-max-ctx"

For more details, see Ollama's Modelfile documentation.

For detailed configuration options, see:

Step 4: Start Using UFO

After configuration, you can start using UFO with Ollama. Refer to the Quick Start Guide for detailed instructions on running your first tasks.