import re from typing import Any, Dict, List from smolagents import tool @tool def find_in_page(page_content: Dict[str, Any], query: str) -> List[str]: """ Find occurrences of a query string in page content. Args: page_content: Page content returned by browse_webpage query: String to search for in the page Returns: List of sentences or sections containing the query """ results = [] if "content" in page_content: content = page_content["content"] # Split content into sentences sentences = re.split(r"(?<=[.!?])\s+", content) # Find sentences containing the query for sentence in sentences: if query.lower() in sentence.lower(): results.append(sentence) return results