Files
Auto-GPT/autogpt/utils.py
2023-04-14 20:42:28 +01:00

27 lines
717 B
Python

import yaml
from colorama import Fore
def clean_input(prompt: str = ""):
try:
return input(prompt)
except KeyboardInterrupt:
print("You interrupted Auto-GPT")
print("Quitting...")
exit(0)
def validate_yaml_file(file: str):
try:
with open(file) as file:
yaml.load(file, 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}!")