diff --git a/api/libs/handlers/src/chats/get_chat_handler.rs b/api/libs/handlers/src/chats/get_chat_handler.rs index c12bead2f..a3fb8634b 100644 --- a/api/libs/handlers/src/chats/get_chat_handler.rs +++ b/api/libs/handlers/src/chats/get_chat_handler.rs @@ -259,7 +259,7 @@ pub async fn get_chat_handler( let request_message = if let Some(request_message) = msg.request_message { Some(ChatUserMessage { - request: request_message, + request: Some(request_message), sender_id: msg.user_id, sender_name: msg.user_name.unwrap_or_else(|| "Unknown".to_string()), sender_avatar, diff --git a/api/libs/handlers/src/chats/post_chat_handler.rs b/api/libs/handlers/src/chats/post_chat_handler.rs index fbfa24b3a..9107ffd63 100644 --- a/api/libs/handlers/src/chats/post_chat_handler.rs +++ b/api/libs/handlers/src/chats/post_chat_handler.rs @@ -292,12 +292,7 @@ pub async fn post_chat_handler( for message in updated_messages { let chat_message = ChatMessage::new_with_messages( message.id, - Some(ChatUserMessage { - request: "".to_string(), - sender_id: user.id, - sender_name: user.name.clone().unwrap_or_default(), - sender_avatar: None, - }), + None, // Use the response_messages from the DB serde_json::from_value(message.response_messages).unwrap_or_default(), vec![], @@ -813,7 +808,7 @@ pub async fn post_chat_handler( let final_message = ChatMessage::new_with_messages( message_id, Some(ChatUserMessage { - request: request.prompt.clone().unwrap_or_default(), + request: request.prompt.clone(), sender_id: user.id, sender_name: user.name.clone().unwrap_or_default(), sender_avatar: None, @@ -2440,7 +2435,7 @@ async fn initialize_chat( let message = ChatMessage::new_with_messages( message_id, Some(ChatUserMessage { - request: prompt_text, + request: Some(prompt_text), sender_id: user.id, sender_name: user.name.clone().unwrap_or_default(), sender_avatar: None, @@ -2479,7 +2474,7 @@ async fn initialize_chat( let message = ChatMessage::new_with_messages( message_id, Some(ChatUserMessage { - request: prompt_text, + request: Some(prompt_text), sender_id: user.id, sender_name: user.name.clone().unwrap_or_default(), sender_avatar: None, diff --git a/api/libs/handlers/src/messages/types.rs b/api/libs/handlers/src/messages/types.rs index 77ccc9d2b..afa9b1099 100644 --- a/api/libs/handlers/src/messages/types.rs +++ b/api/libs/handlers/src/messages/types.rs @@ -24,7 +24,7 @@ pub struct ChatMessage { #[derive(Debug, Serialize, Deserialize, Clone)] pub struct ChatUserMessage { - pub request: String, + pub request: Option, pub sender_id: Uuid, pub sender_name: String, pub sender_avatar: Option, @@ -32,7 +32,7 @@ pub struct ChatUserMessage { impl ChatMessage { pub fn new( - request: String, + request: Option, sender_id: Uuid, sender_name: String, sender_avatar: Option,