Agent with Async Tool Usage

Code

1"""Run `uv pip install kern-ai llama-api-client` to install dependencies."""
2
3import asyncio
4
5from kern.agent import Agent
6from kern.models.meta import Llama
7from kern.tools.hackernews import HackerNewsTools
8
9agent = Agent(
10 model=Llama(id="Llama-4-Maverick-17B-128E-Instruct-FP8"),
11 tools=[HackerNewsTools()],
12 debug_mode=True,
13)
14asyncio.run(agent.aprint_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/async_tool_use.py