Agent with Tools

Code

1"""Run `uv pip install kern-ai llama-api-client` to install dependencies."""
2
3from kern.agent import Agent
4from kern.models.meta import Llama
5from kern.tools.hackernews import HackerNewsTools
6
7agent = Agent(
8 model=Llama(id="Llama-4-Maverick-17B-128E-Instruct-FP8"),
9 tools=[HackerNewsTools()],
10)
11agent.print_response("Whats happening in UK and in USA?")

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 LLAMA API key

1export LLAMA_API_KEY=YOUR_API_KEY

Install dependencies

1uv pip install llama-api-client kern-ai

Run Agent

1python cookbook/11_models/meta/llama/tool_use.py