Spaces:
Build error
Build error
File size: 4,940 Bytes
b293d47 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
from shortGPT.utils.requirements import Requirements
class CLI:
@staticmethod
def display_header():
'''Display the header of the CLI'''
CLI.display_green_text('''
.d88888b dP dP .88888. 888888ba d888888P .88888. 888888ba d888888P
88. "' 88 88 d8' `8b 88 `8b 88 d8' `88 88 `8b 88
`Y88888b. 88aaaaa88 88 88 88aaaa8P' 88 88 88aaaa8P' 88
`8b 88 88 88 88 88 `8b. 88 88 YP88 88 88
d8' .8P 88 88 Y8. .8P 88 88 88 Y8. .88 88 88
Y88888P dP dP `8888P' dP dP dP `88888' dP dP
''')
CLI.display_green_text("Welcome to ShortGPT! This is an experimental AI framework to automate all aspects of content creation.")
print("")
CLI.display_requirements_check()
@staticmethod
def display_help():
'''Display help'''
print("Usage: python shortGPT.py [options]")
print("")
print("Options:")
print(" -h, --help show this help message and exit")
@staticmethod
def display_requirements_check():
'''Display information about the system and requirements'''
print("Checking requirements...")
requirements_manager = Requirements()
print(" - Requirements : List of requirements and installed version:")
all_req_versions = requirements_manager.get_all_requirements_versions()
for req_name, req_version in all_req_versions.items():
if req_version is None:
CLI.display_red_text(f"---> Error : {req_name} is not installed")
print(f"{req_name}=={req_version}")
print("")
# Skipping for now, because it assumes package have the same name as the python import itself, which is not true most sometimes.
# if not requirements_manager.is_all_requirements_installed():
# CLI.display_red_text("Error : Some requirements are missing")
# print("Please install the missing requirements using the following command :")
# print("pip install -r requirements.txt")
# print("")
# requirements_manager.get_all_requirements_not_installed()
# print("")
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKCYAN = '\033[96m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
@staticmethod
def display_error(error_message, stack_trace):
'''Display an error message in the console'''
print(CLI.bcolors.FAIL + "ERROR : " + error_message + CLI.bcolors.ENDC)
print(stack_trace)
print("If the problem persists, don't hesitate to contact our support. We're here to assist you.")
print("Get Help on Discord : https://discord.gg/qn2WJaRH")
@staticmethod
def get_console_green_text(text):
'''Get the text in green color'''
return CLI.bcolors.OKGREEN + text + CLI.bcolors.ENDC
@staticmethod
def get_console_red_text(text):
'''Get the text in red color'''
return CLI.bcolors.FAIL + text + CLI.bcolors.ENDC
@staticmethod
def get_console_yellow_text(text):
'''Get the text in yellow color'''
return CLI.bcolors.WARNING + text + CLI.bcolors.ENDC
@staticmethod
def get_console_blue_text(text):
return CLI.bcolors.OKBLUE + text + CLI.bcolors.ENDC
@staticmethod
def get_console_bold_text(text):
return CLI.bcolors.BOLD + text + CLI.bcolors.ENDC
@staticmethod
def get_console_underline_text(text):
return CLI.bcolors.UNDERLINE + text + CLI.bcolors.ENDC
@staticmethod
def get_console_cyan_text(text):
return CLI.bcolors.OKCYAN + text + CLI.bcolors.ENDC
@staticmethod
def get_console_header_text(text):
return CLI.bcolors.HEADER + text + CLI.bcolors.ENDC
@staticmethod
def get_console_text(text, color):
return color + text + CLI.bcolors.ENDC
@staticmethod
def display_blue_text(text):
print(CLI.get_console_blue_text(text))
@staticmethod
def display_green_text(text):
print(CLI.get_console_green_text(text))
@staticmethod
def display_red_text(text):
print(CLI.get_console_red_text(text))
@staticmethod
def display_yellow_text(text):
print(CLI.get_console_yellow_text(text))
@staticmethod
def display_bold_text(text):
print(CLI.get_console_bold_text(text))
@staticmethod
def display_underline_text(text):
print(CLI.get_console_underline_text(text))
@staticmethod
def display_cyan_text(text):
print(CLI.get_console_cyan_text(text))
@staticmethod
def display_header_text(text):
print(CLI.get_console_header_text(text))
|