|
31 | 31 | logger = logging.getLogger(__name__) |
32 | 32 |
|
33 | 33 |
|
34 | | -logger = logging.getLogger(__name__) |
35 | | - |
36 | | - |
37 | 34 | class ExtractionService: |
38 | 35 | """Service for extracting fields from documents using LLMs.""" |
39 | 36 |
|
@@ -1324,11 +1321,29 @@ def process_document_section(self, document: Document, section_id: str) -> Docum |
1324 | 1321 | # Time the model invocation |
1325 | 1322 | request_start_time = time.time() |
1326 | 1323 |
|
1327 | | - if ( |
| 1324 | + agentic_enabled = ( |
1328 | 1325 | self.config.get("extraction", {}) |
1329 | 1326 | .get("agentic", {}) |
1330 | 1327 | .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: |
1332 | 1347 | if not AGENTIC_AVAILABLE: |
1333 | 1348 | raise ImportError( |
1334 | 1349 | "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 |
1358 | 1373 | data_format=dynamic_model, |
1359 | 1374 | prompt=message_prompt, # pyright: ignore[reportArgumentType] |
1360 | 1375 | custom_instruction=system_prompt, |
1361 | | - review_agent=self.config.get("extraction", {}).get( |
1362 | | - "review_agent", False |
1363 | | - ), |
| 1376 | + review_agent=agentic_review_agent_enabled, |
1364 | 1377 | context="Extraction", |
1365 | 1378 | ) |
1366 | 1379 |
|
|
0 commit comments