File size: 3,374 Bytes
6086e71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
{
  "user_query": "show me top 5 employees",
  "conversation_history": [],
  "tenant_id": "default",
  "user_role": "analyst",
  "trace_id": "debug",
  "intent": "sql",
  "route_intent": "data_query",
  "entities": [
    "employees"
  ],
  "complexity": "simple",
  "retrieval_top_k": 3,
  "relevant_schema": "TABLE employees (employee_id INT PK, department_id INT, manager_id INT, full_name VARCHAR, role VARCHAR, location VARCHAR, hire_date DATE, base_salary DECIMAL, quota_arr DECIMAL, active TINYINT)\n  FK: employees.department_id β†’ departments.department_id",
  "relevant_tables": [
    "employees"
  ],
  "retrieval_source": "rag_top_k:3",
  "generated_sql": "SELECT full_name, base_salary, role FROM employees ORDER BY base_salary DESC LIMIT 5;",
  "sql_explanation": "Query employees table, sort by base_salary DESC, limit to 5.",
  "friendly_message": "The top 5 employees have base salaries ranging from 193,520.00 to 198,704.00, with an average base salary of 196,112.00. The total base salary for these employees is 980,560.00. All of the top 5 employees hold the role of Account Executive.",
  "is_valid": true,
  "validation_errors": [],
  "sanitized_sql": "SELECT full_name, base_salary, role FROM employees ORDER BY base_salary DESC LIMIT 5;",
  "retry_count": 0,
  "guardrail_warnings": [],
  "guardrail_confidence": 1.0,
  "query_results": [
    {
      "full_name": "Employee 016",
      "base_salary": "198704.00",
      "role": "Account Executive"
    },
    {
      "full_name": "Employee 032",
      "base_salary": "197408.00",
      "role": "Account Executive"
    },
    {
      "full_name": "Employee 048",
      "base_salary": "196112.00",
      "role": "Account Executive"
    },
    {
      "full_name": "Employee 064",
      "base_salary": "194816.00",
      "role": "Account Executive"
    },
    {
      "full_name": "Employee 080",
      "base_salary": "193520.00",
      "role": "Account Executive"
    }
  ],
  "execution_time_ms": 368.55,
  "row_count": 5,
  "column_names": [
    "full_name",
    "base_salary",
    "role"
  ],
  "chart_config": {
    "type": "doughnut",
    "data": {
      "labels": [
        "Employee 016",
        "Employee 032",
        "Employee 048",
        "Employee 064",
        "Employee 080"
      ],
      "datasets": [
        {
          "label": "Base Salary",
          "data": [
            198704.0,
            197408.0,
            196112.0,
            194816.0,
            193520.0
          ],
          "backgroundColor": [
            "#38bdf8",
            "#a855f7",
            "#ec4899",
            "#22c55e",
            "#eab308"
          ],
          "borderColor": "#1e293b",
          "borderWidth": 2
        }
      ]
    },
    "options": {
      "responsive": true,
      "maintainAspectRatio": false,
      "plugins": {
        "legend": {
          "position": "bottom",
          "labels": {
            "color": "#94A3B8"
          }
        }
      }
    }
  },
  "chart_type": "doughnut",
  "insights": [
    "πŸ“Š **5** records returned",
    "**Base Salary**: avg 196,112.00 | min 193,520.00 | max 198,704.00",
    "πŸ“ˆ Upward trend detected in **Base Salary**",
    "🏷️ Most common **full name**: 'Employee 016' (20%)"
  ],
  "follow_up_questions": [
    "Show the bottom performers instead",
    "Visualize this as a chart",
    "Export these results"
  ]
}