import re from typing import List from smolagents import tool @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