diff --git a/.env.template b/.env.template index 352fd9c7..6d393e67 100644 --- a/.env.template +++ b/.env.template @@ -95,6 +95,16 @@ IMAGE_PROVIDER=dalle # HUGGINGFACE_API_TOKEN - HuggingFace API token (Example: my-huggingface-api-token) HUGGINGFACE_API_TOKEN=your-huggingface-api-token +################################################################################ +### GIT Provider for repository actions +################################################################################ + +### GITHUB +# GITHUB_API_KEY - Github API key / PAT (Example: github_pat_123) +# GITHUB_USERNAME - Github username +GITHUB_API_KEY=github_pat_123 +GITHUB_USERNAME=your-github-username + ################################################################################ ### SEARCH PROVIDER ################################################################################ diff --git a/Dockerfile b/Dockerfile index d62751fa..309b857c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,10 @@ # Use an official Python base image from the Docker Hub FROM python:3.11-slim +# Install git +RUN apt-get -y update +RUN apt-get -y install git + # Set environment variables ENV PIP_NO_CACHE_DIR=yes \ PYTHONUNBUFFERED=1 \ diff --git a/autogpt/app.py b/autogpt/app.py index 8d9cc9ee..66986786 100644 --- a/autogpt/app.py +++ b/autogpt/app.py @@ -22,6 +22,7 @@ from autogpt.memory import get_memory from autogpt.processing.text import summarize_text from autogpt.speech import say_text from autogpt.commands.web_selenium import browse_website +from autogpt.commands.git_operations import clone_repository CFG = Config() @@ -126,6 +127,8 @@ def execute_command(command_name: str, arguments): return get_text_summary(arguments["url"], arguments["question"]) elif command_name == "get_hyperlinks": return get_hyperlinks(arguments["url"]) + elif command_name == "clone_repository": + return clone_repository(arguments["repository_url"], arguments["clone_path"]) elif command_name == "read_file": return read_file(arguments["file"]) elif command_name == "write_to_file": diff --git a/autogpt/commands/git_operations.py b/autogpt/commands/git_operations.py new file mode 100644 index 00000000..87232589 --- /dev/null +++ b/autogpt/commands/git_operations.py @@ -0,0 +1,14 @@ +import git +from config import Config + +cfg = Config() + + +def clone_repository(repo_url, clone_path): + """Clone a github repository locally""" + split_url = repo_url.split("//") + auth_repo_url = f"//{cfg.github_username}:{cfg.github_api_key}@".join(split_url) + git.Repo.clone_from(auth_repo_url, clone_path) + result = f"""Cloned {repo_url} to {clone_path}""" + + return result diff --git a/autogpt/config/config.py b/autogpt/config/config.py index e3800b29..ed36be69 100644 --- a/autogpt/config/config.py +++ b/autogpt/config/config.py @@ -57,6 +57,9 @@ class Config(metaclass=Singleton): self.use_brian_tts = False self.use_brian_tts = os.getenv("USE_BRIAN_TTS") + self.github_api_key = os.getenv("GITHUB_API_KEY") + self.github_username = os.getenv("GITHUB_USERNAME") + self.google_api_key = os.getenv("GOOGLE_API_KEY") self.custom_search_engine_id = os.getenv("CUSTOM_SEARCH_ENGINE_ID") diff --git a/autogpt/prompt.py b/autogpt/prompt.py index 050c2560..20492978 100644 --- a/autogpt/prompt.py +++ b/autogpt/prompt.py @@ -55,6 +55,7 @@ def get_prompt() -> str: ), ("List GPT Agents", "list_agents", {}), ("Delete GPT Agent", "delete_agent", {"key": ""}), + ("Clone Repository", "clone_repository", {"repository_url": "", "clone_path": ""}), ("Write to file", "write_to_file", {"file": "", "text": ""}), ("Read file", "read_file", {"file": ""}), ("Append to file", "append_to_file", {"file": "", "text": ""}), diff --git a/requirements.txt b/requirements.txt index 5b862bd5..5ea6dcf8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -26,3 +26,4 @@ pre-commit black sourcery isort +gitpython==3.1.31