From eb620ddefc7f2b92047cc7404308e08d428c7992 Mon Sep 17 00:00:00 2001 From: hzg0601 Date: Mon, 12 Jun 2023 16:22:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20bing=5Fsearch.py=E7=9A=84t?= =?UTF-8?q?ypo;=E6=9B=B4=E6=96=B0model=5Fconfig.py=E4=B8=ADBing=20Subscrip?= =?UTF-8?q?tion=20Key=E7=94=B3=E8=AF=B7=E6=96=B9=E5=BC=8F=E5=8F=8A?= =?UTF-8?q?=E6=B3=A8=E6=84=8F=E4=BA=8B=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- agent/bing_search.py | 2 +- configs/model_config.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/agent/bing_search.py b/agent/bing_search.py index 2ff7749..962090c 100644 --- a/agent/bing_search.py +++ b/agent/bing_search.py @@ -7,7 +7,7 @@ from configs.model_config import BING_SEARCH_URL, BING_SUBSCRIPTION_KEY def bing_search(text, result_len=3): if not (BING_SEARCH_URL and BING_SUBSCRIPTION_KEY): return [{"snippet": "please set BING_SUBSCRIPTION_KEY and BING_SEARCH_URL in os ENV", - "title": "env inof not fould", + "title": "env info is not found", "link": "https://python.langchain.com/en/latest/modules/agents/tools/examples/bing_search.html"}] search = BingSearchAPIWrapper(bing_subscription_key=BING_SUBSCRIPTION_KEY, bing_search_url=BING_SEARCH_URL) diff --git a/configs/model_config.py b/configs/model_config.py index e18f69b..9552ee0 100644 --- a/configs/model_config.py +++ b/configs/model_config.py @@ -165,7 +165,14 @@ flagging username: {FLAG_USER_NAME} OPEN_CROSS_DOMAIN = False # Bing 搜索必备变量 -# 使用 Bing 搜索需要使用 Bing Subscription Key -# 具体申请方式请见 https://learn.microsoft.com/en-us/bing/search-apis/bing-web-search/quickstarts/rest/python +# 使用 Bing 搜索需要使用 Bing Subscription Key,需要在azure port中申请试用bing search +# 具体申请方式请见 +# https://learn.microsoft.com/en-us/bing/search-apis/bing-web-search/create-bing-search-service-resource +# 使用python创建bing api 搜索实例详见: +# https://learn.microsoft.com/en-us/bing/search-apis/bing-web-search/quickstarts/rest/python BING_SEARCH_URL = "https://api.bing.microsoft.com/v7.0/search" +# 注意不是bing Webmaster Tools的api key, + +# 此外,如果是在服务器上,报Failed to establish a new connection: [Errno 110] Connection timed out +# 是因为服务器加了防火墙,需要联系管理员加白名单,如果公司的服务器的话,就别想了GG BING_SUBSCRIPTION_KEY = "" \ No newline at end of file