aboutsummaryrefslogtreecommitdiff
path: root/autogpts/autogpt/autogpt/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'autogpts/autogpt/autogpt/utils.py')
-rw-r--r--autogpts/autogpt/autogpt/utils.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/autogpts/autogpt/autogpt/utils.py b/autogpts/autogpt/autogpt/utils.py
new file mode 100644
index 000000000..4aa503a7b
--- /dev/null
+++ b/autogpts/autogpt/autogpt/utils.py
@@ -0,0 +1,19 @@
+from pathlib import Path
+
+import yaml
+from colorama import Fore
+
+
+def validate_yaml_file(file: str | Path):
+ try:
+ with open(file, encoding="utf-8") as fp:
+ yaml.load(fp.read(), Loader=yaml.FullLoader)
+ except FileNotFoundError:
+ return (False, f"The file {Fore.CYAN}`{file}`{Fore.RESET} wasn't found")
+ except yaml.YAMLError as e:
+ return (
+ False,
+ f"There was an issue while trying to read with your AI Settings file: {e}",
+ )
+
+ return (True, f"Successfully validated {Fore.CYAN}`{file}`{Fore.RESET}!")