Skip to content

Commit

Permalink
Fix/Bing Search url endpoint cannot be customized (langgenius#3366)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeuoly authored and Gzn committed Apr 15, 2024
1 parent f7b2212 commit 1806d5f
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class BingSearchTool(BuiltinTool):

def _invoke_bing(self,
user_id: str,
server_url: str,
subscription_key: str, query: str, limit: int,
result_type: str, market: str, lang: str,
filters: list[str]) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
Expand All @@ -26,7 +27,7 @@ def _invoke_bing(self,
}

query = quote(query)
server_url = f'{self.url}?q={query}&mkt={market_code}&count={limit}&responseFilter={",".join(filters)}'
server_url = f'{server_url}?q={query}&mkt={market_code}&count={limit}&responseFilter={",".join(filters)}'
response = get(server_url, headers=headers)

if response.status_code != 200:
Expand Down Expand Up @@ -136,6 +137,7 @@ def validate_credentials(self, credentials: dict[str, Any], tool_parameters: dic

self._invoke_bing(
user_id='test',
server_url=server_url,
subscription_key=key,
query=query,
limit=limit,
Expand Down Expand Up @@ -188,6 +190,7 @@ def _invoke(self,

return self._invoke_bing(
user_id=user_id,
server_url=server_url,
subscription_key=key,
query=query,
limit=limit,
Expand Down

0 comments on commit 1806d5f

Please sign in to comment.