Skip to content

Commit

Permalink
[Feat] browser should support custom base url for bing search (#2321)
Browse files Browse the repository at this point in the history
* feat: browser is now support custom base url

* fix: replae the base url position.

* Update bing_base_url parameter in SimpleTextBrowser class
  • Loading branch information
Mai0313 committed Apr 16, 2024
1 parent 0c5aed0 commit c97f0ff
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion autogen/browser_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def __init__(
start_page: Optional[str] = None,
viewport_size: Optional[int] = 1024 * 8,
downloads_folder: Optional[Union[str, None]] = None,
bing_base_url: str = "https://api.bing.microsoft.com/v7.0/search",
bing_api_key: Optional[Union[str, None]] = None,
request_kwargs: Optional[Union[Dict[str, Any], None]] = None,
):
Expand All @@ -47,6 +48,7 @@ def __init__(
self.viewport_current_page = 0
self.viewport_pages: List[Tuple[int, int]] = list()
self.set_address(self.start_page)
self.bing_base_url = bing_base_url
self.bing_api_key = bing_api_key
self.request_kwargs = request_kwargs

Expand Down Expand Up @@ -145,7 +147,7 @@ def _bing_api_call(self, query: str) -> Dict[str, Dict[str, List[Dict[str, Union
request_kwargs["stream"] = False

# Make the request
response = requests.get("https://api.bing.microsoft.com/v7.0/search", **request_kwargs)
response = requests.get(self.bing_base_url, **request_kwargs)
response.raise_for_status()
results = response.json()

Expand Down

0 comments on commit c97f0ff

Please sign in to comment.