Spaces:
Sleeping
Sleeping
Essi
commited on
Commit
·
db51870
1
Parent(s):
98f5036
docs: add debug print statements to indicate search method used in web_multi_search
Browse files
app.py
CHANGED
@@ -93,6 +93,7 @@ def web_multi_search(query: str, k: int = 5) -> str:
|
|
93 |
try:
|
94 |
hits = _search_duckduckgo(query, k)
|
95 |
if hits:
|
|
|
96 |
return json.dumps(hits, ensure_ascii=False)
|
97 |
except Exception:
|
98 |
pass
|
@@ -100,6 +101,8 @@ def web_multi_search(query: str, k: int = 5) -> str:
|
|
100 |
# Fallback 2: Wikipedia single-article summary
|
101 |
try:
|
102 |
page = wiki_summary(query, sentences=2, auto_suggest=False)
|
|
|
|
|
103 |
return json.dumps([{"title": "Wikipedia", "snippet": page, "link": ""}])
|
104 |
except Exception:
|
105 |
pass
|
@@ -110,6 +113,7 @@ def web_multi_search(query: str, k: int = 5) -> str:
|
|
110 |
"https://lite.duckduckgo.com/lite/?q=" + query
|
111 |
)
|
112 |
txt = requests.get(url, timeout=10).text[:600]
|
|
|
113 |
return json.dumps(
|
114 |
[{"title": "Google-lite", "snippet": re.sub(r"<.*?>", "", txt), "link": ""}]
|
115 |
)
|
|
|
93 |
try:
|
94 |
hits = _search_duckduckgo(query, k)
|
95 |
if hits:
|
96 |
+
print("DuckDuckGo search is used")
|
97 |
return json.dumps(hits, ensure_ascii=False)
|
98 |
except Exception:
|
99 |
pass
|
|
|
101 |
# Fallback 2: Wikipedia single-article summary
|
102 |
try:
|
103 |
page = wiki_summary(query, sentences=2, auto_suggest=False)
|
104 |
+
print("Fallback 2 is used")
|
105 |
+
|
106 |
return json.dumps([{"title": "Wikipedia", "snippet": page, "link": ""}])
|
107 |
except Exception:
|
108 |
pass
|
|
|
113 |
"https://lite.duckduckgo.com/lite/?q=" + query
|
114 |
)
|
115 |
txt = requests.get(url, timeout=10).text[:600]
|
116 |
+
print("Fallback 3 is used")
|
117 |
return json.dumps(
|
118 |
[{"title": "Google-lite", "snippet": re.sub(r"<.*?>", "", txt), "link": ""}]
|
119 |
)
|