File size: 1,110 Bytes
17e10c6 | 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 | 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)
|