Packet
seed_data.packet
Packet generation — coordinated sets of inter-related documents.
A packet is a collection of different document types that share context (e.g., a loan application containing a credit report, pay stubs, and a statement of intent — all for the same applicant).
This module handles
- Loading and validating packet configuration
- Resolving shared context (explicit or LLM-inferred)
- Generating individual sub-documents via the staged pipeline
(
seed_data.stages.pipeline.generate) - Merging sub-document PDFs into a single packet PDF
- Emitting evaluation labels (document_class, page_indices, inference_result)
DocumentSpec
dataclass
A single document type within a packet.
Source code in seed_data/packet.py
33 34 35 36 37 38 39 40 41 | |
PacketConfig
dataclass
Parsed packet configuration.
Source code in seed_data/packet.py
44 45 46 47 48 49 50 51 52 | |
PacketResult
dataclass
Result of generating a single packet.
Source code in seed_data/packet.py
68 69 70 71 72 73 74 75 76 77 | |
PlannedDocument
dataclass
A single document instance to generate.
Source code in seed_data/packet.py
453 454 455 456 457 458 459 | |
SectionResult
dataclass
Result for one sub-document section in the merged packet.
Source code in seed_data/packet.py
55 56 57 58 59 60 61 62 63 64 65 | |
emit_classes_yaml(config, output_dir)
Write classes.yaml listing all document types in the packet.
Returns:
| Type | Description |
|---|---|
str
|
Path to the written classes.yaml. |
Source code in seed_data/packet.py
704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 | |
generate_packet(config, output_dir, packet_id=None, extra='', shared_context=None, shuffle=False, doc_workers=1, data_model='nova2-lite', doc_model='nova2-lite', critic_model='sonnet', aug_model='gpt-oss', context_model='nova2-lite', threshold=7, max_attempts=5, timeout=3600, augment=False, critic_samples=True, renderer='xhtml2pdf', enable_preview=False)
Generate a single packet: resolve context, generate docs, merge, emit labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
PacketConfig
|
Parsed packet configuration. |
required |
output_dir
|
str
|
Root output directory for this packet batch. |
required |
packet_id
|
str | None
|
Unique ID for this packet (auto-generated if None). |
None
|
extra
|
str
|
Scenario brief / extra instructions. |
''
|
shared_context
|
dict[str, Any] | None
|
Pre-resolved shared context (skips resolution if provided). |
None
|
shuffle
|
bool
|
Randomize sub-document order in merged PDF. |
False
|
doc_workers
|
int
|
Parallel workers for sub-document generation within this packet. |
1
|
data_model
|
str
|
Model for data generation. |
'nova2-lite'
|
doc_model
|
str
|
Model for document generation. |
'nova2-lite'
|
critic_model
|
str
|
Model for critique. |
'sonnet'
|
aug_model
|
str
|
Model for augmentation. |
'gpt-oss'
|
context_model
|
str
|
Model for shared context resolution. |
'nova2-lite'
|
threshold
|
int
|
Quality threshold for critics. |
7
|
max_attempts
|
int
|
Max retry attempts per document. |
5
|
timeout
|
int
|
Timeout per document generation. |
3600
|
augment
|
bool
|
Enable per-document augmentation. |
False
|
critic_samples
|
bool
|
Use reference samples in critic. |
True
|
renderer
|
str
|
PDF rendering engine. |
'xhtml2pdf'
|
enable_preview
|
bool
|
Accepted for CLI compatibility; not used by the pipeline (no preview stage yet). |
False
|
Returns:
| Type | Description |
|---|---|
PacketResult
|
PacketResult with merged PDF path, section results, and metadata. |
Source code in seed_data/packet.py
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | |
load_packet_config(packet_dir)
Load and validate a packet.json configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
packet_dir
|
str
|
Directory containing packet.json. |
required |
Returns:
| Type | Description |
|---|---|
PacketConfig
|
Parsed PacketConfig. |
Source code in seed_data/packet.py
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 | |
resolve_shared_context(config, extra='', model='nova2-lite')
Resolve shared context fields for a packet.
If the packet config defines explicit shared_context fields, use those as the schema and ask the LLM to generate values. If not defined, the LLM analyzes all document schemas to infer common fields, then generates values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
PacketConfig
|
Parsed packet configuration. |
required |
extra
|
str
|
Extra instructions / scenario brief from the user. |
''
|
model
|
str
|
Model key for the context-generation agent. |
'nova2-lite'
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary of shared context field names → generated values. |
Source code in seed_data/packet.py
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 | |
write_packet_manifest(results, config, output_dir, command='', elapsed_s=0, **extra_metadata)
Write a packet_manifest.json summarizing the batch of packets.
Returns:
| Type | Description |
|---|---|
str
|
Path to the written manifest. |
Source code in seed_data/packet.py
727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | |