From fc5736a4b315969bd2910a1662d1098cd2a9aacd Mon Sep 17 00:00:00 2001 From: dal Date: Wed, 9 Apr 2025 17:17:05 -0600 Subject: [PATCH] ok I think I fixed the ghost message --- api/libs/handlers/src/chats/post_chat_handler.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/libs/handlers/src/chats/post_chat_handler.rs b/api/libs/handlers/src/chats/post_chat_handler.rs index c6bcc5d5f..308c667da 100644 --- a/api/libs/handlers/src/chats/post_chat_handler.rs +++ b/api/libs/handlers/src/chats/post_chat_handler.rs @@ -210,11 +210,18 @@ pub async fn post_chat_handler( } if request.prompt.is_none() && asset_id.is_some() && asset_type.is_some() { + // Remove the initial empty message added by initialize_chat in this specific case + let message_id_str = message_id.to_string(); + chat_with_messages.messages.remove(&message_id_str); + chat_with_messages.message_ids.retain(|id| id != &message_id_str); + let asset_id_value = asset_id.unwrap(); let asset_type_value = asset_type.unwrap(); let messages = generate_asset_messages(asset_id_value, asset_type_value, &user).await?; + println!("messages: {:?}", messages); + // Add messages to chat and associate with chat_id let mut updated_messages = Vec::new(); for mut message in messages {