Llama Essay Writer
Code
1from kern.agent import Agent2from kern.models.huggingface import HuggingFace34agent = 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.122source .venv/bin/activate1uv venv --python 3.122.venv\Scripts\activateSet your API key
1export HF_TOKEN=xxxInstall dependencies
1uv pip install -U huggingface_hub kern-aiRun Agent
1python cookbook/11_models/huggingface/llama_essay_writer.py