Fixed WA's Inf. Loop Msgs | Validated Claude's msg_hist | Added Typing Indicator#171
Merged
waleedkadous merged 4 commits intoApr 20, 2025
Merged
Conversation
Main changes: fix: Modify main_whatsapp to handle incoming messages with background tasks for better performance feat: Implement message splitting functionality in WhatsAppPresenter to handle long messages fix: Added validation check to AnsariClaude to ensure that a "tool_use" block is followed by only 1 "tool_result" block (in self.message_history) Extra details: fix: Added \n\n in AnsariClaude's response to separate between the text before tool's output and the tool's output refactor: Remove unused `stream` option feat: Enhance logging capabilities in ansari_logger to support file logging in DEV_MODE docs: Add example JSON structures for API responses in documentation feat: Update .gitignore to include logs directory fix: Update Python version in Jupyter notebook for API response structure
OdyAsh
commented
Apr 12, 2025
| if m: | ||
| yield m | ||
|
|
||
| def replace_message_history(self, message_history: list[dict], use_tool=True, stream=True): |
Collaborator
Author
There was a problem hiding this comment.
Removed stream parameters across different files, as that logic is not needed anymore (and was never implemented to begin with0
OdyAsh
commented
Apr 12, 2025
| logger.debug( | ||
| f"_log_message called with message role: {message.get('role')}, " | ||
| f"content type: {type(message.get('content'))}, " | ||
| f"_log_message called with message role: {role}{tool_name_log}, " |
Collaborator
Author
There was a problem hiding this comment.
Logging the tool name as well in _log_message()
amrmelsayed
reviewed
Apr 17, 2025
| # Claude API requires text content blocks to be non-empty | ||
| message_content = [{"type": "text", "text": "I'm processing your request."}] | ||
| # If no content blocks, use a single empty text element | ||
| message_content = [{"type": "text", "text": ""}] |
Contributor
There was a problem hiding this comment.
Empty content blocks causes Claude to crash (I think), did you discuss the changes in ansari_claude with Waleed?
- Introduced user-specific presenter creation for better context management. - Improved typing indicator functionality with a dedicated loop. - Updated message handling to ensure proper async flow and task management. - Cleaned up code for readability and maintainability.
Details: due to previous commits (which handled async flow), the previous AnsariClaude adjustments are now redundant (at least based on multiple tests before this commit)
waleedkadous
approved these changes
Apr 20, 2025
| @@ -0,0 +1,66 @@ | |||
| (manually inserted log) ------------------------------------------------------------------------------ FastAPI receives a message from a whatsapp user on /whatsapp/v1 endpoint, so the event loop picks the `main_webhook()` to be executed now ------------------------------------------------------------------------------ | |||
Collaborator
There was a problem hiding this comment.
This file should not be checked in (I don't think)
| * Adding text delta: 'START OF LLM RESPONSE (PARAPHRASED FROM TOOL RESULT)' (truncated) | ||
|
|
||
| So, "TOOL RESULT:" (at the top) will be directly concatenated to "START OF ...". | ||
| But we want to leave `\n\n` between them, so that's what this function does. |
Collaborator
There was a problem hiding this comment.
I am still a bit fuzzy. What problem is this trying to solve?
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Main description mentioned here: 670d928
(Note: Directly after merging this PR, the WHATSAPP_API_VERSION env. var should be set to
V22.0instead ofV21.0).