Skip to content

Commit edfe986

Browse files
author
Bob Strahan
committed
Add configuration-based assessment and summarization control with runtime enable/disable
1 parent dc12559 commit edfe986

File tree

16 files changed

+488
-72
lines changed

16 files changed

+488
-72
lines changed

CHANGELOG.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,29 @@ SPDX-License-Identifier: MIT-0
1313
- **Cost Optimization**: When disabled, no LLM API calls or S3 operations are performed
1414
- **Configuration Example**: Set `summarization.enabled: false` to disable, `enabled: true` to enable (default)
1515

16-
### Changed
17-
- **State Machine Simplification**: Removed `SummarizationChoice` conditional states from all patterns (Pattern 1, 2, 3) for cleaner workflows
18-
- **Service Logic Enhancement**: SummarizationService now checks configuration `enabled` flag at the beginning of `process_document()`
19-
- **Configuration Schema Updates**: Added `enabled` boolean property to summarization sections in all CloudFormation template schemas
16+
- **Configuration-Based Assessment Control**
17+
- Assessment can now be enabled/disabled via configuration file `assessment.enabled` property instead of CloudFormation stack parameter
18+
- **Key Benefits**: Runtime control without stack redeployment, zero LLM costs when disabled, simplified state machine architecture, backward compatible defaults
19+
- **Implementation**: Always calls AssessmentStep but service skips processing when `enabled: false`
20+
- **Cost Optimization**: When disabled, no LLM API calls or S3 operations are performed
21+
- **Configuration Example**: Set `assessment.enabled: false` to disable, `enabled: true` to enable (default)
22+
23+
### Changed
24+
- **State Machine Simplification**: Removed `SummarizationChoice` and `AssessmentChoice` conditional states from all patterns (Pattern 2, 3) for cleaner workflows
25+
- **Service Logic Enhancement**: SummarizationService and AssessmentService now check configuration `enabled` flag at the beginning of processing methods
26+
- **Configuration Schema Updates**: Added `enabled` boolean property to summarization and assessment sections in all CloudFormation template schemas
27+
- Updated all sample configurations to include `summarization.enabled: true` and `assessment.enabled: true`
28+
- Updated configuration documentation with new summarization and assessment control approaches
2029

2130
### Removed
22-
- **CloudFormation Parameter**: Removed `IsSummarizationEnabled` parameter from all pattern templates (patterns/pattern-1, pattern-2, pattern-3)
23-
- **Related Conditions**: Removed `IsSummarizationEnabled` conditions and state machine definition substitutions
31+
- **CloudFormation Parameters**: Removed `IsSummarizationEnabled` and `IsAssessmentEnabled` parameters from all pattern templates
32+
- **Related Conditions**: Removed parameter conditions and state machine definition substitutions for both features
33+
- **Conditional Logic**: Eliminated complex conditional logic from state machine definitions for summarization and assessment steps
34+
35+
### Fixed
36+
- **CloudFormation Template Deployment Error**: Fixed "Template format error: Unresolved resource dependencies [IsAssessmentEnabled]" by removing final parameter reference in main template PATTERN3STACK parameters
37+
- **State Machine Logic**: Simplified conditional assessment/summarization steps that were causing complex workflow logic
38+
- **Parameter Dependencies**: Cleaned up all CloudFormation parameter dependencies and references
2439

2540
### Documentation
2641
- **Updated Documentation**: Enhanced docs/configuration.md, docs/architecture.md, and all pattern-specific docs (pattern-1.md, pattern-2.md, pattern-3.md)

config_library/pattern-2/bank-statement-sample/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ summarization:
369369
system_prompt: >-
370370
You are a document summarization expert who can analyze and summarize documents from various domains including medical, financial, legal, and general business documents. Your task is to create a summary that captures the key information, main points, and important details from the document. Your output must be in valid JSON format. \nSummarization Style: Balanced\\nCreate a balanced summary that provides a moderate level of detail. Include the main points and key supporting information, while maintaining the document's overall structure. Aim for a comprehensive yet concise summary.\n Your output MUST be in valid JSON format with markdown content. You MUST strictly adhere to the output format specified in the instructions.
371371
assessment:
372+
enabled: true
372373
image:
373374
target_height: ''
374375
target_width: ''

config_library/pattern-2/lending-package-sample/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,7 @@ summarization:
11441144
system_prompt: >-
11451145
You are a document summarization expert who can analyze and summarize documents from various domains including medical, financial, legal, and general business documents. Your task is to create a summary that captures the key information, main points, and important details from the document. Your output must be in valid JSON format. \nSummarization Style: Balanced\\nCreate a balanced summary that provides a moderate level of detail. Include the main points and key supporting information, while maintaining the document's overall structure. Aim for a comprehensive yet concise summary.\n Your output MUST be in valid JSON format with markdown content. You MUST strictly adhere to the output format specified in the instructions.
11461146
assessment:
1147+
enabled: true
11471148
image:
11481149
target_height: ''
11491150
target_width: ''

