Spaces:
Build error
Build error
Refactor agent structure by modularizing agent implementations into separate directories for web, data analysis, and media agents. Remove legacy code from agents.py, prompts.py, and tools.py, enhancing maintainability. Update main_v2.py to reflect new import paths and agent initialization. Add new tools for enhanced functionality, including web searching and data extraction. Update requirements.txt to include necessary dependencies for new tools.
837e221
unverified
import io | |
from typing import Dict, Any | |
import requests | |
import pandas as pd | |
from smolagents import tool | |
def parse_csv(csv_url: str) -> Dict[str, Any]: | |
""" | |
Parse a CSV file and return its content as structured data. | |
Args: | |
csv_url: URL of the CSV file to parse | |
Returns: | |
Dictionary containing parsed CSV data | |
""" | |
try: | |
# Download the CSV | |
response = requests.get(csv_url) | |
response.raise_for_status() | |
# Parse the CSV | |
df = pd.read_csv(io.StringIO(response.text)) | |
# Convert to dictionary format | |
columns = df.columns.tolist() | |
data = df.to_dict(orient="records") | |
# Return basic statistics and preview | |
return { | |
"columns": columns, | |
"row_count": len(data), | |
"preview": data[:5] if len(data) > 5 else data, | |
"column_dtypes": {col: str(df[col].dtype) for col in columns}, | |
} | |
except Exception as e: | |
return {"error": str(e)} |