raviix46 commited on
Commit
5c3d06f
·
verified ·
1 Parent(s): f6cddc5

Update src/ui.py

Browse files
Files changed (1) hide show
  1. src/ui.py +16 -3
src/ui.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  from src.logic import generate_answer, rebuild
3
 
 
4
  def create_ui():
5
  with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue"), title="MindMesh") as demo:
6
  gr.Markdown(
@@ -13,6 +14,7 @@ def create_ui():
13
  )
14
 
15
  with gr.Row(equal_height=False):
 
16
  with gr.Column(scale=2):
17
  q = gr.Textbox(
18
  label="Your Question",
@@ -20,9 +22,14 @@ def create_ui():
20
  lines=2,
21
  show_label=True,
22
  )
23
- rebuild_btn = gr.Button("🔁 Rebuild Index", variant="secondary")
 
 
 
 
24
  status = gr.Markdown(value="", visible=True)
25
 
 
26
  with gr.Column(scale=1):
27
  mode = gr.Radio(
28
  ["Quick Summary (Offline)", "LLM Precision (Groq Llama-3.1 70B)"],
@@ -30,8 +37,10 @@ def create_ui():
30
  label="Answer Mode",
31
  )
32
 
 
33
  out = gr.Markdown()
34
 
 
35
  examples = gr.Examples(
36
  examples=[
37
  ["What can startups learn from the Industrial Revolution?"],
@@ -42,14 +51,18 @@ def create_ui():
42
  inputs=q
43
  )
44
 
 
 
 
45
  q.submit(fn=lambda x, m: generate_answer(x, m), inputs=[q, mode], outputs=out)
46
- rebuild_btn.click(fn=rebuild, inputs=None, outputs=status)
47
 
 
48
  gr.HTML("""
49
  <style>
50
- #component-0 { max-width: 900px; margin: auto; }
51
  textarea { font-size: 15px !important; }
52
  button { font-size: 14px !important; font-weight: 600; border-radius: 8px !important; }
 
53
  </style>
54
  """)
55
 
 
1
  import gradio as gr
2
  from src.logic import generate_answer, rebuild
3
 
4
+
5
  def create_ui():
6
  with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue"), title="MindMesh") as demo:
7
  gr.Markdown(
 
14
  )
15
 
16
  with gr.Row(equal_height=False):
17
+ # Left Section — user question + buttons
18
  with gr.Column(scale=2):
19
  q = gr.Textbox(
20
  label="Your Question",
 
22
  lines=2,
23
  show_label=True,
24
  )
25
+
26
+ with gr.Row():
27
+ generate_btn = gr.Button("⚙️ Generate Insight", variant="primary")
28
+ clear_btn = gr.Button("🧹 Clear", variant="secondary")
29
+
30
  status = gr.Markdown(value="", visible=True)
31
 
32
+ # Right Section — answer mode selector
33
  with gr.Column(scale=1):
34
  mode = gr.Radio(
35
  ["Quick Summary (Offline)", "LLM Precision (Groq Llama-3.1 70B)"],
 
37
  label="Answer Mode",
38
  )
39
 
40
+ # Output section
41
  out = gr.Markdown()
42
 
43
+ # Example prompts
44
  examples = gr.Examples(
45
  examples=[
46
  ["What can startups learn from the Industrial Revolution?"],
 
51
  inputs=q
52
  )
53
 
54
+ # Button logic
55
+ generate_btn.click(fn=lambda x, m: generate_answer(x, m), inputs=[q, mode], outputs=out)
56
+ clear_btn.click(lambda: ("", "", ""), outputs=[q, out, status])
57
  q.submit(fn=lambda x, m: generate_answer(x, m), inputs=[q, mode], outputs=out)
 
58
 
59
+ # Styling
60
  gr.HTML("""
61
  <style>
62
+ #component-0 { max-width: 950px; margin: auto; }
63
  textarea { font-size: 15px !important; }
64
  button { font-size: 14px !important; font-weight: 600; border-radius: 8px !important; }
65
+ .gradio-container { padding-top: 0 !important; }
66
  </style>
67
  """)
68