diff --git a/src/basic/keywords/add_suggestion.rs b/src/basic/keywords/add_suggestion.rs index c7b49e0f..0ffa3f8d 100644 --- a/src/basic/keywords/add_suggestion.rs +++ b/src/basic/keywords/add_suggestion.rs @@ -311,8 +311,13 @@ fn add_tool_suggestion( params: Option>, button_text: &str, ) -> Result<(), Box> { + info!( + "ADD_SUGGESTION_TOOL called: tool={}, button={}", + tool_name, button_text + ); if let Some(cache_client) = cache { let redis_key = format!("suggestions:{}:{}", user_session.user_id, user_session.id); + info!("Adding suggestion to Redis key: {}", redis_key); // Create action object and serialize it to JSON string let action_obj = json!({ @@ -345,9 +350,7 @@ fn add_tool_suggestion( Ok(length) => { info!( "Added tool suggestion '{}' to session {}, total: {}", - tool_name, - user_session.id, - length + tool_name, user_session.id, length ); } Err(e) => error!("Failed to add tool suggestion to Redis: {}", e), @@ -394,8 +397,13 @@ pub fn get_suggestions( let suggestion = crate::core::shared::models::Suggestion { text: json["text"].as_str().unwrap_or("").to_string(), context: json["context"].as_str().map(|s| s.to_string()), - action: json.get("action").and_then(|v| serde_json::to_string(v).ok()), - icon: json.get("icon").and_then(|v| v.as_str()).map(|s| s.to_string()), + action: json + .get("action") + .and_then(|v| serde_json::to_string(v).ok()), + icon: json + .get("icon") + .and_then(|v| v.as_str()) + .map(|s| s.to_string()), }; suggestions.push(suggestion); } diff --git a/src/basic/keywords/hearing/talk.rs b/src/basic/keywords/hearing/talk.rs index f1555084..e55cab7b 100644 --- a/src/basic/keywords/hearing/talk.rs +++ b/src/basic/keywords/hearing/talk.rs @@ -1,7 +1,7 @@ use crate::core::shared::message_types::MessageType; use crate::core::shared::models::{BotResponse, UserSession}; use crate::core::shared::state::AppState; -use log::{error, trace}; +use log::{error, info, trace}; use rhai::{Dynamic, Engine}; use std::sync::Arc; @@ -12,11 +12,13 @@ pub async fn execute_talk( user_session: UserSession, message: String, ) -> Result> { + info!("TALK called with message: {}", message); let mut suggestions = Vec::new(); if let Some(redis_client) = &state.cache { if let Ok(mut conn) = redis_client.get_multiplexed_async_connection().await { let redis_key = format!("suggestions:{}:{}", user_session.user_id, user_session.id); + info!("TALK: Fetching suggestions from Redis key: {}", redis_key); let suggestions_json: Result, _> = redis::cmd("LRANGE") .arg(redis_key.as_str()) @@ -26,12 +28,17 @@ pub async fn execute_talk( .await; if let Ok(suggestions_list) = suggestions_json { + info!("TALK: Got {} suggestions from Redis", suggestions_list.len()); suggestions = suggestions_list .into_iter() .filter_map(|s| serde_json::from_str(&s).ok()) .collect(); + } else { + info!("TALK: No suggestions found in Redis"); } } + } else { + info!("TALK: No cache configured"); } let channel = user_session diff --git a/src/main_module/server.rs b/src/main_module/server.rs index bc6fde16..abdf2228 100644 --- a/src/main_module/server.rs +++ b/src/main_module/server.rs @@ -170,7 +170,8 @@ pub async fn run_axum_server( .route(ApiUrls::SESSIONS, get(crate::core::session::get_sessions)) .route(ApiUrls::SESSION_HISTORY, get(crate::core::session::get_session_history)) .route(ApiUrls::SESSION_START, post(crate::core::session::start_session)) - .route(ApiUrls::WS, get(crate::core::bot::websocket_handler)); + .route(ApiUrls::WS, get(crate::core::bot::websocket_handler)) + .route("/ws/:bot_name", get(crate::core::bot::websocket_handler_with_bot)); #[cfg(feature = "drive")] {