Gas96 commited on
Commit
62ecc93
·
verified ·
1 Parent(s): d42a3ea

Draft before test

Browse files
Files changed (1) hide show
  1. app.py +14 -9
app.py CHANGED
@@ -25,17 +25,22 @@ def get_current_time_in_timezone(timezone: str) -> str:
25
 
26
  #Following my creation.
27
  @tool
28
- def sum_numbers_test(a:float, b:float)-> float:
29
- """A tool that sum two numbers.
 
 
30
  Args:
31
- a: A float number
32
- b: A float number
 
 
33
  """
34
- try:
35
- sum=a+b
36
- return sum
 
37
  except Exception as e:
38
- return f"I could not complete the task. I got this error: {e}"
39
 
40
  final_answer = FinalAnswerTool()
41
 
@@ -58,7 +63,7 @@ with open("prompts.yaml", 'r') as stream:
58
 
59
  agent = CodeAgent(
60
  model=model,
61
- tools=[final_answer, sum_numbers_test], ## add your tools here (don't remove final answer)
62
  max_steps=6,
63
  verbosity_level=1,
64
  grammar=None,
 
25
 
26
  #Following my creation.
27
  @tool
28
+ def get_fun_fact(topic: str) -> str:
29
+ """
30
+ Finds a fun fact about a given topic using DuckDuckGo.
31
+
32
  Args:
33
+ topic (str): The topic to search for a fun fact about.
34
+
35
+ Returns:
36
+ str: A fun fact related to the topic or an error message.
37
  """
38
+ try:
39
+ search_tool = DuckDuckGoSearchTool()
40
+ results = search_tool.run(f"fun fact about {topic}")
41
+ return f"Here's a fun fact about {topic}: {results[:300]}" # Limit to 300 characters
42
  except Exception as e:
43
+ return f"Sorry, I couldn't find a fun fact. Error: {e}"
44
 
45
  final_answer = FinalAnswerTool()
46
 
 
63
 
64
  agent = CodeAgent(
65
  model=model,
66
+ tools=[get_fun_fact, final_answer], ## add your tools here (don't remove final answer)
67
  max_steps=6,
68
  verbosity_level=1,
69
  grammar=None,