-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
interact_web.py
30 lines (25 loc) · 1.05 KB
/
interact_web.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
import re
import json
import requests
import argparse
from urllib.request import urlopen
def s2b(v):
if isinstance(v, bool): return v
if v.lower() in ('yes', 'true', 't', 'y', '1'): return True
elif v.lower() in ('no', 'false', 'f', 'n', '0'): return False
else: raise argparse.ArgumentTypeError('Boolean value expected.')
parser = argparse.ArgumentParser(description='Export checkpoints for serving')
parser.add_argument('-url', type=str, default="woz-model.herokuapp.com",
help='Link to the server hosting the model')
parser.add_argument("-debug", type=s2b, nargs='?', const=True, default=False,
help="debugging flag")
args = parser.parse_args()
args.url="http://interact.jadeai.ml/query"
if __name__ == '__main__':
history = []
uname=input('Username: ')
while True:
inp = input('> ')
inpdata = '{"inputs": ["Input: '+'/b'.join(["Hi", "hello"])+'"]}'
response = requests.post(args.url, data=inpdata.encode("utf-8"))
print(response)