-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch_evidence.py
More file actions
35 lines (28 loc) · 885 Bytes
/
Copy pathfetch_evidence.py
File metadata and controls
35 lines (28 loc) · 885 Bytes
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
#!/usr/bin/env python3
import requests
import json
base = "http://127.0.0.1:8000"
# Get top 10 records from smart-gates context
ctx = requests.get(f"{base}/api/context/smart-gates").json()
top_records = ctx["top_records"][:10]
evidence = []
for rec in top_records:
rid = rec["id"]
# Fetch full record
r = requests.get(f"{base}/api/records/{rid}")
if r.status_code != 200:
print(f"FAIL: {rid} returned {r.status_code}")
continue
full = r.json()
text = full.get("text", "")
# Extract snippet (first 200 chars)
snippet = text[:200].replace("\n", " ") if text else ""
evidence.append({
"title": rec["title"],
"url": rec["url"],
"authority_tier": rec["authority_tier"],
"record_id": rid,
"snippet": snippet,
"full_text": text
})
print(json.dumps(evidence, indent=2))