Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,8 +28,11 @@ def __init__(self, max_results=10, **kwargs):
|
|
| 28 |
def forward(self, query: str) -> str:
|
| 29 |
results = self.ddgs.text(query, max_results=self.max_results)
|
| 30 |
if len(results) == 0:
|
| 31 |
-
|
| 32 |
-
postprocessed_results = [
|
|
|
|
|
|
|
|
|
|
| 33 |
return "## Search Results\n\n" + "\n\n".join(postprocessed_results)
|
| 34 |
|
| 35 |
@tool
|
|
|
|
| 28 |
def forward(self, query: str) -> str:
|
| 29 |
results = self.ddgs.text(query, max_results=self.max_results)
|
| 30 |
if len(results) == 0:
|
| 31 |
+
raise Exception("No results found! Try a less restrictive/shorter query.")
|
| 32 |
+
postprocessed_results = [
|
| 33 |
+
f"[{result['title']}]({result['href']})\n{result['body']}"
|
| 34 |
+
for result in results
|
| 35 |
+
]
|
| 36 |
return "## Search Results\n\n" + "\n\n".join(postprocessed_results)
|
| 37 |
|
| 38 |
@tool
|