forked from facebookresearch/ParlAI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_tb.py
More file actions
37 lines (28 loc) · 974 Bytes
/
Copy pathclient_tb.py
File metadata and controls
37 lines (28 loc) · 974 Bytes
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
import argparse
import json
import requests
def reset_conversation():
url_reset = "http://localhost:8080/reset"
response = requests.request("POST", url_reset, headers=headers, data = payload)
print(response)
def send_message(user_message):
url = "http://localhost:8080/interact"
response = requests.request("POST", url, headers=headers, data = user_message)
response_json = json.loads(response.text.encode('utf8'))
print(response_json['text'])
return response_json['text']
if __name__ == '__main__':
# Construct the argument parser
ap = argparse.ArgumentParser()
# Add the arguments to the parser
ap.add_argument("-m", "--message", required=True,
help="message to be sent to the bot")
args = vars(ap.parse_args())
payload = args['message']
headers = {
'Content-Type': 'application/json'
}
### Reset conversation
reset_conversation()
### Send Message
send_message(payload)