Skip to content

Commit 08423df

Browse files
committed
Fix Agentic config reading
Config Can return boolean values as strings, we need to handle the case for bool and string values
1 parent 9d098d8 commit 08423df

File tree

1 file changed

+21
-8
lines changed
  • lib/idp_common_pkg/idp_common/extraction

1 file changed

+21
-8
lines changed

lib/idp_common_pkg/idp_common/extraction/service.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131
logger = logging.getLogger(__name__)
3232

3333

34-
logger = logging.getLogger(__name__)
35-
36-
3734
class ExtractionService:
3835
"""Service for extracting fields from documents using LLMs."""
3936

@@ -1324,11 +1321,29 @@ def process_document_section(self, document: Document, section_id: str) -> Docum
13241321
# Time the model invocation
13251322
request_start_time = time.time()
13261323

1327-
if (
1324+
agentic_enabled = (
13281325
self.config.get("extraction", {})
13291326
.get("agentic", {})
13301327
.get("enabled", False)
1331-
):
1328+
)
1329+
1330+
agentic_enabled = (
1331+
isinstance(agentic_enabled, str) and agentic_enabled.lower() == "true"
1332+
) or (isinstance(agentic_enabled, bool) and agentic_enabled)
1333+
1334+
agentic_review_agent_enabled = self.config.get("extraction", {}).get(
1335+
"review_agent", False
1336+
)
1337+
1338+
agentic_review_agent_enabled = (
1339+
isinstance(agentic_review_agent_enabled, str)
1340+
and agentic_review_agent_enabled.lower() == "true"
1341+
) or (
1342+
isinstance(agentic_review_agent_enabled, bool)
1343+
and agentic_review_agent_enabled
1344+
)
1345+
1346+
if agentic_enabled:
13321347
if not AGENTIC_AVAILABLE:
13331348
raise ImportError(
13341349
"Agentic extraction requires Python 3.10+ and strands-agents dependencies. "
@@ -1358,9 +1373,7 @@ def process_document_section(self, document: Document, section_id: str) -> Docum
13581373
data_format=dynamic_model,
13591374
prompt=message_prompt, # pyright: ignore[reportArgumentType]
13601375
custom_instruction=system_prompt,
1361-
review_agent=self.config.get("extraction", {}).get(
1362-
"review_agent", False
1363-
),
1376+
review_agent=agentic_review_agent_enabled,
13641377
context="Extraction",
13651378
)
13661379

0 commit comments

Comments
 (0)