Dheeraj-13 commited on
Commit
bb4f4c4
Β·
1 Parent(s): 7f4636f

Refactor UI to side-by-side layout with dark mode support

Browse files
Files changed (1) hide show
  1. apps/web/app.py +67 -67
apps/web/app.py CHANGED
@@ -144,77 +144,77 @@ init_services()
144
  with gr.Blocks(title="RAG Knowledge Assistant", theme=gr.themes.Soft()) as demo:
145
  gr.Markdown("# πŸ€– Super Smart Knowledge Assistant")
146
 
 
 
147
  with gr.Row():
148
- gr.HTML("""
149
- <div style="background-color: #f0f9ff; padding: 20px; border-radius: 10px; border: 2px solid #3b82f6;">
150
- <h3 style="color: #1e40af; margin-top: 0;">πŸ‘‹ Hi! I'm your AI Helper!</h3>
151
- <p style="font-size: 16px;">I can learn from <b>ANY</b> document you give me. creating your own Google is easy as 1-2-3!</p>
152
- <div style="display: flex; gap: 20px; margin-top: 15px;">
153
- <div style="flex: 1; background: white; padding: 15px; border-radius: 8px; border-left: 5px solid #10b981;">
154
- <h4 style="color: #059669;">Step 1: Teach Me 🍎</h4>
155
- <p>Go to <b>'1. Teach Me'</b> tab.<br>Upload a PDF or just click "Use Sample Data".<br>Then hit the big <b>πŸš€ Ingest</b> button!</p>
156
- </div>
157
- <div style="flex: 1; background: white; padding: 15px; border-radius: 8px; border-left: 5px solid #8b5cf6;">
158
- <h4 style="color: #7c3aed;">Step 2: Chat with Me πŸ’¬</h4>
159
- <p>Go to <b>'2. Talk to Me'</b> tab.<br>Pick your brain (OpenAI, Gemini, or Local).<br>Ask me anything about what you taught me!</p>
160
- </div>
161
- </div>
162
- </div>
163
- """)
164
-
165
- with gr.Tabs():
166
- # Tab 1: Knowledge Base (Ingestion)
167
- with gr.Tab("1. Teach Me (Knowledge Base)"):
168
- gr.Markdown("### Step 1: Choose Your Data Source")
169
-
170
- with gr.Row():
171
- with gr.Column():
172
- gr.Markdown("#### Option A: Upload Documents")
173
- file_upload = gr.File(
174
- label="Upload PDF / TXT / HTML",
175
- file_count="multiple",
176
- file_types=[".pdf", ".txt", ".html"]
177
- )
178
- with gr.Column():
179
- gr.Markdown("#### Option B: Use Sample Data")
180
- use_sample_chk = gr.Checkbox(
181
- label="Load 'Sports Legends' Dataset",
182
- info="Perfect for testing without your own files."
183
- )
184
 
185
- gr.Markdown("### Step 2: Build Index")
186
- ingest_btn = gr.Button("πŸš€ Ingest & Re-Index", variant="primary")
 
187
 
188
- status_box = gr.Textbox(label="System Status", value="Ready.", interactive=False, lines=5)
189
-
190
- ingest_btn.click(
191
- admin_ingest,
192
- inputs=[file_upload, use_sample_chk],
193
- outputs=[status_box]
194
- )
195
 
