-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
63 lines (47 loc) · 2.09 KB
/
main.py
File metadata and controls
63 lines (47 loc) · 2.09 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import os
from colorama import Fore, Back, Style, init
from tutor_logic import PythonTutor
init(autoreset=True)
def main():
try:
tutor = PythonTutor()
except Exception as e:
print(Fore.RED + f"Configuration Error: {e}")
return
os.system('clear')
# UI Header
print(Fore.BLUE + "┌" + "─" * 58 + "┐")
print(Fore.BLUE + "│ " + Fore.CYAN + " BIT | SENIOR PYTHON MENTOR - LOCAL AI " + Fore.BLUE + " │")
print(Fore.BLUE + "└" + "─" * 58 + "┘")
print(Fore.WHITE + Style.DIM + " Commands: 'exit' to quit | 'clear' to reset screen | 'save' to export\n")
while True:
try:
user_input = input(Fore.YELLOW + "Student ❯ " + Style.RESET_ALL).strip()
if user_input.lower() in ['exit', 'quit', 'bye']:
print(Fore.BLUE + "\nBit: See you in the next debugging session. Happy coding!")
break
if user_input.lower() == 'clear':
os.system('clear')
continue
if not user_input:
continue
# Visual thinking state
print(Fore.BLACK + Back.CYAN + " BIT IS THINKING... " + Style.RESET_ALL, end="\r")
response = tutor.send_message(user_input)
# Clear "thinking" line
print(" " * 40, end="\r")
# Message Design
print(Fore.BLUE + "╭" + "─" * 5)
print(Fore.BLUE + "│ " + Fore.GREEN + Style.BRIGHT + "BIT SAYS:")
for line in response.split('\n'):
# Handle empty lines for better spacing
line_content = line if line.strip() else ""
print(Fore.BLUE + "│ " + Fore.WHITE + line_content)
print(Fore.BLUE + "╰" + "─" * 5 + "\n")
except KeyboardInterrupt:
print(Fore.YELLOW + "\n\nSession terminated by user.")
break
except Exception as e:
print(Fore.RED + f"\n[!] System Error: {e}")
if __name__ == "__main__":
main()