Llama Essay Writer

Code

1from kern.agent import Agent
2from kern.models.huggingface import HuggingFace
3
4agent = Agent(
5 model=HuggingFace(
6 id="meta-llama/Meta-Llama-3-8B-Instruct",
7 max_tokens=4096,
8 ),
9 description="You are an essay writer. Write a 300 words essay on topic that will be provided by user",
10)
11agent.print_response("topic: AI")

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/llama_essay_writer.py