PhiData (phidata) Library

2.7.10 · active · verified Fri Apr 17

PhiData (phidata) is a Python library designed for building multi-modal AI Agents with capabilities like memory, knowledge retrieval (RAG), and tool integration. It simplifies the development of complex AI workflows by providing high-level abstractions for agents, assistants, and various components. The current stable version is 2.7.10, and it maintains an active release cadence with frequent updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize an OpenAI LLM and create a simple Assistant to handle chat interactions. It highlights the basic setup for agents in phidata. Remember to set your `OPENAI_API_KEY` environment variable.

import os
from phidata.llm.openai import OpenAILLM
from phidata.assistant import Assistant

# Ensure OPENAI_API_KEY is set in your environment variables
# For local development, you might use python-dotenv:
# from dotenv import load_dotenv; load_dotenv()

# Initialize LLM (e.g., OpenAI)
# Replace with os.environ.get('OPENAI_API_KEY', '') for production if not using dotenv
llm = OpenAILLM(model="gpt-4o", api_key=os.environ.get('OPENAI_API_KEY', ''))

# Create an Assistant
assistant = Assistant(llm=llm, name="MyChatAssistant")

# Run a chat interaction
response = assistant.chat("Hello, how are you?")
print(f"Assistant: {response}")

response = assistant.chat("What is the capital of France?")
print(f"Assistant: {response}")

# Example with a tool (requires 'pip install "phidata[wikipedia]"')
# from phidata.tools.wikipedia import WikipediaTool
# assistant_with_tool = Assistant(
#     llm=llm,
#     name="WikiAssistant",
#     tools=[WikipediaTool()]
# )
# response = assistant_with_tool.chat("Who is Marie Curie?")
# print(f"WikiAssistant: {response}")

view raw JSON →