Skip to content

Commit

Permalink
Added ability to output news/announcements on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
richbeales committed Apr 18, 2023
1 parent 5752a46 commit 4a07790
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
2 changes: 2 additions & 0 deletions BULLETIN.md
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions autogpt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
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,
Expand All @@ -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.
Expand All @@ -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()
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions autogpt/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self) -> None:
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")
Expand Down
6 changes: 5 additions & 1 deletion autogpt/configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down Expand Up @@ -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
9 changes: 9 additions & 0 deletions autogpt/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import yaml
from colorama import Fore
import requests


def clean_input(prompt: str = ""):
Expand Down Expand Up @@ -37,3 +38,11 @@ def readable_file_size(size, decimal_places=2):
break
size /= 1024.0
return f"{size:.{decimal_places}f} {unit}"

def get_latest_bulletin() -> str:
try:
response = requests.get('https://raw.githubusercontent.com/Significant-Gravitas/Auto-GPT/master/BULLETIN.md')
if response.status_code == 200:
return response.text
except:
return ""

0 comments on commit 4a07790

Please sign in to comment.