Spaces:
Sleeping
Sleeping
Fix to the tool
Browse files
app.py
CHANGED
|
@@ -34,8 +34,12 @@ def get_fun_fact(topic: str) -> str:
|
|
| 34 |
"""
|
| 35 |
try:
|
| 36 |
search_tool = DuckDuckGoSearchTool()
|
| 37 |
-
results = search_tool.run(f"fun fact
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
except Exception as e:
|
| 40 |
return f"Sorry, I couldn't find a fun fact. Error: {e}"
|
| 41 |
|
|
|
|
| 34 |
"""
|
| 35 |
try:
|
| 36 |
search_tool = DuckDuckGoSearchTool()
|
| 37 |
+
results = search_tool.run(f"{topic} fun fact site:wikipedia.org")
|
| 38 |
+
if results:
|
| 39 |
+
fun_fact = results[0][:300]
|
| 40 |
+
return f"Here's a fun fact about {topic}: {fun_fact}"
|
| 41 |
+
else:
|
| 42 |
+
return f"Sorry, I could not find a fun fact about {topic}."
|
| 43 |
except Exception as e:
|
| 44 |
return f"Sorry, I couldn't find a fun fact. Error: {e}"
|
| 45 |
|