AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
Fix bulletin
Reinier van der Leer725abbb662cd
diff --git a/BULLETIN.md b/BULLETIN.mdindex 6c2b5c0aa5..5190b44880 100644--- a/BULLETIN.md+++ b/BULLETIN.md@@ -1,9 +1,24 @@-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+# Website and Documentation Site π°π+Check out *https://agpt.co*, the official news & updates site for Auto-GPT!+The documentation also has a place here, at *https://docs.agpt.co*-# INCLUDED COMMAND 'send_tweet' IS DEPRICATED, AND WILL BE REMOVED IN THE NEXT STABLE RELEASE-Base Twitter functionality (and more) is now covered by plugins: https://github.com/Significant-Gravitas/Auto-GPT-Plugins+# π v0.3.0 Release π+Over a week and 275 pull requests have passed since v0.2.2, and we are happy to announce+the release of v0.3.0! *From now on, we will be focusing on major improvements* rather+than bugfixes, as we feel stability has reached a reasonable level. Most remaining+issues relate to limitations in prompt generation and the memory system, which will be+the focus of our efforts for the next release.-## Changes to Docker configuration-The workdir has been changed from /home/appuser to /app. Be sure to update any volume mounts accordingly.+Highlights and notable changes in this release:+## Plugin support π+Auto-GPT now has support for plugins! With plugins, you can extend Auto-GPT's abilities,+adding support for third-party services and more.+See https://github.com/Significant-Gravitas/Auto-GPT-Plugins for instructions and available plugins.++## Changes to Docker configuration π+The workdir has been changed from */home/appuser* to */app*.+Be sure to update any volume mounts accordingly!++# β οΈ Command `send_tweet` is DEPRECATED, and will be removed in v0.4.0 β οΈ+Twitter functionality (and more) is now covered by plugins, see [Plugin support π]diff --git a/autogpt/main.py b/autogpt/main.pyindex fca8b47ded..355e1085c3 100644--- a/autogpt/main.py+++ b/autogpt/main.py@@ -3,7 +3,7 @@ import loggingimport sysfrom pathlib import Path-from colorama import Fore+from colorama import Fore, Stylefrom autogpt.agent.agent import Agentfrom autogpt.commands.command import CommandRegistry@@ -13,7 +13,11 @@ from autogpt.logs import loggerfrom autogpt.memory import get_memoryfrom autogpt.plugins import scan_pluginsfrom autogpt.prompts.prompt import DEFAULT_TRIGGERING_PROMPT, construct_main_ai_config-from autogpt.utils import get_current_git_branch, get_latest_bulletin+from autogpt.utils import (+ get_current_git_branch,+ get_latest_bulletin,+ markdown_to_ansi_style,+)from autogpt.workspace import Workspacefrom scripts.install_plugin_deps import install_plugin_dependencies@@ -57,9 +61,19 @@ def run_auto_gpt()if not cfg.skip_news:- motd = get_latest_bulletin()+ motd, is_new_motd = get_latest_bulletin()if motd:- logger.typewriter_log("NEWS: ", Fore.GREEN, motd)+ motd = markdown_to_ansi_style(motd)+ for motd_line in motd.split("\n"):+ logger.info(motd_line, "NEWS:", Fore.GREEN)+ if is_new_motd and not cfg.chat_messages_enabled:+ input(+ Fore.MAGENTA+ + Style.BRIGHT+ + "NEWS: Bulletin was updated! Press Enter to continue..."+ + Style.RESET_ALL+ )+git_branch = get_current_git_branch()if git_branch and git_branch != "stable":logger.typewriter_log(diff --git a/autogpt/utils.py b/autogpt/utils.pyindex 601254d74d..112a15080c 100644--- a/autogpt/utils.py+++ b/autogpt/utils.py@@ -1,8 +1,9 @@import os+import reimport requestsimport yaml-from colorama import Fore+from colorama import Fore, Stylefrom git.repo import Repofrom autogpt.logs import logger@@ -107,15 +108,46 @@ def get_current_git_branch() -> str:return ""-def get_latest_bulletin() -> str:+def get_latest_bulletin() -> tuple[str, bool]: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+ is_new_news = new_bulletin != "" and new_bulletin != current_bulletin++ news_header = Fore.YELLOW + "Welcome to Auto-GPT!\n"+ if new_bulletin or current_bulletin:+ news_header += (+ "Below you'll find the latest Auto-GPT News and updates regarding features!\n"+ "If you don't wish to see this message, you "+ "can run Auto-GPT with the *--skip-news* flag.\n"+ )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+ current_bulletin = f"{Fore.RED}::NEW BULLETIN::{Fore.RESET}\n\n{new_bulletin}"++ return f"{news_header}\n{current_bulletin}", is_new_news+++def markdown_to_ansi_style(markdown: str):+ ansi_lines: list[str] = []+ for line in markdown.split("\n"):+ line_style = ""++ if line.startswith("# "):+ line_style += Style.BRIGHT+ else:+ line = re.sub(+ r"(?<!\*)\*(\*?[^*]+\*?)\*(?!\*)",+ rf"{Style.BRIGHT}\1{Style.NORMAL}",+ line,+ )++ if re.match(r"^#+ ", line) is not None:+ line_style += Fore.CYAN+ line = re.sub(r"^#+ ", "", line)++ ansi_lines.append(f"{line_style}{line}{Style.RESET_ALL}")+ return "\n".join(ansi_lines)diff --git a/tests/test_utils.py b/tests/test_utils.pyindex fdea83d4ca..5b4d181c15 100644--- a/tests/test_utils.py+++ b/tests/test_utils.py@@ -56,45 +56,51 @@ def test_readable_file_size():@patch("requests.get")def test_get_bulletin_from_web_success(mock_get):+ expected_content = "Test bulletin from web"+mock_get.return_value.status_code = 200- mock_get.return_value.text = "Test bulletin"+ mock_get.return_value.text = expected_contentbulletin = get_bulletin_from_web()- assert bulletin == "Test bulletin"+ assert expected_content in bulletin+ mock_get.assert_called_with(+ "https://raw.githubusercontent.com/Significant-Gravitas/Auto-GPT/master/BULLETIN.md"+ )@patch("requests.get")def test_get_bulletin_from_web_failure(mock_get):mock_get.return_value.status_code = 404bulletin = get_bulletin_from_web()- print(bulletin)+assert bulletin == ""-@skip_in_ci-def test_get_current_git_branch():- branch_name = get_current_git_branch()+@patch("requests.get")+def test_get_bulletin_from_web_exception(mock_get):+ mock_get.side_effect = requests.exceptions.RequestException()+ bulletin = get_bulletin_from_web()- # Assuming that the branch name will be non-empty if the function is working correctly.- assert branch_name != ""+ assert bulletin == ""def test_get_latest_bulletin_no_file():if os.path.exists("CURRENT_BULLETIN.md"):os.remove("CURRENT_BULLETIN.md")- with patch("autogpt.utils.get_bulletin_from_web", return_value=""):- bulletin = get_latest_bulletin()- assert bulletin == ""+ bulletin, is_new = get_latest_bulletin()+ assert is_newdef test_get_latest_bulletin_with_file():+ expected_content = "Test bulletin"with open("CURRENT_BULLETIN.md", "w", encoding="utf-8") as f:- f.write("Test bulletin")+ f.write(expected_content)with patch("autogpt.utils.get_bulletin_from_web", return_value=""):- bulletin = get_latest_bulletin()- assert bulletin == "Test bulletin"+ bulletin, is_new = get_latest_bulletin()+ assert expected_content in bulletin+ assert is_new == Falseos.remove("CURRENT_BULLETIN.md")@@ -103,39 +109,35 @@ def test_get_latest_bulletin_with_new_bulletin():with open("CURRENT_BULLETIN.md", "w", encoding="utf-8") as f:f.write("Old bulletin")- with patch("autogpt.utils.get_bulletin_from_web", return_value="New bulletin"):- bulletin = get_latest_bulletin()- assert "New bulletin" in bulletin+ expected_content = "New bulletin from web"+ with patch("autogpt.utils.get_bulletin_from_web", return_value=expected_content):+ bulletin, is_new = get_latest_bulletin()+ assert "::NEW BULLETIN::" in bulletin+ assert expected_content in bulletin+ assert is_newos.remove("CURRENT_BULLETIN.md")-@patch("requests.get")-def test_get_bulletin_from_web_success(mock_get):- mock_get.return_value.status_code = 200- mock_get.return_value.text = "Test bulletin"- bulletin = get_bulletin_from_web()-- assert bulletin == "Test bulletin"- mock_get.assert_called_with(- "https://raw.githubusercontent.com/Significant-Gravitas/Auto-GPT/master/BULLETIN.md"- )-+def test_get_latest_bulletin_new_bulletin_same_as_old_bulletin():+ expected_content = "Current bulletin"+ with open("CURRENT_BULLETIN.md", "w", encoding="utf-8") as f:+ f.write(expected_content)-@patch("requests.get")-def test_get_bulletin_from_web_failure(mock_get):- mock_get.return_value.status_code = 404- bulletin = get_bulletin_from_web()+ with patch("autogpt.utils.get_bulletin_from_web", return_value=expected_content):+ bulletin, is_new = get_latest_bulletin()+ assert expected_content in bulletin+ assert is_new == False- assert bulletin == ""+ os.remove("CURRENT_BULLETIN.md")-@patch("requests.get")-def test_get_bulletin_from_web_exception(mock_get):- mock_get.side_effect = requests.exceptions.RequestException()- bulletin = get_bulletin_from_web()+@skip_in_ci+def test_get_current_git_branch():+ branch_name = get_current_git_branch()- assert bulletin == ""+ # Assuming that the branch name will be non-empty if the function is working correctly.+ assert branch_name != ""@patch("autogpt.utils.Repo")@@ -154,47 +156,5 @@ def test_get_current_git_branch_failure(mock_repo):assert branch_name == ""-def test_get_latest_bulletin_no_file():- if os.path.exists("CURRENT_BULLETIN.md"):- os.remove("CURRENT_BULLETIN.md")-- with patch("autogpt.utils.get_bulletin_from_web", return_value=""):- bulletin = get_latest_bulletin()- assert bulletin == ""---def test_get_latest_bulletin_with_file():- with open("CURRENT_BULLETIN.md", "w", encoding="utf-8") as f:- f.write("Test bulletin")-- with patch("autogpt.utils.get_bulletin_from_web", return_value=""):- bulletin = get_latest_bulletin()- assert bulletin == "Test bulletin"-- os.remove("CURRENT_BULLETIN.md")---def test_get_latest_bulletin_with_new_bulletin():- with open("CURRENT_BULLETIN.md", "w", encoding="utf-8") as f:- f.write("Old bulletin")-- with patch("autogpt.utils.get_bulletin_from_web", return_value="New bulletin"):- bulletin = get_latest_bulletin()- assert f" {Fore.RED}::UPDATED:: {Fore.CYAN}New bulletin{Fore.RESET}" in bulletin-- os.remove("CURRENT_BULLETIN.md")---def test_get_latest_bulletin_new_bulletin_same_as_old_bulletin():- with open("CURRENT_BULLETIN.md", "w", encoding="utf-8") as f:- f.write("Test bulletin")-- with patch("autogpt.utils.get_bulletin_from_web", return_value="Test bulletin"):- bulletin = get_latest_bulletin()- assert bulletin == "Test bulletin"-- os.remove("CURRENT_BULLETIN.md")--if __name__ == "__main__":pytest.main()