> ## 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.

# Docx Knowledge Base

> Learn how to use local docx files in your knowledge base.

The **DocxKnowledgeBase** reads **local docx** files, converts them into vector embeddings and loads them to a vector database.

## Usage

<Note>
  We are using a local PgVector database for this example. [Make sure it's running](https://docs-v1.agno.com/vectordb/pgvector)
</Note>

```shell theme={null}
pip install textract
```

```python theme={null}
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`:

```python theme={null}
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.

```shell theme={null}
pip install qdrant-client
```

We are using a local Qdrant database for this example. [Make sure it's running](https://docs-v1.agno.com/vectordb/qdrant)

```python async_knowledge_base.py theme={null}
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](/reference/knowledge/base) class and has access to the same params.

## Developer Resources

* View [Sync loading Cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/agent_concepts/knowledge/docx_kb.py)
* View [Async loading Cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/agent_concepts/knowledge/docx_kb_async.py)
