-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
63 lines (48 loc) · 1.83 KB
/
main.py
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
import os
import argparse
from dotenv import load_dotenv
import inquirer
from termcolor import colored
import colorama
import google.generativeai as genai
from lib.commands.general.generator import generate
from lib.commands.interfaces import general_interface, internal_interface
from lib.utils import info, warn, error
def exit_command():
info("Thanks for using Atmosphere, exiting...")
return exit()
commands = {
"Generate Immersive Audio 💫": generate,
"General 🚀": general_interface.commands,
"Internal 🔒": internal_interface.commands,
"Exit 🚪": exit_command,
}
# main interface loop
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-e", "--env", help="Environment file to load", type=str)
args = parser.parse_args()
env = args.env if args.env else "development"
if env not in ["development", "production"]:
error("Invalid environment, please use 'development' or 'production'")
return
info(f"Loading environment file .env.{env}")
if env == "production":
warn(f"Atmosphere is running in {env} environment")
load_dotenv(f".env.{env}", verbose=True) # load env vars from desired file
colorama.init() # initialize colorama for windows support
genai.configure(api_key=os.getenv('GEMINI_API_KEY')) # configure gemini with api key
print(f"Welcome to {colored('Atmosphere', 'light_magenta')}! Select an option below:")
# continuously prompt user for commands until exit
while True:
print() # newline
# prompt user for command
questions = [inquirer.List('command', message="Commands", choices=[l for l in commands.keys()])]
answers = inquirer.prompt(questions)
# no answers -> exit
if answers is None:
return exit_command()
commands[answers['command']]() # execute command
# run main function
if __name__ == "__main__":
main()