Documentation Index
Fetch the complete documentation index at: https://docs-v1.agno.com/llms.txt
Use this file to discover all available pages before exploring further.
The DocxKnowledgeBase reads local docx files, converts them into vector embeddings and loads them to a vector database.
Usage
from agno.knowledge.docx import DocxKnowledgeBase
from agno.vectordb.pgvector import PgVector
knowledge_base = DocxKnowledgeBase(
path="data/docs",
# Table name: ai.docx_documents
vector_db=PgVector(
table_name="docx_documents",
db_url="postgresql+psycopg://ai:ai@localhost:5532/ai",
),
)
Then use the knowledge_base with an Agent:
from agno.agent import Agent
from knowledge_base import knowledge_base
agent = Agent(
knowledge=knowledge_base,
search_knowledge=True,
)
agent.knowledge.load(recreate=False)
agent.print_response("Ask me about something from the knowledge base")
DocxKnowledgeBase also supports async loading.
pip install qdrant-client
We are using a local Qdrant database for this example. Make sure it’s running
import asyncio
from pathlib import Path
from agno.agent import Agent
from agno.knowledge.docx import DocxKnowledgeBase
from agno.vectordb.lancedb import LanceDb, SearchType
# Create a knowledge base with the DOCX files from the data/docs directory
knowledge_base = DocxKnowledgeBase(
path=Path("tmp/docs"),
vector_db=LanceDb(
uri="tmp/lancedb",
table_name="docx_reader",
search_type=SearchType.hybrid,
),
)
# Create an agent with the knowledge base
agent = Agent(
knowledge=knowledge_base,
search_knowledge=True,
)
if __name__ == "__main__":
asyncio.run(knowledge_base.aload(recreate=False))
asyncio.run(
agent.aprint_response(
"What docs do you have in your knowledge base?", markdown=True
)
)
Params
| Parameter | Type | Default | Description |
|---|
path | Union[str, Path] | - | Path to text files. Can point to a single docx file or a directory of docx files. |
formats | List[str] | [".doc", ".docx"] | Formats accepted by this knowledge base. |
reader | DocxReader | DocxReader() | A DocxReader that converts the docx files into Documents for the vector database. |
DocxKnowledgeBase is a subclass of the AgentKnowledge class and has access to the same params.
Developer Resources