Repository navigation
Expand file tree
/
Copy pathfinal.py
More file actions
44 lines (31 loc) · 1.45 KB
/
Copy pathfinal.py
File metadata and controls
44 lines (31 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#The AskDoubt where the graphic for AskDoubt is present
import streamlit as stl
from dotenv import load_dotenv
from HTMLTemplates import css, user_template, bot_template
from ConversationChain import get_conversation_chain, handle_userinput
from chunking import get_pdf_text, get_text_chunks, get_vectorstore
def app():
load_dotenv()
# stl.set_page_config(page_title="NETPro", page_icon="books")
# stl.write(css, unsafe_allow_html=True)
if "conversation" not in stl.session_state:
stl.session_state.conversation = None
if "chat-history" not in stl.session_state:
stl.session_state.chat_history = None
stl.header("Chat with multiple books :books:")
user_question = stl.text_input("Ask a question:")
if user_question:
handle_userinput(user_question)
with stl.sidebar:
stl.subheader("Your Documents")
pdf_docs = stl.file_uploader("Upload your PDFs here and click on 'Process'", accept_multiple_files = True)
if stl.button("Process"):
with stl.spinner("Processing"):
# get pdf text
raw_text = get_pdf_text(pdf_docs)
# get the chunks
text_chunks = get_text_chunks(raw_text)
# store chunks in vector store
vectorstore = get_vectorstore(text_chunks)
#conversing on the vectorstore
stl.session_state.conversation = get_conversation_chain(vectorstore)