Code

cookbook/models/ollama/set_client.py
from agno.agent import Agent, RunResponse  # noqa
from agno.models.ollama import Ollama
from agno.tools.yfinance import YFinanceTools
from ollama import Client as OllamaClient

agent = Agent(
    model=Ollama(id="llama3.2", client=OllamaClient()),
    tools=[YFinanceTools(stock_price=True)],
    markdown=True,
)

# Print the response in the terminal
agent.print_response("Share a 2 sentence horror story")

Usage

1

Create a virtual environment

Open the Terminal and create a python virtual environment.

2

Install Ollama

Follow the installation guide and run:

ollama pull llama3.2
3

Install libraries

pip install -U ollama yfinance agno
4

Run Agent