abir-hr196 commited on
Commit
e03518e
·
1 Parent(s): 6367ff1
Files changed (2) hide show
  1. app.py +65 -36
  2. tinysql_model_demo.py +7 -6
app.py CHANGED
@@ -10,6 +10,7 @@ custom_css = """
10
  --martian-gray-medium: #2A2A2A;
11
  }
12
 
 
13
  .gradio-container, .gradio-container * {
14
  color-scheme: dark !important;
15
  }
@@ -20,15 +21,17 @@ custom_css = """
20
  color: #E0E0E0 !important;
21
  }
22
 
 
23
  .block, .panel, div, section {
24
  background-color: var(--martian-black) !important;
25
  }
26
 
 
27
  h1, h2, h3, h4, h5, h6, p, span, label, div {
28
  color: #E0E0E0 !important;
29
  }
30
 
31
- /* TABS - Bigger, bolder */
32
  .tab-nav {
33
  border-bottom: 2px solid var(--martian-gray-dark) !important;
34
  background: var(--martian-gray-dark) !important;
@@ -37,9 +40,9 @@ h1, h2, h3, h4, h5, h6, p, span, label, div {
37
  }
38
 
39
  .tab-nav button {
40
- font-size: 1.5rem !important;
41
- font-weight: 800 !important;
42
- padding: 1.25rem 2.5rem !important;
43
  border-radius: 8px !important;
44
  margin: 0 0.25rem !important;
45
  transition: all 0.3s ease !important;
@@ -59,22 +62,21 @@ h1, h2, h3, h4, h5, h6, p, span, label, div {
59
  box-shadow: 0 2px 8px rgba(255, 107, 74, 0.3) !important;
60
  }
61
 
62
- /* ORANGE LABELS - works in both light and dark mode */
63
  label, .label-wrap {
64
  color: #E0E0E0 !important;
65
- background: transparent !important;
66
  }
67
 
68
- .label-wrap span, label span {
69
  background: var(--martian-orange) !important;
70
  color: white !important;
71
- padding: 0.4rem 0.9rem !important;
72
- border-radius: 8px !important;
73
- font-weight: 700 !important;
74
- font-size: 0.95rem !important;
75
- display: inline-block !important;
76
  }
77
 
 
78
  select, input, textarea {
79
  background: var(--martian-gray-medium) !important;
80
  border: 1px solid #3A3A3A !important;
@@ -87,6 +89,7 @@ select:focus, input:focus, textarea:focus {
87
  box-shadow: 0 0 0 2px rgba(255, 107, 74, 0.2) !important;
88
  }
89
 
 
90
  input[type="range"] {
91
  -webkit-appearance: none;
92
  appearance: none;
@@ -128,6 +131,13 @@ input[type="range"]::-moz-range-thumb {
128
  box-shadow: 0 2px 4px rgba(255, 107, 74, 0.3);
129
  }
130
 
 
 
 
 
 
 
 
131
  .primary, .secondary {
132
  background: var(--martian-orange) !important;
133
  border-color: var(--martian-orange) !important;
@@ -139,12 +149,18 @@ button {
139
  color: #E0E0E0 !important;
140
  }
141
 
 
142
  .compact-header {
143
  text-align: center;
144
  padding: 1.5rem 0 1rem 0;
145
  background: var(--martian-black);
146
  }
147
 
 
 
 
 
 
148
  .compact-header h1 {
149
  font-size: 2rem;
150
  font-weight: 700;
@@ -159,6 +175,7 @@ button {
159
  margin-top: 0.25rem;
160
  }
161
 
 
162
  .footer {
163
  text-align: center;
164
  padding: 2rem 0;
@@ -168,6 +185,19 @@ button {
168
  border-radius: 12px;
169
  }
170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  .footer-text {
172
  color: #999 !important;
173
  font-size: 0.95rem;
@@ -188,50 +218,46 @@ button {
188
  50% { transform: scale(1.1); }
189
  }
190
 
191
- /* CITATION BOX - proper dark background */
192
  .citation-box {
193
- background: var(--martian-gray-medium) !important;
194
- border: 1px solid #3A3A3A !important;
195
- border-radius: 12px !important;
196
- padding: 1.5rem !important;
197
- margin: 2rem auto !important;
198
- max-width: 900px !important;
199
- font-family: 'Monaco', 'Courier New', monospace !important;
200
- font-size: 0.85rem !important;
201
  }
202
 
203
  .citation-header {
204
- font-weight: 700 !important;
205
  color: #FF6B4A !important;
206
- margin-bottom: 1rem !important;
207
- font-size: 1.1rem !important;
208
- text-align: center !important;
209
  }
210
 
211
  .citation-box pre {
212
  color: #D0D0D0 !important;
213
- background: var(--martian-gray-dark) !important;
214
- padding: 1rem !important;
215
- border-radius: 8px !important;
216
- overflow-x: auto !important;
217
- margin: 0 !important;
218
- }
219
-
220
- /* Force dark text for CS1, CS2, etc in all modes */
221
- .dataset-levels-text, .dataset-levels-text * {
222
- color: #E0E0E0 !important;
223
- font-weight: 600 !important;
224
  }
225
  """
226
 
227
  with gr.Blocks(css=custom_css, title="TinySQL Demo", theme=gr.themes.Soft()) as demo:
 
228
  gr.HTML("""
229
  <div class="compact-header">
 
230
  <h1>TinySQL</h1>
231
  <p>Mechanistic Interpretability for Text-to-SQL</p>
232
  </div>
233
  """)
234
 
 
235
  shared_instruction = gr.State("")
236
  shared_schema = gr.State("")
237
 
@@ -242,6 +268,7 @@ with gr.Blocks(css=custom_css, title="TinySQL Demo", theme=gr.themes.Soft()) as
242
  with gr.Tab("Model Demo"):
243
  model_components = model_demo(shared_instruction, shared_schema)
244
 
 
245
  gr.HTML("""
246
  <div class="citation-box">
247
  <div class="citation-header">Cite Our Work</div>
@@ -257,11 +284,13 @@ with gr.Blocks(css=custom_css, title="TinySQL Demo", theme=gr.themes.Soft()) as
257
  </div>
258
  """)
259
 
 
260
  gr.HTML("""
261
  <div class="footer">
262
  <p class="footer-text">
263
  Brought to you with <span class="heart">❤️</span> from the Martian science team
264
  </p>
 
265
  <p class="footer-text" style="font-size: 0.85rem; margin-top: 1rem;">
266
  <a href="https://arxiv.org/abs/2503.12730">Paper</a> •
267
  <a href="https://github.com/withmartian/TinySQL">Code</a> •
 
10
  --martian-gray-medium: #2A2A2A;
11
  }
12
 
13
+ /* FORCE DARK MODE - Override Gradio's light mode */
14
  .gradio-container, .gradio-container * {
15
  color-scheme: dark !important;
16
  }
 
21
  color: #E0E0E0 !important;
22
  }
23
 
24
+ /* Force dark backgrounds everywhere */
25
  .block, .panel, div, section {
26
  background-color: var(--martian-black) !important;
27
  }
28
 
29
+ /* Force text colors */
30
  h1, h2, h3, h4, h5, h6, p, span, label, div {
31
  color: #E0E0E0 !important;
32
  }
33
 
34
+ /* Better tabs - bold, bigger, no icons, ORANGE selection */
35
  .tab-nav {
36
  border-bottom: 2px solid var(--martian-gray-dark) !important;
37
  background: var(--martian-gray-dark) !important;
 
40
  }
41
 
42
  .tab-nav button {
43
+ font-size: 1.2rem !important;
44
+ font-weight: 700 !important;
45
+ padding: 1rem 2rem !important;
46
  border-radius: 8px !important;
47
  margin: 0 0.25rem !important;
48
  transition: all 0.3s ease !important;
 
62
  box-shadow: 0 2px 8px rgba(255, 107, 74, 0.3) !important;
63
  }
64
 
65
+ /* Orange labels */
66
  label, .label-wrap {
67
  color: #E0E0E0 !important;
 
68
  }
69
 
70
+ .label-wrap span {
71
  background: var(--martian-orange) !important;
72
  color: white !important;
73
+ padding: 0.35rem 0.75rem !important;
74
+ border-radius: 6px !important;
75
+ font-weight: 600 !important;
76
+ font-size: 0.9rem !important;
 
77
  }
78
 
79
+ /* Orange inputs */
80
  select, input, textarea {
81
  background: var(--martian-gray-medium) !important;
82
  border: 1px solid #3A3A3A !important;
 
89
  box-shadow: 0 0 0 2px rgba(255, 107, 74, 0.2) !important;
90
  }
91
 
92
+ /* Orange sliders */
93
  input[type="range"] {
94
  -webkit-appearance: none;
95
  appearance: none;
 
131
  box-shadow: 0 2px 4px rgba(255, 107, 74, 0.3);
132
  }
133
 
134
+ input[type="range"]::-moz-range-progress {
135
+ background: var(--martian-orange);
136
+ height: 6px;
137
+ border-radius: 3px;
138
+ }
139
+
140
+ /* Orange buttons */
141
  .primary, .secondary {
142
  background: var(--martian-orange) !important;
143
  border-color: var(--martian-orange) !important;
 
149
  color: #E0E0E0 !important;
150
  }
151
 
152
+ /* Compact header */
153
  .compact-header {
154
  text-align: center;
155
  padding: 1.5rem 0 1rem 0;
156
  background: var(--martian-black);
157
  }
158
 
159
+ .compact-header img {
160
+ height: 35px;
161
+ margin-bottom: 0.5rem;
162
+ }
163
+
164
  .compact-header h1 {
165
  font-size: 2rem;
166
  font-weight: 700;
 
175
  margin-top: 0.25rem;
176
  }
177
 
178
+ /* Footer */
179
  .footer {
180
  text-align: center;
181
  padding: 2rem 0;
 
185
  border-radius: 12px;
186
  }
187
 
188
+ .footer-logo {
189
+ width: 80px !important;
190
+ height: auto !important;
191
+ margin: 1rem auto !important;
192
+ opacity: 0.9;
193
+ transition: opacity 0.3s ease;
194
+ display: block;
195
+ }
196
+
197
+ .footer-logo:hover {
198
+ opacity: 1;
199
+ }
200
+
201
  .footer-text {
202
  color: #999 !important;
203
  font-size: 0.95rem;
 
218
  50% { transform: scale(1.1); }
219
  }
220
 
 
221
  .citation-box {
222
+ background: #2A2A2A !important;
223
+ border: 1px solid #3A3A3A;
224
+ border-radius: 12px;
225
+ padding: 1.5rem;
226
+ margin: 2rem auto;
227
+ max-width: 900px;
228
+ font-family: 'Monaco', 'Courier New', monospace;
229
+ font-size: 0.85rem;
230
  }
231
 
232
  .citation-header {
233
+ font-weight: 700;
234
  color: #FF6B4A !important;
235
+ margin-bottom: 1rem;
236
+ font-size: 1.1rem;
237
+ text-align: center;
238
  }
239
 
240
  .citation-box pre {
241
  color: #D0D0D0 !important;
242
+ background: #1A1A1A !important;
243
+ padding: 1rem;
244
+ border-radius: 8px;
245
+ overflow-x: auto;
246
+ margin: 0;
 
 
 
 
 
 
247
  }
248
  """
249
 
250
  with gr.Blocks(css=custom_css, title="TinySQL Demo", theme=gr.themes.Soft()) as demo:
251
+ # Compact Header
252
  gr.HTML("""
253
  <div class="compact-header">
254
+ <img src="file/static/images/martian_logo.jpg" alt="Martian">
255
  <h1>TinySQL</h1>
256
  <p>Mechanistic Interpretability for Text-to-SQL</p>
257
  </div>
258
  """)
259
 
260
+ # Shared state for passing data between tabs
261
  shared_instruction = gr.State("")
262
  shared_schema = gr.State("")
263
 
 
268
  with gr.Tab("Model Demo"):
269
  model_components = model_demo(shared_instruction, shared_schema)
270
 
271
+ # Citation section
272
  gr.HTML("""
273
  <div class="citation-box">
274
  <div class="citation-header">Cite Our Work</div>
 
284
  </div>
285
  """)
286
 
287
+ # Footer with Martian branding
288
  gr.HTML("""
289
  <div class="footer">
290
  <p class="footer-text">
291
  Brought to you with <span class="heart">❤️</span> from the Martian science team
292
  </p>
293
+ <img src="abir-hr196/tinysql-demo/static/images/martian_logo.jpg" alt="Martian" class="footer-logo">
294
  <p class="footer-text" style="font-size: 0.85rem; margin-top: 1rem;">
295
  <a href="https://arxiv.org/abs/2503.12730">Paper</a> •
296
  <a href="https://github.com/withmartian/TinySQL">Code</a> •
tinysql_model_demo.py CHANGED
@@ -110,12 +110,12 @@ def model_demo(shared_instruction, shared_schema):
110
 
111
  <div style="padding-top: 1rem; border-top: 1px solid #3A3A3A;">
112
  <div style="color: #FF6B4A; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.75rem;">Dataset Complexity</div>
113
- <div class="dataset-levels-text" style="color: #E0E0E0; font-size: 0.85rem; line-height: 1.8;">
114
- <div><strong style="color: #E0E0E0;">CS1:</strong> Basic SELECT-FROM</div>
115
- <div><strong style="color: #E0E0E0;">CS2:</strong> Adds ORDER BY</div>
116
- <div><strong style="color: #E0E0E0;">CS3:</strong> Aggregations</div>
117
- <div><strong style="color: #E0E0E0;">CS4:</strong> WHERE filters</div>
118
- <div><strong style="color: #E0E0E0;">CS5:</strong> Multi-table JOINs</div>
119
  </div>
120
  </div>
121
  </div>
@@ -148,6 +148,7 @@ def model_demo(shared_instruction, shared_schema):
148
 
149
  gr.Markdown("### Example Query")
150
 
 
151
  gr.HTML("""
152
  <div style="background: #2A2A2A; border-radius: 12px; padding: 1.5rem; margin: 1rem 0; border: 1px solid #3A3A3A;">
153
  <div style="margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid #3A3A3A;">
 
110
 
111
  <div style="padding-top: 1rem; border-top: 1px solid #3A3A3A;">
112
  <div style="color: #FF6B4A; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.75rem;">Dataset Complexity</div>
113
+ <div style="color: #999; font-size: 0.85rem; line-height: 1.8;">
114
+ <div><strong style="color: #D0D0D0;">CS1:</strong> Basic SELECT-FROM</div>
115
+ <div><strong style="color: #D0D0D0;">CS2:</strong> Adds ORDER BY</div>
116
+ <div><strong style="color: #D0D0D0;">CS3:</strong> Aggregations</div>
117
+ <div><strong style="color: #D0D0D0;">CS4:</strong> WHERE filters</div>
118
+ <div><strong style="color: #D0D0D0;">CS5:</strong> Multi-table JOINs</div>
119
  </div>
120
  </div>
121
  </div>
 
148
 
149
  gr.Markdown("### Example Query")
150
 
151
+ # Better styled example with proper font
152
  gr.HTML("""
153
  <div style="background: #2A2A2A; border-radius: 12px; padding: 1.5rem; margin: 1rem 0; border: 1px solid #3A3A3A;">
154
  <div style="margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid #3A3A3A;">