[Feat] browser should support custom base url for bing search (#2321)

* feat: browser is now support custom base url

* fix: replae the base url position.

* Update bing_base_url parameter in SimpleTextBrowser class
This commit is contained in:
Wei 2024-04-16 22:07:50 +08:00 committed by GitHub
parent 0c5aed0489
commit c97f0ffc3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -36,6 +36,7 @@ class SimpleTextBrowser:
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,
):
@ -47,6 +48,7 @@ class SimpleTextBrowser:
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
@ -145,7 +147,7 @@ class SimpleTextBrowser:
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()