Skip to content

Commit 5c2eea4

Browse files
committed
improve typing
1 parent 6d5d150 commit 5c2eea4

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/idp_common_pkg/idp_common/extraction/agentic_idp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ async def structured_output_async(
10981098
)
10991099

11001100
review_response = await invoke_agent_with_retry(
1101-
agent=agent, input=review_prompt
1101+
agent=agent, input=[review_prompt]
11021102
)
11031103
logger.debug("Review response received", extra={"review_completed": True})
11041104

lib/idp_common_pkg/idp_common/utils/bedrock_utils.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@
1919
InvokeModelRequestTypeDef,
2020
InvokeModelResponseTypeDef,
2121
)
22-
from strands.types.exceptions import ModelThrottledException
22+
23+
# Optional import for strands-agents (may not be installed in all environments)
24+
try:
25+
from strands.types.exceptions import ModelThrottledException
26+
27+
_STRANDS_AVAILABLE = True
28+
except ImportError:
29+
_STRANDS_AVAILABLE = False
30+
# Create a placeholder exception class that will never match
31+
ModelThrottledException = type("ModelThrottledException", (Exception,), {}) # type: ignore[misc, assignment]
2332

2433
# Configure logger
2534
logger = logging.getLogger(__name__)
@@ -42,8 +51,9 @@
4251
}
4352

4453
# Default retryable exception types (caught by isinstance check)
54+
# Only include ModelThrottledException if strands is available
4555
DEFAULT_RETRYABLE_EXCEPTION_TYPES: tuple[type[Exception], ...] = (
46-
ModelThrottledException,
56+
(ModelThrottledException,) if _STRANDS_AVAILABLE else ()
4757
)
4858

4959

0 commit comments

Comments
 (0)