justmotes commited on
Commit
e6a96ed
·
1 Parent(s): bf79e3e

UI: Fix header, logo, layout and add debug logs

Browse files
Files changed (1) hide show
  1. app.py +29 -11
app.py CHANGED
@@ -27,6 +27,8 @@ except Exception as e:
27
 
28
  # --- HTML Templates (Extracted from dashVector_benchmark.html) ---
29
 
 
 
30
  HEAD_HTML = """
31
  <script src="https://cdn.tailwindcss.com"></script>
32
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
@@ -52,12 +54,21 @@ HEAD_HTML = """
52
  padding: 0.75rem 1rem !important;
53
  font-size: 1rem !important;
54
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05) !important;
 
55
  }
56
  #custom-input textarea:focus {
57
  outline: 2px solid #3b82f6 !important; /* blue-500 */
58
  border-color: #3b82f6 !important;
59
  }
60
 
 
 
 
 
 
 
 
 
61
  /* Loader Overlay */
62
  .loader-overlay {
63
  position: absolute; inset: 0; background: rgba(255,255,255,0.8);
@@ -77,20 +88,15 @@ NAVBAR_HTML = """
77
  <header class="bg-white border-b border-slate-200 sticky top-0 z-40 shadow-sm w-full">
78
  <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 h-16 flex items-center justify-between">
79
  <div class="flex items-center gap-2">
80
- <div class="w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center text-white font-bold text-lg shadow-sm">
81
- d
82
- </div>
83
- <h1 class="text-xl font-bold tracking-tight text-slate-900">dashVector <span class="text-slate-400 font-normal text-sm ml-1">Search Benchmark</span></h1>
84
  </div>
85
  <div class="flex items-center gap-4">
86
  <div class="hidden md:flex items-center gap-1.5 px-3 py-1 bg-slate-100 rounded-full border border-slate-200">
87
  <span class="material-symbols-outlined text-slate-500 text-sm">database</span>
88
  <span class="text-xs font-medium text-slate-600">Dataset: <span class="font-bold text-slate-800">MS Marco</span></span>
89
  </div>
90
- <div class="hidden md:flex items-center gap-1.5 px-3 py-1 bg-orange-50 rounded-full border border-orange-100">
91
- <span class="material-symbols-outlined text-orange-600 text-sm">bolt</span>
92
- <span class="text-xs font-medium text-orange-800">Powered by Qdrant</span>
93
- </div>
94
  </div>
95
  </div>
96
  </header>
@@ -233,6 +239,8 @@ def generate_table_html(rows):
233
  """
234
 
235
  def run_benchmark(query):
 
 
236
  # 1. Yield Loader
237
  yield LOADER_HTML
238
 
@@ -241,19 +249,26 @@ def run_benchmark(query):
241
 
242
  # Generate Embedding
243
  try:
 
244
  query_vec = get_embedding(query)
 
245
  except Exception as e:
246
- print(f"Embedding failed: {e}")
247
  query_vec = [0.0] * VECTOR_SIZE # Dummy
248
 
249
  # Router Prediction
250
  if router:
 
251
  target_cluster, confidence = router.predict(query_vec)
 
252
  else:
 
253
  target_cluster, confidence = 0, 0.95 # Mock
254
 
255
  # Search
 
256
  results, mode = vector_db.search_hybrid(query_vec, target_cluster, confidence)
 
257
 
258
  end_total = time.time()
259
  latency_ms = (end_total - start_total) * 1000
@@ -306,6 +321,7 @@ def run_benchmark(query):
306
 
307
  all_rows = [live_row] + ref_rows
308
 
 
309
  # 4. Yield Final HTML
310
  yield generate_table_html(all_rows)
311
 
@@ -318,7 +334,9 @@ with gr.Blocks(theme=gr.themes.Base(), css=None, head=HEAD_HTML) as demo:
318
  # Search Section
319
  with gr.Group(elem_classes="bg-white p-6 rounded-2xl shadow-sm border border-slate-200 mb-6"):
320
  gr.HTML('<label class="block text-sm font-medium text-slate-700 mb-2">Evaluate Search Architecture</label>')
321
- with gr.Row():
 
 
322
  query_input = gr.Textbox(
323
  placeholder="Enter a benchmark query (e.g., 'climate change impact')...",
324
  show_label=False,
@@ -330,7 +348,7 @@ with gr.Blocks(theme=gr.themes.Base(), css=None, head=HEAD_HTML) as demo:
330
  "Run Benchmark",
331
  variant="primary",
332
  scale=1,
333
- elem_classes="bg-blue-600 hover:bg-blue-700 text-white font-semibold py-3 px-6 rounded-xl shadow-md transition-all"
334
  )
335
 
336
  # Results Section
 
27
 
28
  # --- HTML Templates (Extracted from dashVector_benchmark.html) ---
29
 
30
+ # --- HTML Templates (Extracted from dashVector_benchmark.html) ---
31
+
32
  HEAD_HTML = """
33
  <script src="https://cdn.tailwindcss.com"></script>
34
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
 
54
  padding: 0.75rem 1rem !important;
55
  font-size: 1rem !important;
56
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05) !important;
57
+ height: 50px !important; /* Fixed height for alignment */
58
  }
59
  #custom-input textarea:focus {
60
  outline: 2px solid #3b82f6 !important; /* blue-500 */
61
  border-color: #3b82f6 !important;
62
  }
63
 
64
+ /* Search Bar Layout Fix */
65
+ .search-row {
66
+ display: flex !important;
67
+ flex-direction: row !important;
68
+ align-items: flex-start !important; /* Align top to handle potential textarea growth */
69
+ gap: 1rem !important;
70
+ }
71
+
72
  /* Loader Overlay */
73
  .loader-overlay {
74
  position: absolute; inset: 0; background: rgba(255,255,255,0.8);
 
88
  <header class="bg-white border-b border-slate-200 sticky top-0 z-40 shadow-sm w-full">
89
  <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 h-16 flex items-center justify-between">
90
  <div class="flex items-center gap-2">
91
+ <!-- User Logo -->
92
+ <img src="file/logo.png" alt="dashVector Logo" class="h-8 w-auto" />
93
+ <h1 class="text-xl font-bold tracking-tight text-slate-900">dashVector</h1>
 
94
  </div>
95
  <div class="flex items-center gap-4">
96
  <div class="hidden md:flex items-center gap-1.5 px-3 py-1 bg-slate-100 rounded-full border border-slate-200">
97
  <span class="material-symbols-outlined text-slate-500 text-sm">database</span>
98
  <span class="text-xs font-medium text-slate-600">Dataset: <span class="font-bold text-slate-800">MS Marco</span></span>
99
  </div>
 
 
 
 
100
  </div>
101
  </div>
102
  </header>
 
239
  """
240
 
241
  def run_benchmark(query):
242
+ print(f"DEBUG: Starting benchmark for query: {query}")
243
+
244
  # 1. Yield Loader
245
  yield LOADER_HTML
246
 
 
249
 
250
  # Generate Embedding
251
  try:
252
+ print("DEBUG: Generating embedding...")
253
  query_vec = get_embedding(query)
254
+ print("DEBUG: Embedding generated.")
255
  except Exception as e:
256
+ print(f"ERROR: Embedding failed: {e}")
257
  query_vec = [0.0] * VECTOR_SIZE # Dummy
258
 
259
  # Router Prediction
260
  if router:
261
+ print("DEBUG: Predicting cluster...")
262
  target_cluster, confidence = router.predict(query_vec)
263
+ print(f"DEBUG: Predicted cluster {target_cluster} with confidence {confidence}")
264
  else:
265
+ print("DEBUG: No router loaded, using mock.")
266
  target_cluster, confidence = 0, 0.95 # Mock
267
 
268
  # Search
269
+ print("DEBUG: Searching Qdrant...")
270
  results, mode = vector_db.search_hybrid(query_vec, target_cluster, confidence)
271
+ print(f"DEBUG: Search complete. Found {len(results)} results.")
272
 
273
  end_total = time.time()
274
  latency_ms = (end_total - start_total) * 1000
 
321
 
322
  all_rows = [live_row] + ref_rows
323
 
324
+ print("DEBUG: Yielding final HTML.")
325
  # 4. Yield Final HTML
326
  yield generate_table_html(all_rows)
327
 
 
334
  # Search Section
335
  with gr.Group(elem_classes="bg-white p-6 rounded-2xl shadow-sm border border-slate-200 mb-6"):
336
  gr.HTML('<label class="block text-sm font-medium text-slate-700 mb-2">Evaluate Search Architecture</label>')
337
+
338
+ # Use a Row with custom CSS class for Flexbox layout
339
+ with gr.Row(elem_classes="search-row"):
340
  query_input = gr.Textbox(
341
  placeholder="Enter a benchmark query (e.g., 'climate change impact')...",
342
  show_label=False,
 
348
  "Run Benchmark",
349
  variant="primary",
350
  scale=1,
351
+ elem_classes="bg-blue-600 hover:bg-blue-700 text-white font-semibold py-3 px-6 rounded-xl shadow-md transition-all h-[50px]" # Fixed height to match input
352
  )
353
 
354
  # Results Section