-
-
Save KyMidd/d52a307c00317ff6aca8af164c4abbf4 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
| # Common function to handle both DMs and app mentions | |
| def handle_message_event(client, body, say, bedrock_client, app, token): | |
| .... | |
| if "thread_ts" in body["event"]: | |
| .... | |
| # Iterate through every message in the thread | |
| for message in messages["messages"]: | |
| # Build the content array | |
| thread_conversation_content, unsupported_file_type_found = ( | |
| build_conversation_content(message, token) | |
| ) | |
| if os.environ.get("VERA_DEBUG", "False") == "True": | |
| print("๐ Thread conversation content:", thread_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 thread_conversation_content != []: | |
| # Conversation content is not empty, append to conversation | |
| # Check if message came from the bot | |
| # We're assuming the bot only generates text content, which is true of Claude v3.5 Sonnet v2 | |
| if "bot_id" in message: | |
| conversation.append( | |
| { | |
| "role": "assistant", | |
| "content": [ | |
| { | |
| "type": "text", | |
| "text": message["text"], | |
| } | |
| ], | |
| } | |
| ) | |
| # If not, the message came from a user | |
| else: | |
| conversation.append( | |
| {"role": "user", "content": thread_conversation_content} | |
| ) | |
| if os.environ.get("VERA_DEBUG", "False") == "True": | |
| print( | |
| "๐ State of conversation after threaded message append:", | |
| conversation, | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment