Chia Woon Yap commited on
Commit
9f948da
·
verified ·
1 Parent(s): b0c86b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +81 -83
app.py CHANGED
@@ -283,92 +283,90 @@ def tutor_ai_chatbot():
283
  gr.Markdown("# 📚 AI Tutor - We.(POC)")
284
  gr.Markdown("An interactive Personal AI Tutor chatbot to help with your learning needs.")
285
 
286
- # Chatbot Tab
287
- with gr.Tab("AI Chatbot"):
288
- with gr.Row():
289
- with gr.Column(scale=3):
290
- chatbot = gr.Chatbot(height=500, type="messages")
291
-
292
- with gr.Column(scale=1):
293
- audio_playback = gr.Audio(label="Audio Response", type="filepath")
294
-
295
- # Move the input controls here to span full width
296
- with gr.Row():
297
- msg = gr.Textbox(
298
- label="Ask a question",
299
- placeholder="Type your question here...",
300
- container=False # Removes the default container styling
301
- )
302
- submit = gr.Button("Send")
303
-
304
- with gr.Row():
305
- with gr.Column(scale=1):
306
- audio_input = gr.Audio(type="numpy", label="Record or Upload Audio")
307
-
308
- # Clear chat history button
309
- clear_btn = gr.Button("Clear Chat")
310
 
311
- # ... rest of your event handlers remain the same
312
-
313
- # Handle chat interaction
314
- submit.click(
315
- chat_with_groq,
316
- inputs=[msg, chatbot],
317
- outputs=[chatbot, msg, audio_playback]
318
- )
319
-
320
- # Clear chat history function
321
- clear_btn.click(
322
- lambda: [], # Return empty list in message format
323
- inputs=None,
324
- outputs=[chatbot]
325
- )
326
-
327
- # Also allow Enter key to submit
328
- msg.submit(
329
- chat_with_groq,
330
- inputs=[msg, chatbot],
331
- outputs=[chatbot, msg, audio_playback]
332
- )
333
-
334
- # Add some examples of questions students might ask
335
- with gr.Accordion("Example Questions", open=False):
336
- gr.Examples(
337
- examples=[
338
- "Can you explain the concept of RLHF AI?",
339
- "What are AI transformers?",
340
- "What is MoE AI?",
341
- "What's gate networks AI?",
342
- "I am making a switch, please generating baking recipe?"
343
- ],
344
- inputs=msg
345
  )
346
 
347
- # Connect audio input to transcription
348
- audio_input.change(fn=transcribe_audio, inputs=audio_input, outputs=msg)
349
-
350
- # Upload Notes & Generate Quiz Tab
351
- with gr.Tab("Upload Notes & Generate Quiz"):
352
- with gr.Row():
353
- with gr.Column(scale=2):
354
- file_input = gr.File(label="Upload Lecture Notes (PDF, DOCX, PPTX)")
355
- with gr.Column(scale=3):
356
- quiz_output = gr.Textbox(label="Generated Quiz", lines=10)
357
-
358
- # Connect file input to document processing
359
- file_input.change(process_document, inputs=file_input, outputs=quiz_output)
360
-
361
- # Introduction Video Tab - Now with the working video
362
- with gr.Tab("Introduction Video"):
363
- with gr.Row():
364
- with gr.Column(scale=1):
365
- gr.Markdown("### Welcome to the Introduction Video")
366
- gr.Markdown("Music from Xu Mengyuan - China-O, musician Xu Mengyuan YUAN! | 徐梦圆 - China-O 音乐人徐梦圆YUAN!")
367
- # Use the local video file that's stored in your Space
368
- gr.Video("We_not_me_video.mp4", label="Introduction Video")
369
-
370
- # Launch the application
371
- app.launch(share=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
372
 
373
  # Launch the AI chatbot
374
  if __name__ == "__main__":
 
283
  gr.Markdown("# 📚 AI Tutor - We.(POC)")
284
  gr.Markdown("An interactive Personal AI Tutor chatbot to help with your learning needs.")
285
 
286
+ # Chatbot Tab
287
+ with gr.Tab("AI Chatbot"):
288
+ with gr.Row():
289
+ with gr.Column(scale=3):
290
+ chatbot = gr.Chatbot(height=500, type="messages")
291
+
292
+ with gr.Column(scale=1):
293
+ audio_playback = gr.Audio(label="Audio Response", type="filepath")
294
+
295
+ # Move the input controls here to span full width
296
+ with gr.Row():
297
+ msg = gr.Textbox(
298
+ label="Ask a question",
299
+ placeholder="Type your question here...",
300
+ container=False # Removes the default container styling
301
+ )
302
+ submit = gr.Button("Send")
 
 
 
 
 
 
 
303
 
304
+ with gr.Row():
305
+ with gr.Column(scale=1):
306
+ audio_input = gr.Audio(type="numpy", label="Record or Upload Audio")
307
+
308
+ # Clear chat history button
309
+ clear_btn = gr.Button("Clear Chat")
310
+
311
+ # Handle chat interaction
312
+ submit.click(
313
+ chat_with_groq,
314
+ inputs=[msg, chatbot],
315
+ outputs=[chatbot, msg, audio_playback]
316
+ )
317
+
318
+ # Clear chat history function
319
+ clear_btn.click(
320
+ lambda: [], # Return empty list in message format
321
+ inputs=None,
322
+ outputs=[chatbot]
323
+ )
324
+
325
+ # Also allow Enter key to submit
326
+ msg.submit(
327
+ chat_with_groq,
328
+ inputs=[msg, chatbot],
329
+ outputs=[chatbot, msg, audio_playback]
 
 
 
 
 
 
 
 
330
  )
331
 
332
+ # Add some examples of questions students might ask
333
+ with gr.Accordion("Example Questions", open=False):
334
+ gr.Examples(
335
+ examples=[
336
+ "Can you explain the concept of RLHF AI?",
337
+ "What are AI transformers?",
338
+ "What is MoE AI?",
339
+ "What's gate networks AI?",
340
+ "I am making a switch, please generating baking recipe?"
341
+ ],
342
+ inputs=msg
343
+ )
344
+
345
+ # Connect audio input to transcription
346
+ audio_input.change(fn=transcribe_audio, inputs=audio_input, outputs=msg)
347
+
348
+ # Upload Notes & Generate Quiz Tab
349
+ with gr.Tab("Upload Notes & Generate Quiz"):
350
+ with gr.Row():
351
+ with gr.Column(scale=2):
352
+ file_input = gr.File(label="Upload Lecture Notes (PDF, DOCX, PPTX)")
353
+ with gr.Column(scale=3):
354
+ quiz_output = gr.Textbox(label="Generated Quiz", lines=10)
355
+
356
+ # Connect file input to document processing
357
+ file_input.change(process_document, inputs=file_input, outputs=quiz_output)
358
+
359
+ # Introduction Video Tab - Now with the working video
360
+ with gr.Tab("Introduction Video"):
361
+ with gr.Row():
362
+ with gr.Column(scale=1):
363
+ gr.Markdown("### Welcome to the Introduction Video")
364
+ gr.Markdown("Music from Xu Mengyuan - China-O, musician Xu Mengyuan YUAN! | 徐梦圆 - China-O 音乐人徐梦圆YUAN!")
365
+ # Use the local video file that's stored in your Space
366
+ gr.Video("We_not_me_video.mp4", label="Introduction Video")
367
+
368
+ # Launch the application
369
+ app.launch(share=False)
370
 
371
  # Launch the AI chatbot
372
  if __name__ == "__main__":