Basic Agent

Code

1from kern.agent import Agent
2from kern.models.huggingface import HuggingFace
3
4agent = Agent(
5 model=HuggingFace(
6 id="mistralai/Mistral-7B-Instruct-v0.2", max_tokens=4096, temperature=0
7 ),
8)
9agent.print_response(
10 "What is meaning of life and then recommend 5 best books to read about it"
11)

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 HF_TOKEN=xxx

Install dependencies

1uv pip install -U huggingface_hub kern-ai

Run Agent

1python cookbook/11_models/huggingface/basic.py