KingNish commited on
Commit
95b1c76
·
1 Parent(s): 496fee6

simplify reasoning display and polish layout

Browse files
Files changed (2) hide show
  1. app.css +23 -3
  2. app.py +17 -35
app.css CHANGED
@@ -5,6 +5,10 @@
5
  --layout-gap: 0 !important;
6
  }
7
 
 
 
 
 
8
  html {
9
  scroll-behavior: smooth;
10
  }
@@ -14,6 +18,10 @@ html {
14
  max-height: 1500px;
15
  }
16
 
 
 
 
 
17
  #chat-column {
18
  height: 100%;
19
  display: flex;
@@ -210,7 +218,11 @@ label span {
210
  }
211
 
212
  .input-container textarea {
213
- background: transparent !important;
 
 
 
 
214
  }
215
 
216
  /* ============================================
@@ -270,7 +282,7 @@ label span {
270
  text-align: center;
271
  }
272
 
273
- body:not(.dark) .landing-logo svg, body:not(.dark) .sidebar-content::before {
274
  filter: invert(0.8);
275
  }
276
 
@@ -300,7 +312,7 @@ body:not(.dark) .landing-logo svg, body:not(.dark) .sidebar-content::before {
300
  /* When landing page is hidden (chat active), keep input at bottom */
301
  #chat-column:not(.landing-active) #input-row {
302
  position: relative;
303
- bottom: auto;
304
  left: auto;
305
  transform: none;
306
  max-width: none;
@@ -352,6 +364,14 @@ body:not(.dark) .landing-logo svg, body:not(.dark) .sidebar-content::before {
352
  }
353
  }
354
 
 
 
 
 
 
 
 
 
355
  /* Apply monospace font to body for terminal feel */
356
  body, .gradio-container {
357
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace !important;
 
5
  --layout-gap: 0 !important;
6
  }
7
 
8
+ footer {
9
+ display: none !important;
10
+ }
11
+
12
  html {
13
  scroll-behavior: smooth;
14
  }
 
18
  max-height: 1500px;
19
  }
20
 
21
+ button[aria-label="Clear"] {
22
+ display: none;
23
+ }
24
+
25
  #chat-column {
26
  height: 100%;
27
  display: flex;
 
218
  }
219
 
220
  .input-container textarea {
221
+ background: var(--background-fill-secondary) !important;
222
+ }
223
+
224
+ .bubble-wrap {
225
+ background: var(--background-fill-primary) !important;
226
  }
227
 
228
  /* ============================================
 
282
  text-align: center;
283
  }
284
 
285
+ body:not(.dark) .landing-logo img, body:not(.dark) .sidebar-content::before {
286
  filter: invert(0.8);
287
  }
288
 
 
312
  /* When landing page is hidden (chat active), keep input at bottom */
313
  #chat-column:not(.landing-active) #input-row {
314
  position: relative;
315
+ bottom: 3%;
316
  left: auto;
317
  transform: none;
318
  max-width: none;
 
364
  }
365
  }
366
 
367
+ /* Center chat column on larger screens */
368
+ @media (min-width: 749px) {
369
+ #chat-column {
370
+ max-width: 748px;
371
+ margin: 0 auto;
372
+ }
373
+ }
374
+
375
  /* Apply monospace font to body for terminal feel */
