-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path__main__.py
31 lines (27 loc) · 947 Bytes
/
__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
from ChatGPT import ChatGPT
import os
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
if __name__ == '__main__':
session_token = input('Please enter your session token: ')
chat = ChatGPT(session_token)
clear_screen()
print(
'Conversation started. Type "reset" to reset the conversation. Type "reauth" to reauthenticate.'
)
while True:
prompt = input('\nYou: ')
if prompt.lower() == 'reset':
chat.reset_conversation()
clear_screen()
print(
'Conversation started. Type "reset" to reset the conversation. Type "reauth" to reauthenticate.'
)
continue
if prompt.lower() == 'reauth':
chat.refresh_auth()
print('Reauthenticated.')
continue
print('\nChatGPT:', end=' ')
response = chat.send_message(prompt)
print(response['message'])