lfoppiano commited on
Commit
abd4433
1 Parent(s): 66819b5

remove show_annotations checkbox

Browse files
Files changed (1) hide show
  1. streamlit_app.py +15 -20
streamlit_app.py CHANGED
@@ -308,17 +308,17 @@ with st.sidebar:
308
 
309
  # Add a checkbox for showing annotations
310
  # st.session_state['show_annotations'] = st.checkbox("Show annotations", value=True)
311
- st.session_state['should_show_annotations'] = st.checkbox("Show annotations", value=True)
312
 
313
- chunk_size = st.slider("Chunks size", -1, 2000, value=-1,
314
- help="Size of chunks in which the document is partitioned",
315
  disabled=uploaded_file is not None)
316
  if chunk_size == -1:
317
- context_size = st.slider("Context size", 3, 20, value=10,
318
  help="Number of paragraphs to consider when answering a question",
319
  disabled=not uploaded_file)
320
  else:
321
- context_size = st.slider("Context size", 3, 10, value=4,
322
  help="Number of chunks to consider when answering a question",
323
  disabled=not uploaded_file)
324
 
@@ -437,7 +437,8 @@ with right_column:
437
  for i, color in enumerate(gradients):
438
  for annotation in annotations[i]:
439
  annotation['color'] = color
440
- st.session_state['annotations'] = [annotation for annotation_doc in annotations for annotation in annotation_doc]
 
441
 
442
  if not text_response:
443
  st.error("Something went wrong. Contact Luca Foppiano ([email protected]) to report the issue.")
@@ -456,26 +457,20 @@ with right_column:
456
  st.write(text_response)
457
  st.session_state.messages.append({"role": "assistant", "mode": mode, "content": text_response})
458
 
459
- # if len(st.session_state.messages) > 1:
460
- # last_answer = st.session_state.messages[len(st.session_state.messages)-1]
461
- # if last_answer['role'] == "assistant":
462
- # last_question = st.session_state.messages[len(st.session_state.messages)-2]
463
- # st.session_state.memory.save_context({"input": last_question['content']}, {"output": last_answer['content']})
464
-
465
  elif st.session_state.loaded_embeddings and st.session_state.doc_id:
466
  play_old_messages()
467
 
468
  with left_column:
469
  if st.session_state['binary']:
470
- if st.session_state['should_show_annotations']:
471
- pdf_viewer(input=st.session_state['binary'],
472
  width=600,
473
  height=800,
474
  annotation_outline_size=2,
475
  annotations=st.session_state['annotations'])
476
- else:
477
- pdf_viewer(input=st.session_state['binary'],
478
- width=600,
479
- height=800,
480
- annotation_outline_size=2
481
- )
 
308
 
309
  # Add a checkbox for showing annotations
310
  # st.session_state['show_annotations'] = st.checkbox("Show annotations", value=True)
311
+ # st.session_state['should_show_annotations'] = st.checkbox("Show annotations", value=True)
312
 
313
+ chunk_size = st.slider("Text chunks size", -1, 2000, value=-1,
314
+ help="Size of chunks in which split the document. -1: use paragraphs, > 0 paragraphs are aggregated.",
315
  disabled=uploaded_file is not None)
316
  if chunk_size == -1:
317
+ context_size = st.slider("Context size (paragraphs)", 3, 20, value=10,
318
  help="Number of paragraphs to consider when answering a question",
319
  disabled=not uploaded_file)
320
  else:
321
+ context_size = st.slider("Context size (chunks)", 3, 10, value=4,
322
  help="Number of chunks to consider when answering a question",
323
  disabled=not uploaded_file)
324
 
 
437
  for i, color in enumerate(gradients):
438
  for annotation in annotations[i]:
439
  annotation['color'] = color
440
+ st.session_state['annotations'] = [annotation for annotation_doc in annotations for annotation in
441
+ annotation_doc]
442
 
443
  if not text_response:
444
  st.error("Something went wrong. Contact Luca Foppiano ([email protected]) to report the issue.")
 
457
  st.write(text_response)
458
  st.session_state.messages.append({"role": "assistant", "mode": mode, "content": text_response})
459
 
 
 
 
 
 
 
460
  elif st.session_state.loaded_embeddings and st.session_state.doc_id:
461
  play_old_messages()
462
 
463
  with left_column:
464
  if st.session_state['binary']:
465
+ # if st.session_state['should_show_annotations']:
466
+ pdf_viewer(input=st.session_state['binary'],
467
  width=600,
468
  height=800,
469
  annotation_outline_size=2,
470
  annotations=st.session_state['annotations'])
471
+ # else:
472
+ # pdf_viewer(input=st.session_state['binary'],
473
+ # width=600,
474
+ # height=800,
475
+ # annotation_outline_size=2
476
+ # )