aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Richard Beales <rich@richbeales.net> 2023-04-18 21:45:09 +0100
committerGravatar Richard Beales <rich@richbeales.net> 2023-04-18 21:45:09 +0100
commit88ebebf74fecf43703a476fdce27ca66d4295ea3 (patch)
treedfd2a5be7011f112ac50600b80c82d94d5cb3867
parentisort (diff)
downloadAuto-GPT-88ebebf74fecf43703a476fdce27ca66d4295ea3.tar.gz
Auto-GPT-88ebebf74fecf43703a476fdce27ca66d4295ea3.tar.bz2
Auto-GPT-88ebebf74fecf43703a476fdce27ca66d4295ea3.zip
Implement suggestions from pi - save current news to file
-rw-r--r--.gitignore3
-rw-r--r--autogpt/utils.py20
2 files changed, 21 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 26d7e5a3f..85111ce97 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/autogpt/utils.py b/autogpt/utils.py
index ab7fe82af..0e4ce5e9a 100644
--- a/autogpt/utils.py
+++ b/autogpt/utils.py
@@ -1,3 +1,5 @@
+import os
+
import requests
import yaml
from colorama import Fore
@@ -40,12 +42,26 @@ def readable_file_size(size, decimal_places=2):
return f"{size:.{decimal_places}f} {unit}"
-def get_latest_bulletin() -> str:
+def get_bulletin_from_web() -> str:
try:
response = requests.get(
- "https://raw.githubusercontent.com/Significant-Gravitas/Auto-GPT/master/BULLETIN.md"
+ "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