Skip to content

Commit 7fcb78a

Browse files
committed
Fix HITL Confidence alerts for Pattern1
1 parent bf656df commit 7fcb78a

File tree

1 file changed

+5
-8
lines changed
  • patterns/pattern-1/src/processresults_function

1 file changed

+5
-8
lines changed

patterns/pattern-1/src/processresults_function/index.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
ssm_client = boto3.client('ssm')
3232
bedrock_client = boto3.client('bedrock-data-automation')
3333
SAGEMAKER_A2I_REVIEW_PORTAL_URL = os.environ.get('SAGEMAKER_A2I_REVIEW_PORTAL_URL', '')
34-
enable_hitl = os.environ.get('ENABLE_HITL', 'false').lower() == 'true'
34+
enable_hitl = os.environ.get('ENABLE_HITL', 'false').lower()
3535

3636
def get_confidence_threshold_from_config(document: Document) -> float:
3737
"""
@@ -871,16 +871,13 @@ def process_segments(
871871
bp_confidence = custom_output["matched_blueprint"]["confidence"]
872872

873873
# Check if any key-value or blueprint confidence is below threshold
874-
if enable_hitl:
875-
874+
if enable_hitl == 'true':
876875
low_confidence = any(
877876
kv['confidence'] < confidence_threshold
878877
for page_num in page_indices
879878
for kv in pagespecific_details['key_value_details'].get(str(page_num), [])
880879
) or float(bp_confidence) < confidence_threshold
881-
else:
882-
low_confidence = 'false'
883-
logger.info(f"HITL STatus Low confidence {low_confidence}")
880+
logger.info(f"HITL Status Low confidence {low_confidence}")
884881

885882
item.update({
886883
"page_array": page_indices,
@@ -900,7 +897,7 @@ def process_segments(
900897
)
901898

902899
if low_confidence:
903-
hitl_triggered = True
900+
hitl_triggered = low_confidence
904901
metrics.put_metric('HITLTriggered', 1)
905902
for page_number in page_indices:
906903
page_str = str(page_number)
@@ -953,7 +950,7 @@ def process_segments(
953950
)
954951

955952
hitl_triggered = enable_hitl
956-
if enable_hitl:
953+
if enable_hitl == 'true':
957954
for page_number in range(start_page, end_page + 1):
958955
ImageUri = f"s3://{output_bucket}/{object_key}/pages/{page_number}/image.jpg"
959956
try:

0 commit comments

Comments
 (0)