diff --git a/server/src/data/models.rs b/server/src/data/models.rs index 5a1880530..8802d9534 100644 --- a/server/src/data/models.rs +++ b/server/src/data/models.rs @@ -5068,7 +5068,7 @@ impl From for ClickhouseRagTypes { } impl RagQueryEventClickhouse { - pub async fn from_clickhouse(self, pool: web::Data, top_score: f32) -> RagQueryEvent { + pub async fn from_clickhouse(self, pool: web::Data) -> RagQueryEvent { let chunk_ids = self .results .iter() @@ -5106,7 +5106,7 @@ impl RagQueryEventClickhouse { user_message: self.user_message, search_id: uuid::Uuid::from_bytes(*self.search_id.as_bytes()), results, - top_score, + top_score: 0.0, query_rating, dataset_id: uuid::Uuid::from_bytes(*self.dataset_id.as_bytes()), llm_response: self.llm_response, @@ -6518,7 +6518,7 @@ pub enum RAGAnalyticsResponse { #[schema(title = "RAGUsageGraph")] RAGUsageGraph(RAGUsageGraphResponse), #[schema(title = "RAGQueryDetails")] - RAGQueryDetails(RagQueryEvent), + RAGQueryDetails(Box), } #[derive(Debug, Serialize, Deserialize, ToSchema)] diff --git a/server/src/handlers/analytics_handler.rs b/server/src/handlers/analytics_handler.rs index 74d8e563d..97daf80d4 100644 --- a/server/src/handlers/analytics_handler.rs +++ b/server/src/handlers/analytics_handler.rs @@ -388,7 +388,7 @@ pub async fn get_rag_analytics( clickhouse_client.get_ref(), ) .await?; - RAGAnalyticsResponse::RAGQueryDetails(rag_query) + RAGAnalyticsResponse::RAGQueryDetails(Box::new(rag_query)) } }; diff --git a/server/src/operators/analytics_operator.rs b/server/src/operators/analytics_operator.rs index 887fb2188..eb89f7b6d 100644 --- a/server/src/operators/analytics_operator.rs +++ b/server/src/operators/analytics_operator.rs @@ -752,10 +752,8 @@ pub async fn get_rag_queries_query( let mut query_string = String::from( "SELECT ?fields, - top_score, FROM rag_queries - JOIN search_queries ON rag_queries.search_id = search_queries.id WHERE dataset_id = ?", ); @@ -777,7 +775,7 @@ pub async fn get_rag_queries_query( .query(query_string.as_str()) .bind(dataset_id) .bind((page.unwrap_or(1) - 1) * 10) - .fetch_all::<(RagQueryEventClickhouse, f32)>() + .fetch_all::() .await .map_err(|e| { log::error!("Error fetching query: {:?}", e); @@ -787,7 +785,7 @@ pub async fn get_rag_queries_query( let queries: Vec = join_all( clickhouse_query .into_iter() - .map(|(q, score)| q.from_clickhouse(pool.clone(), score)), + .map(|q| q.from_clickhouse(pool.clone())), ) .await; @@ -890,24 +888,18 @@ pub async fn get_rag_query( pool: web::Data, clickhouse_client: &clickhouse::Client, ) -> Result { - let (clickhouse_query, top_score) = clickhouse_client - .query( - "SELECT ?fields, top_score FROM rag_queries - JOIN search_queries ON rag_queries.search_id = search_queries.id - WHERE id = ? AND dataset_id = ?", - ) + let clickhouse_query = clickhouse_client + .query("SELECT ?fields FROM rag_queries WHERE id = ? AND dataset_id = ?") .bind(request_id) .bind(dataset_id) - .fetch_one::<(RagQueryEventClickhouse, f32)>() + .fetch_one::() .await .map_err(|e| { log::error!("Error fetching query: {:?}", e); ServiceError::InternalServerError("Error fetching query".to_string()) })?; - let query: RagQueryEvent = clickhouse_query - .from_clickhouse(pool.clone(), top_score) - .await; + let query: RagQueryEvent = clickhouse_query.from_clickhouse(pool.clone()).await; Ok(query) }