config_library/pattern-2/rvl-cdip-package-sample-with-few-shot-examples/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,7 @@ pricing:
886886
- name: cacheWriteInputTokens
887887
price: '3.75E-6'
888888
assessment:
889+
enabled: true
889890
image:
890891
target_height: ''
891892
target_width: ''

config_library/pattern-2/rvl-cdip-package-sample/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@ summarization:
609609
system_prompt: >-
610610
You are a document summarization expert who can analyze and summarize documents from various domains including medical, financial, legal, and general business documents. Your task is to create a summary that captures the key information, main points, and important details from the document. Your output must be in valid JSON format. \nSummarization Style: Balanced\\nCreate a balanced summary that provides a moderate level of detail. Include the main points and key supporting information, while maintaining the document's overall structure. Aim for a comprehensive yet concise summary.\n Your output MUST be in valid JSON format with markdown content. You MUST strictly adhere to the output format specified in the instructions.
611611
assessment:
612+
enabled: true
612613
image:
613614
target_height: ''
614615
target_width: ''

config_library/pattern-3/rvl-cdip-package-sample/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ summarization:
469469
system_prompt: >-
470470
You are a document summarization expert who can analyze and summarize documents from various domains including medical, financial, legal, and general business documents. Your task is to create a summary that captures the key information, main points, and important details from the document. Your output must be in valid JSON format. \nSummarization Style: Balanced\\nCreate a balanced summary that provides a moderate level of detail. Include the main points and key supporting information, while maintaining the document's overall structure. Aim for a comprehensive yet concise summary.\n Your output MUST be in valid JSON format with markdown content. You MUST strictly adhere to the output format specified in the instructions.
471471
assessment:
472+
enabled: true
472473
image:
473474
target_width: ''
474475
target_height: ''

docs/assessment.md

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,33 @@ The assessment step is conditionally integrated into Pattern-2's ProcessSections
5454

5555
## Configuration
5656

57-
### Deployment Parameter
57+
### Configuration-Based Control
5858

59-
Enable assessment during stack deployment:
59+
Assessment can now be controlled via the configuration file rather than CloudFormation stack parameters. This provides more flexibility and eliminates the need for stack redeployment when changing assessment behavior.
6060

61+
**Configuration-based Control (Recommended):**
6162
```yaml
62-
Parameters:
63-
IsAssessmentEnabled:
64-
Type: String
65-
Default: "false"
66-
AllowedValues: ["true", "false"]
67-
Description: Enable assessment functionality for extraction confidence evaluation
63+
assessment:
64+
enabled: true # Set to false to disable assessment
65+
model: us.amazon.nova-lite-v1:0
66+
temperature: 0.0
67+
# ... other assessment settings
6868
```
6969

70+
**Key Benefits:**
71+
- **Runtime Control**: Enable/disable without stack redeployment
72+
- **Cost Optimization**: Zero LLM costs when disabled (`enabled: false`)
73+
- **Simplified Architecture**: No conditional logic in state machines
74+
- **Backward Compatible**: Defaults to `enabled: true` when property is missing
75+
76+
**Behavior When Disabled:**
77+
- Assessment lambda is still called (minimal overhead)
78+
- Service immediately returns with logging: "Assessment is disabled via configuration"
79+
- No LLM API calls or S3 operations are performed
80+
- Document processing continues to completion
81+
82+
**Migration Note**: The previous `IsAssessmentEnabled` CloudFormation parameter has been removed in favor of this configuration-based approach.
83+
7084
### Assessment Configuration Section
7185

7286
Add the assessment section to your configuration YAML:
@@ -808,7 +822,7 @@ The assessment feature implements several cost optimization techniques:
808822

809823
1. **Text Confidence Data**: Uses condensed OCR confidence information instead of full raw OCR results (80-90% token reduction)
810824
2. **Conditional Image Processing**: Images only processed when `{DOCUMENT_IMAGE}` placeholder is present
811-
3. **Optional Deployment**: Assessment infrastructure only deployed when `IsAssessmentEnabled=true`
825+
3. **Configuration-Based Control**: Assessment can be enabled/disabled via configuration `enabled` property for flexible deployment
812826
4. **Efficient Prompting**: Optimized prompt templates minimize token usage while maintaining accuracy
813827
5. **Configurable Image Dimensions**: Adjust image resolution to balance assessment quality and processing costs
814828
6. **Granular Assessment with Caching**: For complex documents, use granular assessment with prompt caching for 60-80% cost reduction
@@ -889,7 +903,7 @@ ValueError: "Assessment prompt template formatting failed: missing required plac
889903
### Common Issues
890904

