-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo_client_builders.py
More file actions
180 lines (145 loc) · 6.1 KB
/
demo_client_builders.py
File metadata and controls
180 lines (145 loc) · 6.1 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/usr/bin/env python3
"""
Demo script showing the type-safe client builders in action.
This demonstrates the exact usage patterns described in the README,
including the example: create_infreco_request(inputs=text).config_option("from_key", "premises").add_filter("infreco", "version", "v3").build()
"""
import sys
sys.path.insert(0, 'src')
from argdown_feedback.api.client.builders import (
create_infreco_request,
create_arganno_request,
create_argmap_request,
create_logreco_request,
create_argmap_infreco_request,
create_arganno_argmap_request,
create_arganno_infreco_request,
create_argmap_logreco_request,
create_arganno_logreco_request,
create_arganno_argmap_logreco_request
)
def demo_readme_example():
"""Demo the exact example from the README."""
print("=== README Example ===")
text = """
```argdown
<P1>: Some premise
<P2>: Another premise
----
<C1>: Conclusion
```
"""
# Exact README example
request = (create_infreco_request(inputs=text)
.config_option("from_key", "premises")
.add_filter("infreco", "version", "v3")
.build())
print("✅ README example works!")
print(f" Inputs: {request.inputs[:50]}...")
print(f" Config: {request.config}")
print()
def demo_advanced_filtering():
"""Demo advanced filtering capabilities."""
print("=== Advanced Filtering Demo ===")
# Complex filter with regex
request = (create_infreco_request("Test content")
.config_option("from_key", "premises")
.add_filter("infreco", "version", "v3", regex=False)
.add_filter("infreco", "task", "reconstruction|analysis", regex=True)
.add_filter("infreco", "quality", "high", regex=False)
.build())
print("✅ Complex inference reconstruction with multiple filters")
print(f" Config: {request.config}")
print()
def demo_coherence_checks():
"""Demo coherence verification builders."""
print("=== Coherence Verification Demo ===")
# Argmap + Infreco coherence
request = (create_argmap_infreco_request("Test coherence content")
.config_option("from_key", "from")
.add_filter("argmap", "version", "v3")
.add_filter("infreco", "version", "v3")
.add_filter("infreco", "task", "analysis")
.build())
print("✅ Argmap + Infreco coherence check")
print(f" Config: {request.config}")
# Triple coherence check
triple_request = (create_arganno_argmap_logreco_request("Complex content")
.config_option("from_key", "mapping")
.add_filter("arganno", "annotator", "expert")
.add_filter("argmap", "version", "v3")
.add_filter("logreco", "level", "detailed")
.build())
print("✅ Triple coherence check (Arganno + Argmap + Logreco)")
print(f" Config: {triple_request.config}")
print()
def demo_type_safety():
"""Demo compile-time type safety features."""
print("=== Type Safety Demo ===")
# This works - correct verifier role
try:
(create_infreco_request("content")
.add_filter("infreco", "version", "v3") # ✅ Valid role
.build())
print("✅ Valid filter role accepted")
except Exception as e:
print(f"❌ Unexpected error: {e}")
# Demonstrate type safety (this shows a type error at development time)
print("⚠️ Type checker prevents invalid filter roles at compile time")
print(" Example: create_infreco_request().add_filter('argmap', ...) would fail type check")
print()
def demo_all_verifiers():
"""Demo builders for available verifier types."""
print("=== Available Verifier Types Demo ===")
builders = [
("Inference Reconstruction", create_infreco_request),
("Argument Annotation", create_arganno_request),
("Argument Mapping", create_argmap_request),
("Logical Reconstruction", create_logreco_request),
("Argmap + Infreco", create_argmap_infreco_request),
("Arganno + Argmap", create_arganno_argmap_request),
("Arganno + Infreco", create_arganno_infreco_request),
("Argmap + Logreco", create_argmap_logreco_request),
("Arganno + Logreco", create_arganno_logreco_request),
("Arganno + Argmap + Logreco", create_arganno_argmap_logreco_request),
]
for name, builder_func in builders:
request = builder_func("Test content").build()
print(f"✅ {name}: {type(request).__name__}")
print()
def demo_filter_composition():
"""Demo how filters compose for complex verifiers."""
print("=== Filter Composition Demo ===")
# Show how filters work for multi-verifier scenarios
request = (create_arganno_argmap_logreco_request("Complex analysis")
.config_option("from_key", "comprehensive")
.add_filter("arganno", "version", "v3")
.add_filter("arganno", "annotator", "expert")
.add_filter("argmap", "version", "v3")
.add_filter("argmap", "layout", "hierarchical")
.add_filter("logreco", "level", "detailed")
.add_filter("logreco", "format", "natural", regex=False)
.build())
print("✅ Complex 3-verifier composition with role-specific filters")
filters = request.config.get('filters', {}) if request.config else {}
print(f" Config filters: {filters}")
print()
if __name__ == "__main__":
print("🚀 Type-Safe Client Builders Demo")
print("=" * 50)
print()
demo_readme_example()
demo_advanced_filtering()
demo_coherence_checks()
demo_type_safety()
demo_all_verifiers()
demo_filter_composition()
print("✅ All demos completed successfully!")
print("\nKey Features Demonstrated:")
print("- ✅ README example works exactly as specified")
print("- ✅ Type-safe verifier role validation")
print("- ✅ Fluent builder API with method chaining")
print("- ✅ Custom metadata filtering with regex support")
print("- ✅ Available verifier combinations supported")
print("- ✅ Compile-time safety with Literal types")
print("- ✅ Complex filter composition for multi-verifier scenarios")