Spaces:
Running
Running
Added a button to enable control over the display of annotations.
Browse files- streamlit_app.py +13 -2
streamlit_app.py
CHANGED
@@ -73,6 +73,9 @@ if 'binary' not in st.session_state:
|
|
73 |
if 'annotations' not in st.session_state:
|
74 |
st.session_state['annotations'] = None
|
75 |
|
|
|
|
|
|
|
76 |
if 'pdf' not in st.session_state:
|
77 |
st.session_state['pdf'] = None
|
78 |
|
@@ -222,7 +225,7 @@ with st.sidebar:
|
|
222 |
st.session_state['model'] = model = st.selectbox(
|
223 |
"Model:",
|
224 |
options=OPENAI_MODELS + list(OPEN_MODELS.keys()),
|
225 |
-
index=
|
226 |
placeholder="Select model",
|
227 |
help="Select the LLM model:",
|
228 |
disabled=st.session_state['doc_id'] is not None or st.session_state['uploaded']
|
@@ -300,6 +303,11 @@ with st.sidebar:
|
|
300 |
mode = st.radio("Query mode", ("LLM", "Embeddings"), disabled=not uploaded_file, index=0, horizontal=True,
|
301 |
help="LLM will respond the question, Embedding will show the "
|
302 |
"paragraphs relevant to the question in the paper.")
|
|
|
|
|
|
|
|
|
|
|
303 |
chunk_size = st.slider("Chunks size", -1, 2000, value=-1,
|
304 |
help="Size of chunks in which the document is partitioned",
|
305 |
disabled=uploaded_file is not None)
|
@@ -457,4 +465,7 @@ with right_column:
|
|
457 |
|
458 |
with left_column:
|
459 |
if st.session_state['binary']:
|
460 |
-
|
|
|
|
|
|
|
|
73 |
if 'annotations' not in st.session_state:
|
74 |
st.session_state['annotations'] = None
|
75 |
|
76 |
+
if 'should_show_annotations' not in st.session_state:
|
77 |
+
st.session_state['should_show_annotations'] = True
|
78 |
+
|
79 |
if 'pdf' not in st.session_state:
|
80 |
st.session_state['pdf'] = None
|
81 |
|
|
|
225 |
st.session_state['model'] = model = st.selectbox(
|
226 |
"Model:",
|
227 |
options=OPENAI_MODELS + list(OPEN_MODELS.keys()),
|
228 |
+
index=OPENAI_MODELS.index('gpt-3.5-turbo'),
|
229 |
placeholder="Select model",
|
230 |
help="Select the LLM model:",
|
231 |
disabled=st.session_state['doc_id'] is not None or st.session_state['uploaded']
|
|
|
303 |
mode = st.radio("Query mode", ("LLM", "Embeddings"), disabled=not uploaded_file, index=0, horizontal=True,
|
304 |
help="LLM will respond the question, Embedding will show the "
|
305 |
"paragraphs relevant to the question in the paper.")
|
306 |
+
|
307 |
+
# Add a checkbox for showing annotations
|
308 |
+
# st.session_state['show_annotations'] = st.checkbox("Show annotations", value=True)
|
309 |
+
st.session_state['should_show_annotations'] = st.checkbox("Show annotations", value=True)
|
310 |
+
|
311 |
chunk_size = st.slider("Chunks size", -1, 2000, value=-1,
|
312 |
help="Size of chunks in which the document is partitioned",
|
313 |
disabled=uploaded_file is not None)
|
|
|
465 |
|
466 |
with left_column:
|
467 |
if st.session_state['binary']:
|
468 |
+
if st.session_state['should_show_annotations']:
|
469 |
+
pdf_viewer(input=st.session_state['binary'], width=600, height=800, annotations=st.session_state['annotations'])
|
470 |
+
else:
|
471 |
+
pdf_viewer(input=st.session_state['binary'], width=600, height=800)
|