196
- # Tab 2: Chat Interface
197
- with gr.Tab("2. Talk to Me (Chat)"):
198
- gr.Markdown("### Step 3: Ask Questions")
199
-
200
- with gr.Accordion("βš™οΈ Model Settings", open=True):
201
- backend_radio = gr.Radio(
202
- choices=["openai", "gemini", "local"],
203
- value="openai",
204
- label="Select LLM Backend",
205
- info="OpenAI/Gemini require API Keys. Local runs on ZeroGPU (slower cold start)."
206
- )
207
-
208
- chatbot = gr.ChatInterface(
209
- fn=chat_fn,
210
- additional_inputs=[backend_radio],
211
- title="Chat with your Documents",
212
- description="Ask questions about the content you indexed in the 'Knowledge Base' tab.",
213
- examples=[
214
- ["Who is the greatest quarterback?", "openai"],
215
- ["Summary of Lionel Messi", "local"]
216
- ]
217
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
 
219
  if __name__ == "__main__":
220
  # specific server_name needed for Docker/Spaces
 
144
  with gr.Blocks(title="RAG Knowledge Assistant", theme=gr.themes.Soft()) as demo:
145
  gr.Markdown("# πŸ€– Super Smart Knowledge Assistant")
146
 
147
+ gr.Markdown("# πŸ€– Super Smart Knowledge Assistant")
148
+
149
  with gr.Row():
150
+ # Left Column: Guide (Scale 1)
151
+ with gr.Column(scale=1):
152
+ gr.Markdown("### πŸ‘‹ Hi! I'm your AI Helper!")
153
+ gr.Markdown("I can learn from **ANY** document you give me. Creating your own Google is easy as 1-2-3!")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
 
155
+ with gr.Group():
156
+ gr.Markdown("#### Step 1: Teach Me 🍎")
157
+ gr.Markdown("1. Go to **'1. Teach Me'** tab.\n2. Upload a PDF or check **'Load Sports Legends'**.\n3. Click **πŸš€ Ingest**.")
158
 
159
+ with gr.Group():
160
+ gr.Markdown("#### Step 2: Chat with Me πŸ’¬")
161
+ gr.Markdown("1. Go to **'2. Talk to Me'** tab.\n2. Pick **Gemini/OpenAI**.\n3. Ask me anything!")
 
 
 
 
162
 
163
+ # Right Column: Main App (Scale 3)
164
+ with gr.Column(scale=3):
165
+ with gr.Tabs():
166
+ # Tab 1: Knowledge Base (Ingestion)
167
+ with gr.Tab("1. Teach Me (Knowledge Base)"):
168
+ gr.Markdown("### Step 1: Choose Your Data Source")
169
+
170
+ with gr.Row():
171
+ with gr.Column():
172
+ gr.Markdown("#### Option A: Upload Documents")
173
+ file_upload = gr.File(
174
+ label="Upload PDF / TXT / HTML",
175
+ file_count="multiple",
176
+ file_types=[".pdf", ".txt", ".html"]
177
+ )
178
+ with gr.Column():
179
+ gr.Markdown("#### Option B: Use Sample Data")
180
+ use_sample_chk = gr.Checkbox(
181
+ label="Load 'Sports Legends' Dataset",
182
+ info="Perfect for testing without your own files."
183
+ )
184
+
185
+ gr.Markdown("### Step 2: Build Index")
186
+ ingest_btn = gr.Button("πŸš€ Ingest & Re-Index", variant="primary")
187
+
188
+ status_box = gr.Textbox(label="System Status", value="Ready.", interactive=False, lines=5)
189
+
190
+ ingest_btn.click(
191
+ admin_ingest,
192
+ inputs=[file_upload, use_sample_chk],
193
+ outputs=[status_box]
194
+ )
195
+
196
+ # Tab 2: Chat Interface
197
+ with gr.Tab("2. Talk to Me (Chat)"):
198
+ gr.Markdown("### Step 3: Ask Questions")
199
+
200
+ with gr.Accordion("βš™οΈ Model Settings", open=True):
201
+ backend_radio = gr.Radio(
202
+ choices=["openai", "gemini", "local"],
203
+ value="openai",
204
+ label="Select LLM Backend",
205
+ info="OpenAI/Gemini require API Keys. Local runs on ZeroGPU (slower cold start)."
206
+ )
207
+
208
+ chatbot = gr.ChatInterface(
209
+ fn=chat_fn,
210
+ additional_inputs=[backend_radio],
211
+ title="Chat with your Documents",
212
+ description="Ask questions about the content you indexed in the 'Knowledge Base' tab.",
213
+ examples=[
214
+ ["Who is the greatest quarterback?", "openai"],
215
+ ["Summary of Lionel Messi", "local"]
216
+ ]
217
+ )
218
 
219
  if __name__ == "__main__":
220
  # specific server_name needed for Docker/Spaces