LlamaIndexTool
Description
TheLlamaIndexTool
is designed to be a general wrapper around LlamaIndex tools and query engines, enabling you to leverage LlamaIndex resources in terms of RAG/agentic pipelines as tools to plug into CrewAI agents. This tool allows you to seamlessly integrate LlamaIndex’s powerful data processing and retrieval capabilities into your CrewAI workflows.
Installation
To use this tool, you need to install LlamaIndex:Steps to Get Started
To effectively use theLlamaIndexTool
, follow these steps:
- Install LlamaIndex: Install the LlamaIndex package using the command above.
- Set Up LlamaIndex: Follow the LlamaIndex documentation to set up a RAG/agent pipeline.
- Create a Tool or Query Engine: Create a LlamaIndex tool or query engine that you want to use with CrewAI.
Example
The following examples demonstrate how to initialize the tool from different LlamaIndex components:From a LlamaIndex Tool
Code
From LlamaHub Tools
Code
From a LlamaIndex Query Engine
Code
Class Methods
TheLlamaIndexTool
provides two main class methods for creating instances:
from_tool
Creates aLlamaIndexTool
from a LlamaIndex tool.
Code
from_query_engine
Creates aLlamaIndexTool
from a LlamaIndex query engine.
Code
Parameters
Thefrom_query_engine
method accepts the following parameters:
- query_engine: Required. The LlamaIndex query engine to wrap.
- name: Optional. The name of the tool.
- description: Optional. The description of the tool.
- return_direct: Optional. Whether to return the response directly. Default is
False
.
Conclusion
TheLlamaIndexTool
provides a powerful way to integrate LlamaIndex’s capabilities into CrewAI agents. By wrapping LlamaIndex tools and query engines, it enables agents to leverage sophisticated data retrieval and processing functionalities, enhancing their ability to work with complex information sources.