Quent1Fvr commited on
Commit
2a2ee46
1 Parent(s): 4ff8150

Update src/view/view.py

Browse files
Files changed (1) hide show
  1. src/view/view.py +6 -12
src/view/view.py CHANGED
@@ -12,7 +12,6 @@ def run(ctrl: Chatbot, config: {}):
12
  with gr.Column(scale=10):
13
  gr.Markdown(config['title'])
14
  intro_text = gr.Markdown('<center> Ask questions on any PDF, Word or HTML document. Start with "Le Petit Prince" or upload your own document.<center/>', visible=True)
15
- page_start_warning = gr.Markdown("<center>⚠️ If your document starts with a front cover and/or a table of contents, please enter the page number of the ⚠️ first page with real content.<center/>")
16
 
17
  actual_page_start = gr.Number(
18
  label="Start page (default = 1)",
@@ -25,7 +24,7 @@ def run(ctrl: Chatbot, config: {}):
25
  include_images_btn = gr.Checkbox(
26
  label="Analyse text from images. This option is definitely slower, particularly on big documents. (ONLY for .pdf)",
27
  value=False,
28
- visible=True,
29
  container=True,
30
  )
31
 
@@ -88,7 +87,6 @@ def run(ctrl: Chatbot, config: {}):
88
  delete_database_btn: gr.update(visible=False),
89
  upload_another_doc_btn: gr.update(visible=True),
90
  collections_list: gr.update(choices=[a.name for a in ctrl.client_db.list_collections()],value=ctrl.retriever.collection.name),
91
- page_start_warning: gr.update(visible=False),
92
  actual_page_start: gr.update(visible=False),
93
  intro_text: gr.update(visible=False),
94
 
@@ -101,7 +99,6 @@ def run(ctrl: Chatbot, config: {}):
101
  input_example_comp: gr.update(visible=False),
102
  clear_btn: gr.update(visible=False),
103
  include_images_btn: gr.update(visible=True,value=include_images_),
104
- page_start_warning: gr.update(visible=True),
105
  actual_page_start: gr.update(visible=False, value=1),
106
  intro_text: gr.update(visible=False),
107
 
@@ -117,7 +114,6 @@ def run(ctrl: Chatbot, config: {}):
117
  include_images_btn: gr.update(visible=True),
118
  upload_another_doc_btn: gr.update(visible=False),
119
  delete_database_btn: gr.update(visible=False),
120
- page_start_warning: gr.update(visible=True),
121
  actual_page_start: gr.update(visible=False, value=1),
122
  collections_list: gr.update(value=None, choices=[a.name for a in ctrl.client_db.list_collections()]),
123
  intro_text: gr.update(visible=False),
@@ -202,7 +198,6 @@ def run(ctrl: Chatbot, config: {}):
202
  histo_text_comp: gr.update(visible=False, value=''),
203
  upload_another_doc_btn: gr.update(visible=True),
204
  actual_page_start: gr.update(visible=False),
205
- page_start_warning: gr.update(visible=False),
206
  intro_text: gr.update(visible=False),
207
 
208
  }
@@ -221,26 +216,25 @@ def run(ctrl: Chatbot, config: {}):
221
  histo_text_comp: gr.update(visible=False, value=''),
222
  upload_another_doc_btn: gr.update(visible=False),
223
  actual_page_start: gr.update(visible=False, value=1),
224
- page_start_warning: gr.update(visible=True),
225
  intro_text: gr.update(visible=False),
226
  }
227
 
228
  upload_another_doc_btn.click(input_file_clear,
229
  inputs=None,
230
- outputs=[intro_text,collections_list, page_start_warning, actual_page_start, input_doc_comp, input_text_comp, input_example_comp, clear_btn, include_images_btn, histo_text_comp, delete_database_btn,upload_another_doc_btn, source_text_comp[0], source_text_comp[1], source_text_comp[2], source_text_comp[3]])
231
 
232
  delete_database_btn.click(delete_curr_database,
233
  inputs=None,
234
- outputs=[intro_text,page_start_warning, actual_page_start, delete_database_btn, input_doc_comp, input_text_comp, input_example_comp, clear_btn, collections_list, include_images_btn, histo_text_comp, upload_another_doc_btn])
235
 
236
  collections_list.input(change_collection,
237
  inputs=[collections_list],
238
- outputs=[intro_text,actual_page_start, page_start_warning, collections_list, input_text_comp, input_example_comp, clear_btn, include_images_btn, histo_text_comp, input_doc_comp, delete_database_btn,upload_another_doc_btn])
239
 
240
  input_doc_comp \
241
  .upload(input_doc_fn,
242
  inputs=[input_doc_comp, include_images_btn, actual_page_start],
243
- outputs=[intro_text, page_start_warning, actual_page_start, input_doc_comp, input_text_comp,upload_another_doc_btn,
244
  input_example_comp, include_images_btn, clear_btn, histo_text_comp, delete_database_btn,collections_list, source_text_comp[0], source_text_comp[1], source_text_comp[2], source_text_comp[3]])\
