mirror of https://github.com/buster-so/buster.git
timeout and file message
This commit is contained in:
parent
8f3fb8732d
commit
8899fb8549
|
@ -34,8 +34,9 @@ use uuid::Uuid;
|
||||||
use crate::chats::{
|
use crate::chats::{
|
||||||
asset_messages::{create_message_file_association, generate_asset_messages},
|
asset_messages::{create_message_file_association, generate_asset_messages},
|
||||||
context_loaders::{
|
context_loaders::{
|
||||||
chat_context::ChatContextLoader, create_asset_context_loader, dashboard_context::DashboardContextLoader,
|
chat_context::ChatContextLoader, create_asset_context_loader,
|
||||||
fetch_asset_details, metric_context::MetricContextLoader, validate_context_request, ContextLoader,
|
dashboard_context::DashboardContextLoader, fetch_asset_details,
|
||||||
|
metric_context::MetricContextLoader, validate_context_request, ContextLoader,
|
||||||
},
|
},
|
||||||
get_chat_handler,
|
get_chat_handler,
|
||||||
streaming_parser::StreamingParser,
|
streaming_parser::StreamingParser,
|
||||||
|
@ -161,7 +162,13 @@ pub async fn post_chat_handler(
|
||||||
let (asset_id, asset_type) = normalize_asset_fields(&request);
|
let (asset_id, asset_type) = normalize_asset_fields(&request);
|
||||||
|
|
||||||
// Validate that only one context type is provided
|
// Validate that only one context type is provided
|
||||||
validate_context_request(request.chat_id, asset_id, asset_type, request.metric_id, request.dashboard_id)?;
|
validate_context_request(
|
||||||
|
request.chat_id,
|
||||||
|
asset_id,
|
||||||
|
asset_type,
|
||||||
|
request.metric_id,
|
||||||
|
request.dashboard_id,
|
||||||
|
)?;
|
||||||
|
|
||||||
let user_org_id = match user.attributes.get("organization_id") {
|
let user_org_id = match user.attributes.get("organization_id") {
|
||||||
Some(Value::String(org_id)) => Uuid::parse_str(org_id).unwrap_or_default(),
|
Some(Value::String(org_id)) => Uuid::parse_str(org_id).unwrap_or_default(),
|
||||||
|
@ -194,11 +201,7 @@ pub async fn post_chat_handler(
|
||||||
let asset_id_value = asset_id.unwrap();
|
let asset_id_value = asset_id.unwrap();
|
||||||
let asset_type_value = asset_type.unwrap();
|
let asset_type_value = asset_type.unwrap();
|
||||||
|
|
||||||
let messages = generate_asset_messages(
|
let messages = generate_asset_messages(asset_id_value, asset_type_value, &user).await?;
|
||||||
asset_id_value,
|
|
||||||
asset_type_value,
|
|
||||||
&user,
|
|
||||||
).await?;
|
|
||||||
|
|
||||||
// Add messages to chat and associate with chat_id
|
// Add messages to chat and associate with chat_id
|
||||||
let mut updated_messages = Vec::new();
|
let mut updated_messages = Vec::new();
|
||||||
|
@ -216,7 +219,8 @@ pub async fn post_chat_handler(
|
||||||
message.id,
|
message.id,
|
||||||
asset_id_value,
|
asset_id_value,
|
||||||
asset_type_value,
|
asset_type_value,
|
||||||
).await;
|
)
|
||||||
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,7 +300,9 @@ pub async fn post_chat_handler(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the new user message (now with unwrap_or_default for optional prompt)
|
// Add the new user message (now with unwrap_or_default for optional prompt)
|
||||||
initial_messages.push(AgentMessage::user(request.prompt.clone().unwrap_or_default()));
|
initial_messages.push(AgentMessage::user(
|
||||||
|
request.prompt.clone().unwrap_or_default(),
|
||||||
|
));
|
||||||
|
|
||||||
// Initialize raw_llm_messages with initial_messages
|
// Initialize raw_llm_messages with initial_messages
|
||||||
let mut raw_llm_messages = initial_messages.clone();
|
let mut raw_llm_messages = initial_messages.clone();
|
||||||
|
@ -945,8 +951,8 @@ pub async fn transform_message(
|
||||||
metadata: Some(vec![BusterChatResponseFileMetadata {
|
metadata: Some(vec![BusterChatResponseFileMetadata {
|
||||||
status: "completed".to_string(),
|
status: "completed".to_string(),
|
||||||
message: format!(
|
message: format!(
|
||||||
"File {} completed",
|
"Created new {}",
|
||||||
file_content.file_name
|
file_content.file_type
|
||||||
),
|
),
|
||||||
timestamp: Some(Utc::now().timestamp()),
|
timestamp: Some(Utc::now().timestamp()),
|
||||||
}]),
|
}]),
|
||||||
|
@ -1031,8 +1037,8 @@ pub async fn transform_message(
|
||||||
metadata: Some(vec![BusterChatResponseFileMetadata {
|
metadata: Some(vec![BusterChatResponseFileMetadata {
|
||||||
status: "completed".to_string(),
|
status: "completed".to_string(),
|
||||||
message: format!(
|
message: format!(
|
||||||
"File {} completed",
|
"Created new {}",
|
||||||
file_content.file_name
|
file_content.file_type
|
||||||
),
|
),
|
||||||
timestamp: Some(Utc::now().timestamp()),
|
timestamp: Some(Utc::now().timestamp()),
|
||||||
}]),
|
}]),
|
||||||
|
|
|
@ -36,7 +36,7 @@ use super::{
|
||||||
collections::collections_router::CollectionEvent, dashboards::dashboards_router::DashboardEvent, data_sources::data_sources_router::DataSourceEvent, datasets::datasets_router::DatasetEvent, metrics::MetricEvent, organizations::organization_router::OrganizationEvent, permissions::permissions_router::PermissionEvent, search::search_router::SearchEvent, sql::sql_router::SqlEvent, teams::teams_routes::TeamEvent, terms::terms_router::TermEvent, threads_and_messages::threads_router::ThreadEvent, users::users_router::UserEvent, ws_router::{ws_router, WsRoutes}, ws_utils::{subscribe_to_stream, unsubscribe_from_stream}
|
collections::collections_router::CollectionEvent, dashboards::dashboards_router::DashboardEvent, data_sources::data_sources_router::DataSourceEvent, datasets::datasets_router::DatasetEvent, metrics::MetricEvent, organizations::organization_router::OrganizationEvent, permissions::permissions_router::PermissionEvent, search::search_router::SearchEvent, sql::sql_router::SqlEvent, teams::teams_routes::TeamEvent, terms::terms_router::TermEvent, threads_and_messages::threads_router::ThreadEvent, users::users_router::UserEvent, ws_router::{ws_router, WsRoutes}, ws_utils::{subscribe_to_stream, unsubscribe_from_stream}
|
||||||
};
|
};
|
||||||
|
|
||||||
const CLIENT_TIMEOUT: Duration = Duration::from_secs(300);
|
const CLIENT_TIMEOUT: Duration = Duration::from_secs(900);
|
||||||
const PING_INTERVAL: Duration = Duration::from_secs(15);
|
const PING_INTERVAL: Duration = Duration::from_secs(15);
|
||||||
const PING_TIMEOUT: Duration = Duration::from_secs(5);
|
const PING_TIMEOUT: Duration = Duration::from_secs(5);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue