Documentation Index
Fetch the complete documentation index at: https://docs.phidata.com/llms.txt
Use this file to discover all available pages before exploring further.
Example
from phi.agent import Agent, RunResponse
from phi.model.huggingface import HuggingFaceChat
agent = Agent(
model=HuggingFaceChat(
id="meta-llama/Meta-Llama-3-8B-Instruct",
max_tokens=4096,
),
markdown=True
)
# Get the response in a variable
# run: RunResponse = agent.run("Share a 2 sentence horror story.")
# print(run.content)
# Print the response on the terminal
agent.print_response("Share a 2 sentence horror story.")
Usage
Get your API key from HuggingFace here.
Create a virtual environment
Open the Terminal and create a python virtual environment.python3 -m venv ~/.venvs/aienv
source ~/.venvs/aienv/bin/activate
Install libraries
pip install -U huggingface_hub phidata
Export Environment Variables
Run HuggingFace Agent
python cookbook/providers/huggingface/basic.py