Thanh Vinh Vo
commited on
Commit
·
d1db3c3
1
Parent(s):
bad363e
update
Browse files
app.py
CHANGED
|
@@ -28,14 +28,12 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
|
| 28 |
|
| 29 |
|
| 30 |
@tool
|
| 31 |
-
def extract_table_from_html(
|
| 32 |
"""
|
| 33 |
-
A tool that extracts
|
| 34 |
Example usecases include extracting tables from Wikipedia pages, HTML emails, or other web content.
|
| 35 |
Args:
|
| 36 |
-
|
| 37 |
-
string content or a URL to a webpage.
|
| 38 |
-
|
| 39 |
Returns:
|
| 40 |
list: A list of pandas DataFrames, where each DataFrame represents a table found
|
| 41 |
in the HTML content. Returns an empty list if no tables are found.
|
|
@@ -44,7 +42,7 @@ def extract_table_from_html(html: str) -> list:
|
|
| 44 |
|
| 45 |
try:
|
| 46 |
# Extract tables using pandas
|
| 47 |
-
tables = pd.read_html(
|
| 48 |
|
| 49 |
# Return the list of DataFrames directly
|
| 50 |
return tables if tables else []
|
|
@@ -203,7 +201,7 @@ class BasicAgent:
|
|
| 203 |
)
|
| 204 |
|
| 205 |
self.code_agent = CodeAgent(
|
| 206 |
-
tools=[VisitWebpageTool(), GoogleSearchTool("serper"), get_file, audio_to_text],
|
| 207 |
model=InferenceClientModel(
|
| 208 |
model_id="Qwen/Qwen2.5-Coder-32B-Instruct"
|
| 209 |
),
|
|
@@ -235,9 +233,8 @@ class BasicAgent:
|
|
| 235 |
- Parsing and extracting data from Wikipedia pages.
|
| 236 |
This agent follows rules below:
|
| 237 |
1. `wikipedia` Python package is provided, we should use it to search and retrieve Wikipedia pages.
|
| 238 |
-
2. `pandas` Python package is provided, we should use it to extract table data from Wikipedia pages.
|
| 239 |
""",
|
| 240 |
-
verbosity_level=
|
| 241 |
max_steps=10,
|
| 242 |
)
|
| 243 |
|
|
|
|
| 28 |
|
| 29 |
|
| 30 |
@tool
|
| 31 |
+
def extract_table_from_html(url: str) -> list:
|
| 32 |
"""
|
| 33 |
+
A tool that extracts table data from a website and returns them as pandas DataFrames.
|
| 34 |
Example usecases include extracting tables from Wikipedia pages, HTML emails, or other web content.
|
| 35 |
Args:
|
| 36 |
+
url (str): URL to a webpage.
|
|
|
|
|
|
|
| 37 |
Returns:
|
| 38 |
list: A list of pandas DataFrames, where each DataFrame represents a table found
|
| 39 |
in the HTML content. Returns an empty list if no tables are found.
|
|
|
|
| 42 |
|
| 43 |
try:
|
| 44 |
# Extract tables using pandas
|
| 45 |
+
tables = pd.read_html(url)
|
| 46 |
|
| 47 |
# Return the list of DataFrames directly
|
| 48 |
return tables if tables else []
|
|
|
|
| 201 |
)
|
| 202 |
|
| 203 |
self.code_agent = CodeAgent(
|
| 204 |
+
tools=[VisitWebpageTool(), GoogleSearchTool("serper"), get_file, audio_to_text, extract_table_from_html],
|
| 205 |
model=InferenceClientModel(
|
| 206 |
model_id="Qwen/Qwen2.5-Coder-32B-Instruct"
|
| 207 |
),
|
|
|
|
| 233 |
- Parsing and extracting data from Wikipedia pages.
|
| 234 |
This agent follows rules below:
|
| 235 |
1. `wikipedia` Python package is provided, we should use it to search and retrieve Wikipedia pages.
|
|
|
|
| 236 |
""",
|
| 237 |
+
verbosity_level=1,
|
| 238 |
max_steps=10,
|
| 239 |
)
|
| 240 |
|