Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Last active December 27, 2024 20:16
Show Gist options
  • Select an option

  • Save KyMidd/52f077cd3e14157d5f0e7196e8540f9d to your computer and use it in GitHub Desktop.

Select an option

Save KyMidd/52f077cd3e14157d5f0e7196e8540f9d to your computer and use it in GitHub Desktop.
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