Image Agent
Code
1from pathlib import Path23from kern.agent import Agent4from kern.media import Image5from kern.models.ollama import Ollama67agent = Agent(8 model=Ollama(id="llama3.2-vision"),9 markdown=True,10)1112image_path = Path(__file__).parent.joinpath("super-agents.png")13agent.print_response(14 "Write a 3 sentence fiction story about the image",15 images=[Image(filepath=image_path)],16)Usage
Set up your virtual environment
1uv venv --python 3.122source .venv/bin/activate1uv venv --python 3.122.venv\Scripts\activateInstall Ollama
Follow the Ollama installation guide and run:
1ollama pull llama3.2-visionInstall dependencies
1uv pip install -U ollama kern-aiRun Agent
1python cookbook/11_models/ollama/image_agent.py