Datasets:
Download analyze.py from LayerLens/hubspot-open-deal-count-test: direct link, hf CLI and curl.
- Browser
- Download file 1.4 kB
-
https://huggingface.co/datasets/LayerLens/hubspot-open-deal-count-test/resolve/main/analyze.py
- Command line
-
hf download hf://datasets/LayerLens/hubspot-open-deal-count-test/analyze.py
-
curl -L -o analyze.py https://huggingface.co/datasets/LayerLens/hubspot-open-deal-count-test/resolve/main/analyze.py
1.4 kB
| """Recomputes summary.json from traces.jsonl: checks each trace's SHA-256, then counts tool calls, the deal records each agent got back and whether its answer matches the open deals in those records.""" | |
| import hashlib, json | |
| summary = {} | |
| for line in open("traces.jsonl", encoding="utf-8"): | |
| r = json.loads(line) | |
| assert hashlib.sha256(r["trace_json"].encode()).hexdigest() == r["sha256"], "hash mismatch" | |
| t = json.loads(r["trace_json"]); ev = t["events"] | |
| calls = [e["payload"] for e in ev if e["type"] == "tool.call"] | |
| seen = {} | |
| for c in calls: | |
| if c["tool_name"] == "search_objects" and c["arguments"].get("objectType") == "deals": | |
| for d in c["result"].get("results", []): seen[d["id"]] = d["properties"].get("dealstage") | |
| open_n = sum(1 for s in seen.values() if s not in ("closedwon", "closedlost")) | |
| answer = next(e["payload"]["output"] for e in ev if e["type"] == "agent.output") | |
| line_ = answer.strip().splitlines()[-1].replace("ANSWER:", "").strip() | |
| summary[r["agent"]] = {"passed": t["grading"]["verdict"] == "pass", "answer_line": line_, "tool_calls": len(calls), | |
| "deal_records_returned": len(seen), "open_deals_in_records_returned": open_n, | |
| "answer_matches_records_read": int(line_) == open_n} | |
| json.dump(summary, open("summary.json", "w"), indent=1) | |
| print(json.dumps(summary, indent=1)) | |