ShigatoraShuz commited on
Commit
fc4d604
·
verified ·
1 Parent(s): d74cc8d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -63,12 +63,11 @@ def get_search_text(question):
63
  query = " ".join(query.split()[:26])
64
  items = []
65
  try:
66
- with DDGS() as ddgs:
67
- items = list(ddgs.text(query, max_results=5))
68
  except Exception as exc:
69
  print("Web search unavailable:", str(exc)[:160])
70
  if not items:
71
- return "No web search results were available."
72
 
73
  sources = []
74
  for x in items:
@@ -93,4 +92,5 @@ def get_search_text(question):
93
  soup = BeautifulSoup(r.content[:650000], "html.parser")
94
  for elem in soup(["script", "style", "nav", "footer", "header"]):
95
  elem.decompose()
96
- text = re.sub(r"\s+", " ", soup.get_text(" ", strip=True))
 
 
63
  query = " ".join(query.split()[:26])
64
  items = []
65
  try:
66
+ items = list(DDGS().text(query, max_results=5))
 
67
  except Exception as exc:
68
  print("Web search unavailable:", str(exc)[:160])
69
  if not items:
70
+ return "No web search results were available; use your existing knowledge carefully."
71
 
72
  sources = []
73
  for x in items:
 
92
  soup = BeautifulSoup(r.content[:650000], "html.parser")
93
  for elem in soup(["script", "style", "nav", "footer", "header"]):
94
  elem.decompose()
95
+ text = re.sub(r"\s+", " ", soup.get_text(" ", strip=True))
96
+ sources.append(f"Page excerpt from {url}: {text[:7000]}")