245
  .then(list_all_chroma_collections,
246
  inputs=None,
@@ -249,7 +243,7 @@ def run(ctrl: Chatbot, config: {}):
249
  input_doc_comp \
250
  .clear(input_file_clear,
251
  inputs=None,
252
- outputs=[intro_text,page_start_warning, actual_page_start, input_doc_comp, clear_btn, upload_another_doc_btn, input_text_comp, histo_text_comp, input_example_comp, include_images_btn, delete_database_btn,
253
  source_text_comp[0], source_text_comp[1], source_text_comp[2], source_text_comp[3]])\
254
 
255
  input_text_comp \
 
12
  with gr.Column(scale=10):
13
  gr.Markdown(config['title'])
14
  intro_text = gr.Markdown('<center> Ask questions on any PDF, Word or HTML document. Start with "Le Petit Prince" or upload your own document.<center/>', visible=True)
 
15
 
16
  actual_page_start = gr.Number(
17
  label="Start page (default = 1)",
 
24
  include_images_btn = gr.Checkbox(
25
  label="Analyse text from images. This option is definitely slower, particularly on big documents. (ONLY for .pdf)",
26
  value=False,
27
+ visible=False,
28
  container=True,
29
  )
30
 
 
87
  delete_database_btn: gr.update(visible=False),
88
  upload_another_doc_btn: gr.update(visible=True),
89
  collections_list: gr.update(choices=[a.name for a in ctrl.client_db.list_collections()],value=ctrl.retriever.collection.name),
 
90
  actual_page_start: gr.update(visible=False),
91
  intro_text: gr.update(visible=False),
92
 
 
99
  input_example_comp: gr.update(visible=False),
100
  clear_btn: gr.update(visible=False),
101
  include_images_btn: gr.update(visible=True,value=include_images_),
 
102
  actual_page_start: gr.update(visible=False, value=1),
103
  intro_text: gr.update(visible=False),
104
 
 
114
  include_images_btn: gr.update(visible=True),
115
  upload_another_doc_btn: gr.update(visible=False),
116
  delete_database_btn: gr.update(visible=False),
 
117
  actual_page_start: gr.update(visible=False, value=1),
118
  collections_list: gr.update(value=None, choices=[a.name for a in ctrl.client_db.list_collections()]),
119
  intro_text: gr.update(visible=False),
 
198
  histo_text_comp: gr.update(visible=False, value=''),
199
  upload_another_doc_btn: gr.update(visible=True),
200
  actual_page_start: gr.update(visible=False),
 
201
  intro_text: gr.update(visible=False),
202
 
203
  }
 
216
  histo_text_comp: gr.update(visible=False, value=''),
217
  upload_another_doc_btn: gr.update(visible=False),
218
  actual_page_start: gr.update(visible=False, value=1),
 
219
  intro_text: gr.update(visible=False),
220
  }
221
 
222
  upload_another_doc_btn.click(input_file_clear,
223
  inputs=None,
224
+ outputs=[intro_text,collections_list , actual_page_start, input_doc_comp, input_text_comp, input_example_comp, clear_btn, include_images_btn, histo_text_comp, delete_database_btn,upload_another_doc_btn, source_text_comp[0], source_text_comp[1], source_text_comp[2], source_text_comp[3]])
225
 
226
  delete_database_btn.click(delete_curr_database,
227
  inputs=None,
228
+ outputs=[intro_text, actual_page_start, delete_database_btn, input_doc_comp, input_text_comp, input_example_comp, clear_btn, collections_list, include_images_btn, histo_text_comp, upload_another_doc_btn])
229
 
230
  collections_list.input(change_collection,
231
  inputs=[collections_list],
232
+ outputs=[intro_text,actual_page_start, collections_list, input_text_comp, input_example_comp, clear_btn, include_images_btn, histo_text_comp, input_doc_comp, delete_database_btn,upload_another_doc_btn])
233
 
234
  input_doc_comp \
235
  .upload(input_doc_fn,
236
  inputs=[input_doc_comp, include_images_btn, actual_page_start],
237
+ outputs=[intro_text, actual_page_start, input_doc_comp, input_text_comp,upload_another_doc_btn,
238
  input_example_comp, include_images_btn, clear_btn, histo_text_comp, delete_database_btn,collections_list, source_text_comp[0], source_text_comp[1], source_text_comp[2], source_text_comp[3]])\
239
  .then(list_all_chroma_collections,
240
  inputs=None,
 
243
  input_doc_comp \
244
  .clear(input_file_clear,
245
  inputs=None,
246
+ outputs=[intro_text, actual_page_start, input_doc_comp, clear_btn, upload_another_doc_btn, input_text_comp, histo_text_comp, input_example_comp, include_images_btn, delete_database_btn,
247
  source_text_comp[0], source_text_comp[1], source_text_comp[2], source_text_comp[3]])\
248
 
249
  input_text_comp \