valeriylo commited on
Commit
e9813d0
1 Parent(s): e6567e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -29
app.py CHANGED
@@ -75,41 +75,39 @@ def handle_userinput(user_question):
75
  "{{MSG}}", message.content), unsafe_allow_html=True)
76
 
77
 
78
- def main():
79
- load_dotenv()
80
- st.set_page_config(page_title="Chat with multiple PDFs",
81
- page_icon=":books:")
82
- st.write(css, unsafe_allow_html=True)
83
 
84
- if "conversation" not in st.session_state:
85
- st.session_state.conversation = None
86
- if "chat_history" not in st.session_state:
87
- st.session_state.chat_history = None
88
 
89
- st.header("Chat with multiple PDFs :books:")
90
- user_question = st.text_input("Ask a question about your documents:")
91
- if user_question:
92
- handle_userinput(user_question)
93
 
94
- with st.sidebar:
95
- st.subheader("Your documents")
96
- pdf_docs = st.file_uploader(
97
- "Upload your PDFs here and click on 'Process'", accept_multiple_files=True)
98
- if st.button("Process"):
99
- with st.spinner("Processing"):
100
- # get pdf text
101
- raw_text = get_pdf_text(pdf_docs)
102
 
103
- # get the text chunks
104
- text_chunks = get_text_chunks(raw_text)
105
 
106
- # create vector store
107
- vectorstore = get_vectorstore(text_chunks)
108
 
109
- # create conversation chain
110
- st.session_state.conversation = get_conversation_chain(
111
- vectorstore)
112
 
113
 
114
 
115
- main()
 
75
  "{{MSG}}", message.content), unsafe_allow_html=True)
76
 
77
 
78
+ load_dotenv()
79
+ st.set_page_config(page_title="Chat with multiple PDFs",
80
+ page_icon=":books:")
81
+ st.write(css, unsafe_allow_html=True)
 
82
 
83
+ if "conversation" not in st.session_state:
84
+ st.session_state.conversation = None
85
+ if "chat_history" not in st.session_state:
86
+ st.session_state.chat_history = None
87
 
88
+ st.header("Chat with multiple PDFs :books:")
89
+ user_question = st.text_input("Ask a question about your documents:")
90
+ if user_question:
91
+ handle_userinput(user_question)
92
 
93
+ with st.sidebar:
94
+ st.subheader("Your documents")
95
+ pdf_docs = st.file_uploader(
96
+ "Upload your PDFs here and click on 'Process'", accept_multiple_files=True)
97
+ if st.button("Process"):
98
+ with st.spinner("Processing"):
99
+ # get pdf text
100
+ raw_text = get_pdf_text(pdf_docs)
101
 
102
+ # get the text chunks
103
+ text_chunks = get_text_chunks(raw_text)
104
 
105
+ # create vector store
106
+ vectorstore = get_vectorstore(text_chunks)
107
 
108
+ # create conversation chain
109
+ st.session_state.conversation = get_conversation_chain(
110
+ vectorstore)
111
 
112
 
113