Skip to content

Commit

Permalink
Update setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
sunwaterdev committed Jul 10, 2024
1 parent be54911 commit cd39603
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
3 changes: 0 additions & 3 deletions lydia.sh

This file was deleted.

40 changes: 25 additions & 15 deletions scripts/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -17,41 +22,46 @@
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-*")
if bool(api_key_pattern.match(OPENAI_KEY)):
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))
Expand All @@ -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, \
Expand Down

0 comments on commit cd39603

Please sign in to comment.