lfoppiano commited on
Commit
325dca4
1 Parent(s): 16e8140

add pdf_viewer

Browse files
Files changed (1) hide show
  1. streamlit_app.py +4 -3
streamlit_app.py CHANGED
@@ -8,6 +8,7 @@ import dotenv
8
  from grobid_quantities.quantities import QuantitiesAPI
9
  from langchain.llms.huggingface_hub import HuggingFaceHub
10
  from langchain.memory import ConversationBufferWindowMemory
 
11
 
12
  dotenv.load_dotenv(override=True)
13
 
@@ -321,10 +322,10 @@ with st.sidebar:
321
  """If you switch the mode to "Embedding," the system will return specific chunks from the document that are semantically related to your query. This mode helps to test why sometimes the answers are not satisfying or incomplete. """)
322
 
323
 
324
- @st.cache_resource
325
  def get_pdf_display(binary):
326
- base64_pdf = base64.b64encode(binary).decode('utf-8')
327
- return F'<embed src="data:application/pdf;base64,{base64_pdf}" width="100%" height="700" type="application/pdf"></embed>'
328
 
329
 
330
  if uploaded_file and not st.session_state.loaded_embeddings:
 
8
  from grobid_quantities.quantities import QuantitiesAPI
9
  from langchain.llms.huggingface_hub import HuggingFaceHub
10
  from langchain.memory import ConversationBufferWindowMemory
11
+ from streamlit_pdf_viewer import pdf_viewer
12
 
13
  dotenv.load_dotenv(override=True)
14
 
 
322
  """If you switch the mode to "Embedding," the system will return specific chunks from the document that are semantically related to your query. This mode helps to test why sometimes the answers are not satisfying or incomplete. """)
323
 
324
 
325
+ # @st.cache_resource
326
  def get_pdf_display(binary):
327
+ pdf_viewer(binary)
328
+ # return F'<embed src="data:application/pdf;base64,{base64_pdf}" width="100%" height="700" type="application/pdf"></embed>'
329
 
330
 
331
  if uploaded_file and not st.session_state.loaded_embeddings: