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.
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.
Optional[str]
): Directory path containing text files to be added. If specified, the function searches this directory for eligible files.Optional[List]
): A list of specific text file paths to add. Takes precedence over input_dir
if provided.bool
): If True
, ignores hidden files or files starting with a dot (.) within input_dir
.bool
): If True
, uses the filename as the unique identifier for each document.bool
): If True
, includes files from subdirectories within input_dir
.Optional[List[str]]
): Specifies the file extensions to include, defaulting to text files.str
): An optional prompt to guide the system in processing text content.str
): An optional prompt to enhance the relevance of user queries by wrapping them.Union[str, EmbedType]
): The embedding model used for text extraction and embedding, defaulting to a standard model.dict
): Configuration parameters for integrating Large Language Models, if needed.dict
): Configuration for the vector storage, detailing how and where embeddings are stored.dict
): Additional parameters for customizing the service context.dict
): Parameters to customize the behavior of the query engine.dict
): Configuration for the document retriever, influencing how documents are retrieved based on queries.This snippet scans the specified directory (and subdirectories, if recursive
is True
) for text files, adding them to the search agentβs database.
Here, specific text files are added directly, with unique identifiers generated by the search agent if filename_as_id
is False
.