Update app.py
Browse filesRemoved old comments and clutter
app.py
CHANGED
|
@@ -1,36 +1,28 @@
|
|
| 1 |
-
|
| 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 |
-
|
| 13 |
-
|
| 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
|
| 21 |
-
This will not retrieve the actual pages, but gives
|
| 22 |
-
|
| 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 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 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:
|