mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-19 15:04:26 +01:00
Merge branch 'Significant-Gravitas:master' into master
This commit is contained in:
@@ -13,11 +13,11 @@ RUN chown appuser:appuser /home/appuser
|
|||||||
USER appuser
|
USER appuser
|
||||||
|
|
||||||
# Copy the requirements.txt file and install the requirements
|
# Copy the requirements.txt file and install the requirements
|
||||||
COPY --chown=appuser:appuser requirements.txt .
|
COPY --chown=appuser:appuser requirements-docker.txt .
|
||||||
RUN pip install --no-cache-dir --user -r requirements.txt
|
RUN pip install --no-cache-dir --user -r requirements-docker.txt
|
||||||
|
|
||||||
# Copy the application files
|
# Copy the application files
|
||||||
COPY --chown=appuser:appuser autogpt/ .
|
COPY --chown=appuser:appuser autogpt/ ./autogpt
|
||||||
|
|
||||||
# Set the entrypoint
|
# Set the entrypoint
|
||||||
ENTRYPOINT ["python", "-m", "autogpt"]
|
ENTRYPOINT ["python", "-m", "autogpt"]
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class AgentManager(metaclass=Singleton):
|
|||||||
# Create new GPT agent
|
# Create new GPT agent
|
||||||
# TODO: Centralise use of create_chat_completion() to globally enforce token limit
|
# 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
|
"""Create a new agent and return its key
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ def get_response(
|
|||||||
timeout (int): The timeout for the HTTP request
|
timeout (int): The timeout for the HTTP request
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
tuple[None, str] | tuple[Response, None]: The response and error message
|
Tuple[None, str] | Tuple[Response, None]: The response and error message
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
ValueError: If the URL is invalid
|
ValueError: If the URL is invalid
|
||||||
|
|||||||
@@ -14,12 +14,13 @@ from selenium.webdriver.safari.options import Options as SafariOptions
|
|||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from autogpt.config import Config
|
from autogpt.config import Config
|
||||||
|
from typing import List, Tuple, Union
|
||||||
|
|
||||||
FILE_DIR = Path(__file__).parent.parent
|
FILE_DIR = Path(__file__).parent.parent
|
||||||
CFG = Config()
|
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
|
"""Browse a website and return the answer and links to the user
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -27,7 +28,7 @@ def browse_website(url: str, question: str) -> tuple[str, WebDriver]:
|
|||||||
question (str): The question asked by the user
|
question (str): The question asked by the user
|
||||||
|
|
||||||
Returns:
|
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)
|
driver, text = scrape_text_with_selenium(url)
|
||||||
add_header(driver)
|
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
|
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
|
"""Scrape text from a website using selenium
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
url (str): The url of the website to scrape
|
url (str): The url of the website to scrape
|
||||||
|
|
||||||
Returns:
|
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)
|
logging.getLogger("selenium").setLevel(logging.CRITICAL)
|
||||||
|
|
||||||
@@ -91,14 +92,14 @@ def scrape_text_with_selenium(url: str) -> tuple[WebDriver, str]:
|
|||||||
return driver, text
|
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
|
"""Scrape links from a website using selenium
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
driver (WebDriver): The webdriver to use to scrape the links
|
driver (WebDriver): The webdriver to use to scrape the links
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list[str]: The links scraped from the website
|
List[str]: The links scraped from the website
|
||||||
"""
|
"""
|
||||||
page_source = driver.page_source
|
page_source = driver.page_source
|
||||||
soup = BeautifulSoup(page_source, "html.parser")
|
soup = BeautifulSoup(page_source, "html.parser")
|
||||||
@@ -123,26 +124,26 @@ def close_browser(driver: WebDriver) -> None:
|
|||||||
driver.quit()
|
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
|
"""Extract hyperlinks from a BeautifulSoup object
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
soup (BeautifulSoup): The BeautifulSoup object to extract the hyperlinks from
|
soup (BeautifulSoup): The BeautifulSoup object to extract the hyperlinks from
|
||||||
|
|
||||||
Returns:
|
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)]
|
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
|
"""Format hyperlinks to be displayed to the user
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
hyperlinks (list[tuple[str, str]]): The hyperlinks to format
|
hyperlinks (List[Tuple[str, str]]): The hyperlinks to format
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list[str]: The formatted hyperlinks
|
List[str]: The formatted hyperlinks
|
||||||
"""
|
"""
|
||||||
return [f"{link_text} ({link_url})" for link_text, link_url in hyperlinks]
|
return [f"{link_text} ({link_url})" for link_text, link_url in hyperlinks]
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ def create_chat_completion(
|
|||||||
"""Create a chat completion using the OpenAI API
|
"""Create a chat completion using the OpenAI API
|
||||||
|
|
||||||
Args:
|
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.
|
model (str, optional): The model to use. Defaults to None.
|
||||||
temperature (float, optional): The temperature to use. Defaults to 0.9.
|
temperature (float, optional): The temperature to use. Defaults to 0.9.
|
||||||
max_tokens (int, optional): The max tokens to use. Defaults to None.
|
max_tokens (int, optional): The max tokens to use. Defaults to None.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"""Text processing functions"""
|
"""Text processing functions"""
|
||||||
from typing import Generator, Optional
|
from typing import Generator, Optional, Dict
|
||||||
from selenium.webdriver.remote.webdriver import WebDriver
|
from selenium.webdriver.remote.webdriver import WebDriver
|
||||||
from autogpt.memory import get_memory
|
from autogpt.memory import get_memory
|
||||||
from autogpt.config import Config
|
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});")
|
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
|
"""Create a message for the chat completion
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -122,7 +122,7 @@ def create_message(chunk: str, question: str) -> dict[str, str]:
|
|||||||
question (str): The question to answer
|
question (str): The question to answer
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict[str, str]: The message to send to the chat completion
|
Dict[str, str]: The message to send to the chat completion
|
||||||
"""
|
"""
|
||||||
return {
|
return {
|
||||||
"role": "user",
|
"role": "user",
|
||||||
|
|||||||
25
requirements-docker.txt
Normal file
25
requirements-docker.txt
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user