Async Basic.Py
Code
1import asyncio23from kern.agent import Agent4from kern.models.huggingface import HuggingFace56agent = Agent(7 model=HuggingFace(8 id="mistralai/Mistral-7B-Instruct-v0.2", max_tokens=4096, temperature=09 ),10)11asyncio.run(12 agent.aprint_response(13 "What is meaning of life and then recommend 5 best books to read about it"14 )15)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/async_basic.py