diff --git a/.gitignore b/.gitignore index 26d7e5a3..85111ce9 100644 --- a/.gitignore +++ b/.gitignore @@ -157,3 +157,6 @@ vicuna-* # mac .DS_Store + +# news +CURRENT_BULLETIN.md \ No newline at end of file diff --git a/BULLETIN.md b/BULLETIN.md new file mode 100644 index 00000000..735048dd --- /dev/null +++ b/BULLETIN.md @@ -0,0 +1,2 @@ +Welcome to Auto-GPT! We'll keep you informed of the latest news and features by printing messages here. +If you don't wish to see this message, you can run Auto-GPT with the --skip-news flag \ No newline at end of file diff --git a/autogpt/cli.py b/autogpt/cli.py index 8ed9abb0..a69a53ac 100644 --- a/autogpt/cli.py +++ b/autogpt/cli.py @@ -42,6 +42,11 @@ import click is_flag=True, help="Dangerous: Allows Auto-GPT to download files natively.", ) +@click.option( + "--skip-news", + is_flag=True, + help="Specifies whether to suppress the output of latest news on startup.", +) @click.pass_context def main( ctx: click.Context, @@ -56,6 +61,7 @@ def main( memory_type: str, browser_name: str, allow_downloads: bool, + skip_news: bool, ) -> None: """ Welcome to AutoGPT an experimental open-source application showcasing the capabilities of the GPT-4 pushing the boundaries of AI. @@ -73,6 +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 if ctx.invoked_subcommand is None: cfg = Config() @@ -90,9 +97,14 @@ def main( memory_type, browser_name, allow_downloads, + skip_news, ) logger.set_level(logging.DEBUG if cfg.debug_mode else logging.INFO) ai_name = "" + if not cfg.skip_news: + motd = get_latest_bulletin() + if motd: + logger.typewriter_log("NEWS: ", Fore.GREEN, motd) system_prompt = construct_prompt() # print(prompt) # Initialize variables diff --git a/autogpt/config/config.py b/autogpt/config/config.py index bc75b031..763882ec 100644 --- a/autogpt/config/config.py +++ b/autogpt/config/config.py @@ -24,6 +24,7 @@ class Config(metaclass=Singleton): self.speak_mode = False self.skip_reprompt = False self.allow_downloads = False + self.skip_news = False self.selenium_web_browser = os.getenv("USE_WEB_BROWSER", "chrome") self.ai_settings_file = os.getenv("AI_SETTINGS_FILE", "ai_settings.yaml") diff --git a/autogpt/configurator.py b/autogpt/configurator.py index 247cdac9..1dc3be12 100644 --- a/autogpt/configurator.py +++ b/autogpt/configurator.py @@ -22,6 +22,7 @@ def create_config( memory_type: str, browser_name: str, allow_downloads: bool, + skip_news: bool, ) -> None: """Updates the config object with the given arguments. @@ -37,7 +38,7 @@ def create_config( memory_type (str): The type of memory backend to use browser_name (str): The name of the browser to use when using selenium to scrape the web allow_downloads (bool): Whether to allow Auto-GPT to download files natively - + skips_news (bool): Whether to suppress the output of latest news on startup """ CFG.set_debug_mode(False) CFG.set_continuous_mode(False) @@ -126,5 +127,8 @@ def create_config( ) CFG.allow_downloads = True + if skip_news: + CFG.skip_news = True + if browser_name: CFG.selenium_web_browser = browser_name diff --git a/autogpt/utils.py b/autogpt/utils.py index db7d3321..0e4ce5e9 100644 --- a/autogpt/utils.py +++ b/autogpt/utils.py @@ -1,3 +1,6 @@ +import os + +import requests import yaml from colorama import Fore @@ -37,3 +40,28 @@ def readable_file_size(size, decimal_places=2): break size /= 1024.0 return f"{size:.{decimal_places}f} {unit}" + + +def get_bulletin_from_web() -> str: + try: + response = requests.get( + "https://raw.githubusercontent.com/Significant-Gravitas/Auto-GPT/master/CONTRIBUTING.md" + ) + if response.status_code == 200: + return response.text + except: + return "" + + +def get_latest_bulletin() -> str: + exists = os.path.exists("CURRENT_BULLETIN.md") + current_bulletin = "" + if exists: + current_bulletin = open("CURRENT_BULLETIN.md", "r", encoding="utf-8").read() + new_bulletin = get_bulletin_from_web() + is_new_news = new_bulletin != current_bulletin + + if new_bulletin and is_new_news: + open("CURRENT_BULLETIN.md", "w", encoding="utf-8").write(new_bulletin) + return f" {Fore.RED}::UPDATED:: {Fore.CYAN}{new_bulletin}{Fore.RESET}" + return current_bulletin