-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathworker.py
28 lines (24 loc) · 1.01 KB
/
worker.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
#test worker
import requests
import json
from real_world import toolkit
from model_api_config import planner_model,distributor_model
def work4plan(plan):
data = {'user_prompt': plan}
response = requests.post(distributor_model.URI, json=data)
if response.status_code == 200:
# print('My command:')
# print(data.get('user_prompt'))
# print("Response from /stream_with_function:")
print(json.loads(response.text)['result'].split('[/INST]')[-1].strip())
try:
func = json.loads(json.loads(response.text)['result'].split('[/INST]')[-1].strip())
return toolkit.scheduler(func)
except:
return json.loads(response.text)['result'].split('[/INST]')[-1].strip()
# func = json.loads(json.loads(response.text)['result'].split('[/INST]')[-1].strip())
# return toolkit.scheduler(func)
else:
print(f"Failed to get a response: {response.status_code}")
if __name__ == '__main__':
print(work4plan('''How does rnn work?\n'''))