Example

Install beautifulsoup4 using this guide

knowledge_base.py
from phi.knowledge.website import WebsiteKnowledgeBase
from phi.vectordb.pgvector import PgVector

from resources import vector_db

knowledge_base = WebsiteKnowledgeBase(
    urls=["https://docs.phidata.com/introduction"],
    # Number of links to follow from the seed URLs
    max_links=10,
    # Table name: ai.website_documents
    vector_db=PgVector(
        table_name="website_documents",
        db_url=vector_db.get_db_connection_local(),
    ),
)

WebsiteKnowledgeBase Params

ParameterTypeDefaultDescription
urlsList[str][]URLs to read
readerOptional[WebsiteReader]NoneA WebsiteReader that reads the urls and converts them into Documents for the vector database.
max_depthint3Maximum depth to crawl.
max_linksint10Number of links to crawl.

AgentKnowledge Params

WebsiteKnowledgeBase is a subclass of the AgentKnowledge class and has access to the same params

ParameterTypeDefaultDescription
readerOptional[Reader]NoneReader to read the documents
vector_dbOptional[VectorDb]NoneVector db to store the knowledge base
num_documentsint2Number of relevant documents to return on search
optimize_onOptional[int]1000Number of documents to optimize the vector db on
driverstr"knowledge"Driver for the Assistant knowledge