Skip to content

Commit

Permalink
feat: 搜索功能现在可以使用config中设置的http_proxy和https_proxy了
Browse files Browse the repository at this point in the history
  • Loading branch information
GaiZhenbiao committed Jan 4, 2024
1 parent 8e2216a commit bfec72c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions modules/models/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,19 @@ def prepare_inputs(
)
elif use_websearch:
search_results = []
with DDGS() as ddgs:
ddgs_gen = ddgs.text(fake_inputs, backend="lite")
for r in islice(ddgs_gen, 10):
search_results.append(r)
with retrieve_proxy() as proxy:
if proxy[0] or proxy[1]:
proxies = {}
if proxy[0]:
proxies["http"] = proxy[0]
if proxy[1]:
proxies["https"] = proxy[1]
else:
proxies = None
with DDGS(proxies=proxies) as ddgs:
ddgs_gen = ddgs.text(fake_inputs, backend="lite")
for r in islice(ddgs_gen, 10):
search_results.append(r)
reference_results = []
for idx, result in enumerate(search_results):
logging.debug(f"搜索结果{idx + 1}{result}")
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ openpyxl
pandoc
wolframalpha
faiss-cpu==1.7.4
duckduckgo-search>=3.9.5
duckduckgo-search>=4.1.1
arxiv
wikipedia
google.generativeai
Expand Down

0 comments on commit bfec72c

Please sign in to comment.