Closed
Description
Describe the bug
Hey, thanks for this project, this is helping a lot to create examples of how to work with Bedrock Agents using CDK.
I'm trying to update from 0.1.146 to 0.1.148 and getting this error with mypy:
poetry run mypy --pretty aws_lambda_powertools examples
examples/event_handler_bedrock_agents/cdk/bedrock_agent_stack.py: note: In member "__init__" of class "AgentsCdkStack":
examples/event_handler_bedrock_agents/cdk/bedrock_agent_stack.py:34:9: error:
Unexpected keyword argument "action_group_name" for "add_action_group" of
"Agent"; did you mean "action_group"? [call-arg]
agent.add_action_group(
^
/home/runner/.cache/pypoetry/virtualenvs/aws-lambda-powertools-2Yi3cwHL-py3.11/lib/python3.11/site-packages/cdklabs/generative_ai_cdk_constructs/bedrock/__init__.py:751:5: note: "add_action_group" of "Agent" defined here
examples/event_handler_bedrock_agents/cdk/bedrock_agent_stack.py:34:9: error:
Unexpected keyword argument "description" for "add_action_group" of "Agent"
[call-arg]
agent.add_action_group(
^
/home/runner/.cache/pypoetry/virtualenvs/aws-lambda-powertools-2Yi3cwHL-py3.11/lib/python3.11/site-packages/cdklabs/generative_ai_cdk_constructs/bedrock/__init__.py:751:5: note: "add_action_group" of "Agent" defined here
examples/event_handler_bedrock_agents/cdk/bedrock_agent_stack.py:34:9: error:
Unexpected keyword argument "action_group_executor" for "add_action_group" of
"Agent" [call-arg]
agent.add_action_group(
^
/home/runner/.cache/pypoetry/virtualenvs/aws-lambda-powertools-2Yi3cwHL-py3.11/lib/python3.11/site-packages/cdklabs/generative_ai_cdk_constructs/bedrock/__init__.py:751:5: note: "add_action_group" of "Agent" defined here
examples/event_handler_bedrock_agents/cdk/bedrock_agent_stack.py:34:9: error:
Unexpected keyword argument "action_group_state" for "add_action_group" of
"Agent"; did you mean "action_group"? [call-arg]
agent.add_action_group(
^
/home/runner/.cache/pypoetry/virtualenvs/aws-lambda-powertools-2Yi3cwHL-py3.11/lib/python3.11/site-packages/cdklabs/generative_ai_cdk_constructs/bedrock/__init__.py:751:5: note: "add_action_group" of "Agent" defined here
examples/event_handler_bedrock_agents/cdk/bedrock_agent_stack.py:34:9: error:
Unexpected keyword argument "api_schema" for "add_action_group" of "Agent"
[call-arg]
agent.add_action_group(
^
/home/runner/.cache/pypoetry/virtualenvs/aws-lambda-powertools-2Yi3cwHL-py3.11/lib/python3.11/site-packages/cdklabs/generative_ai_cdk_constructs/bedrock/__init__.py:751:5: note: "add_action_group" of "Agent" defined here
To make debugging easier, here is the code:
from aws_cdk import (
Stack,
)
from aws_cdk.aws_lambda import Runtime
from aws_cdk.aws_lambda_python_alpha import PythonFunction
from cdklabs.generative_ai_cdk_constructs.bedrock import (
Agent,
ApiSchema,
BedrockFoundationModel,
)
from constructs import Construct
class AgentsCdkStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)
action_group_function = PythonFunction(
self,
"LambdaFunction",
runtime=Runtime.PYTHON_3_12,
entry="./lambda", # (1)!
index="app.py",
handler="lambda_handler",
)
agent = Agent(
self,
"Agent",
foundation_model=BedrockFoundationModel.ANTHROPIC_CLAUDE_INSTANT_V1_2,
instruction="You are a helpful and friendly agent that answers questions about insurance claims.",
)
agent.add_action_group( # type: ignore[call-arg]
action_group_name="InsureClaimsSupport",
description="Use these functions for insurance claims support",
action_group_executor=action_group_function,
action_group_state="ENABLED",
api_schema=ApiSchema.from_asset("./lambda/openapi.json"), # (2)!
)
Expected Behavior
May it work as in version 0.1.146.
Current Behavior
Mypy errors.
Reproduction Steps
1 - Create a venv
2 - Install mypy and cdklabs.generative-ai-cdk-constructs
3 - Create a stack with the code I sent
4 - Run mypy --pretty DIRECTORY/FILE
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
aws-cdk-lib (2.141.0)
Framework Version
No response
Node.js Version
I'm not deploying the code, so, I don't have nodejs installed
OS
Linux
Language
Python
Language Version
No response
Region experiencing the issue
I'm not deploying the code
Code modification
I don't know
Other information
No response
Service quota
- I have reviewed the service quotas for this construct
Metadata
Metadata
Assignees
Type
Projects
Status
Done