Skip to content

fix: set comprehend_client when ComprehendFilterAgent creates a default client#514

Open
YuemengZheng wants to merge 1 commit into
2FastLabs:mainfrom
YuemengZheng:fix/comprehend-filter-default-client
Open

fix: set comprehend_client when ComprehendFilterAgent creates a default client#514
YuemengZheng wants to merge 1 commit into
2FastLabs:mainfrom
YuemengZheng:fix/comprehend-filter-default-client

Conversation

@YuemengZheng

Copy link
Copy Markdown

Issue Link (REQUIRED)

Fixes #359

Summary

Changes

When no client is passed to ComprehendFilterAgent, the constructor created the boto3 Comprehend client but assigned it to self.client instead of self.comprehend_client. Since detect_sentiment / detect_pii_entities / detect_toxic_content all use self.comprehend_client, calling process_request raised:
'ComprehendFilterAgent' object has no attribute 'comprehend_client'.

Assign the default-created client to self.comprehend_client so the agent works without an explicitly provided client. Added a regression test that patches boto3.client and asserts comprehend_client is set when client=None.

User experience

Before: constructing a ComprehendFilterAgent without a client (the documented default) crashed on the first request. After: the agent creates its own Comprehend client and runs normally.

Checklist

  • I have performed a self-review of this change
  • Changes have been tested
  • Changes are documented
  • I have linked this PR to an existing issue (required)

When no client was passed, the boto3 client was assigned to self.client
instead of self.comprehend_client, so process_request raised AttributeError.
Assign it to self.comprehend_client and add a regression test.

Closes 2FastLabs#359
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Comprehend filter agent - no client exception

1 participant