-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexecutor.py
64 lines (59 loc) · 2.19 KB
/
executor.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
64
from typing import Dict, Any
import server
import json
class Executor:
def __init__(self):
pass
def run(self, function_json) -> Dict[str, Any]:
function_name = function_json.get("api_name")
function_args = function_json.get("arguments")
if function_name == "get_sprint_id":
return server.get_sprint_id()
elif function_name == "get_similar_work_items":
work_id = function_args.get("work_id")
return server.get_similar_work_items(work_id)
elif function_name == "add_work_items_to_sprint":
work_ids = function_args.get("work_ids")
sprint_id = function_args.get("sprint_id")
return server.add_work_items_to_sprint(work_ids, sprint_id)
elif function_name == "create_actionable_tasks_from_text":
text = function_args.get("text")
return server.create_actionable_tasks_from_text(text)
elif function_name == "prioritize_objects":
objects = function_args.get("objects")
return server.prioritize_objects(objects)
elif function_name == "search_object_by_name":
object_name = function_args.get("object_name")
return server.search_object_by_name(object_name)
elif function_name == "summarize_objects":
objects = function_args.get("objects")
return server.summarize_objects(objects)
elif function_name == "who_am_i":
return server.who_am_i()
elif function_name == "work_list":
return server.work_list()
else:
return {
"status": 200,
"message": "Successfully ran function: " + function_name,
}
if __name__ == "__main__":
function_json = """
{
"api_name": "add_work_items_to_sprint",
"arguments": {
"work_ids": [
"work_id_1",
"work_id_2"
],
"sprint_id": "sprint_id_1"
}
}
"""
function_json = json.loads(function_json)
api_tree = []
executor = Executor()
res = executor.run(function_json)
if res is not None:
res, execution_res = res
print(execution_res)