Gas96 commited on
Commit
2cc667d
·
verified ·
1 Parent(s): 38a35d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -14
app.py CHANGED
@@ -3,11 +3,9 @@ import datetime
3
  import requests
4
  import pytz
5
  import yaml
6
- from tools.visit_webpage import VisitWebpageTool
7
  from tools.final_answer import FinalAnswerTool
8
  from Gradio_UI import GradioUI
9
 
10
- visit_web_page=VisitWebpageTool()
11
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
12
  @tool
13
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -27,20 +25,25 @@ def get_current_time_in_timezone(timezone: str) -> str:
27
 
28
  #Following my creation.
29
  @tool
30
- def get_news(topic: str) -> str:
31
- """Finds a newspaper article about a given topic.
32
  Args:
33
- topic: The topic to search for news.
34
- """
35
  try:
36
- search_tool=DuckDuckGoSearchTool(max_results=1)
37
- results = search_tool.forward(f"Today news about {topic}")
38
- if results:
39
- return f"Here's an url where you can read news about {topic}: {results}"
40
- else:
41
- return f"Sorry, I could not find any news about {topic}."
 
 
 
 
 
 
42
  except Exception as e:
43
- return f"Sorry, I couldn't find any news. Error: {e}"
44
 
45
  final_answer = FinalAnswerTool()
46
 
@@ -63,7 +66,7 @@ with open("prompts.yaml", 'r') as stream:
63
 
64
  agent = CodeAgent(
65
  model=model,
66
- tools=[get_news, final_answer, visit_web_page], ## add your tools here (don't remove final answer)
67
  max_steps=6,
68
  verbosity_level=1,
69
  grammar=None,
 
3
  import requests
4
  import pytz
5
  import yaml
 
6
  from tools.final_answer import FinalAnswerTool
7
  from Gradio_UI import GradioUI
8
 
 
9
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
10
  @tool
11
  def get_current_time_in_timezone(timezone: str) -> str:
 
25
 
26
  #Following my creation.
27
  @tool
28
+ def fibonacci(n: int) -> str:
29
+ """Returns the Fibonacci series up to the nth number.
30
  Args:
31
+ n: An integer number to indicate after how many numbers the fibonacci series should stop"""
 
32
  try:
33
+ # Initialize the Fibonacci sequence
34
+ fib_sequence = [0, 1]
35
+
36
+ if n > 30:
37
+ n=30
38
+ # Generate Fibonacci numbers up to n
39
+ for i in range(2, n):
40
+ fib_sequence.append(fib_sequence[-1] + fib_sequence[-2])
41
+
42
+ # Return the sequence as a string
43
+ return f"The Fibonacci series up to the {n}th number (but not higher than 30) is: {', '.join(map(str, fib_sequence))}"
44
+
45
  except Exception as e:
46
+ return f"Sorry, there was an error generating the Fibonacci series: {e}"
47
 
48
  final_answer = FinalAnswerTool()
49
 
 
66
 
67
  agent = CodeAgent(
68
  model=model,
69
+ tools=[fibonacci, final_answer], ## add your tools here (don't remove final answer)
70
  max_steps=6,
71
  verbosity_level=1,
72
  grammar=None,