structa-maestro 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- structa_maestro/__init__.py +294 -0
- structa_maestro/batch.py +564 -0
- structa_maestro/binding.py +206 -0
- structa_maestro/builder/__init__.py +0 -0
- structa_maestro/builder/result_builder.py +308 -0
- structa_maestro/cli.py +730 -0
- structa_maestro/confidence/__init__.py +49 -0
- structa_maestro/confidence/calibration.py +990 -0
- structa_maestro/confidence/normalizer.py +203 -0
- structa_maestro/config.py +111 -0
- structa_maestro/contracts/__init__.py +0 -0
- structa_maestro/contracts/enums.py +86 -0
- structa_maestro/contracts/models.py +229 -0
- structa_maestro/contracts/serialization.py +169 -0
- structa_maestro/documents/__init__.py +32 -0
- structa_maestro/documents/docx_parser.py +215 -0
- structa_maestro/documents/eml_parser.py +360 -0
- structa_maestro/documents/html_parser.py +337 -0
- structa_maestro/documents/inputs.py +277 -0
- structa_maestro/documents/loader.py +675 -0
- structa_maestro/documents/markdown_parser.py +225 -0
- structa_maestro/documents/models.py +33 -0
- structa_maestro/documents/normalization.py +24 -0
- structa_maestro/documents/pdf_parser.py +186 -0
- structa_maestro/documents/txt_parser.py +169 -0
- structa_maestro/engine.py +1201 -0
- structa_maestro/exceptions.py +38 -0
- structa_maestro/provenance/__init__.py +0 -0
- structa_maestro/provenance/associator.py +234 -0
- structa_maestro/py.typed +0 -0
- structa_maestro/review.py +1234 -0
- structa_maestro/schema/__init__.py +19 -0
- structa_maestro/schema/loader.py +616 -0
- structa_maestro/schema/models.py +269 -0
- structa_maestro/schema/pydantic_adapter.py +566 -0
- structa_maestro/schema/rules.py +526 -0
- structa_maestro/schema/serializer.py +156 -0
- structa_maestro/strategies/__init__.py +45 -0
- structa_maestro/strategies/base.py +101 -0
- structa_maestro/strategies/llm_anthropic.py +1142 -0
- structa_maestro/strategies/llm_config.py +154 -0
- structa_maestro/strategies/llm_gemini.py +1171 -0
- structa_maestro/strategies/llm_helpers.py +240 -0
- structa_maestro/strategies/llm_openai_compat.py +1183 -0
- structa_maestro/strategies/schema_compiler.py +248 -0
- structa_maestro/strategies/testing.py +71 -0
- structa_maestro/telemetry.py +800 -0
- structa_maestro/validation/__init__.py +0 -0
- structa_maestro/validation/cross_field.py +463 -0
- structa_maestro/validation/validator.py +531 -0
- structa_maestro-0.2.0.dist-info/METADATA +394 -0
- structa_maestro-0.2.0.dist-info/RECORD +55 -0
- structa_maestro-0.2.0.dist-info/WHEEL +4 -0
- structa_maestro-0.2.0.dist-info/entry_points.txt +2 -0
- structa_maestro-0.2.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
"""structa-maestro: Structured Data Extraction Engine."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from structa_maestro.batch import (
|
|
6
|
+
BatchDocumentInput,
|
|
7
|
+
BatchExtractionResult,
|
|
8
|
+
BatchOptions,
|
|
9
|
+
BatchSummary,
|
|
10
|
+
)
|
|
11
|
+
from structa_maestro.binding import bind_record, bind_records
|
|
12
|
+
from structa_maestro.builder.result_builder import ResultBuilder
|
|
13
|
+
from structa_maestro.confidence import (
|
|
14
|
+
CALIBRATION_ARTIFACT_VERSION,
|
|
15
|
+
DEFAULT_CALIBRATION_MIN_SAMPLES,
|
|
16
|
+
MAX_CALIBRATION_ARTIFACT_BYTES,
|
|
17
|
+
MIN_CALIBRATION_SAMPLES_FLOOR,
|
|
18
|
+
BinningStrategy,
|
|
19
|
+
CalibrationBin,
|
|
20
|
+
CalibrationMetadata,
|
|
21
|
+
CalibrationMethod,
|
|
22
|
+
CalibrationMetrics,
|
|
23
|
+
CalibrationModel,
|
|
24
|
+
CalibrationSample,
|
|
25
|
+
ConfidenceCalibrator,
|
|
26
|
+
ConfidenceNormalizationResult,
|
|
27
|
+
ConfidenceNormalizer,
|
|
28
|
+
HistogramParameters,
|
|
29
|
+
IsotonicParameters,
|
|
30
|
+
PlattParameters,
|
|
31
|
+
compute_calibration_metrics,
|
|
32
|
+
fit_calibrator,
|
|
33
|
+
)
|
|
34
|
+
from structa_maestro.config import DocumentLimits, SecretValue
|
|
35
|
+
from structa_maestro.contracts.enums import (
|
|
36
|
+
DocumentFormat,
|
|
37
|
+
EvidenceRelationship,
|
|
38
|
+
ExtractionCardinality,
|
|
39
|
+
FieldPresence,
|
|
40
|
+
FieldType,
|
|
41
|
+
IssueSeverity,
|
|
42
|
+
PipelineStage,
|
|
43
|
+
ProcessingStatus,
|
|
44
|
+
ValidationStatus,
|
|
45
|
+
)
|
|
46
|
+
from structa_maestro.contracts.models import (
|
|
47
|
+
CONTRACT_VERSION,
|
|
48
|
+
ConfidenceAssessment,
|
|
49
|
+
DiagnosticIssue,
|
|
50
|
+
ExtractedField,
|
|
51
|
+
ExtractedRecord,
|
|
52
|
+
ExtractionResult,
|
|
53
|
+
ProvenanceEvidence,
|
|
54
|
+
SchemaMetadata,
|
|
55
|
+
SourceLocation,
|
|
56
|
+
SourceMetadata,
|
|
57
|
+
ValidationOutcome,
|
|
58
|
+
)
|
|
59
|
+
from structa_maestro.documents.inputs import DocumentInput, DocumentInputKind
|
|
60
|
+
from structa_maestro.documents.models import DocumentSegment, PreparedDocument
|
|
61
|
+
from structa_maestro.engine import (
|
|
62
|
+
ExtractionEngine,
|
|
63
|
+
aextract,
|
|
64
|
+
aextract_batch,
|
|
65
|
+
extract,
|
|
66
|
+
extract_batch,
|
|
67
|
+
)
|
|
68
|
+
from structa_maestro.exceptions import (
|
|
69
|
+
ConfigurationError,
|
|
70
|
+
ContractDeserializationError,
|
|
71
|
+
RecordBindingError,
|
|
72
|
+
SchemaDefinitionError,
|
|
73
|
+
StructaMaestroError,
|
|
74
|
+
)
|
|
75
|
+
from structa_maestro.provenance.associator import ProvenanceAssociator
|
|
76
|
+
from structa_maestro.review import (
|
|
77
|
+
MAX_REVIEW_PAYLOAD_BYTES,
|
|
78
|
+
REVIEW_AUDIT_VERSION,
|
|
79
|
+
REVIEW_PLAN_VERSION,
|
|
80
|
+
REVIEW_SUBMISSION_VERSION,
|
|
81
|
+
FieldReviewDecision,
|
|
82
|
+
ProvenanceSummary,
|
|
83
|
+
RecordReviewDecision,
|
|
84
|
+
ReviewAction,
|
|
85
|
+
ReviewApplicationResult,
|
|
86
|
+
ReviewAudit,
|
|
87
|
+
ReviewAuditEntry,
|
|
88
|
+
ReviewItem,
|
|
89
|
+
ReviewPlan,
|
|
90
|
+
ReviewPolicy,
|
|
91
|
+
ReviewReason,
|
|
92
|
+
ReviewSubmission,
|
|
93
|
+
apply_review,
|
|
94
|
+
plan_review,
|
|
95
|
+
)
|
|
96
|
+
from structa_maestro.schema.models import ExtractionSchema, FieldConstraints, FieldSpec
|
|
97
|
+
from structa_maestro.schema.rules import (
|
|
98
|
+
ArithmeticRule,
|
|
99
|
+
ArithmeticTerm,
|
|
100
|
+
ComparisonOperator,
|
|
101
|
+
ComparisonRule,
|
|
102
|
+
ConditionalPresenceKind,
|
|
103
|
+
ConditionalPresenceRule,
|
|
104
|
+
ConditionOperator,
|
|
105
|
+
FieldCondition,
|
|
106
|
+
GroupPresenceKind,
|
|
107
|
+
GroupPresenceRule,
|
|
108
|
+
RuleSeverity,
|
|
109
|
+
ValidationRule,
|
|
110
|
+
)
|
|
111
|
+
from structa_maestro.strategies.base import (
|
|
112
|
+
AsyncExtractionStrategy,
|
|
113
|
+
ExtractionStrategy,
|
|
114
|
+
ProposedEvidence,
|
|
115
|
+
ProposedField,
|
|
116
|
+
ProposedRecord,
|
|
117
|
+
StrategyOutput,
|
|
118
|
+
)
|
|
119
|
+
from structa_maestro.strategies.llm_anthropic import (
|
|
120
|
+
AnthropicLLMStrategy,
|
|
121
|
+
AsyncAnthropicLLMStrategy,
|
|
122
|
+
)
|
|
123
|
+
from structa_maestro.strategies.llm_config import (
|
|
124
|
+
InputBudgetOverflowPolicy,
|
|
125
|
+
InputBudgetPolicy,
|
|
126
|
+
RetryPolicy,
|
|
127
|
+
StructuredOutputMode,
|
|
128
|
+
)
|
|
129
|
+
from structa_maestro.strategies.llm_gemini import (
|
|
130
|
+
AsyncGeminiLLMStrategy,
|
|
131
|
+
GeminiLLMStrategy,
|
|
132
|
+
)
|
|
133
|
+
from structa_maestro.strategies.llm_openai_compat import (
|
|
134
|
+
AsyncOpenAICompatibleLLMStrategy,
|
|
135
|
+
OpenAICompatibleLLMStrategy,
|
|
136
|
+
)
|
|
137
|
+
from structa_maestro.strategies.schema_compiler import (
|
|
138
|
+
CompiledOutputSchema,
|
|
139
|
+
compile_extraction_output_schema,
|
|
140
|
+
)
|
|
141
|
+
from structa_maestro.strategies.testing import (
|
|
142
|
+
AsyncDeterministicTestStrategy,
|
|
143
|
+
DeterministicTestStrategy,
|
|
144
|
+
)
|
|
145
|
+
from structa_maestro.telemetry import (
|
|
146
|
+
AsyncExtractionObserver,
|
|
147
|
+
BatchProgress,
|
|
148
|
+
ExtractionEvent,
|
|
149
|
+
ExtractionEventKind,
|
|
150
|
+
ExtractionObserver,
|
|
151
|
+
InMemoryTelemetryObserver,
|
|
152
|
+
StageTiming,
|
|
153
|
+
StageTimingSummary,
|
|
154
|
+
StrategyTelemetry,
|
|
155
|
+
StructuredLoggingObserver,
|
|
156
|
+
TelemetrySummary,
|
|
157
|
+
TokenUsage,
|
|
158
|
+
)
|
|
159
|
+
from structa_maestro.validation.validator import DeterministicValidator
|
|
160
|
+
|
|
161
|
+
__version__ = "0.2.0"
|
|
162
|
+
|
|
163
|
+
__all__ = [
|
|
164
|
+
"CALIBRATION_ARTIFACT_VERSION",
|
|
165
|
+
"CONTRACT_VERSION",
|
|
166
|
+
"DEFAULT_CALIBRATION_MIN_SAMPLES",
|
|
167
|
+
"MAX_CALIBRATION_ARTIFACT_BYTES",
|
|
168
|
+
"MAX_REVIEW_PAYLOAD_BYTES",
|
|
169
|
+
"MIN_CALIBRATION_SAMPLES_FLOOR",
|
|
170
|
+
"REVIEW_AUDIT_VERSION",
|
|
171
|
+
"REVIEW_PLAN_VERSION",
|
|
172
|
+
"REVIEW_SUBMISSION_VERSION",
|
|
173
|
+
"AnthropicLLMStrategy",
|
|
174
|
+
"ArithmeticRule",
|
|
175
|
+
"ArithmeticTerm",
|
|
176
|
+
"AsyncAnthropicLLMStrategy",
|
|
177
|
+
"AsyncDeterministicTestStrategy",
|
|
178
|
+
"AsyncExtractionObserver",
|
|
179
|
+
"AsyncExtractionStrategy",
|
|
180
|
+
"AsyncGeminiLLMStrategy",
|
|
181
|
+
"AsyncOpenAICompatibleLLMStrategy",
|
|
182
|
+
"BatchDocumentInput",
|
|
183
|
+
"BatchExtractionResult",
|
|
184
|
+
"BatchOptions",
|
|
185
|
+
"BatchProgress",
|
|
186
|
+
"BatchSummary",
|
|
187
|
+
"BinningStrategy",
|
|
188
|
+
"CalibrationBin",
|
|
189
|
+
"CalibrationMetadata",
|
|
190
|
+
"CalibrationMethod",
|
|
191
|
+
"CalibrationMetrics",
|
|
192
|
+
"CalibrationModel",
|
|
193
|
+
"CalibrationSample",
|
|
194
|
+
"ComparisonOperator",
|
|
195
|
+
"ComparisonRule",
|
|
196
|
+
"CompiledOutputSchema",
|
|
197
|
+
"ConditionOperator",
|
|
198
|
+
"ConditionalPresenceKind",
|
|
199
|
+
"ConditionalPresenceRule",
|
|
200
|
+
"ConfidenceAssessment",
|
|
201
|
+
"ConfidenceCalibrator",
|
|
202
|
+
"ConfidenceNormalizationResult",
|
|
203
|
+
"ConfidenceNormalizer",
|
|
204
|
+
"ConfigurationError",
|
|
205
|
+
"ContractDeserializationError",
|
|
206
|
+
"DeterministicTestStrategy",
|
|
207
|
+
"DeterministicValidator",
|
|
208
|
+
"DiagnosticIssue",
|
|
209
|
+
"DocumentFormat",
|
|
210
|
+
"DocumentInput",
|
|
211
|
+
"DocumentInputKind",
|
|
212
|
+
"DocumentLimits",
|
|
213
|
+
"DocumentSegment",
|
|
214
|
+
"EvidenceRelationship",
|
|
215
|
+
"ExtractedField",
|
|
216
|
+
"ExtractedRecord",
|
|
217
|
+
"ExtractionCardinality",
|
|
218
|
+
"ExtractionEngine",
|
|
219
|
+
"ExtractionEvent",
|
|
220
|
+
"ExtractionEventKind",
|
|
221
|
+
"ExtractionObserver",
|
|
222
|
+
"ExtractionResult",
|
|
223
|
+
"ExtractionSchema",
|
|
224
|
+
"ExtractionStrategy",
|
|
225
|
+
"FieldCondition",
|
|
226
|
+
"FieldConstraints",
|
|
227
|
+
"FieldPresence",
|
|
228
|
+
"FieldReviewDecision",
|
|
229
|
+
"FieldSpec",
|
|
230
|
+
"FieldType",
|
|
231
|
+
"GeminiLLMStrategy",
|
|
232
|
+
"GroupPresenceKind",
|
|
233
|
+
"GroupPresenceRule",
|
|
234
|
+
"HistogramParameters",
|
|
235
|
+
"InMemoryTelemetryObserver",
|
|
236
|
+
"InputBudgetOverflowPolicy",
|
|
237
|
+
"InputBudgetPolicy",
|
|
238
|
+
"IsotonicParameters",
|
|
239
|
+
"IssueSeverity",
|
|
240
|
+
"OpenAICompatibleLLMStrategy",
|
|
241
|
+
"PipelineStage",
|
|
242
|
+
"PlattParameters",
|
|
243
|
+
"PreparedDocument",
|
|
244
|
+
"ProcessingStatus",
|
|
245
|
+
"ProposedEvidence",
|
|
246
|
+
"ProposedField",
|
|
247
|
+
"ProposedRecord",
|
|
248
|
+
"ProvenanceAssociator",
|
|
249
|
+
"ProvenanceEvidence",
|
|
250
|
+
"ProvenanceSummary",
|
|
251
|
+
"RecordBindingError",
|
|
252
|
+
"RecordReviewDecision",
|
|
253
|
+
"ResultBuilder",
|
|
254
|
+
"RetryPolicy",
|
|
255
|
+
"ReviewAction",
|
|
256
|
+
"ReviewApplicationResult",
|
|
257
|
+
"ReviewAudit",
|
|
258
|
+
"ReviewAuditEntry",
|
|
259
|
+
"ReviewItem",
|
|
260
|
+
"ReviewPlan",
|
|
261
|
+
"ReviewPolicy",
|
|
262
|
+
"ReviewReason",
|
|
263
|
+
"ReviewSubmission",
|
|
264
|
+
"RuleSeverity",
|
|
265
|
+
"SchemaDefinitionError",
|
|
266
|
+
"SchemaMetadata",
|
|
267
|
+
"SecretValue",
|
|
268
|
+
"SourceLocation",
|
|
269
|
+
"SourceMetadata",
|
|
270
|
+
"StageTiming",
|
|
271
|
+
"StageTimingSummary",
|
|
272
|
+
"StrategyOutput",
|
|
273
|
+
"StrategyTelemetry",
|
|
274
|
+
"StructaMaestroError",
|
|
275
|
+
"StructuredLoggingObserver",
|
|
276
|
+
"StructuredOutputMode",
|
|
277
|
+
"TelemetrySummary",
|
|
278
|
+
"TokenUsage",
|
|
279
|
+
"ValidationOutcome",
|
|
280
|
+
"ValidationRule",
|
|
281
|
+
"ValidationStatus",
|
|
282
|
+
"__version__",
|
|
283
|
+
"aextract",
|
|
284
|
+
"aextract_batch",
|
|
285
|
+
"apply_review",
|
|
286
|
+
"bind_record",
|
|
287
|
+
"bind_records",
|
|
288
|
+
"compile_extraction_output_schema",
|
|
289
|
+
"compute_calibration_metrics",
|
|
290
|
+
"extract",
|
|
291
|
+
"extract_batch",
|
|
292
|
+
"fit_calibrator",
|
|
293
|
+
"plan_review",
|
|
294
|
+
]
|