Make sure that crewai[tools] package is installed in your Python environment: pip install 'crewai[tools]'
Follow the LlamaIndex docs on how to set up a RAG/agent pipeline.
Here’s an example from the docs:
from crewai import Agent
from crewai_tools import LlamaIndexTool
# Example 1: Initialize from FunctionTool
from llama_index.core.tools import FunctionTool
your_python_function = lambda ...: ...
og_tool = FunctionTool.from_defaults(
your_python_function,
name="<name>",
description='<description>'
)
tool = LlamaIndexTool.from_tool(og_tool)
# Example 2: Initialize from LlamaHub Tools
from llama_index.tools.wolfram_alpha import WolframAlphaToolSpec
wolfram_spec = WolframAlphaToolSpec(app_id="<app_id>")
wolfram_tools = wolfram_spec.to_tool_list()
tools = [LlamaIndexTool.from_tool(t) for t in wolfram_tools]
# Example 3: Initialize Tool from a LlamaIndex Query Engine
query_engine = index.as_query_engine()
query_tool = LlamaIndexTool.from_query_engine(
query_engine,
name="Uber 2019 10K Query Tool",
description="Use this tool to lookup the 2019 Uber 10K Annual Report"
)
# Create and assign the tools to an agent
agent = Agent(
role='Research Analyst',
goal='Provide up-to-date market analysis',
backstory='An expert analyst with a keen eye for market trends.',
tools=[tool, *tools, query_tool]
)
# rest of the code ...
Awesome. I think I need something very similar to example 3. I am assembling a set of agents each one specialized in analyzing (and do some computation) in some specific PDF sections - in a way AgentSection1 can be focused on just that Section1, AgentSection2, Section2, etc.
Again, thank you
PS: CrewAI was the missing tool. I was playing with LangChain and LlamaIndex but glueing everything in a nasty way… Now it will be very clean and integrated.