Tonic commited on
Commit
b645ccb
·
1 Parent(s): d936359

adds interface improvements

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -258,16 +258,26 @@ def generate_response(input_data, chat_history, max_new_tokens, model_identity,
258
  logging.exception("Generation streaming failed")
259
  yield f"❌ Error during generation: {e}"
260
 
261
- with gr.Blocks(theme=gr.themes.Soft()) as demo:
 
 
 
 
 
262
  gr.Markdown(TITLE_MD)
 
263
  with gr.Row():
264
  with gr.Column(scale=3):
265
  gr.Markdown(DESCRIPTION_MD)
266
  with gr.Column(scale=2):
267
  gr.Markdown(JOIN_US_MD)
268
 
 
 
 
269
  gr.ChatInterface(
270
  fn=generate_response,
 
271
  additional_inputs=[
272
  gr.Slider(label="Max new tokens", minimum=64, maximum=4096, step=1, value=2048),
273
  gr.Textbox(
@@ -295,6 +305,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
295
  interactive=True,
296
  ),
297
  ],
 
298
  examples=[
299
  [{"text": "A 68-year-old man complains of several blisters arising over the back and trunk for the preceding 2 weeks. He takes no medications and has not noted systemic symptoms such as fever, sore throat, weight loss, or fatigue. The general physical examination is normal. The oral mucosa and the lips are normal. Several 2- to 3-cm bullae are present over the trunk and back. A few excoriations where the blisters have ruptured are present. The remainder of the skin is normal, without erythema or scale. What is the best diagnostic approach at this time?"}],
300
  [{"text": "A 28-year-old woman, gravida 2, para 1, at 40 weeks of gestation is admitted to the hospital in active labor. The patient has attended many prenatal appointments and followed her physician's advice about screening for diseases, laboratory testing, diet, and exercise. Her pregnancy has been uncomplicated. She has no history of a serious illness. Her first child was delivered via normal vaginal delivery. Her vital signs are within normal limits. Cervical examination shows 100% effacement and 10 cm dilation. A cardiotocograph is shown. Which of the following is the most appropriate initial step in management?"}],
@@ -305,6 +316,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
305
  cache_examples=False,
306
  type="messages",
307
  fill_height=True,
 
308
  textbox=gr.Textbox(
309
  label="Query Input",
310
  placeholder="Type your prompt (supports LaTeX: $x^2 + y^2 = z^2$)"
 
258
  logging.exception("Generation streaming failed")
259
  yield f"❌ Error during generation: {e}"
260
 
261
+ APP_CSS = """
262
+ #main_chatbot {height: calc(100vh - 220px);}
263
+ .gradio-container {min-height: 100vh;}
264
+ """
265
+
266
+ with gr.Blocks(theme=gr.themes.Soft(), css=APP_CSS) as demo:
267
  gr.Markdown(TITLE_MD)
268
+ # Informational sections above the chatbot
269
  with gr.Row():
270
  with gr.Column(scale=3):
271
  gr.Markdown(DESCRIPTION_MD)
272
  with gr.Column(scale=2):
273
  gr.Markdown(JOIN_US_MD)
274
 
275
+ # Large chatbot (fills viewport minus header via CSS)
276
+ large_chatbot = gr.Chatbot(label="Chatbot", elem_id="main_chatbot")
277
+
278
  gr.ChatInterface(
279
  fn=generate_response,
280
+ chatbot=large_chatbot,
281
  additional_inputs=[
282
  gr.Slider(label="Max new tokens", minimum=64, maximum=4096, step=1, value=2048),
283
  gr.Textbox(
 
305
  interactive=True,
306
  ),
307
  ],
308
+ additional_inputs_accordion="Additional Parameters",
309
  examples=[
310
  [{"text": "A 68-year-old man complains of several blisters arising over the back and trunk for the preceding 2 weeks. He takes no medications and has not noted systemic symptoms such as fever, sore throat, weight loss, or fatigue. The general physical examination is normal. The oral mucosa and the lips are normal. Several 2- to 3-cm bullae are present over the trunk and back. A few excoriations where the blisters have ruptured are present. The remainder of the skin is normal, without erythema or scale. What is the best diagnostic approach at this time?"}],
311
  [{"text": "A 28-year-old woman, gravida 2, para 1, at 40 weeks of gestation is admitted to the hospital in active labor. The patient has attended many prenatal appointments and followed her physician's advice about screening for diseases, laboratory testing, diet, and exercise. Her pregnancy has been uncomplicated. She has no history of a serious illness. Her first child was delivered via normal vaginal delivery. Her vital signs are within normal limits. Cervical examination shows 100% effacement and 10 cm dilation. A cardiotocograph is shown. Which of the following is the most appropriate initial step in management?"}],
 
316
  cache_examples=False,
317
  type="messages",
318
  fill_height=True,
319
+ fill_width=True,
320
  textbox=gr.Textbox(
321
  label="Query Input",
322
  placeholder="Type your prompt (supports LaTeX: $x^2 + y^2 = z^2$)"