MCPcopy
hub / github.com/microsoft/JARVIS / toolbench_process

Function toolbench_process

easytool/data_process.py:29–51  ·  view source on GitHub ↗
(data_file, dataset)

Source from the content-addressed store, hash-verified

27
28
29def toolbench_process(data_file, dataset):
30 ls = read_json(data_file)
31 all_data = read_json(f"{dataset}/tool_instruction/toolbench_tool_instruction.json")
32 all_dic = {}
33 for ID in all_data.keys():
34 all_dic[all_data[ID]["tool_name"]] = all_data[ID]
35
36 not_in = []
37 for data in ls:
38 Tool_dic = []
39 data_dic = {}
40 already = []
41 for tool in data['api_list']:
42 if tool['tool_name'] in all_dic:
43 if all_dic[tool['tool_name']]["ID"] not in already:
44 already.append(all_dic[tool['tool_name']]["ID"])
45 Tool_dic.append({"ID": all_dic[tool['tool_name']]["ID"],
46 "Description": all_dic[tool['tool_name']]["tool_description"], })
47 data["Tool_dic"] = Tool_dic
48
49 json_str = json.dumps(ls, indent=4)
50 with open(data_file, 'w', encoding='utf-8') as json_file:
51 json.dump(ls, json_file, ensure_ascii=False, indent=4)
52
53
54def main():

Callers 1

mainFunction · 0.85

Calls 1

read_jsonFunction · 0.70

Tested by

no test coverage detected