Gas96 commited on
Commit
b97b913
·
verified ·
1 Parent(s): 5166633

Fix to the tool

Browse files
Files changed (1) hide show
  1. app.py +6 -2
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 about {topic}")
38
- return f"Here's a fun fact about {topic}: {results[:300]}" # Limit to 300 characters
 
 
 
 
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