Download inspect_mt.py from DevGwardo/minicpm5-toolcall-code: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/datasets/DevGwardo/minicpm5-toolcall-code/resolve/main/inspect_mt.py
- Command line
-
hf download hf://datasets/DevGwardo/minicpm5-toolcall-code/inspect_mt.py
-
curl -L -o inspect_mt.py https://huggingface.co/datasets/DevGwardo/minicpm5-toolcall-code/resolve/main/inspect_mt.py
1.11 kB
| import json, collections, ast, re, sys | |
| sys.path.insert(0, "pipeline") | |
| from prepare_data import parse_tools, parse_calls | |
| data = json.load(open("raw/data.json", encoding="utf-8")) | |
| lens = collections.Counter(len(d["conversations"]) for d in data) | |
| print("conv length histogram:", sorted(lens.items())) | |
| multi = [] | |
| for d in data: | |
| if len(d["conversations"]) < 4: | |
| continue | |
| tools = parse_tools(d.get("system", "")) | |
| if not tools: | |
| continue | |
| names = {t["name"] for t in tools} | |
| conv = d["conversations"] | |
| if conv[0]["from"] != "user": | |
| continue | |
| first = conv[1] | |
| if first.get("from") != "assistant": | |
| continue | |
| calls = parse_calls(first["value"]) | |
| if not calls or any(c["name"] not in names for c in calls): | |
| continue | |
| if any(m["from"] == "tool" for m in conv[2:]): | |
| multi.append((d, calls)) | |
| print("multi-turn rows with first call + tool response:", len(multi)) | |
| if multi: | |
| d, calls = multi[0] | |
| for m in d["conversations"]: | |
| print(m["from"], "::", m["value"][:220].replace("\n", "\\n")) | |
| print("parsed first calls:", calls) | |