Image Agent with Memory
Code
1from kern.agent import Agent2from kern.media import Image3from kern.models.together import Together45agent = Agent(6 model=Together(id="meta-llama/Llama-Vision-Free"),7 markdown=True,8 add_history_to_context=True,9 num_history_runs=3,10)1112agent.print_response(13 "Tell me about this image",14 images=[15 Image(16 url="https://upload.wikimedia.org/wikipedia/commons/0/0c/GoldenGateBridge-001.jpg"17 )18 ],19 stream=True,20)2122agent.print_response("Tell me where I can get more images?")Usage
Set up your virtual environment
1uv venv --python 3.122source .venv/bin/activate1uv venv --python 3.122.venv\Scripts\activateSet your API key
1export TOGETHER_API_KEY=xxxInstall dependencies
1uv pip install -U openai kern-aiRun Agent
1python cookbook/11_models/together/image_agent_memory.py