Silence1412 commited on
Commit
ec207f8
1 Parent(s): 0e534cb

Update Chat_with_pdf_LLM.py

Browse files
Files changed (1) hide show
  1. Chat_with_pdf_LLM.py +2 -2
Chat_with_pdf_LLM.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import streamlit as st
2
  from PyPDF2 import PdfReader
3
  from langchain.text_splitter import CharacterTextSplitter
@@ -13,14 +14,12 @@ def LLM_pdf(model_name = 'google/flan-t5-large'):
13
 
14
  # upload file
15
  pdf = st.file_uploader("Upload your PDF", type="pdf")
16
- print(pdf)
17
  # extract the text
18
  if pdf is not None:
19
  pdf_reader = PdfReader(pdf)
20
  text = ""
21
  for page in pdf_reader.pages:
22
  text += page.extract_text()
23
- print(pdf_reader)
24
 
25
  # split into chunks
26
  text_splitter = CharacterTextSplitter(
@@ -40,6 +39,7 @@ def LLM_pdf(model_name = 'google/flan-t5-large'):
40
  st.session_state['generated'] = []
41
  if 'past' not in st.session_state:
42
  st.session_state['past'] = []
 
43
 
44
  # show user input
45
  user_question = st.text_input("Ask a question about your PDF:")
 
1
+ from dotenv import load_dotenv
2
  import streamlit as st
3
  from PyPDF2 import PdfReader
4
  from langchain.text_splitter import CharacterTextSplitter
 
14
 
15
  # upload file
16
  pdf = st.file_uploader("Upload your PDF", type="pdf")
 
17
  # extract the text
18
  if pdf is not None:
19
  pdf_reader = PdfReader(pdf)
20
  text = ""
21
  for page in pdf_reader.pages:
22
  text += page.extract_text()
 
23
 
24
  # split into chunks
25
  text_splitter = CharacterTextSplitter(
 
39
  st.session_state['generated'] = []
40
  if 'past' not in st.session_state:
41
  st.session_state['past'] = []
42
+ print(st.session_state['generated'],st.session_state['past'])
43
 
44
  # show user input
45
  user_question = st.text_input("Ask a question about your PDF:")