Learning from Bing Search

UFO provides the capability to reinforce the AppAgent by searching for information on Bing to obtain up-to-date knowledge for niche tasks or applications which beyond the AppAgent's knowledge.

Mechanism

Upon receiving a request, the AppAgent constructs a Bing search query based on the request and retrieves the search results from Bing. The AppAgent then extracts the relevant information from the top-k search results from Bing and generates a plan based on the retrieved information.

Step 1: Obtain Bing API Key

To use the Bing search, you need to obtain a Bing API key. You can follow the instructions on the Microsoft Azure Bing Search API to get the API key.

Step 2: Configure the AppAgent

Configure the following parameters to allow UFO to use online Bing search for the decision-making process:

Configuration Option Description Type Default Value
RAG_ONLINE_SEARCH Whether to use the Bing search Boolean False
BING_API_KEY The Bing search API key String ""
RAG_ONLINE_SEARCH_TOPK The topk for the online search Integer 5
RAG_ONLINE_RETRIEVED_TOPK The topk for the online retrieved searched results Integer 1

Reference

Bases: Retriever

Class to create online retrievers.

Create a new OfflineDocRetriever. :query: The query to create an indexer for. :top_k: The number of documents to retrieve.

Source code in rag/retriever.py
173
174
175
176
177
178
179
180
def __init__(self, query: str, top_k: int) -> None:
    """
    Create a new OfflineDocRetriever.
    :query: The query to create an indexer for.
    :top_k: The number of documents to retrieve.
    """
    self.query = query
    self.indexer = self.get_indexer(top_k)

get_indexer(top_k)

Create an online search indexer.

Parameters:
  • top_k (int) –

    The number of documents to retrieve.

Returns:
  • The created indexer.

Source code in rag/retriever.py
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
def get_indexer(self, top_k: int):
    """
    Create an online search indexer.
    :param top_k: The number of documents to retrieve.
    :return: The created indexer.
    """

    bing_retriever = web_search.BingSearchWeb()
    result_list = bing_retriever.search(self.query, top_k=top_k)
    documents = bing_retriever.create_documents(result_list)
    if len(documents) == 0:
        return None
    try:
        indexer = bing_retriever.create_indexer(documents)
        print_with_color(
            "Online indexer created successfully for {num} searched results.".format(
                num=len(documents)
            ),
            "cyan",
        )
    except Exception as e:
        print_with_color(
            "Warning: Failed to create online indexer, error: {error}.".format(
                error=e
            ),
            "yellow",
        )
        return None

    return indexer