RAG with LlamaIndex x Desearch

    RAG with LlamaIndex x Desearch

    Add Desearch retrieval to a LlamaIndex agent: register Desearch's search tool as a retriever, then set up an OpenAI Agent that uses it.

    Quick Start

    1. Install Required Packages

    bash
    pip install llama-index llama-index-core llama-index-desearch

    2. Instantiate the Desearch Tool

    Set the DESEARCH_API_KEY environment variable first. Get a key at Desearch.

    python
    from llama_index_desearch.tools import DesearchToolSpec import os desearch_tool = DesearchToolSpec( api_key=os.environ["DESEARCH_API_KEY"], )

    3. Select Desearch Methods to Use

    This example passes only the ai_search_tool method to the agent, using the .to_tool_list method:

    python
    search_and_retrieves_tool = desearch_tool.to_tool_list( spec_functions=["ai_search_tool"] )

    4. Set Up the OpenAI Agent

    python
    from llama_index.agent.openai import OpenAIAgent agent = OpenAIAgent.from_tools( search_and_retrieves_tool, verbose=True, )

    Use the chat method to interact with the agent:

    python
    agent.chat( "Can you summarize the news from the last month related to the US stock market?" )

    Desearch Tool Functions

    • ai_search_tool: AI-powered search across multiple sources, including web pages, research papers, and social media.
    • twitter_search_tool: retrieves links and tweets matching a search query, without AI models.
    • web_search_tool: plain web search, like a normal search engine.

    For more details, see the Desearch Tool API Reference.


    Additional Resources