-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync_new_sheet_and_train.py
executable file
·65 lines (39 loc) · 1.17 KB
/
sync_new_sheet_and_train.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
53
54
55
56
57
58
59
60
61
62
63
import requests, json
url = "http://localhost/api/auth"
USERNAME = "me"
PASSWORD = ""
LANGUAGES = ['ENG','HAU','KAU']
BOT_STRINGS_SHEET = ""
NLU_SHEET = ""
payload = {
"username": USERNAME,
"password": PASSWORD
}
headers = {
'content-type': "application/json",
}
response = requests.request("POST", url, data=json.dumps(payload), headers=headers)
json_resp = response.json()
access_token = json_resp['access_token']
print('[info] generating files... ')
url = "http://localhost/custom/generate"
payload = {
"bot_strings_sheet": BOT_STRINGS_SHEET,
"nlu_sheet": NLU_SHEET,
"lang": LANGUAGES
}
headers = {
'content-type': "application/json",
'authorization': "Bearer {access_token}".format(access_token=access_token)
}
response = requests.request("POST", url, data=json.dumps(payload), headers=headers)
print(response.text)
print('[info] files generated! ')
print('[info] training the model... ')
url = "http://localhost/custom/train"
headers = {
'content-type': "application/json",
'authorization': "Bearer {access_token}".format(access_token=access_token)
}
response = requests.request("GET", url, headers=headers)
print(response.text)