Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -30,10 +30,14 @@ class BasicAgent:
|
|
30 |
return result["text"]
|
31 |
|
32 |
def search(self, question: str) -> str:
|
33 |
-
|
34 |
with DDGS() as ddgs:
|
35 |
results = list(ddgs.text(question, max_results=3))
|
36 |
-
|
|
|
|
|
|
|
|
|
37 |
except Exception as e:
|
38 |
return f"Search error: {e}"
|
39 |
|
|
|
30 |
return result["text"]
|
31 |
|
32 |
def search(self, question: str) -> str:
|
33 |
+
try:
|
34 |
with DDGS() as ddgs:
|
35 |
results = list(ddgs.text(question, max_results=3))
|
36 |
+
if results:
|
37 |
+
# Score all the results and return the best one
|
38 |
+
return self.score_search_results(question, results)
|
39 |
+
else:
|
40 |
+
return "No relevant search results found."
|
41 |
except Exception as e:
|
42 |
return f"Search error: {e}"
|
43 |
|