Spaces:
Sleeping
Sleeping
Added fetch_wikipedia_page_content
Browse files- app.py +12 -1
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -13,6 +13,8 @@ import pytz
|
|
| 13 |
import yaml
|
| 14 |
from tools.final_answer import FinalAnswerTool
|
| 15 |
|
|
|
|
|
|
|
| 16 |
huggingface_hub.login(os.getenv('HF_TOKEN'))
|
| 17 |
|
| 18 |
# (Keep Constants as is)
|
|
@@ -63,6 +65,15 @@ class VisitWebpageTool(Tool):
|
|
| 63 |
|
| 64 |
search_tool = DuckDuckGoSearchTool()
|
| 65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
@tool
|
| 67 |
def say_hello() -> str:
|
| 68 |
"""A tool that says hello
|
|
@@ -123,7 +134,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 123 |
|
| 124 |
agent = CodeAgent(
|
| 125 |
model=model,
|
| 126 |
-
tools=[final_answer, say_hello, image_generation_tool, search_tool, VisitWebpageTool()], ## add your tools here (don't remove final answer)
|
| 127 |
max_steps=10,
|
| 128 |
verbosity_level=1,
|
| 129 |
grammar=None,
|
|
|
|
| 13 |
import yaml
|
| 14 |
from tools.final_answer import FinalAnswerTool
|
| 15 |
|
| 16 |
+
import wikipedia
|
| 17 |
+
|
| 18 |
huggingface_hub.login(os.getenv('HF_TOKEN'))
|
| 19 |
|
| 20 |
# (Keep Constants as is)
|
|
|
|
| 65 |
|
| 66 |
search_tool = DuckDuckGoSearchTool()
|
| 67 |
|
| 68 |
+
@tool
|
| 69 |
+
def fetch_wikipedia_page_content(topic:str)-> str: #it's import to specify the return type
|
| 70 |
+
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 71 |
+
"""A tool that fetchs the contents of a page topic on Wikipedia
|
| 72 |
+
Args:
|
| 73 |
+
topic: the topic
|
| 74 |
+
"""
|
| 75 |
+
return wikipedia.page(topic).content
|
| 76 |
+
|
| 77 |
@tool
|
| 78 |
def say_hello() -> str:
|
| 79 |
"""A tool that says hello
|
|
|
|
| 134 |
|
| 135 |
agent = CodeAgent(
|
| 136 |
model=model,
|
| 137 |
+
tools=[fetch_wikipedia_page_content, final_answer, say_hello, image_generation_tool, search_tool, VisitWebpageTool()], ## add your tools here (don't remove final answer)
|
| 138 |
max_steps=10,
|
| 139 |
verbosity_level=1,
|
| 140 |
grammar=None,
|
requirements.txt
CHANGED
|
@@ -4,3 +4,4 @@ requests
|
|
| 4 |
markdownify
|
| 5 |
duckduckgo_search
|
| 6 |
pandas
|
|
|
|
|
|
| 4 |
markdownify
|
| 5 |
duckduckgo_search
|
| 6 |
pandas
|
| 7 |
+
wikipedia
|