add in initialize

This commit is contained in:
dal 2025-03-03 16:43:44 -07:00
parent d44e2f2946
commit 8232f628ea
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
5 changed files with 22 additions and 8 deletions

View File

@ -36,6 +36,7 @@ pub enum ThreadEvent {
GeneratingResponseMessage,
GeneratingReasoningMessage,
GeneratingTitle,
InitializeChat,
}
#[derive(Debug, Deserialize, Clone)]
@ -101,6 +102,15 @@ pub async fn post_chat_handler(
created_by_avatar: None,
};
// Send initial chat state to client
if let Some(tx) = tx.clone() {
tx.send(Ok((
BusterContainer::Chat(chat_with_messages.clone()),
ThreadEvent::InitializeChat,
)))
.await?;
}
// Create database connection
let mut conn = get_pg_pool().get().await?;
@ -439,7 +449,7 @@ pub struct BusterReasoningText {
#[serde(rename = "type")]
pub reasoning_type: String,
pub title: String,
pub secondary_title: Option<String>,
pub secondary_title: String,
pub message: Option<String>,
pub message_chunk: Option<String>,
pub status: Option<String>,
@ -491,6 +501,7 @@ pub struct BusterFileMetadata {
#[derive(Debug, Serialize, Clone)]
#[serde(untagged)]
pub enum BusterContainer {
Chat(ChatWithMessages),
ChatMessage(BusterChatMessageContainer),
ReasoningMessage(BusterReasoningMessageContainer),
GeneratingTitle(BusterGeneratingTitle),
@ -1170,7 +1181,7 @@ fn assistant_create_plan(
id: text.id,
thought_type: "thought".to_string(),
title: text.title,
secondary_title: text.secondary_title.unwrap_or_default(),
secondary_title: text.secondary_title,
pill_containers: Some(vec![plan_container]),
status: status.to_string(),
})])

View File

@ -50,7 +50,7 @@ impl StreamingParser {
id,
reasoning_type: "text".to_string(),
title: "Creating a plan...".to_string(),
secondary_title: None,
secondary_title: String::from(""),
message: None,
message_chunk: Some(plan_markdown.to_string()),
status: Some("loading".to_string()),
@ -85,7 +85,7 @@ impl StreamingParser {
id,
reasoning_type: "text".to_string(),
title: "Searching your data catalog...".to_string(),
secondary_title: None,
secondary_title: String::from(""),
message: None,
message_chunk: Some(search_requirements.to_string()),
status: Some("loading".to_string()),

View File

@ -3,7 +3,7 @@ use uuid::Uuid;
use crate::messages::types::ChatMessage;
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ChatWithMessages {
pub id: Uuid,
pub title: String,

View File

@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
use serde_json::Value;
use uuid::Uuid;
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ChatMessage {
pub id: Uuid,
pub request_message: ChatUserMessage,
@ -11,7 +11,7 @@ pub struct ChatMessage {
pub created_at: String,
}
#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ChatUserMessage {
pub request: String,
pub sender_id: Uuid,

View File

@ -43,6 +43,9 @@ pub async fn post_thread(
ThreadEvent::GeneratingTitle => {
WsEvent::Threads(WSThreadEvent::GeneratingTitle)
}
ThreadEvent::InitializeChat => {
WsEvent::Threads(WSThreadEvent::InitializeChat)
}
};
let response = WsResponseMessage::new_no_user(