891905
1. **Assessment Not Running**
892-
- Verify `IsAssessmentEnabled=true` in deployment
906+
- Verify `assessment.enabled: true` in configuration file
893907
- Check state machine definition includes assessment step
894908
- Confirm assessment Lambda function deployed successfully
895909

docs/configuration.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,35 @@ summarization:
5656

5757
**Migration Note**: The previous `IsSummarizationEnabled` CloudFormation parameter has been removed in favor of this configuration-based approach.
5858

59+
## Assessment Configuration
60+
61+
### Enable/Disable Assessment
62+
63+
Similar to summarization, assessment can now be controlled via the configuration file rather than CloudFormation stack parameters. This provides more flexibility and eliminates the need for stack redeployment when changing assessment behavior.
64+
65+
**Configuration-based Control (Recommended):**
66+
```yaml
67+
assessment:
68+
enabled: true # Set to false to disable assessment
69+
model: us.amazon.nova-lite-v1:0
70+
temperature: 0.0
71+
# ... other assessment settings
72+
```
73+
74+
**Key Benefits:**
75+
- **Runtime Control**: Enable/disable without stack redeployment
76+
- **Cost Optimization**: Zero LLM costs when disabled (`enabled: false`)
77+
- **Simplified Architecture**: No conditional logic in state machines
78+
- **Backward Compatible**: Defaults to `enabled: true` when property is missing
79+
80+
**Behavior When Disabled:**
81+
- Assessment lambda is still called (minimal overhead)
82+
- Service immediately returns with logging: "Assessment is disabled via configuration"
83+
- No LLM API calls or S3 operations are performed
84+
- Document processing continues to completion
85+
86+
**Migration Note**: The previous `IsAssessmentEnabled` CloudFormation parameter has been removed in favor of this configuration-based approach.
87+
5988
## Stack Parameters
6089

6190
Key parameters that can be configured during CloudFormation deployment:

docs/evaluation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ The framework supports multiple comparison methods:
4343

4444
## Assessment Confidence Integration
4545

46-
The evaluation framework automatically integrates with the assessment feature to provide enhanced quality insights. When documents have been processed with assessment enabled, the evaluation reports include confidence scores alongside traditional accuracy metrics.
46+
The evaluation framework automatically integrates with the assessment feature to provide enhanced quality insights. When documents have been processed with assessment enabled via the configuration `assessment.enabled: true` property, the evaluation reports include confidence scores alongside traditional accuracy metrics.
4747

4848
### Confidence Score Display
4949

docs/pattern-2.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -619,16 +619,32 @@ The assessment feature runs after successful extraction and provides:
619619

620620
### Enabling Assessment
621621

622-
Assessment is controlled by the `IsAssessmentEnabled` deployment parameter:
622+
Assessment can now be controlled via the configuration file rather than CloudFormation stack parameters. This provides more flexibility and eliminates the need for stack redeployment when changing assessment behavior.
623623

624-
```bash
625-
# Deploy with assessment enabled
626-
aws cloudformation deploy \
627-
--template-file template.yaml \
628-
--parameter-overrides IsAssessmentEnabled=true
624+
**Configuration-based Control (Recommended):**
625+
```yaml
626+
assessment:
627+
enabled: true # Set to false to disable assessment
628+
model: us.amazon.nova-lite-v1:0
629+
temperature: 0.0
630+
# ... other assessment settings
629631
```
630632

631-
When enabled, the assessment step is conditionally added to the state machine workflow:
633+
**Key Benefits:**
634+
- **Runtime Control**: Enable/disable without stack redeployment
635+
- **Cost Optimization**: Zero LLM costs when disabled (`enabled: false`)
636+
- **Simplified Architecture**: No conditional logic in state machines
637+
- **Backward Compatible**: Defaults to `enabled: true` when property is missing
638+
639+
**Behavior When Disabled:**
640+
- Assessment lambda is still called (minimal overhead)
641+
- Service immediately returns with logging: "Assessment is disabled via configuration"
642+
- No LLM API calls or S3 operations are performed
643+
- Document processing continues to completion
644+
645+
**Migration Note**: The previous `IsAssessmentEnabled` CloudFormation parameter has been removed in favor of this configuration-based approach.
646+
647+
The assessment step is always called in the state machine workflow, but the service itself handles the enablement decision:
632648

633649
```
634650
OCRStep → ClassificationStep → ProcessPageGroups (Map State):

0 commit comments

Comments
 (0)