33# SPDX-License-Identifier: MIT-0
44
55"""
6- Example usage of the Granular Assessment Service.
6+ Example usage of the Strands-Based Assessment Service.
77
8- This script demonstrates how to use the granular assessment approach
8+ This script demonstrates how to use the Strands-based assessment approach
99for improved accuracy and scalability when assessing document extraction confidence.
10+ All assessment now uses this unified approach with tool-based agent interactions.
1011"""
1112
1213import json
@@ -30,13 +31,14 @@ def load_config(config_path: str) -> Dict[str, Any]:
3031
3132
3233def example_granular_assessment ():
33- """Example of using granular assessment service."""
34+ """Example of using Strands-based assessment service."""
3435
35- # Load configuration with granular assessment enabled
36+ # Load configuration for assessment (always uses Strands-based approach)
3637 config = {
3738 "assessment" : {
39+ "enabled" : True ,
3840 "default_confidence_threshold" : 0.9 ,
39- "model" : "us.anthropic.claude-3-7- sonnet-20250219 -v1:0" ,
41+ "model" : "us.anthropic.claude-sonnet-4-20250514 -v1:0" ,
4042 "system_prompt" : "You are a document analysis assessment expert..." ,
4143 "task_prompt" : """
4244 <background>
@@ -53,13 +55,8 @@ def example_granular_assessment():
5355 Analyze and provide confidence assessments...
5456 </final-instructions>
5557 """ ,
56- # Granular assessment configuration
57- "granular" : {
58- "enabled" : True ,
59- "max_workers" : 20 ,
60- "simple_batch_size" : 3 ,
61- "list_batch_size" : 1 ,
62- },
58+ # Strands-based assessment settings
59+ "max_workers" : 20 ,
6360 },
6461 "classes" : [
6562 {
@@ -158,86 +155,61 @@ def example_granular_assessment():
158155
159156
160157def compare_approaches ():
161- """Compare original vs granular assessment approaches."""
162-
163- logger .info ("=== Comparison: Original vs Granular Assessment ===" )
158+ """Demonstrate the Strands-based assessment approach."""
164159
165- # Configuration for original approach
166- original_config = {"assessment" : {"granular" : {"enabled" : False }}}
160+ logger .info ("=== Strands-Based Assessment Approach ===" )
167161
168- # Configuration for granular approach
169- granular_config = {
162+ # Configuration for Strands-based assessment (always used)
163+ assessment_config = {
170164 "assessment" : {
171- "granular" : {
172- "enabled" : True ,
173- "max_workers" : 4 ,
174- "simple_batch_size" : 3 ,
175- "list_batch_size" : 1 ,
176- }
165+ "enabled" : True ,
166+ "max_workers" : 4 ,
177167 }
178168 }
179169
180170 from idp_common .assessment import create_assessment_service
181171
182- # Create both services
183- original_service = create_assessment_service (config = original_config )
184- granular_service = create_assessment_service (config = granular_config )
185-
186- logger .info (f"Original service: { type (original_service ).__name__ } " )
187- logger .info (f"Granular service: { type (granular_service ).__name__ } " )
172+ # Create assessment service
173+ assessment_service = create_assessment_service (config = assessment_config )
188174
189- # Show the differences
190- logger .info ("\n Key Differences:" )
191- logger .info ("Original Approach:" )
192- logger .info (" - Single inference for all attributes" )
193- logger .info (" - Simple implementation" )
194- logger .info (" - May struggle with complex documents" )
175+ logger .info (f"Assessment service: { type (assessment_service ).__name__ } " )
195176
196- logger .info ("\n Granular Approach:" )
197- logger .info (" - Multiple focused inferences" )
177+ # Show the features
178+ logger .info ("\n Strands-Based Assessment Features:" )
179+ logger .info (" - Multiple focused inferences per field" )
180+ logger .info (" - Tool-based interaction with Strands agents" )
198181 logger .info (" - Prompt caching for cost optimization" )
199182 logger .info (" - Parallel processing for speed" )
200183 logger .info (" - Better handling of complex documents" )
184+ logger .info (" - Consistent assessment structure" )
201185
202186
203187def demonstrate_configuration_options ():
204- """Demonstrate different configuration options for granular assessment."""
188+ """Demonstrate different configuration options for Strands-based assessment."""
205189
206190 logger .info ("=== Configuration Options ===" )
207191
208192 # Conservative configuration (good for starting)
209193 conservative_config = {
210194 "assessment" : {
211- "granular" : {
212- "enabled" : True ,
213- "max_workers" : 2 ,
214- "simple_batch_size" : 2 ,
215- "list_batch_size" : 1 ,
216- }
195+ "enabled" : True ,
196+ "max_workers" : 2 ,
217197 }
218198 }
219199
220200 # Aggressive configuration (for high-throughput)
221201 aggressive_config = {
222202 "assessment" : {
223- "granular" : {
224- "enabled" : True ,
225- "max_workers" : 8 ,
226- "simple_batch_size" : 5 ,
227- "list_batch_size" : 2 ,
228- }
203+ "enabled" : True ,
204+ "max_workers" : 50 ,
229205 }
230206 }
231207
232208 # Balanced configuration (recommended)
233209 balanced_config = {
234210 "assessment" : {
235- "granular" : {
236- "enabled" : True ,
237- "max_workers" : 4 ,
238- "simple_batch_size" : 3 ,
239- "list_batch_size" : 1 ,
240- }
211+ "enabled" : True ,
212+ "max_workers" : 20 ,
241213 }
242214 }
243215
@@ -249,35 +221,36 @@ def demonstrate_configuration_options():
249221
250222 for name , config in configs .items ():
251223 logger .info (f"\n { name } Configuration:" )
252- granular_settings = config ["assessment" ][ "granular " ]
253- for key , value in granular_settings .items ():
224+ assessment_settings = config ["assessment" ]
225+ for key , value in assessment_settings .items ():
254226 logger .info (f" { key } : { value } " )
255227
256228
257229def main ():
258230 """Main example function."""
259231
260- logger .info ("=== Granular Assessment Service Examples ===" )
232+ logger .info ("=== Strands-Based Assessment Service Examples ===" )
261233
262234 try :
263235 # Example 1: Basic usage
264236 logger .info ("\n 1. Basic Usage Example" )
265237 service , config = example_granular_assessment ()
266238
267- # Example 2: Compare approaches
268- logger .info ("\n 2. Approach Comparison " )
239+ # Example 2: Demonstrate the approach
240+ logger .info ("\n 2. Assessment Approach " )
269241 compare_approaches ()
270242
271243 # Example 3: Configuration options
272244 logger .info ("\n 3. Configuration Options" )
273245 demonstrate_configuration_options ()
274246
275247 logger .info ("\n === Examples Complete ===" )
276- logger .info ("To use granular assessment in your application:" )
277- logger .info ("1. Add granular configuration to your config file" )
278- logger .info ("2. Use create_assessment_service() factory function" )
279- logger .info ("3. Process documents with the same interface" )
280- logger .info ("4. Monitor performance and tune parameters" )
248+ logger .info ("To use Strands-based assessment in your application:" )
249+ logger .info ("1. Set assessment.enabled to true in your config" )
250+ logger .info ("2. Configure max_workers based on your throughput needs" )
251+ logger .info ("3. Use create_assessment_service() factory function" )
252+ logger .info ("4. Process documents with the same interface" )
253+ logger .info ("5. Monitor performance and tune max_workers parameter" )
281254
282255 except ImportError as e :
283256 logger .error (f"Import error: { e } " )
0 commit comments