AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
update type annotation
youkaichaoafd2c5e2c6c3
diff --git a/autogpt/agent/agent_manager.py b/autogpt/agent/agent_manager.pyindex a22adff38f..3467f8bf33 100644--- a/autogpt/agent/agent_manager.py+++ b/autogpt/agent/agent_manager.py@@ -14,7 +14,7 @@ class AgentManager(metaclass=Singleton):# Create new GPT agent# TODO: Centralise use of create_chat_completion() to globally enforce token limit- def create_agent(self, task: str, prompt: str, model: str) -> tuple[int, str]:+ def create_agent(self, task: str, prompt: str, model: str) -> Tuple[int, str]:"""Create a new agent and return its keyArgs:diff --git a/autogpt/commands/web_requests.py b/autogpt/commands/web_requests.pyindex 59c3e5229f..97b23fe4e2 100644--- a/autogpt/commands/web_requests.py+++ b/autogpt/commands/web_requests.py@@ -72,7 +72,7 @@ def get_response(timeout (int): The timeout for the HTTP requestReturns:- tuple[None, str] | tuple[Response, None]: The response and error message+ Tuple[None, str] | Tuple[Response, None]: The response and error messageRaises:ValueError: If the URL is invaliddiff --git a/autogpt/commands/web_selenium.py b/autogpt/commands/web_selenium.pyindex 4d5703aa88..727695ef2f 100644--- a/autogpt/commands/web_selenium.py+++ b/autogpt/commands/web_selenium.py@@ -11,12 +11,13 @@ from selenium.webdriver.chrome.options import Optionsimport loggingfrom pathlib import Pathfrom autogpt.config import Config+from typing import List, Tuple, UnionFILE_DIR = Path(__file__).parent.parentCFG = Config()-def browse_website(url: str, question: str) -> tuple[str, WebDriver]:+def browse_website(url: str, question: str) -> Tuple[str, WebDriver]:"""Browse a website and return the answer and links to the userArgs:@@ -24,7 +25,7 @@ def browse_website(url: str, question: str) -> tuple[str, WebDriver]:question (str): The question asked by the userReturns:- tuple[str, WebDriver]: The answer and links to the user and the webdriver+ Tuple[str, WebDriver]: The answer and links to the user and the webdriver"""driver, text = scrape_text_with_selenium(url)add_header(driver)@@ -38,14 +39,14 @@ def browse_website(url: str, question: str) -> tuple[str, WebDriver]:return f"Answer gathered from website: {summary_text} \n \n Links: {links}", driver-def scrape_text_with_selenium(url: str) -> tuple[WebDriver, str]:+def scrape_text_with_selenium(url: str) -> Tuple[WebDriver, str]:"""Scrape text from a website using seleniumArgs:url (str): The url of the website to scrapeReturns:- tuple[WebDriver, str]: The webdriver and the text scraped from the website+ Tuple[WebDriver, str]: The webdriver and the text scraped from the website"""logging.getLogger("selenium").setLevel(logging.CRITICAL)@@ -77,14 +78,14 @@ def scrape_text_with_selenium(url: str) -> tuple[WebDriver, str]:return driver, text-def scrape_links_with_selenium(driver: WebDriver) -> list[str]:+def scrape_links_with_selenium(driver: WebDriver) -> List[str]:"""Scrape links from a website using seleniumArgs:driver (WebDriver): The webdriver to use to scrape the linksReturns:- list[str]: The links scraped from the website+ List[str]: The links scraped from the website"""page_source = driver.page_sourcesoup = BeautifulSoup(page_source, "html.parser")@@ -109,26 +110,26 @@ def close_browser(driver: WebDriver) -> None:driver.quit()-def extract_hyperlinks(soup: BeautifulSoup) -> list[tuple[str, str]]:+def extract_hyperlinks(soup: BeautifulSoup) -> List[Tuple[str, str]]:"""Extract hyperlinks from a BeautifulSoup objectArgs:soup (BeautifulSoup): The BeautifulSoup object to extract the hyperlinks fromReturns:- list[tuple[str, str]]: The hyperlinks extracted from the BeautifulSoup object+ List[Tuple[str, str]]: The hyperlinks extracted from the BeautifulSoup object"""return [(link.text, link["href"]) for link in soup.find_all("a", href=True)]-def format_hyperlinks(hyperlinks: list[tuple[str, str]]) -> list[str]:+def format_hyperlinks(hyperlinks: List[Tuple[str, str]]) -> List[str]:"""Format hyperlinks to be displayed to the userArgs:- hyperlinks (list[tuple[str, str]]): The hyperlinks to format+ hyperlinks (List[Tuple[str, str]]): The hyperlinks to formatReturns:- list[str]: The formatted hyperlinks+ List[str]: The formatted hyperlinks"""return [f"{link_text} ({link_url})" for link_text, link_url in hyperlinks]