-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.py
50 lines (40 loc) · 1.56 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
import os
import sys
import yaml
from src.ai_core import NeoAI
from src.terminal_interface import TerminalInterface
def load_config():
script_dir = os.path.dirname(os.path.realpath(__file__))
config_path = os.path.join(script_dir, 'config', 'config.yaml')
if os.path.exists(config_path):
with open(config_path, "r") as config_file:
return yaml.safe_load(config_file)
else:
print("Error: The 'config.yaml' file is missing. Please ensure it exists in the 'config' directory.")
sys.exit(1)
def main():
try:
# Load configuration
config = load_config()
# Check for required keys in the configuration
if 'api_url' not in config:
raise KeyError("'api_url'")
# Initialize NeoAI and TerminalInterface
neo_ai = NeoAI(config)
terminal = TerminalInterface(neo_ai, config)
terminal.run()
except KeyError as e:
if str(e) == "'api_url'":
print("Error: The key 'api_url' is missing in the 'config.yaml' file.")
print("Please ensure that the 'config.yaml' file is properly configured with all required fields.")
else:
print(f"Error: Missing configuration key: {e}. Please check your 'config.yaml' file.")
sys.exit(1)
except FileNotFoundError:
print("Error: The 'config.yaml' file is missing.")
sys.exit(1)
except Exception as e:
print(f"An unexpected error occurred: {e}")
sys.exit(1)
if __name__ == "__main__":
main()