You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Cache successful page classifications (only when some pages fail - for retry scenarios)
466
+
successful_results= [
467
+
r
468
+
forrinall_page_results
469
+
if"error"notinr.classification.metadata
470
+
]
471
+
ifsuccessful_results:
472
+
logger.info(
473
+
f"Caching {len(successful_results)} successful page classifications for document {document.id} due to {len(failed_page_exceptions)} failed pages (retry scenario)"
474
+
)
475
+
self._cache_successful_page_classifications(
476
+
document, successful_results
477
+
)
478
+
else:
479
+
logger.warning(
480
+
f"No successful page classifications to cache for document {document.id} - all {len(failed_page_exceptions)} pages failed"
481
+
)
482
+
else:
483
+
# All pages succeeded - no need to cache since there won't be retries
484
+
logger.info(
485
+
f"All pages succeeded for document {document.id} - skipping cache (no retry needed)"
486
+
)
457
487
else:
458
488
logger.info(
459
489
f"All {len(cached_page_classifications)} page classifications found in cache"
460
490
)
461
491
462
-
# Group pages into sections
492
+
# Group pages into sections only if we have results
description: "Number of pages to use for classification [When set to a number, forces the entire document to be assigned a single class]"
519
+
enum: ["ALL", "1", "2", "3", "5", "10"]
520
+
order: 3
518
521
temperature:
519
522
type: number
520
523
minimum: 0
521
524
maximum: 1
522
525
description: Sampling temperature
523
-
order: 3
526
+
order: 4
524
527
top_k:
525
528
type: integer
526
529
minimum: 1
527
530
description: Sampling Top K
528
-
order: 4
531
+
order: 5
529
532
top_p:
530
533
type: number
531
534
description: Sampling Top P
532
-
order: 5
535
+
order: 6
533
536
max_tokens:
534
537
type: number
535
538
description: Max tokens
536
-
order: 6
539
+
order: 7
537
540
system_prompt:
538
541
type: string
539
542
description: System prompt
540
-
order: 7
543
+
order: 8
541
544
task_prompt:
542
545
type: string
543
546
description: Task prompt - include placeholders {CLASS_NAMES_AND_DESCRIPTIONS} (replaced with the class names and descriptions for all specified classes), {FEW_SHOT_EXAMPLES} (replaced by classPrompt and image data from examples in class definitions), {DOCUMENT_TEXT} (replaced by the OCR output), and for multi-modal classification {DOCUMENT_IMAGE} (replaced by the page image attachment). Optionally use <<CACHEPOINT>> to separate static and dynamic elements of prompt for Bedrock prompt caching.
Copy file name to clipboardExpand all lines: template.yaml
-2Lines changed: 0 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -114,8 +114,6 @@ Parameters:
114
114
Description: >-
115
115
Select the configuration preset for Pattern 1. Each configuration contains pre-tuned settings for specific document processing scenarios - see https://github.com/aws-samples/sample-genai-idp/blob/main/config_library/README.md. Note: This selected configuration will be replaced by the Custom Configuration Path if specified.
0 commit comments