# Phidata Assistants — Memory, Knowledge & Tools in One Class > Phidata Assistant glues memory, knowledge bases, tool use into one Python class. Add knowledge with PgVector or Lance, free UI playground included. ## Install Copy the content below into your project: ## Quick Use 1. `pip install phidata duckduckgo-search` 2. Define an Assistant with `description`, `tools`, optional `memory` and `knowledge_base` 3. `assistant.print_response("")` — or serve the playground at localhost:7777 --- ## Intro Phidata's `Assistant` class is the Python-first agent abstraction — memory, knowledge bases, structured outputs, and tool use plugged in as keyword arguments. No graph, no nodes, no decorators outside the tool registration. Best for: builders who want a Python class they can grow into a production agent, not a framework that takes over their whole codebase. Works with: any LLM via LiteLLM, PgVector / Lance / SingleStore for knowledge. Setup time: 5 minutes. --- ### Hello assistant ```python from phi.assistant import Assistant from phi.tools.duckduckgo import DuckDuckGo assistant = Assistant( description="Research assistant. Use web search aggressively, cite sources.", tools=[DuckDuckGo()], show_tool_calls=True, markdown=True, ) assistant.print_response("Compare Pinecone, Weaviate, Qdrant in 2026") ``` ### Add memory ```python from phi.memory import AssistantMemory from phi.memory.db.postgres import PgMemoryDb assistant = Assistant( memory=AssistantMemory(db=PgMemoryDb(table_name="assistant_memory")), ... ) ``` Memory persists across runs. The next session starts with a summary of past conversations. ### Add knowledge (RAG built in) ```python from phi.knowledge.pdf import PDFUrlKnowledgeBase from phi.vectordb.pgvector import PgVector kb = PDFUrlKnowledgeBase( urls=["https://example.com/paper.pdf"], vector_db=PgVector(table_name="kb"), ) kb.load(recreate=False) assistant = Assistant( knowledge_base=kb, add_references_to_prompt=True, ... ) ``` The Assistant retrieves relevant chunks per query and injects them into the prompt. ### Built-in playground ```python from phi.playground import Playground, serve_playground_app app = Playground(assistants=[assistant]).get_app() serve_playground_app("main:app", reload=True) ``` `localhost:7777` gives you a chat UI to test the Assistant — useful in dev, not for prod. --- ### FAQ **Q: Phidata vs Agno — what's the relationship?** A: Same team. Phidata is the older brand; Agno is the newer name + cleaner runtime. Phidata still maintained but Agno is where new features land. For new projects, prefer Agno. **Q: Is Phidata free?** A: Yes — open-source under Mozilla Public License 2.0. The hosted Phidata Cloud (monitoring + auth) is paid, but everything you run on your own infra is free. **Q: Can I use Phidata with Claude?** A: Yes — Phidata uses LiteLLM under the hood. Set `llm=Claude(model='claude-3-5-sonnet-20241022')` or any of 100+ providers. Tool use, structured outputs, and memory all work the same. --- ## Source & Thanks > Built by [Phidata](https://github.com/phidatahq). Licensed under MPL-2.0. > > [phidatahq/phidata](https://github.com/phidatahq/phidata) — ⭐ 13,000+ --- ## 快速使用 1. `pip install phidata duckduckgo-search` 2. 定义 Assistant,写 `description`、`tools`、可选 `memory` 和 `knowledge_base` 3. `assistant.print_response("<你的问题>")` 或在 localhost:7777 起 playground --- ## 简介 Phidata 的 `Assistant` 类是 Python 优先的 agent 抽象 —— 记忆、知识库、结构化输出、工具使用都作为关键字参数接进来。没有图、没有节点、除了工具注册没有装饰器。适合想要一个能长成生产 agent 的 Python 类、而不是一个接管整个代码库的框架的开发者。兼容任何走 LiteLLM 的 LLM 和 PgVector / Lance / SingleStore 知识后端。装机时间 5 分钟。 --- ### Hello assistant ```python from phi.assistant import Assistant from phi.tools.duckduckgo import DuckDuckGo assistant = Assistant( description="Research assistant. Use web search aggressively, cite sources.", tools=[DuckDuckGo()], show_tool_calls=True, markdown=True, ) assistant.print_response("Compare Pinecone, Weaviate, Qdrant in 2026") ``` ### 加记忆 ```python from phi.memory import AssistantMemory from phi.memory.db.postgres import PgMemoryDb assistant = Assistant( memory=AssistantMemory(db=PgMemoryDb(table_name="assistant_memory")), ... ) ``` 记忆跨运行保存。下次会话以过去对话的摘要起手。 ### 加知识(内置 RAG) ```python from phi.knowledge.pdf import PDFUrlKnowledgeBase from phi.vectordb.pgvector import PgVector kb = PDFUrlKnowledgeBase( urls=["https://example.com/paper.pdf"], vector_db=PgVector(table_name="kb"), ) kb.load(recreate=False) assistant = Assistant( knowledge_base=kb, add_references_to_prompt=True, ... ) ``` Assistant 按 query 取相关 chunk 注入 prompt。 ### 自带 playground ```python from phi.playground import Playground, serve_playground_app app = Playground(assistants=[assistant]).get_app() serve_playground_app("main:app", reload=True) ``` `localhost:7777` 给你一个聊天 UI 测 Assistant —— 开发时用,生产别用。 --- ### FAQ **Q: Phidata 跟 Agno 啥关系?** A: 同一个团队。Phidata 是旧品牌,Agno 是新名字加干净的运行时。Phidata 还维护但新功能都进 Agno。新项目优先选 Agno。 **Q: Phidata 免费吗?** A: 免费 —— Mozilla Public License 2.0 开源。托管的 Phidata Cloud(监控 + 认证)付费,但自己跑的部分全免费。 **Q: Phidata 能配 Claude 吗?** A: 能 —— Phidata 底层走 LiteLLM。设 `llm=Claude(model='claude-3-5-sonnet-20241022')` 或 100+ provider 任意一个。工具、结构化输出、记忆都一样工作。 --- ## 来源与感谢 > Built by [Phidata](https://github.com/phidatahq). Licensed under MPL-2.0. > > [phidatahq/phidata](https://github.com/phidatahq/phidata) — ⭐ 13,000+ --- Source: https://tokrepo.com/en/workflows/phidata-assistants-memory-knowledge-tools-in-one-class Author: Phidata