Merge pull request #1229 from edcohen08/clone-github-repository

command clone github repository
This commit is contained in:
Richard Beales
2023-04-15 18:19:47 +01:00
committed by GitHub
7 changed files with 36 additions and 0 deletions

View File

@@ -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
################################################################################

View File

@@ -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 \

View File

@@ -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":

View File

@@ -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

View File

@@ -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")

View File

@@ -55,6 +55,7 @@ def get_prompt() -> str:
),
("List GPT Agents", "list_agents", {}),
("Delete GPT Agent", "delete_agent", {"key": "<key>"}),
("Clone Repository", "clone_repository", {"repository_url": "<url>", "clone_path": "<directory>"}),
("Write to file", "write_to_file", {"file": "<file>", "text": "<text>"}),
("Read file", "read_file", {"file": "<file>"}),
("Append to file", "append_to_file", {"file": "<file>", "text": "<text>"}),

View File

@@ -26,3 +26,4 @@ pre-commit
black
sourcery
isort
gitpython==3.1.31