XML RAG Search
XMLSearchTool
Section titled “XMLSearchTool”Description
Section titled “Description”The XMLSearchTool is a cutting-edge RAG tool engineered for conducting semantic searches within XML files. Ideal for users needing to parse and extract information from XML content efficiently, this tool supports inputting a search query and an optional XML file path. By specifying an XML path, users can target their search more precisely to the content of that file, thereby obtaining more relevant search outcomes.
Installation
Section titled “Installation”To start using the XMLSearchTool, you must first install the crewai_tools package. This can be easily done with the following command:
pip install 'crewai[tools]'Example
Section titled “Example”Here are two examples demonstrating how to use the XMLSearchTool. The first example shows searching within a specific XML file, while the second example illustrates initiating a search without predefining an XML path, providing flexibility in search scope.
from crewai_tools import XMLSearchTool
# Allow agents to search within any XML file's content#as it learns about their paths during executiontool = XMLSearchTool()
# OR
# Initialize the tool with a specific XML file path#for exclusive search within that documenttool = XMLSearchTool(xml='path/to/your/xmlfile.xml')Arguments
Section titled “Arguments”xml: This is the path to the XML file you wish to search. It is an optional parameter during the tool’s initialization but must be provided either at initialization or as part of therunmethod’s arguments to execute a search.
Custom model and embeddings
Section titled “Custom model and embeddings”By default, the tool uses OpenAI for both embeddings and summarization. To customize the model, you can use a config dictionary as follows:
from chromadb.config import Settings
tool = XMLSearchTool( config={ "embedding_model": { "provider": "openai", "config": { "model": "text-embedding-3-small", # "api_key": "sk-...", }, }, "vectordb": { "provider": "chromadb", # or "qdrant" "config": { # "settings": Settings(persist_directory="/content/chroma", allow_reset=True, is_persistent=True), # from qdrant_client.models import VectorParams, Distance # "vectors_config": VectorParams(size=384, distance=Distance.COSINE), } }, })