diff --git a/crates/ui/src/main.rs b/crates/ui/src/main.rs index dbbd979..7b69ee9 100644 --- a/crates/ui/src/main.rs +++ b/crates/ui/src/main.rs @@ -109,10 +109,12 @@ async fn fetch_health(path: &str) -> Result { resp.text().await.map_err(|e| e.to_string()) } -/// Get schema context for all datasets (used for AI SQL generation) +/// Get schema context for datasets (used for AI SQL generation). +/// Limits to core tables to keep prompt size reasonable. async fn get_schema_context(datasets: &[Dataset]) -> String { + let core_tables = ["candidates", "clients", "job_orders", "placements", "timesheets", "call_log", "email_log"]; let mut ctx = String::from("DATABASE SCHEMA:\n\n"); - for ds in datasets { + for ds in datasets.iter().filter(|d| core_tables.contains(&d.name.as_str())) { let desc = run_sql(&format!("DESCRIBE {}", ds.name)).await; match desc { Ok(resp) => { @@ -1001,6 +1003,9 @@ fn ResultsTable(response: QueryResponse) -> Element { if response.row_count == 0 { div { class: "empty-sm", "no rows returned" } } else if let Some(rows) = rows { + if rows.len() > 200 { + div { class: "results-info", "Showing first 200 of {response.row_count} rows" } + } div { class: "table-wrap", table { thead { @@ -1011,7 +1016,7 @@ fn ResultsTable(response: QueryResponse) -> Element { } } tbody { - for row in rows.iter() { + for row in rows.iter().take(200) { tr { for col in response.columns.iter() { td { {format_cell(row.get(&col.name))} }