-
Notifications
You must be signed in to change notification settings - Fork 621
Description
Expected Behaviour
When I use a ComprehendFilterAgent with no client in the configuration options, it should work without throwing exceptions, when the process_request method is called.
Current Behaviour
When no client is passed to the ComprehendContentFilterAgent, an exception is thrown when process_request is executed:
ERROR:agent_squad.utils.logger:Error in ComprehendContentFilterAgent:'ComprehendFilterAgent' object has no attribute 'comprehend_client'
ERROR:agent_squad.utils.logger:Error processing request with agent Filter agent:'ComprehendFilterAgent' object has no attribute 'comprehend_client'
Code snippet
filter_agent = ComprehendFilterAgent(
ComprehendFilterAgentOptions(
name="Filter agent",
description="Analyzes and filters content using Amazon Comprehend",
enable_sentiment_check=True,
enable_toxicity_check=True,
enable_pii_check=False,
region=os.getenv("AWS_REGION"),
client=None,
)
)
chain_agent = ChainAgent(
ChainAgentOptions(
name="A chain agent",
description="A simple chain agent",
agents=[filter_agent],
)
)
orchestrator.add_agent(chain_agent)
orchestrator.route_request(
"any message", "user_id", "session_id"
)
Possible Solution
in the ComprehendContentFilterAgent set the comprehend_client when no client is passed
if options.client:
self.comprehend_client = options.client
else:
if options.region:
self.comprehend_client = boto3.client(
'comprehend',
region_name=options.region or os.environ.get('AWS_REGION')
)
else:
self.comprehend_client = boto3.client('comprehend')
Steps to Reproduce
- create a comprehedfilteragent with no client
- create another agent, any agent is fine
- create a chain agent and pass it the other agents
- create a orchestrator and pass it the chain agent
- route a message using the orchestrator