from agno.agent import Agent
from agno.models.huggingface import HuggingFace
agent = Agent(
model=HuggingFace(
id="mistralai/Mistral-7B-Instruct-v0.2", max_tokens=4096, temperature=0
),
)
agent.print_response(
"What is meaning of life and then recommend 5 best books to read about it",
stream=True,
)
创建虚拟环境
打开 Terminal
并创建一个 python 虚拟环境。
python3 -m venv .venv
source .venv/bin/activate
设置您的 API 密钥
export HF_TOKEN=xxx
安装函式库
pip install -U huggingface_hub agno
运行 Agent
python cookbook/models/huggingface/basic_stream.py