sreesh2804 commited on
Commit
d77afce
·
verified ·
1 Parent(s): 62b8dc9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -101,13 +101,28 @@ def query_document(question):
101
  # ✅ Gradio UI
102
  with gr.Blocks() as demo:
103
  gr.Markdown("# 📄 AI-Powered Multi-Document Chatbot with Voice Output")
 
104
  file_dropdown = gr.Dropdown(choices=get_files_from_drive(), label="📂 Select Files", multiselect=True)
 
105
  process_button = gr.Button("🚀 Process Documents")
 
106
  user_input = gr.Textbox(label="🔎 Ask a Question")
107
  submit_button = gr.Button("💬 Get Answer")
 
108
  response_output = gr.Textbox(label="📝 Response")
109
  audio_output = gr.Audio(label="🔊 Audio Response")
 
 
 
 
 
 
 
 
 
110
  process_button.click(process_documents, inputs=file_dropdown, outputs=response_output)
 
 
111
  submit_button.click(query_document, inputs=user_input, outputs=[response_output, audio_output])
112
 
113
  demo.launch()
 
101
  # ✅ Gradio UI
102
  with gr.Blocks() as demo:
103
  gr.Markdown("# 📄 AI-Powered Multi-Document Chatbot with Voice Output")
104
+
105
  file_dropdown = gr.Dropdown(choices=get_files_from_drive(), label="📂 Select Files", multiselect=True)
106
+ refresh_button = gr.Button("🔄 Refresh Files") # 🔄 Add Refresh Button
107
  process_button = gr.Button("🚀 Process Documents")
108
+
109
  user_input = gr.Textbox(label="🔎 Ask a Question")
110
  submit_button = gr.Button("💬 Get Answer")
111
+
112
  response_output = gr.Textbox(label="📝 Response")
113
  audio_output = gr.Audio(label="🔊 Audio Response")
114
+
115
+ # 🔄 Function to Refresh File List
116
+ def refresh_files():
117
+ return gr.update(choices=get_files_from_drive())
118
+
119
+ # ✅ Connect Refresh Button
120
+ refresh_button.click(refresh_files, outputs=file_dropdown)
121
+
122
+ # ✅ Connect Process Button
123
  process_button.click(process_documents, inputs=file_dropdown, outputs=response_output)
124
+
125
+ # ✅ Connect Query Button
126
  submit_button.click(query_document, inputs=user_input, outputs=[response_output, audio_output])
127
 
128
  demo.launch()