Update search_utils.py
Browse files- search_utils.py +4 -12
search_utils.py
CHANGED
@@ -1,17 +1,9 @@
|
|
1 |
-
# search_utils.py — Simple DuckDuckGo-based web search
|
2 |
import requests
|
3 |
import re
|
4 |
|
5 |
-
def web_search(query
|
6 |
try:
|
7 |
-
|
8 |
-
|
9 |
-
resp = requests.get(url, headers=headers)
|
10 |
-
if resp.status_code != 200:
|
11 |
-
return "No web results found."
|
12 |
-
|
13 |
-
results = re.findall(r'<a rel="nofollow" class="result__a" href="(.*?)">(.*?)</a>', resp.text)
|
14 |
-
summaries = [re.sub('<[^<]+?>', '', title) for _, title in results]
|
15 |
-
return " | ".join(summaries[:num_results])
|
16 |
except Exception as e:
|
17 |
-
return f"
|
|
|
|
|
1 |
import requests
|
2 |
import re
|
3 |
|
4 |
+
def web_search(query):
|
5 |
try:
|
6 |
+
# Placeholder fallback (can integrate SerpAPI/DuckDuckGo API here)
|
7 |
+
return f"Live search not implemented. You asked: {query}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
except Exception as e:
|
9 |
+
return f"(RAG Error: {e})"
|