376
  body, .gradio-container {
377
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace !important;
app.py CHANGED
@@ -69,11 +69,10 @@ class GradioEvents:
69
 
70
  yield { msg: gr.update(value=""), chatbot: gr.update(value=ctx["history"]), state: gr.update(value=state_value), conv_choice: _conv_choices(state_value), send_btn: gr.update(visible=False), stop_btn: gr.update(visible=True)}
71
 
72
- reasoning_content = ""
73
  normal_content = ""
74
- reasoning_started = False
75
- start_time = time.time()
76
- partial = []
77
  temp = []
78
 
79
  try:
@@ -87,35 +86,19 @@ class GradioEvents:
87
  chunk = chunk.to_dict()
88
  delta = chunk['choices'][0]['delta']
89
 
90
- if delta.get('reasoning_content'):
91
- reasoning_content += delta['reasoning_content']
92
- if not reasoning_started:
93
- start_time = time.time()
94
- if normal_content:
95
- partial.append({
96
- "role": "assistant",
97
- "content": normal_content,
98
- "metadata": None,
99
- "is_final": True,
100
- })
101
- normal_content = ""
102
- reasoning_started = True
103
  temp = [{
104
  "role": "assistant",
105
- "content": reasoning_content,
106
- "metadata": {"title": "Thinking..."},
107
  "is_final": False,
108
  }]
109
  elif delta.get('content', ''):
110
- if reasoning_started:
111
- reasoning_started = False
112
- partial.append({
113
- "role": "assistant",
114
- "content": reasoning_content,
115
- "metadata": {"title": "Thought for " + f"{time.time() - start_time:.2f}s"},
116
- "is_final": True,
117
- })
118
- reasoning_content = ""
119
  normal_content += delta['content']
120
  temp = [{
121
  "role": "assistant",
@@ -125,15 +108,14 @@ class GradioEvents:
125
  }]
126
 
127
  yield {
128
- chatbot: gr.update(value=ctx["history"] + partial + temp),
129
  state: gr.update(value=state_value),
130
  }
131
 
132
- ctx["history"].extend(partial)
133
- if temp:
134
  ctx["history"].extend(temp)
135
- if ctx["history"] and ctx["history"][-1].get("role") == "assistant":
136
- ctx["history"][-1]["is_final"] = True
137
 
138
  yield {
139
  chatbot: gr.update(value=ctx["history"]),
@@ -248,7 +230,7 @@ with gr.Blocks(fill_width=True, title="Demo Chat") as demo:
248
  js_save_input = gr.Textbox(visible=False, elem_id="js-save-input")
249
 
250
  with gr.Row(elem_id="main-row"):
251
- with gr.Sidebar():
252
  new_chat_btn = gr.Button(
253
  value="New Conversation",
254
  variant="primary",
@@ -273,7 +255,7 @@ with gr.Blocks(fill_width=True, title="Demo Chat") as demo:
273
  <div id="landing-page">
274
  <div class="landing-content">
275
  <div class="landing-logo">
276
- <img src="/gradio_api/file=static/svg/logo.svg" alt="MythosHarness" width="300" height="42" />
277
  </div>
278
  </div>
279
  <div class="landing-prompt">
 
69
 
70
  yield { msg: gr.update(value=""), chatbot: gr.update(value=ctx["history"]), state: gr.update(value=state_value), conv_choice: _conv_choices(state_value), send_btn: gr.update(visible=False), stop_btn: gr.update(visible=True)}
71
 
 
72
  normal_content = ""
73
+ is_reasoning = False
74
+ spinner_frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]
75
+ spinner_idx = 0
76
  temp = []
77
 
78
  try:
 
86
  chunk = chunk.to_dict()
87
  delta = chunk['choices'][0]['delta']
88
 
89
+ if delta.get('reasoning_content') or delta.get('reasoning'):
90
+ if not is_reasoning:
91
+ is_reasoning = True
92
+ spinner_idx += 1
 
 
 
 
 
 
 
 
 
93
  temp = [{
94
  "role": "assistant",
95
+ "content": f"<span class=\"thinking-indicator\">{spinner_frames[spinner_idx % len(spinner_frames)]} Thinking...</span>",
96
+ "metadata": None,
97
  "is_final": False,
98
  }]
99
  elif delta.get('content', ''):
100
+ if is_reasoning:
101
+ is_reasoning = False
 
 
 
 
 
 
 
102
  normal_content += delta['content']
103
  temp = [{
104
  "role": "assistant",
 
108
  }]
109
 
110
  yield {
111
+ chatbot: gr.update(value=ctx["history"] + temp),
112
  state: gr.update(value=state_value),
113
  }
114
 
115
+ if not is_reasoning and temp:
 
116
  ctx["history"].extend(temp)
117
+ if ctx["history"][-1].get("role") == "assistant":
118
+ ctx["history"][-1]["is_final"] = True
119
 
120
  yield {
121
  chatbot: gr.update(value=ctx["history"]),
 
230
  js_save_input = gr.Textbox(visible=False, elem_id="js-save-input")
231
 
232
  with gr.Row(elem_id="main-row"):
233
+ with gr.Sidebar(open=False):
234
  new_chat_btn = gr.Button(
235
  value="New Conversation",
236
  variant="primary",
 
255
  <div id="landing-page">
256
  <div class="landing-content">
257
  <div class="landing-logo">
258
+ <img src="/gradio_api/file=static/svg/logo.svg" alt="MythosHarness" width="420" height="70" />
259
  </div>
260
  </div>
261
  <div class="landing-prompt">