From 1806d5fb93887a8a351493ded41de07141d402ab Mon Sep 17 00:00:00 2001 From: Yeuoly <45712896+Yeuoly@users.noreply.github.com> Date: Thu, 11 Apr 2024 19:56:08 +0800 Subject: [PATCH] Fix/Bing Search url endpoint cannot be customized (#3366) --- .../tools/provider/builtin/bing/tools/bing_web_search.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/core/tools/provider/builtin/bing/tools/bing_web_search.py b/api/core/tools/provider/builtin/bing/tools/bing_web_search.py index 8f11d2173ca526..c51c4d567fd75e 100644 --- a/api/core/tools/provider/builtin/bing/tools/bing_web_search.py +++ b/api/core/tools/provider/builtin/bing/tools/bing_web_search.py @@ -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]]: @@ -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: @@ -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, @@ -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,