()
| 65 | |
| 66 | |
| 67 | def main(): |
| 68 | load_dotenv() |
| 69 | st.set_page_config(page_title="Chat with multiple PDFs", |
| 70 | page_icon=":books:") |
| 71 | st.write(css, unsafe_allow_html=True) |
| 72 | |
| 73 | if "conversation" not in st.session_state: |
| 74 | st.session_state.conversation = None |
| 75 | if "chat_history" not in st.session_state: |
| 76 | st.session_state.chat_history = None |
| 77 | |
| 78 | st.header("Chat with multiple PDFs :books:") |
| 79 | user_question = st.text_input("Ask a question about your documents:") |
| 80 | if user_question: |
| 81 | handle_userinput(user_question) |
| 82 | |
| 83 | with st.sidebar: |
| 84 | st.subheader("Your documents") |
| 85 | pdf_docs = st.file_uploader( |
| 86 | "Upload your PDFs here and click on 'Process'", accept_multiple_files=True) |
| 87 | if st.button("Process"): |
| 88 | with st.spinner("Processing"): |
| 89 | # get pdf text |
| 90 | raw_text = get_pdf_text(pdf_docs) |
| 91 | |
| 92 | # get the text chunks |
| 93 | text_chunks = get_text_chunks(raw_text) |
| 94 | |
| 95 | # create vector store |
| 96 | vectorstore = get_vectorstore(text_chunks) |
| 97 | |
| 98 | # create conversation chain |
| 99 | st.session_state.conversation = get_conversation_chain( |
| 100 | vectorstore) |
| 101 | |
| 102 | |
| 103 | if __name__ == '__main__': |
no test coverage detected