> ## Documentation Index
> Fetch the complete documentation index at: https://crewai.burt.pe.kr/llms.txt
> Use this file to discover all available pages before exploring further.

# LlamaIndex 도구 활용하기

> CrewAI 에이전트와 LlamaIndex 도구를 통합하여 검색 기반 쿼리 등을 강화하는 방법을 알아보세요.

## LlamaIndex 도구 사용하기

<Info>
  CrewAI는 RAG(Retrieval-Augmented Generation)와 에이전트 파이프라인을 위한 LlamaIndex의 포괄적인 도구 키트와 원활하게 통합된다. 이를 통해 고급 검색 기반 쿼리와 더 많은 기능을 사용할 수 있다.
</Info>

LlamaIndex가 제공하는 내장 도구는 다음과 같다.

```python theme={null}
from crewai import Agent
from crewai_tools import LlamaIndexTool

# 예제 1: 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)

# 예제 2: LlamaHub 도구에서 초기화
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]

# 예제 3: LlamaIndex Query Engine에서 도구 초기화
query_engine = index.as_query_engine()
query_tool = LlamaIndexTool.from_query_engine(
    query_engine,
    name="Uber 2019 10K Query Tool",
    description="이 도구를 사용해 2019년 Uber 10K 연간 보고서를 조회한다."
)

# 도구를 생성하고 에이전트에 할당
agent = Agent(
    role='Research Analyst',
    goal='최신 시장 분석 제공',
    backstory='시장 동향을 꿰뚫어보는 전문 분석가.',
    tools=[tool, *tools, query_tool]
)

# 나머지 코드 ...
```

## 시작하기 단계

LlamaIndexTool을 효과적으로 사용하려면 다음 단계를 따르세요:

<Steps>
  <Step title="패키지 설치">
    Python 환경에 `crewai[tools]` 패키지가 설치되어 있는지 확인하세요:

    <CodeGroup>
      ```shell Terminal theme={null}
      pip install 'crewai[tools]'
      ```
    </CodeGroup>
  </Step>

  <Step title="LlamaIndex 설치 및 사용">
    LlamaIndex 문서 [LlamaIndex Documentation](https://docs.llamaindex.ai/)를 참고하여 RAG/agent 파이프라인을 설정하세요.
  </Step>
</Steps>
