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

# 📝 Text

# Adding Text Files to Your Search Agent

Incorporating plain text (.txt) documents into your search agent is crucial for broadening its knowledge base, enabling it to source information from a wide array of text-based documents. The `add_text` method simplifies this process, allowing for efficient integration of text content into the agent's searchable data.

## Function Signature

The `add_text` function is designed for flexibility, facilitating the addition of text files either from a specified directory or as a list of individual files.

### Parameters

* **input\_dir** (`Optional[str]`): Directory path containing text files to be added. If specified, the function searches this directory for eligible files.
* **input\_files** (`Optional[List]`): A list of specific text file paths to add. Takes precedence over `input_dir` if provided.
* **exclude\_hidden** (`bool`): If `True`, ignores hidden files or files starting with a dot (.) within `input_dir`.
* **filename\_as\_id** (`bool`): If `True`, uses the filename as the unique identifier for each document.
* **recursive** (`bool`): If `True`, includes files from subdirectories within `input_dir`.
* **required\_exts** (`Optional[List[str]]`): Specifies the file extensions to include, defaulting to text files.
* **system\_prompt** (`str`): An optional prompt to guide the system in processing text content.
* **query\_wrapper\_prompt** (`str`): An optional prompt to enhance the relevance of user queries by wrapping them.
* **embed\_model** (`Union[str, EmbedType]`): The embedding model used for text extraction and embedding, defaulting to a standard model.
* **llm\_params** (`dict`): Configuration parameters for integrating Large Language Models, if needed.
* **vector\_store\_params** (`dict`): Configuration for the vector storage, detailing how and where embeddings are stored.
* **service\_context\_params** (`dict`): Additional parameters for customizing the service context.
* **query\_engine\_params** (`dict`): Parameters to customize the behavior of the query engine.
* **retriever\_params** (`dict`): Configuration for the document retriever, influencing how documents are retrieved based on queries.

## Example Usage

### Adding Text Files from a Directory

```python theme={null}
search_agent.add_text(
    input_dir="/path/to/text/files",
    recursive=True
)
```

This snippet scans the specified directory (and subdirectories, if `recursive` is `True`) for text files, adding them to the search agent's database.

### Adding Specific Text Files

```python theme={null}
search_agent.add_text(
    input_files=["/path/to/specific_file1.txt", "/path/to/specific_file2.txt"],
)
```

Here, specific text files are added directly, with unique identifiers generated by the search agent if `filename_as_id` is `False`.
