from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool import datetime import requests import pytz import yaml from tools.final_answer import FinalAnswerTool from Gradio_UI import GradioUI from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager @tool def get_zh_top_news() -> tuple[str, str]: """A tool that retrieves the current top news article's title and URL from www.zerohedge.com. Returns: tuple[str, str]: A tuple containing the article title (str) and its URL (str). Raises: Exception: If the page fails to load or the expected element is not found. """ # Set up Chrome options for headless browsing chrome_options = Options() chrome_options.add_argument("--headless") # Run without opening a browser window chrome_options.add_argument("--disable-gpu") # Disable GPU for headless mode chrome_options.add_argument("--no-sandbox") # Required for Docker environments chrome_options.add_argument("--disable-dev-shm-usage") # Avoid memory issues in containers # Specify ChromeDriver path (installed via Dockerfile) service = Service(executable_path="/usr/local/bin/chromedriver") # Initialize the WebDriver driver = webdriver.Chrome(service=service, options=chrome_options) try: # Navigate to ZeroHedge homepage driver.get("https://www.zerohedge.com") # Find the first