diff --git a/Dockerfile b/Dockerfile index 3ae1ac12..d62751fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,11 +13,11 @@ RUN chown appuser:appuser /home/appuser USER appuser # Copy the requirements.txt file and install the requirements -COPY --chown=appuser:appuser requirements.txt . -RUN pip install --no-cache-dir --user -r requirements.txt +COPY --chown=appuser:appuser requirements-docker.txt . +RUN pip install --no-cache-dir --user -r requirements-docker.txt # Copy the application files -COPY --chown=appuser:appuser autogpt/ . +COPY --chown=appuser:appuser autogpt/ ./autogpt # Set the entrypoint ENTRYPOINT ["python", "-m", "autogpt"] diff --git a/autogpt/agent/agent_manager.py b/autogpt/agent/agent_manager.py index a22adff3..3467f8bf 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 key Args: diff --git a/autogpt/commands/web_requests.py b/autogpt/commands/web_requests.py index 59c3e522..97b23fe4 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 request Returns: - tuple[None, str] | tuple[Response, None]: The response and error message + Tuple[None, str] | Tuple[Response, None]: The response and error message Raises: ValueError: If the URL is invalid diff --git a/autogpt/commands/web_selenium.py b/autogpt/commands/web_selenium.py index 379d8cbe..ddcb3155 100644 --- a/autogpt/commands/web_selenium.py +++ b/autogpt/commands/web_selenium.py @@ -14,12 +14,13 @@ from selenium.webdriver.safari.options import Options as SafariOptions import logging from pathlib import Path from autogpt.config import Config +from typing import List, Tuple, Union FILE_DIR = Path(__file__).parent.parent CFG = 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 user Args: @@ -27,7 +28,7 @@ def browse_website(url: str, question: str) -> tuple[str, WebDriver]: question (str): The question asked by the user Returns: - 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) @@ -41,14 +42,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 selenium Args: url (str): The url of the website to scrape Returns: - 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) @@ -91,14 +92,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 selenium Args: driver (WebDriver): The webdriver to use to scrape the links Returns: - list[str]: The links scraped from the website + List[str]: The links scraped from the website """ page_source = driver.page_source soup = BeautifulSoup(page_source, "html.parser") @@ -123,26 +124,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 object Args: soup (BeautifulSoup): The BeautifulSoup object to extract the hyperlinks from Returns: - 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 user Args: - hyperlinks (list[tuple[str, str]]): The hyperlinks to format + hyperlinks (List[Tuple[str, str]]): The hyperlinks to format Returns: - list[str]: The formatted hyperlinks + List[str]: The formatted hyperlinks """ return [f"{link_text} ({link_url})" for link_text, link_url in hyperlinks] diff --git a/autogpt/llm_utils.py b/autogpt/llm_utils.py index f2418b65..260403e2 100644 --- a/autogpt/llm_utils.py +++ b/autogpt/llm_utils.py @@ -59,7 +59,7 @@ def create_chat_completion( """Create a chat completion using the OpenAI API Args: - messages (list[dict[str, str]]): The messages to send to the chat completion + messages (List[Dict[str, str]]): The messages to send to the chat completion model (str, optional): The model to use. Defaults to None. temperature (float, optional): The temperature to use. Defaults to 0.9. max_tokens (int, optional): The max tokens to use. Defaults to None. diff --git a/autogpt/processing/text.py b/autogpt/processing/text.py index 24e3bb85..d9e335f8 100644 --- a/autogpt/processing/text.py +++ b/autogpt/processing/text.py @@ -1,5 +1,5 @@ """Text processing functions""" -from typing import Generator, Optional +from typing import Generator, Optional, Dict from selenium.webdriver.remote.webdriver import WebDriver from autogpt.memory import get_memory from autogpt.config import Config @@ -114,7 +114,7 @@ def scroll_to_percentage(driver: WebDriver, ratio: float) -> None: driver.execute_script(f"window.scrollTo(0, document.body.scrollHeight * {ratio});") -def create_message(chunk: str, question: str) -> dict[str, str]: +def create_message(chunk: str, question: str) -> Dict[str, str]: """Create a message for the chat completion Args: @@ -122,7 +122,7 @@ def create_message(chunk: str, question: str) -> dict[str, str]: question (str): The question to answer Returns: - dict[str, str]: The message to send to the chat completion + Dict[str, str]: The message to send to the chat completion """ return { "role": "user", diff --git a/requirements-docker.txt b/requirements-docker.txt new file mode 100644 index 00000000..fecbd0a6 --- /dev/null +++ b/requirements-docker.txt @@ -0,0 +1,25 @@ +beautifulsoup4 +colorama==0.4.6 +openai==0.27.2 +playsound==1.2.2 +python-dotenv==1.0.0 +pyyaml==6.0 +readability-lxml==0.8.1 +requests +tiktoken==0.3.3 +gTTS==2.3.1 +docker +duckduckgo-search +google-api-python-client #(https://developers.google.com/custom-search/v1/overview) +pinecone-client==2.2.1 +redis +orjson +Pillow +selenium +webdriver-manager +coverage +flake8 +numpy +pre-commit +black +isort