Demo DeepSeek R1
Run the Ollama deepseek-r1:14b model to write and explain Python code for solving quadratic equations.
Code
from agno.agent import Agent, RunOutput # noqa
from agno.models.ollama import Ollama
agent = Agent(model=Ollama(host="http://localhost:11434", api_key=None, id="deepseek-r1:14b"), markdown=True)
# Print the response in the terminal
agent.print_response(
"Write me python code to solve quadratic equations. Explain your reasoning."
)
Usage
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateStart the local Ollama service
Install Ollama and start its desktop app or service on http://localhost:11434. If you start it manually with ollama serve, keep that process running in a separate terminal.
In the terminal where you will pull models and run Python, select that server and clear the direct-cloud key. The native Ollama client also reads this key independently of Agno.
export OLLAMA_HOST=http://localhost:11434
unset OLLAMA_API_KEYPull the model
ollama pull deepseek-r1:14bInstall dependencies
uv pip install -U ollama agnoRun Agent
Save the code above as demo_deepseek_r1.py, then run:
python demo_deepseek_r1.py