Extracts relevant information from the request body, such as the webhook description, username, conversation ID, and simplified payload.
Checks for any attachments in the comment and processes them accordingly. If there are no memories of the attachment, it fetches the attachment description using the vision API and stores it as a memory. If there are memories of the attachment, it retrieves them from the database and adds them to the formatted messages array.
Fetches the context messages for the conversation from the database and adds them to the formatted messages array.
Adds the webhook description and contents to the formatted messages array as system and user messages, respectively.
Removes any embedding objects from the formatted messages.
Constructs the final message chain by combining the formatted messages and the user's message.
Processes the message chain using the processMessageChain function.
Extracts the last message from the processed message chain.
POSTs the response back to the Missive API using the conversation ID.
Logs the response status and body from the Missive API.
Extracts relevant information from the request body, such as the webhook description, username, conversation ID, and simplified payload.
Checks for any attachments in the comment and processes them accordingly. If there are no memories of the attachment, it fetches the attachment description using the vision API and stores it as a memory. If there are memories of the attachment, it retrieves them from the database and adds them to the formatted messages array.
Fetches the context messages for the conversation from the database and adds them to the formatted messages array.
Adds the webhook description and contents to the formatted messages array as system and user messages, respectively.
Removes any embedding objects from the formatted messages.
Constructs the final message chain by combining the formatted messages and the user's message.
Processes the message chain using the processMessageChain function.
Extracts the last message from the processed message chain.
POSTs the response back to the Missive API using the conversation ID.
Logs the response status and body from the Missive API.