RemVdH commited on
Commit
2abba01
·
verified ·
1 Parent(s): d02327e

Update app.py

Browse files

Removed old comments and clutter

Files changed (1) hide show
  1. app.py +11 -19
app.py CHANGED
@@ -1,36 +1,28 @@
1
- # from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
  from smolagents import CodeAgent, HfApiModel, load_tool, tool
3
- # import datetime
4
- # import requests
5
- # import pytz
6
- import yaml
7
- import wikipedia
8
  from tools.final_answer import FinalAnswerTool
9
  from typing import List
10
  from Gradio_UI import GradioUI
11
 
12
- # import gradio as gr
13
- # from huggingface_hub import InferenceClient
14
- # from smolagents import CodeAgent, HfApiModel, load_tool, tool
15
- # from tools.final_answer import FinalAnswerTool
16
- # from Gradio_UI import GradioUI
17
 
18
  @tool
19
  def search_wikipedia_pages(search_string: str) -> List[str]:
20
- """This tool helps to search for the names of the wikipedia pages related to a search string.
21
- This will not retrieve the actual pages, but gives a good oversight of the different pages on wikipedia to find more information.
22
- The output are the first 10 pages related to the search string in a list of strings.
23
  Args:
24
  search_string: the search string
25
  """
26
  try:
27
  page_titles = wikipedia.search(search_string, results=10)
28
  return page_titles
29
- except (
30
- self.wiki_client.exceptions.PageError,
31
- self.wiki_client.exceptions.DisambiguationError,
32
- ):
33
- print ("An error occured")
34
 
35
  @tool
36
  def get_wikipedia_page_content(page_name: str) -> str:
 
1
+
2
  from smolagents import CodeAgent, HfApiModel, load_tool, tool
 
 
 
 
 
3
  from tools.final_answer import FinalAnswerTool
4
  from typing import List
5
  from Gradio_UI import GradioUI
6
 
7
+ import yaml
8
+ import wikipedia
 
 
 
9
 
10
  @tool
11
  def search_wikipedia_pages(search_string: str) -> List[str]:
12
+ """This tool helps to search for the names of wikipedia pages that relate to a search string.
13
+ This will not retrieve the actual pages, but gives oversight of the different pages on wikipedia to find more information.
14
+ This tool will output the first 10 pages related to the search string as a list of strings.
15
  Args:
16
  search_string: the search string
17
  """
18
  try:
19
  page_titles = wikipedia.search(search_string, results=10)
20
  return page_titles
21
+ except wikipedia.exceptions.PageError:
22
+ s_error = "PageError"
23
+ except wikipedia.exceptions.DisambiguationError:
24
+ s_error = "DisambiguationError"
25
+ print (f"An error occured {s_error}")
26
 
27
  @tool
28
  def get_wikipedia_page_content(page_name: str) -> str: