Maharshi Gor commited on
Commit
22e8b31
·
1 Parent(s): 633b045

UI Changes: Sidebar, fonts and theme

Browse files
Files changed (4) hide show
  1. app.py +27 -23
  2. src/app_configs.py +1 -1
  3. src/display/custom_css.py +32 -13
  4. src/display/guide.py +77 -0
app.py CHANGED
@@ -7,6 +7,7 @@ from app_configs import AVAILABLE_MODELS, DEFAULT_SELECTIONS, THEME
7
  from components.quizbowl.bonus import BonusInterface
8
  from components.quizbowl.tossup import TossupInterface
9
  from display.custom_css import css_pipeline, css_tossup
 
10
 
11
  # Constants
12
  from envs import (
@@ -26,7 +27,7 @@ def restart_space():
26
  API.restart_space(repo_id=REPO_ID)
27
 
28
 
29
- ### Space initialisation
30
  try:
31
  print(EVAL_REQUESTS_PATH)
32
  snapshot_download(
@@ -52,10 +53,15 @@ try:
52
  except Exception:
53
  restart_space()
54
 
 
 
 
 
 
 
 
55
 
56
- js_preamble = """
57
- <link href="https://fonts.cdnfonts.com/css/roboto-mono" rel="stylesheet">
58
-
59
  <script>
60
  const gradioApp = document.getElementsByTagName('gradio-app')[0];
61
  console.log("Gradio app:", gradioApp);
@@ -137,36 +143,34 @@ def load_dataset(mode: str):
137
  return ds
138
 
139
 
140
- def main():
 
 
 
 
 
141
  tossup_ds = load_dataset("tossup")
142
  bonus_ds = load_dataset("bonus")
143
- app = gr.Blocks(
144
- css=css_pipeline + css_tossup,
145
- head=js_preamble,
146
  theme=THEME,
147
  title="Quizbowl Bot",
148
- )
149
- with app:
 
 
 
150
  with gr.Tabs():
151
  with gr.Tab("Tossup Agents"):
152
  defaults = DEFAULT_SELECTIONS["tossup"] | {
153
  "init_workflow": factory.create_quizbowl_simple_workflow(),
154
- "simple_workflow": False,
155
  }
156
- tossup_interface = TossupInterface(app, tossup_ds, AVAILABLE_MODELS, defaults)
157
- # ModelStepComponent(value=factory.create_quizbowl_simple_step())
158
  with gr.Tab("Bonus Round Agents"):
159
  defaults = DEFAULT_SELECTIONS["bonus"] | {
160
  "init_workflow": factory.create_quizbowl_bonus_simple_workflow(),
161
- "simple_workflow": True,
162
  }
163
- bonus_interface = BonusInterface(app, bonus_ds, AVAILABLE_MODELS, defaults)
164
-
165
- app.queue(default_concurrency_limit=40).launch()
166
 
167
-
168
- if __name__ == "__main__":
169
- scheduler = BackgroundScheduler()
170
- scheduler.add_job(restart_space, "interval", seconds=1800)
171
- scheduler.start()
172
- main()
 
7
  from components.quizbowl.bonus import BonusInterface
8
  from components.quizbowl.tossup import TossupInterface
9
  from display.custom_css import css_pipeline, css_tossup
10
+ from display.guide import GUIDE_MARKDOWN
11
 
12
  # Constants
13
  from envs import (
 
27
  API.restart_space(repo_id=REPO_ID)
28
 
29
 
30
+ # Space initialisation
31
  try:
32
  print(EVAL_REQUESTS_PATH)
33
  snapshot_download(
 
53
  except Exception:
54
  restart_space()
55
 
56
+ fonts_header = """
57
+ <link rel="preconnect" href="https://fonts.googleapis.com">
58
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
59
+ <link href="https://fonts.googleapis.com/css2?family=Shantell+Sans:ital,wght@0,300..800;1,300..800&display=swap" rel="stylesheet">
60
+ <link href="https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
61
+ <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700&display=swap" rel="stylesheet">
62
+ """
63
 
64
+ js_head = """
 
 
65
  <script>
66
  const gradioApp = document.getElementsByTagName('gradio-app')[0];
67
  console.log("Gradio app:", gradioApp);
 
143
  return ds
144
 
145
 
146
+ if __name__ == "__main__":
147
+ scheduler = BackgroundScheduler()
148
+ scheduler.add_job(restart_space, "interval", seconds=1800)
149
+ scheduler.start()
150
+
151
+ full_css = css_pipeline + css_tossup
152
  tossup_ds = load_dataset("tossup")
153
  bonus_ds = load_dataset("bonus")
154
+ with gr.Blocks(
155
+ css=full_css,
156
+ head=fonts_header + js_head,
157
  theme=THEME,
158
  title="Quizbowl Bot",
159
+ ) as demo:
160
+ with gr.Sidebar(width=400):
161
+ gr.Markdown(GUIDE_MARKDOWN)
162
+ with gr.Row():
163
+ gr.Markdown("## Welcome to Quizbowl Bot! This is a tool for creating and testing quizbowl agents.")
164
  with gr.Tabs():
165
  with gr.Tab("Tossup Agents"):
166
  defaults = DEFAULT_SELECTIONS["tossup"] | {
167
  "init_workflow": factory.create_quizbowl_simple_workflow(),
 
168
  }
169
+ tossup_interface = TossupInterface(demo, tossup_ds, AVAILABLE_MODELS, defaults)
 
170
  with gr.Tab("Bonus Round Agents"):
171
  defaults = DEFAULT_SELECTIONS["bonus"] | {
172
  "init_workflow": factory.create_quizbowl_bonus_simple_workflow(),
 
173
  }
174
+ bonus_interface = BonusInterface(demo, bonus_ds, AVAILABLE_MODELS, defaults)
 
 
175
 
176
+ demo.queue(default_concurrency_limit=40).launch()
 
 
 
 
 
src/app_configs.py CHANGED
@@ -1,4 +1,4 @@
1
- THEME = "gstaff/xkcd"
2
 
3
  UNSELECTED_VAR_NAME = "Select Variable..."
4
  UNSELECTED_MODEL_NAME = "Select Model..."
 
1
+ THEME = "gstaff/sketch"
2
 
3
  UNSELECTED_VAR_NAME = "Select Variable..."
4
  UNSELECTED_MODEL_NAME = "Select Model..."
src/display/custom_css.py CHANGED
@@ -4,8 +4,17 @@ css_pipeline = """
4
  --block-border-width: 0;
5
  --section-header-text-weight: 600;
6
  --section-header-text-size: 14px;
7
- --mono-font-family: "Roboto Mono", monospace;
 
 
 
8
  --body-text-size: 14px !important;
 
 
 
 
 
 
9
 
10
  --card-bg-color: #fcecd4;
11
  --card-btn-color: #D4E4FC;
@@ -15,6 +24,12 @@ css_pipeline = """
15
  }
16
 
17
  .dark {
 
 
 
 
 
 
18
  --block-border-width: 0;
19
  --card-bg-color: #383127;
20
  --answer-bg-color: #1a2b3c;
@@ -219,7 +234,7 @@ css_pipeline = """
219
  }
220
 
221
  .output-field-variable {
222
- font-family: var(--mono-font-family) !important;
223
  font-weight: 300 !important;
224
  font-size: 12px !important;
225
  padding: 8px 8px;
@@ -240,21 +255,21 @@ css_pipeline = """
240
  }
241
 
242
  .field-name input, .field-description input, .field-type input {
243
- font-family: var(--mono-font-family) !important;
244
  font-size: 12px !important;
245
  }
246
 
247
  .field-variable input, .field-type input, .output-field-variable input {
248
- font-family: var(--mono-font-family) !important;
249
  font-size: 12px !important;
250
- padding-top: 3px;
251
- padding-bottom: 3px;
252
  }
253
 
254
  .field-name listbox, .field-variable listbox, .field-type listbox {
255
- font-family: var(--mono-font-family) !important;
256
- padding-top: 2px;
257
- padding-bottom: 2px;
258
  font-size: 12px !important;
259
  }
260
 
@@ -266,13 +281,13 @@ css_pipeline = """
266
  .step-accordion button.label-wrap {
267
  font-size: 14px;
268
  font-weight: bold !important;
269
- font-family: var(--mono-font-family) !important;
270
  }
271
 
272
  .step-accordion button.label-wrap.open {
273
  font-size: 14px;
274
  font-weight: bold !important;
275
- font-family: var(--mono-font-family) !important;
276
  }
277
 
278
  .button-column {
@@ -372,6 +387,7 @@ css_tossup = """
372
  border-radius: 4px;
373
  cursor: pointer;
374
  transition: background-color 0.2s;
 
375
  }
