BingSearchToolSpec
that inherits from the BaseToolSpec
class. It is designed to interact with the Bing Search API and provides methods for news, image, and video searches.BingSearchToolSpec
class:``
The
BingSearchToolSpec class requires an API key for the Bing Search API, a language parameter (default is "en-US"), and a results parameter (default is 3) during initialization. It has three main methods:
bing_news_search,
bing_image_search, and
bing_video_search`, each of which takes a query string as an argument and returns relevant results from Bing.BingSearchToolSpec
module is located in the llama_index.tools.bing_search
package of the LlamaIndex project. You can import it into your Python script as follows:from llama_index.tools.bing_search import BingSearchToolSpec
BingSearchToolSpec
for news search, you need to first import the module and then create an instance of the BingSearchToolSpec
class. Here is an example:from llama_index.tools.bing_search import BingSearchToolSpec # Initialize BingSearchToolSpec with your Bing API key bing_search_tool = BingSearchToolSpec(api_key='your_bing_api_key') # Use the bing_news_search method to search for news news_results = bing_search_tool.bing_news_search('your_search_query')
'your_bing_api_key'
with your actual Bing API key and 'your_search_query'
with the topic you want to search for in the news.BingSearchToolSpec
class and then pass it to the OpenAIAgent
when initializing it. Here is an example:import openai from llama_index.agent import OpenAIAgent from llama_index.tools.bing_search.base import BingSearchToolSpec # Set your OpenAI API key openai.api_key = "sk-your-key" # Initialize BingSearchToolSpec with your Bing API key bing_tool = BingSearchToolSpec(api_key="your-bing-api-key") # Initialize OpenAIAgent with BingSearchToolSpec agent = OpenAIAgent.from_tools( bing_tool.to_tool_list(), verbose=True, )
"sk-your-key"
with your actual OpenAI API key and "your-bing-api-key"
with your actual Bing API key.agent
to chat and it will use the Bing Search tool to find information. For example:print(agent.chat("whats the latest news about superconductors"))
llama_index.tools
module using pip. However, the llama_index.tools
module is a part of the LlamaIndex library, so you should be able to access it by installing the main LlamaIndex library. You can install the LlamaIndex library using pip with the following command:pip install llama-index
llama_index.tools
module in your Python scripts./Users/sourabhdesai/Library/Caches/pypoetry/virtualenvs/llama-index-cXQhuK8v-py3.11/lib/python3.11/site-packages
indicates that Python 3.11 is being used./Users/sourabhdesai/Library/Caches/pypoetry/virtualenvs/llama-index-cXQhuK8v-py3.11/lib/python3.11/site-packages
indicates that Python 3.11 is being used.