Image Compare Agent

Code

1from kern.agent import Agent
2from kern.media import Image
3from kern.models.mistral.mistral import MistralChat
4
5agent = Agent(
6 model=MistralChat(id="pixtral-12b-2409"),
7 markdown=True,
8)
9
10agent.print_response(
11 "what are the differences between two images?",
12 images=[
13 Image(
14 url="https://tripfixers.com/wp-content/uploads/2019/11/eiffel-tower-with-snow.jpeg"
15 ),
16 Image(
17 url="https://assets.visitorscoverage.com/production/wp-content/uploads/2024/04/AdobeStock_626542468-min-1024x683.jpeg"
18 ),
19 ],
20 stream=True,
21)

Usage

Set up your virtual environment

1uv venv --python 3.12
2source .venv/bin/activate
1uv venv --python 3.12
2.venv\Scripts\activate

Set your API key

1export MISTRAL_API_KEY=xxx

Install dependencies

1uv pip install -U mistralai kern-ai

Run Agent

1python cookbook/11_models/mistral/image_compare_agent.py