mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2026-01-10 09:44:26 +01:00
Patch master with fixes from release-v0.3 (#3694)
This commit is contained in:
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -4,7 +4,7 @@ on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
branches: [ master, stable ]
|
||||
|
||||
concurrency:
|
||||
group: ${{ format('ci-{0}', github.head_ref && format('pr-{0}', github.event.pull_request.number) || github.sha) }}
|
||||
|
||||
2
.github/workflows/docker-ci.yml
vendored
2
.github/workflows/docker-ci.yml
vendored
@@ -4,7 +4,7 @@ on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
branches: [ master, stable ]
|
||||
|
||||
concurrency:
|
||||
group: ${{ format('docker-ci-{0}', github.head_ref && format('pr-{0}', github.event.pull_request.number) || github.sha) }}
|
||||
|
||||
27
BULLETIN.md
27
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 🔌]
|
||||
|
||||
@@ -3,7 +3,7 @@ import logging
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from colorama import Fore
|
||||
from colorama import Fore, Style
|
||||
|
||||
from autogpt.agent.agent import Agent
|
||||
from autogpt.commands.command import CommandRegistry
|
||||
@@ -13,7 +13,11 @@ from autogpt.logs import logger
|
||||
from autogpt.memory import get_memory
|
||||
from autogpt.plugins import scan_plugins
|
||||
from 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 Workspace
|
||||
from 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(
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import os
|
||||
import re
|
||||
|
||||
import requests
|
||||
import yaml
|
||||
from colorama import Fore
|
||||
from colorama import Fore, Style
|
||||
from git.repo import Repo
|
||||
|
||||
from 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)
|
||||
|
||||
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "agpt"
|
||||
version = "0.2.2"
|
||||
version = "0.3.0"
|
||||
authors = [
|
||||
{ name="Torantulino", email="support@agpt.co" },
|
||||
]
|
||||
|
||||
@@ -56,67 +56,13 @@ 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_content
|
||||
bulletin = get_bulletin_from_web()
|
||||
|
||||
assert bulletin == "Test bulletin"
|
||||
|
||||
|
||||
@patch("requests.get")
|
||||
def test_get_bulletin_from_web_failure(mock_get):
|
||||
mock_get.return_value.status_code = 404
|
||||
bulletin = get_bulletin_from_web()
|
||||
print(bulletin)
|
||||
assert bulletin == ""
|
||||
|
||||
|
||||
@skip_in_ci
|
||||
def test_get_current_git_branch():
|
||||
branch_name = get_current_git_branch()
|
||||
|
||||
# Assuming that the branch name will be non-empty if the function is working correctly.
|
||||
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 "New bulletin" in bulletin
|
||||
|
||||
os.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"
|
||||
assert expected_content in bulletin
|
||||
mock_get.assert_called_with(
|
||||
"https://raw.githubusercontent.com/Significant-Gravitas/Auto-GPT/master/BULLETIN.md"
|
||||
)
|
||||
@@ -138,6 +84,62 @@ def test_get_bulletin_from_web_exception(mock_get):
|
||||
assert bulletin == ""
|
||||
|
||||
|
||||
def test_get_latest_bulletin_no_file():
|
||||
if os.path.exists("CURRENT_BULLETIN.md"):
|
||||
os.remove("CURRENT_BULLETIN.md")
|
||||
|
||||
bulletin, is_new = get_latest_bulletin()
|
||||
assert is_new
|
||||
|
||||
|
||||
def test_get_latest_bulletin_with_file():
|
||||
expected_content = "Test bulletin"
|
||||
with open("CURRENT_BULLETIN.md", "w", encoding="utf-8") as f:
|
||||
f.write(expected_content)
|
||||
|
||||
with patch("autogpt.utils.get_bulletin_from_web", return_value=""):
|
||||
bulletin, is_new = get_latest_bulletin()
|
||||
assert expected_content in bulletin
|
||||
assert is_new == False
|
||||
|
||||
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")
|
||||
|
||||
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_new
|
||||
|
||||
os.remove("CURRENT_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)
|
||||
|
||||
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
|
||||
|
||||
os.remove("CURRENT_BULLETIN.md")
|
||||
|
||||
|
||||
@skip_in_ci
|
||||
def test_get_current_git_branch():
|
||||
branch_name = get_current_git_branch()
|
||||
|
||||
# Assuming that the branch name will be non-empty if the function is working correctly.
|
||||
assert branch_name != ""
|
||||
|
||||
|
||||
@patch("autogpt.utils.Repo")
|
||||
def test_get_current_git_branch_success(mock_repo):
|
||||
mock_repo.return_value.active_branch.name = "test-branch"
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user