gourisankar85 commited on
Commit
e25b23e
·
verified ·
1 Parent(s): f1e890e

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -18
app.py CHANGED
@@ -11,7 +11,7 @@ def load_sample_question(question):
11
  return question
12
 
13
  def clear_selection():
14
- return gr.update(value=[]), "", "" # Reset doc_selector to empty list
15
 
16
  def process_uploaded_file(file, current_selection):
17
  """Process uploaded file using DocumentManager and update UI."""
@@ -126,16 +126,7 @@ with gr.Blocks(css="""
126
  filename_state
127
  ]
128
  )
129
- clear_btn.click(
130
- clear_selection,
131
- outputs=[doc_selector, upload_status, filename_state]
132
- )
133
- # Reinitialize LLM when the model changes
134
- model_selector.change(
135
- app_config.gen_llm.reinitialize_llm,
136
- inputs=[model_selector],
137
- outputs=[upload_status]
138
- )
139
 
140
  # Middle Section (Chat & LLM Response)
141
  with gr.Column(scale=6):
@@ -159,12 +150,17 @@ with gr.Blocks(css="""
159
  interactive=True,
160
  allow_custom_value=True # Allows users to type custom questions if needed
161
  )
162
- '''question_dropdown = gr.Dropdown(
163
- label="",
164
- choices=all_questions,
165
- interactive=True,
166
- info="Choose a question from the dropdown to populate the query box."
167
- )'''
 
 
 
 
 
168
 
169
  # After upload, generate "Auto Summary" message only if trigger_summary is True
170
  upload_event.then(
@@ -192,7 +188,10 @@ with gr.Blocks(css="""
192
  inputs=[chunks_state],
193
  outputs=[sample_questions_state]
194
  ).then(
195
- fn=lambda questions: gr.update(choices=questions if questions else ["No questions available"]),
 
 
 
196
  inputs=[sample_questions_state],
197
  outputs=[sample_questions]
198
  )
 
11
  return question
12
 
13
  def clear_selection():
14
+ return gr.update(value=[]), "", "", gr.update(value=[]) # Reset doc_selector to empty list
15
 
16
  def process_uploaded_file(file, current_selection):
17
  """Process uploaded file using DocumentManager and update UI."""
 
126
  filename_state
127
  ]
128
  )
129
+
 
 
 
 
 
 
 
 
 
130
 
131
  # Middle Section (Chat & LLM Response)
132
  with gr.Column(scale=6):
 
150
  interactive=True,
151
  allow_custom_value=True # Allows users to type custom questions if needed
152
  )
153
+
154
+ clear_btn.click(
155
+ clear_selection,
156
+ outputs=[doc_selector, upload_status, filename_state, sample_questions]
157
+ )
158
+ # Reinitialize LLM when the model changes
159
+ model_selector.change(
160
+ app_config.gen_llm.reinitialize_llm,
161
+ inputs=[model_selector],
162
+ outputs=[upload_status]
163
+ )
164
 
165
  # After upload, generate "Auto Summary" message only if trigger_summary is True
166
  upload_event.then(
 
188
  inputs=[chunks_state],
189
  outputs=[sample_questions_state]
190
  ).then(
191
+ fn=lambda questions: gr.update(
192
+ choices=questions if questions else ["No questions available"],
193
+ value=questions[0] if questions else None # Set the first question as default
194
+ ),
195
  inputs=[sample_questions_state],
196
  outputs=[sample_questions]
197
  )