Wildstash commited on
Commit
4e639b4
·
verified ·
1 Parent(s): 2fa83ff

Sync AfterBlock 3200 runtime files

Browse files
Files changed (1) hide show
  1. tools/export_artifact_traces.py +100 -0
tools/export_artifact_traces.py ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import sys
3
+ from pathlib import Path
4
+
5
+ sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
6
+
7
+ from app import DEMO_ARTIFACTS, build_museum_artifact, museum_packet_for
8
+
9
+
10
+ GENERATED_VARIANTS = [
11
+ {
12
+ "owner_name": "Mira",
13
+ "owner_handle": "@pixelmira",
14
+ "input_type": "object_photo",
15
+ "source_prompt": "a scratched blue water bottle with a moon sticker",
16
+ "memory_text": "It sat beside every late-night build and made the desk feel survivable.",
17
+ },
18
+ {
19
+ "owner_name": "Jon",
20
+ "owner_handle": "@lampkeeper",
21
+ "input_type": "object_photo",
22
+ "source_prompt": "a warm desk lamp beside messy notes",
23
+ "memory_text": "It kept one square of the room awake when the rest of the house was asleep.",
24
+ },
25
+ {
26
+ "owner_name": "Nova",
27
+ "owner_handle": "@bookishnova",
28
+ "input_type": "memory_prompt",
29
+ "source_prompt": "a toy car from a childhood shelf",
30
+ "memory_text": "It was speed before distance became real.",
31
+ },
32
+ {
33
+ "owner_name": "Ivy",
34
+ "owner_handle": "@redstoneivy",
35
+ "input_type": "animal_spirit",
36
+ "source_prompt": "a fox that represents curiosity",
37
+ "memory_text": "It appears whenever a locked room feels more like an invitation.",
38
+ },
39
+ {
40
+ "owner_name": "Kai",
41
+ "owner_handle": "@skyreceipt",
42
+ "input_type": "painting_prompt",
43
+ "source_prompt": "a cloud dragon sleeping inside a circuit board",
44
+ "memory_text": "A strange painting about softness hiding inside machines.",
45
+ },
46
+ ]
47
+
48
+
49
+ def trace_for(seed_name: str, config: dict) -> dict:
50
+ artifact = build_museum_artifact(**config)
51
+ packet = museum_packet_for(artifact)
52
+ top_scores = sorted(
53
+ artifact["curation_scores"].items(),
54
+ key=lambda item: item[1] if isinstance(item[1], int) else -1,
55
+ reverse=True,
56
+ )[:3]
57
+ return {
58
+ "seed_name": seed_name,
59
+ "input": {
60
+ "owner_handle": config["owner_handle"],
61
+ "input_type": config["input_type"],
62
+ "source_prompt": config["source_prompt"],
63
+ "memory_text": config["memory_text"],
64
+ },
65
+ "curation_interpretation": {
66
+ "object_guess": artifact["object_guess"],
67
+ "hall": artifact["hall"],
68
+ "zone": artifact["zone"],
69
+ "placement_reason": artifact["placement_reason"],
70
+ "top_scores": top_scores,
71
+ "curation_score": artifact["curation_scores"]["curation_score"],
72
+ },
73
+ "spirit_output": {
74
+ "name": artifact["spirit_name"],
75
+ "traits": artifact["spirit_traits"],
76
+ "first_line": artifact["spirit_first_line"],
77
+ "sample_questions": artifact["sample_visitor_questions"],
78
+ "sample_replies": artifact["sample_spirit_responses"],
79
+ },
80
+ "passport_fields": artifact["passport_card"],
81
+ "minecraft_packet": packet["minecraft"],
82
+ "museum_packet": packet,
83
+ }
84
+
85
+
86
+ def main() -> None:
87
+ traces = []
88
+ for name, config in DEMO_ARTIFACTS.items():
89
+ traces.append(trace_for(name, config))
90
+ for index, config in enumerate(GENERATED_VARIANTS, 1):
91
+ traces.append(trace_for(f"generated_variant_{index}", config))
92
+
93
+ out = Path("data/artifact_traces.jsonl")
94
+ out.parent.mkdir(parents=True, exist_ok=True)
95
+ out.write_text("\n".join(json.dumps(trace, sort_keys=True) for trace in traces) + "\n", encoding="utf-8")
96
+ print(f"wrote {len(traces)} artifact traces to {out}")
97
+
98
+
99
+ if __name__ == "__main__":
100
+ main()