Directory
Directory reads the files in a folder in one go and passes the text of each one to the flow, along with its location. It reads text documents, PDFs, Word documents, spreadsheets, data files (CSV, JSON, YAML, XML), web pages and code files.
Use it when you have several documents grouped in a folder and want an agent or a model to work with all of them.
When to use it
- Load every manual in a folder into a knowledge base.
- Have an agent summarise a set of reports.
- Review in one go the contracts stored in a folder and its subfolders.
Configuration
| Field | What it does |
|---|---|
| Path | The folder you want to read. |
| Types | Optional. The file extensions you want to load, separated by commas, for example pdf, docx. Only files with those extensions are read. Leave it empty to read every supported file type listed above. |
| Depth | How many levels of subfolders are read. With 0, the Recursive setting is used. Default: 0. |
Advanced options
| Field | What it does |
|---|---|
| Recursive | Also reads the files in every subfolder. When off, it reads only the files in the chosen folder. |
| Load Hidden | Also reads hidden files. |
| Silent Errors | If a file can’t be read, skips it and carries on with the rest instead of stopping the flow. |
| Use Multithreading | Reads several files at the same time to finish sooner. |
| Max Concurrency | With Use Multithreading, how many files are read at the same time. Default: 2. |
Output
The Data output returns one item per file read, with its text and its location. Connect it to an agent, a model or a document store.
Example
A quality department wants to query its procedures with an agent:
- Add Directory and, in Path, pick the procedures folder.
- In the advanced options, turn on Recursive to include the subfolders and Silent Errors so a damaged file doesn’t stop the reading.
- Connect Data to a document store.
- Connect an agent to that store to answer questions about the procedures.
Good practices
- Turn on Silent Errors when the folder holds many files: a single damaged file won’t stop the flow.
- With large folders, turn on Use Multithreading to speed up the reading.
Related components
- File: reads a single file.
- Parse Data: turns the data read into text.