Spaces:
Sleeping
Sleeping
Enhance agent functionality in main_v2.py by adding WikipediaSearchTool and updating DuckDuckGoSearchTool and VisitWebpageTool parameters. Modify agent initialization to accommodate new tools and increase max results and output length. Update requirements.txt to include Wikipedia-API dependency. Refactor imports for better organization across agent modules.
e4c7240
unverified
| import io | |
| from typing import Any, Dict | |
| import pandas as pd | |
| import requests | |
| 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)} | |