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 re | |
from typing import List | |
from smolagents import tool | |
def extract_dates(text: str) -> List[str]: | |
""" | |
Extract dates from text content. | |
Args: | |
text: Text content to extract dates from | |
Returns: | |
List of date strings found in the text | |
""" | |
# Simple regex patterns for date extraction | |
# These patterns can be expanded for better coverage | |
date_patterns = [ | |
r"\d{1,2}/\d{1,2}/\d{2,4}", # MM/DD/YYYY or DD/MM/YYYY | |
r"\d{1,2}-\d{1,2}-\d{2,4}", # MM-DD-YYYY or DD-MM-YYYY | |
r"\b(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]* \d{1,2},? \d{4}\b", # Month DD, YYYY | |
r"\b\d{1,2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]* \d{4}\b", # DD Month YYYY | |
] | |
results = [] | |
for pattern in date_patterns: | |
matches = re.findall(pattern, text, re.IGNORECASE) | |
results.extend(matches) | |
return results | |