-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
45 lines (37 loc) · 1.28 KB
/
Copy pathmain.py
File metadata and controls
45 lines (37 loc) · 1.28 KB
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
# main.py
import sys
import config
from engine.brain import Brain
from utils.logger import setup_logger
def main():
logger = setup_logger("Main")
print("===================================")
print(" LGOS Studio AI Console v1.1.3")
print(" Type 'quit' to exit.")
print("===================================")
# 初始化大脑
try:
ai = Brain()
except Exception as e:
logger.critical(f"Failed to initialize AI: {e}", exc_info=True)
return
# 交互循环
while True:
try:
user_input = input(config.PROMPT).strip()
if not user_input:
continue
if user_input.lower() in config.EXIT_COMMANDS:
print("ChatAI: 再见!")
break
# 思考并生成回复
response = ai.process(user_input)
print(f"ChatAI: {response}")
except KeyboardInterrupt:
print("\nChatAI: 检测到中断,再见。")
break
except Exception as e:
logger.error(f"Main loop error: {e}", exc_info=True)
print("ChatAI: 发生了一个内部错误。")
if __name__ == "__main__":
main()