Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -79,28 +79,30 @@ def user_input(user_question, api_key):
|
|
79 |
text_to_speech(text)
|
80 |
|
81 |
def main():
|
82 |
-
|
83 |
st.set_page_config(layout="centered")
|
84 |
st.header("Chat with DOCS")
|
85 |
st.markdown("<h1 style='font-size:20px;'>ChatBot by Muhammad Huzaifa</h1>", unsafe_allow_html=True)
|
86 |
api_key = st.secrets["inference_api_key"]
|
87 |
|
88 |
-
|
89 |
with st.sidebar:
|
90 |
st.header("Chat with PDF")
|
91 |
-
|
92 |
pdf_docs = st.file_uploader("Upload your PDF Files and Click on the Submit Button", accept_multiple_files=True, type=["pdf"])
|
93 |
-
|
|
|
94 |
with st.spinner("Processing..."):
|
95 |
raw_text = get_pdf_text(pdf_docs)
|
96 |
text_chunks = get_text_chunks(raw_text)
|
97 |
get_vector_store(text_chunks, api_key)
|
98 |
-
st.success("
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
|
|
|
|
|
|
104 |
# # Check if any document is uploaded
|
105 |
# if pdf_docs:
|
106 |
# user_question = st.text_input("Ask a question from the Docs")
|
|
|
79 |
text_to_speech(text)
|
80 |
|
81 |
def main():
|
|
|
82 |
st.set_page_config(layout="centered")
|
83 |
st.header("Chat with DOCS")
|
84 |
st.markdown("<h1 style='font-size:20px;'>ChatBot by Muhammad Huzaifa</h1>", unsafe_allow_html=True)
|
85 |
api_key = st.secrets["inference_api_key"]
|
86 |
|
|
|
87 |
with st.sidebar:
|
88 |
st.header("Chat with PDF")
|
89 |
+
|
90 |
pdf_docs = st.file_uploader("Upload your PDF Files and Click on the Submit Button", accept_multiple_files=True, type=["pdf"])
|
91 |
+
|
92 |
+
if st.button("Submit") and pdf_docs:
|
93 |
with st.spinner("Processing..."):
|
94 |
raw_text = get_pdf_text(pdf_docs)
|
95 |
text_chunks = get_text_chunks(raw_text)
|
96 |
get_vector_store(text_chunks, api_key)
|
97 |
+
st.success("Processing Complete")
|
98 |
+
|
99 |
+
if pdf_docs:
|
100 |
+
user_question = st.text_input("Ask a question from the Docs")
|
101 |
+
if user_question:
|
102 |
+
user_input(user_question, api_key)
|
103 |
+
else:
|
104 |
+
st.write("Please upload PDF documents to proceed.")
|
105 |
+
|
106 |
# # Check if any document is uploaded
|
107 |
# if pdf_docs:
|
108 |
# user_question = st.text_input("Ask a question from the Docs")
|