-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathrise-chat.py
More file actions
35 lines (29 loc) · 1.09 KB
/
rise-chat.py
File metadata and controls
35 lines (29 loc) · 1.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
from rise import rise
import time
from colorama import Fore, Style, init # type: ignore
import sys
import threading
def thinking_bubble(stop_event):
while not stop_event.is_set():
for _ in range(3):
if stop_event.is_set():
break
sys.stdout.write('.')
sys.stdout.flush()
time.sleep(0.5)
sys.stdout.write('\b\b\b \b\b\b') # Erase the dots
def main():
rise.register_rise_client()
while True:
# Get user input
user_prompt = input(Fore.CYAN + "ME: " + Style.RESET_ALL)
stop_event = threading.Event() # Event to signal the thinking bubble to stop
thinking_thread = threading.Thread(
target=thinking_bubble, args=(stop_event,))
thinking_thread.start() # Start the thinking dots in a separate thread
response = rise.send_rise_command(user_prompt)
stop_event.set() # Signal the thinking thread to stop
thinking_thread.join() # Wait for the thread to finish
print(Fore.YELLOW + "RISE: " + response)
if __name__ == "__main__":
main()