File size: 706 Bytes
01377f7 9a9a2f5 01377f7 9a9a2f5 01377f7 | 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 | import json
with open("./datasets/apigen/xlam_function_calling_60k.json", "r") as f:
data = json.load(f)
results = []
max_tool_usage = 0
from tqdm import tqdm
for sample in tqdm(data, desc="Processing APIGen samples"):
used_tools = list(set([x["name"] for x in json.loads(sample["answers"])]))
if len(used_tools) == 0:
continue
tools = [
{"name": x["name"].replace(".", "_"), "description": x["description"]}
for x in json.loads(sample["tools"])
]
result = {"instruction": sample["query"], "tools": tools, "used_tools": used_tools}
results.append(result)
with open("./datasets/apigen/output.json", "w") as f:
json.dump(results, f, indent=4)
|