-
-
Save KyMidd/52f077cd3e14157d5f0e7196e8540f9d to your computer and use it in GitHub Desktop.
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
| def handle_message_event(client, body, say, bedrock_client, app, token): | |
| .... | |
| # Build the user's part of the conversation | |
| user_conversation_content, unsupported_file_type_found = build_conversation_content( | |
| event, token | |
| ) | |
| if os.environ.get("VERA_DEBUG", "False") == "True": | |
| print("π User conversation content:", user_conversation_content) | |
| # Check if the thread conversation content is empty. This happens when a user sends an unsupported doc type only, with no message | |
| if user_conversation_content != []: | |
| # Conversation content is not empty, append to conversation | |
| # Append the user's prompt to the conversation | |
| conversation.append( | |
| { | |
| "role": "user", | |
| "content": user_conversation_content, | |
| } | |
| ) | |
| if os.environ.get("VERA_DEBUG", "False") == "True": | |
| print("π State of conversation after append user's prompt:", conversation) | |
| # Check if conversation content is empty, this happens when a user sends an unsupported doc type only, with no message | |
| # Conversation looks like this: [{'role': 'user', 'content': []}] | |
| if os.environ.get("VERA_DEBUG", "False") == "True": | |
| print("π State of conversation before check if convo is empty:", conversation) | |
| if conversation == []: | |
| # Conversation is empty, append to error message | |
| if os.environ.get("VERA_DEBUG", "False") == "True": | |
| print("π Conversation is empty, exiting") | |
| # Announce the error | |
| say( | |
| text=f"> `Error`: Unsupported file type found, please ensure you are sending a supported file type. Supported file types are: images (png, jpeg, gif, webp).", | |
| thread_ts=thread_ts, | |
| ) | |
| return | |
| ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment