langchain.utilities.bing_search.BingSearchAPIWrapper¶

class langchain.utilities.bing_search.BingSearchAPIWrapper(*, bing_subscription_key: str, bing_search_url: str, k: int = 10)[source]¶

Bases: BaseModel

Wrapper for Bing Search API.

In order to set this up, follow instructions at: https://levelup.gitconnected.com/api-tutorial-how-to-use-bing-web-search-api-in-python-4165d5592a7e

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

param bing_search_url: str [Required]¶
param bing_subscription_key: str [Required]¶
param k: int = 10¶
results(query: str, num_results: int) List[Dict][source]¶

Run query through BingSearch and return metadata.

Parameters
  • query – The query to search for.

  • num_results – The number of results to return.

Returns

snippet - The description of the result. title - The title of the result. link - The link to the result.

Return type

A list of dictionaries with the following keys

run(query: str) str[source]¶

Run query through BingSearch and parse result.

validator validate_environment  »  all fields[source]¶

Validate that api key and endpoint exists in environment.

model Config[source]¶

Bases: object

Configuration for this pydantic object.

extra = 'forbid'¶

Examples using BingSearchAPIWrapper¶