Thanh Vinh Vo
commited on
Commit
·
ee7c16d
1
Parent(s):
8bbf29a
update
Browse files
app.py
CHANGED
|
@@ -26,36 +26,6 @@ import whisper
|
|
| 26 |
# --- Constants ---
|
| 27 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 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.
|
| 40 |
-
"""
|
| 41 |
-
import pandas as pd
|
| 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 []
|
| 49 |
-
|
| 50 |
-
except ValueError as e:
|
| 51 |
-
if "No tables found" in str(e):
|
| 52 |
-
# Return empty list instead of raising error
|
| 53 |
-
return []
|
| 54 |
-
else:
|
| 55 |
-
raise ValueError(f"Error extracting tables from HTML content: {e}")
|
| 56 |
-
except Exception as e:
|
| 57 |
-
raise Exception(f"Failed to extract tables from HTML content: {e}")
|
| 58 |
-
|
| 59 |
@tool
|
| 60 |
def audio_to_text(file_path: str) -> str:
|
| 61 |
"""
|
|
@@ -201,7 +171,7 @@ class BasicAgent:
|
|
| 201 |
)
|
| 202 |
|
| 203 |
self.code_agent = CodeAgent(
|
| 204 |
-
tools=[VisitWebpageTool(), GoogleSearchTool("serper"), get_file, audio_to_text
|
| 205 |
model=InferenceClientModel(
|
| 206 |
model_id="Qwen/Qwen2.5-Coder-32B-Instruct"
|
| 207 |
),
|
|
|
|
| 26 |
# --- Constants ---
|
| 27 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
@tool
|
| 30 |
def audio_to_text(file_path: str) -> str:
|
| 31 |
"""
|
|
|
|
| 171 |
)
|
| 172 |
|
| 173 |
self.code_agent = CodeAgent(
|
| 174 |
+
tools=[VisitWebpageTool(), GoogleSearchTool("serper"), get_file, audio_to_text],
|
| 175 |
model=InferenceClientModel(
|
| 176 |
model_id="Qwen/Qwen2.5-Coder-32B-Instruct"
|
| 177 |
),
|