Skip to content

fix: assign comprehend_client correctly in ComprehendFilterAgent and fix on_llm_start docstring#469

Open
octo-patch wants to merge 1 commit into2FastLabs:mainfrom
octo-patch:fix/issue-359-comprehend-filter-client
Open

fix: assign comprehend_client correctly in ComprehendFilterAgent and fix on_llm_start docstring#469
octo-patch wants to merge 1 commit into2FastLabs:mainfrom
octo-patch:fix/issue-359-comprehend-filter-client

Conversation

@octo-patch
Copy link
Copy Markdown

Fixes #359, fixes #360

Problem 1 (fixes #359)

When ComprehendFilterAgent is initialized without a client option, the constructor assigned the boto3 client to self.client instead of self.comprehend_client. All detection methods (detect_sentiment, detect_pii_entities, detect_toxic_content) reference self.comprehend_client, so they raised AttributeError: 'ComprehendFilterAgent' object has no attribute 'comprehend_client' on the first request.

Solution 1

Changed self.client = boto3.client(...) to self.comprehend_client = boto3.client(...) in both branches of the else block, consistent with the existing options.client path.

Problem 2 (fixes #360)

The on_llm_start docstring listed two incorrect parameters: agent_name (actual parameter is name) and messages (not a parameter of this method at all).

Solution 2

Updated the docstring to match the actual method signature: replaced agent_name with name and removed the non-existent messages entry.

- ComprehendFilterAgent: use self.comprehend_client (not self.client) when
  no client is passed, so detect_sentiment/pii/toxicity methods can find it.
  Fixes 2FastLabs#359
- AgentCallbacks.on_llm_start: correct docstring to match actual parameter
  names (name instead of agent_name, remove non-existent messages param).
  Fixes 2FastLabs#360
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: Agent callback - on_llm_start documentation Bug: Comprehend filter agent - no client exception

1 participant