376
  .answer-header {
377
  font-weight: 900;
@@ -390,10 +406,13 @@ css_tossup = """
390
  background-color: #ffcc00;
391
  }
392
  .token.guess-point {
393
- border-bottom: 3px solid;
 
 
 
394
  }
395
  .token.no-buzz {
396
- border-color: #6b96b3;
397
  }
398
  .token.buzz-0 {
399
  border-color: #ff4444;
 
4
  --block-border-width: 0;
5
  --section-header-text-weight: 600;
6
  --section-header-text-size: 14px;
7
+ --input-radius: var(--radius-xl);
8
+ --font-mono: "Space Mono", monospace;
9
+ --text-md: 14px;
10
+ --text-lg: 16px;
11
  --body-text-size: 14px !important;
12
+ --input-background-fill-focus: var(--secondary-300) !important;
13
+
14
+ // Button Colors
15
+ --button-primary-background-fill: var(--primary-800) !important;
16
+ --button-secondary-background-fill: var(--secondary-600) !important;
17
+
18
 
19
  --card-bg-color: #fcecd4;
20
  --card-btn-color: #D4E4FC;
 
24
  }
25
 
26
  .dark {
27
+ // Button Colors
28
+ --button-primary-background-fill: var(--primary-100) !important;
29
+ --button-secondary-background-fill: var(--secondary-200) !important;
30
+ --button-primary-text-color: black !important;
31
+ --button-secondary-text-color: black !important
32
+
33
  --block-border-width: 0;
34
  --card-bg-color: #383127;
35
  --answer-bg-color: #1a2b3c;
 
234
  }
235
 
236
  .output-field-variable {
237
+ font-family: var(--font-mono) !important;
238
  font-weight: 300 !important;
239
  font-size: 12px !important;
240
  padding: 8px 8px;
 
255
  }
256
 
257
  .field-name input, .field-description input, .field-type input {
258
+ font-family: var(--font-mono) !important;
259
  font-size: 12px !important;
260
  }
261
 
262
  .field-variable input, .field-type input, .output-field-variable input {
263
+ font-family: var(--font-mono) !important;
264
  font-size: 12px !important;
265
+ padding-top: 1px;
266
+ padding-bottom: 1px;
267
  }
268
 
269
  .field-name listbox, .field-variable listbox, .field-type listbox {
270
+ font-family: var(--font-mono) !important;
271
+ padding-top: 1px;
272
+ padding-bottom: 1px;
273
  font-size: 12px !important;
274
  }
275
 
 
281
  .step-accordion button.label-wrap {
282
  font-size: 14px;
283
  font-weight: bold !important;
284
+ font-family: var(--font-mono) !important;
285
  }
286
 
287
  .step-accordion button.label-wrap.open {
288
  font-size: 14px;
289
  font-weight: bold !important;
290
+ font-family: var(--font-mono) !important;
291
  }
292
 
293
  .button-column {
 
387
  border-radius: 4px;
388
  cursor: pointer;
389
  transition: background-color 0.2s;
390
+ position: relative;
391
  }
392
  .answer-header {
393
  font-weight: 900;
 
406
  background-color: #ffcc00;
407
  }
408
  .token.guess-point {
409
+ border-top: 1px solid;
410
+ border-left: 3px solid;
411
+ border-right: 1px solid;
412
+ border-bottom: 1px solid;
413
  }
414
  .token.no-buzz {
415
+ border-color: #808080;
416
  }
417
  .token.buzz-0 {
418
  border-color: #ff4444;
src/display/guide.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Guide content for the Quizbowl platform."""
2
+
3
+ GUIDE_MARKDOWN = """
4
+ # 🎯 Quizbowl Bot Guide
5
+
6
+ ## Quick Start
7
+ 1. Choose between Tossup or Bonus mode
8
+ 2. Design your pipeline
9
+ 3. Test on example questions
10
+ 4. Submit for evaluation
11
+
12
+ ## Competition Rules
13
+
14
+ ### 🧠 Tossup Questions
15
+ - **Format**: Individual questions with progressive difficulty
16
+ - **Scoring**:
17
+ - Correct early buzz: +10 points
18
+ - Incorrect early buzz: -5 points
19
+ - Correct after full read: +10 points
20
+ - **Required Outputs**:
21
+ - `answer`: Your predicted answer
22
+ - `confidence`: Score between 0-1
23
+ - Buzz threshold: When to attempt answering
24
+
25
+ ### 🎁 Bonus Questions
26
+ - **Format**: Three-part questions (10 points each)
27
+ - **Scoring**: +10 points per correct part (max 30)
28
+ - **Required Outputs**:
29
+ - `answer`: Your predicted answer
30
+ - `confidence`: Score between 0-1
31
+ - `explanation`: Brief justification for human collaboration
32
+
33
+ ## Building Your First Pipeline
34
+
35
+ ### 1. Simple Pipeline (Recommended for First Submission)
36
+ - Single model step
37
+ - Configure:
38
+ - Model selection
39
+ - Temperature (0.0-1.0)
40
+ - System prompt
41
+ - Required outputs
42
+
43
+ ### 2. Testing Your Pipeline
44
+ 1. Select an example question
45
+ 2. For Tossup:
46
+ - Set buzz threshold (0.5-1.0)
47
+ - Enable early stopping
48
+ 3. Run and check:
49
+ - Answer accuracy
50
+ - Confidence scores
51
+ - Performance metrics
52
+
53
+ ### 3. Evaluation
54
+ - Test on multiple questions
55
+ - Monitor:
56
+ - Accuracy
57
+ - Confidence patterns
58
+ - Response times
59
+
60
+ ### 4. Submission
61
+ 1. Log in
62
+ 2. Name your model
63
+ 3. Add description
64
+ 4. Submit for evaluation
65
+
66
+ ## Tips for Success
67
+ - Start with simple pipeline
68
+ - Test thoroughly before submission
69
+ - Use appropriate temperature (0.3-0.7 recommended)
70
+ - Monitor confidence scores
71
+ - Check example submissions
72
+
73
+ ## Need Help?
74
+ - Review example submissions
75
+ - Check documentation
76
+ - Contact support
77
+ """