From cd3960364b888463623307a779dac12ada95b70b Mon Sep 17 00:00:00 2001 From: Jules Date: Wed, 10 Jul 2024 21:52:31 +0200 Subject: [PATCH] Update setup.py --- lydia.sh | 3 --- scripts/setup.py | 40 +++++++++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 18 deletions(-) delete mode 100755 lydia.sh diff --git a/lydia.sh b/lydia.sh deleted file mode 100755 index fc77b32..0000000 --- a/lydia.sh +++ /dev/null @@ -1,3 +0,0 @@ -# Run lidya - -python3 lidya/core.py \ No newline at end of file diff --git a/scripts/setup.py b/scripts/setup.py index 614df4c..18f7380 100644 --- a/scripts/setup.py +++ b/scripts/setup.py @@ -7,6 +7,11 @@ import re import json import requests +from rich import print as dprint +from rich.console import Console +from rich.prompt import Prompt + +console = Console() CONFIG_URL = "https://pastebin.com/raw/Rmu8qxB9" MESSAGES_URL = "https://pastebin.com/raw/4BaVZZS7" @@ -17,18 +22,21 @@ KEYS_FILE = "./config/keys.json" WAKEWORDS_FILE = "./config/wakewords.json" -print('[*] Collecting default configurations... ') -CONFIG = json.loads(requests.get(CONFIG_URL, timeout=500).text) -MESSAGES = json.loads(requests.get(MESSAGES_URL, timeout=500).text) -KEYS = json.loads(requests.get(KEYS_URL, timeout=500).text) -WAKEWORDS = json.loads(requests.get(WAKEWORDS_URL, timeout=500).text) - -print('[*] Setup wizard is ready! Please complete few questions bellow.') +dprint('[bold blue][*][/bold blue] Collecting default configurations... ') +with console.status("Fetching configuration... ", + spinner="dots10", + spinner_style="blue") as progress: + CONFIG = json.loads(requests.get(CONFIG_URL, timeout=100).text) + MESSAGES = json.loads(requests.get(MESSAGES_URL, timeout=100).text) + KEYS = json.loads(requests.get(KEYS_URL, timeout=100).text) + WAKEWORDS = json.loads(requests.get(WAKEWORDS_URL, timeout=100).text) +dprint('[bold blue][*][/bold blue] Online default configuration is ready! ') +dprint('[bold blue][*][/bold blue] Setup wizard is ready! Please complete few questions bellow.') # Collect OpenAI key VALIDATED = False while VALIDATED is False: - OPENAI_KEY = input('[?] We need a working API key for OpenAI: ') + OPENAI_KEY = Prompt.ask('[bold blue][?][/bold blue] We need a working API key for OpenAI') # Validating key api_key_pattern = re.compile(r"sk-*") @@ -36,22 +44,24 @@ VALIDATED = True else: VALIDATED = False - print('[!] The key does not appear to be valid. Check if there is a line break at the end.') + dprint('[bold yellow][!][/bold yellow] The key does not appear to be valid. ' + + 'Check if there is a line break at the end.') -print('[*] Updating configuration... ') +dprint('[bold blue][*][/bold blue] Updating configuration... ') KEYS['openai'] = OPENAI_KEY # Collect favorite model -OPENAI_FAV_MODEL = input('[?] What is your favorite OpenAI llm model [gpt-3.5-turbo]: ') +OPENAI_FAV_MODEL = Prompt.ask('[bold blue][?][/bold blue] What is your favorite OpenAI llm model', + default="gpt-3.5-turbo") if OPENAI_FAV_MODEL == "": - print('[*] Nothing provied. Choosing gpt-3.5-turbo') + dprint('[bold blue][*][/bold blue] Nothing provied. Choosing gpt-3.5-turbo') OPENAI_FAV_MODEL = "gpt-3.5-turbo" -print('[*] Updating configuration... ') +dprint('[bold blue][*][/bold blue] Updating configuration... ') CONFIG['main_model'] = OPENAI_FAV_MODEL -print('[*] Writing configuration... ') +dprint('[bold blue][*][/bold blue] Writing configuration... ') with open(CONFIG_FILE, 'w', encoding="utf8") as f: f.write(json.dumps(CONFIG)) @@ -65,7 +75,7 @@ with open(MESSAGES_FILE, 'w', encoding="utf8") as f: f.write(json.dumps(MESSAGES)) -print('The assistant is ready for use! \ +dprint('The assistant is ready for use! \ Note that you can change the STT \ language and model in the setting\ s outside of the wizard. However, \