-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.py
53 lines (42 loc) · 1.48 KB
/
cli.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
51
52
from persona_bot import persona_bot
import argparse
import pyfiglet
import sys
def main():
def chat(bot):
# Largely from: https://github.com/jezhiggins/eliza.py
print(pyfiglet.figlet_format(bot.persona['name']))
print("You are chatting with the persona named:", bot.persona['name'] )
print()
print("This persona is inspired by", bot.persona['inspired_by'] )
print("This persona is designed by", bot.persona['designed_by'] )
print()
print("type `quit` to quit")
print('='*72)
print()
print('Please ask me a question')
print()
s = ''
while s != 'quit':
try:
s = input('Q: ')
except EOFError:
s = 'quit'
print(s)
if (s=='quit' or s==''):
raise Exception('Exiting chat. Thank you for chattign with the '+ bot.persona['name'] + ' persona')
break
response = bot.ask(s)
print("A:", response)
print()
parser = argparse.ArgumentParser(description=None)
parser.add_argument("-p", "--persona", default="guru")
args = parser.parse_args()
persona = args.persona
bot = persona_bot(persona_name=persona)
chat(bot)
if __name__ == "__main__":
try:
sys.exit(main())
except Exception as e:
print(e)