happyday1 commited on
Commit
476c6d3
·
verified ·
1 Parent(s): 2fef3ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -4,19 +4,26 @@ import requests
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
 
7
 
8
  from Gradio_UI import GradioUI
9
 
10
- # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
- def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
- #Keep this format for the description / args / args description but feel free to modify the tool
14
- """A tool that does nothing yet
15
  Args:
16
- arg1: the first argument
17
- arg2: the second argument
 
18
  """
19
- return "What magic will you build ?"
 
 
 
 
 
 
 
20
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
 
4
  import pytz
5
  import yaml
6
  from tools.final_answer import FinalAnswerTool
7
+ import wikipedia
8
 
9
  from Gradio_UI import GradioUI
10
 
 
11
  @tool
12
+ def wikipedia_search(question: str) -> str:
13
+ """Search Wikipedia for factual information about a topic, person, place or concept.
 
14
  Args:
15
+ Question about a topic, person, place, or concept: str
16
+ Output:
17
+ Answer to the question based on content in wikipedia: str
18
  """
19
+ try:
20
+ return wikipedia.summary(question)
21
+ except wikipedia.exceptions.PageError:
22
+ return "Wikipedia page not found for the question."
23
+ except wikipedia.exceptions.DisambiguationError as e:
24
+ return "Wikipedia found multiple possible pages, please be more specific: " + str(e.options)
25
+ except Exception as e:
26
+ return f"An error occurred while searching Wikipedia: {e}"
27
 
28
  @tool
29
  def get_current_time_in_timezone(timezone: str) -> str: