Writo commited on
Commit
e80b06b
·
1 Parent(s): 00465b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -3
app.py CHANGED
@@ -1,8 +1,25 @@
1
  import streamlit as st
2
- # Other imports remain the same
 
 
 
 
 
 
 
 
 
 
3
 
4
  def process_pdf(pdf):
5
- # Function remains the same
 
 
 
 
 
 
 
6
 
7
  def display_chat_history():
8
  history_text = ""
@@ -46,4 +63,4 @@ def main():
46
  # Logging and exception handling remain the same
47
 
48
  if __name__ == "__main__":
49
- main()
 
1
  import streamlit as st
2
+ from dotenv import load_dotenv
3
+ import streamlit as st
4
+ from PyPDF2 import PdfReader
5
+ from langchain.text_splitter import CharacterTextSplitter
6
+ from langchain.embeddings.openai import OpenAIEmbeddings
7
+ from langchain.vectorstores import FAISS
8
+ from langchain.chains.question_answering import load_qa_chain
9
+ from langchain.llms import OpenAI
10
+ import time
11
+ import logging
12
+ import os
13
 
14
  def process_pdf(pdf):
15
+ start_time = time.time()
16
+ pdf_reader = PdfReader(pdf)
17
+ text = ""
18
+ for page in pdf_reader.pages:
19
+ text += page.extract_text() or ""
20
+ end_time = time.time()
21
+ logging.info(f"Processed PDF in {end_time - start_time} seconds")
22
+ return text
23
 
24
  def display_chat_history():
25
  history_text = ""
 
63
  # Logging and exception handling remain the same
64
 
65
  if __name__ == "__main__":
66
+ main()