diff --git a/autogpt/cli.py b/autogpt/cli.py index a69a53acc..a2e99cb42 100644 --- a/autogpt/cli.py +++ b/autogpt/cli.py @@ -79,7 +79,7 @@ def main( from autogpt.logs import logger from autogpt.memory import get_memory from autogpt.prompt import construct_prompt - from autogpt.utils import get_latest_bulletin + from autogpt.utils import get_current_git_branch, get_latest_bulletin if ctx.invoked_subcommand is None: cfg = Config() @@ -105,6 +105,14 @@ def main( motd = get_latest_bulletin() if motd: logger.typewriter_log("NEWS: ", Fore.GREEN, motd) + git_branch = get_current_git_branch() + if git_branch and git_branch != "stable": + logger.typewriter_log( + "WARNING: ", + Fore.RED, + f"You are running on `{git_branch}` branch " + "- this is not a supported branch.", + ) system_prompt = construct_prompt() # print(prompt) # Initialize variables diff --git a/autogpt/utils.py b/autogpt/utils.py index 0f52c060f..e93d5ac74 100644 --- a/autogpt/utils.py +++ b/autogpt/utils.py @@ -3,6 +3,7 @@ import os import requests import yaml from colorama import Fore +from git import Repo def clean_input(prompt: str = ""): @@ -53,6 +54,15 @@ def get_bulletin_from_web() -> str: return "" +def get_current_git_branch() -> str: + try: + repo = Repo(search_parent_directories=True) + branch = repo.active_branch + return branch.name + except: + return "" + + def get_latest_bulletin() -> str: exists = os.path.exists("CURRENT_BULLETIN.md") current_bulletin = ""