> ## Documentation Index
> Fetch the complete documentation index at: https://docs.phidata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Text KnowledgeBase

## Example

<Note>
  Install `textract` if needed using [this guide](/how-to/install)
</Note>

```python knowledge_base.py theme={null}
from phi.knowledge.text import TextKnowledgeBase
from phi.vectordb.pgvector import PgVector

from resources import vector_db

knowledge_base = TextKnowledgeBase(
    path="data/docs",
    # Table name: ai.text_documents
    vector_db=PgVector(
        table_name="text_documents",
        db_url=vector_db.get_db_connection_local(),
    ),
)
```

## TextKnowledgeBase Params

| Parameter | Type               | Default        | Description                                                                           |
| --------- | ------------------ | -------------- | ------------------------------------------------------------------------------------- |
| `path`    | `Union[str, Path]` | -              | Path to text files. Can point to a single text file or a directory of text files.     |
| `formats` | `List[str]`        | `[".txt"]`     | Formats accepted by this knowledge base.                                              |
| `reader`  | `TextReader`       | `TextReader()` | A `TextReader` that converts the text files into `Documents` for the vector database. |

## AgentKnowledge Params

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

<Snippet file="kb-base-reference.mdx" />
