mirror of
https://github.com/RYDE-WORK/Langchain-Chatchat.git
synced 2026-01-23 23:40:03 +08:00
* 修复 bing_search.py的typo;更新model_config.py中Bing Subscription Key申请方式及注意事项 * 更新FAQ,增加了[Errno 110] Connection timed out的原因与解决方案 * 修改loader.py中load_in_8bit失败的原因和详细解决方案 * update loader.py
20 lines
756 B
Python
20 lines
756 B
Python
#coding=utf8
|
|
|
|
from langchain.utilities import BingSearchAPIWrapper
|
|
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 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)
|
|
return search.results(text, result_len)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
r = bing_search('python')
|
|
print(r)
|