import os
from getpass import getpass
from agno.agent import Agent
from agno.models.huggingface import HuggingFace
agent = Agent(
model=HuggingFace(
id="meta-llama/Meta-Llama-3-8B-Instruct",
max_tokens=4096,
),
description="你是一位论文写作助手。请根据用户提供的主题撰写一篇 300 字的论文。",
)
agent.print_response("topic: AI")
创建虚拟环境
打开 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/llama_essay_writer.py