Spaces:
Build error
Build error
Chandranshu Jain
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -86,8 +86,7 @@ def embedding(chunk,query):
|
|
| 86 |
chain = get_conversational_chain()
|
| 87 |
response = chain({"input_documents": doc, "question": query}, return_only_outputs=True)
|
| 88 |
print(response)
|
| 89 |
-
|
| 90 |
-
#st.write("Reply: ", response["output_text"])
|
| 91 |
|
| 92 |
|
| 93 |
|
|
@@ -97,8 +96,6 @@ def main():
|
|
| 97 |
st.title("Menu:")
|
| 98 |
pdf_docs = st.file_uploader("Upload your PDF File and Click on the Submit & Process Button", accept_multiple_files=False, key="pdf_uploader")
|
| 99 |
query = st.text_input("Ask a Question from the PDF File", key="query")
|
| 100 |
-
if 'messages' not in st.session_state:
|
| 101 |
-
st.session_state.messages = [{'role': 'assistant', "content": 'Hello! Upload a PDF and ask me anything about its content.'}]
|
| 102 |
if st.button("Submit & Process", key="process_button"):
|
| 103 |
with st.spinner("Processing..."):
|
| 104 |
raw_text = get_pdf(pdf_docs)
|
|
@@ -106,14 +103,7 @@ def main():
|
|
| 106 |
if query:
|
| 107 |
embedding(text_chunks,query)
|
| 108 |
st.success("Done")
|
| 109 |
-
|
| 110 |
-
st.session_state.messages.append({'role': 'user', "content": query})
|
| 111 |
-
response = embedding(text_chunks,query)
|
| 112 |
-
st.session_state.messages.append({'role': 'assistant', "content": response})
|
| 113 |
-
|
| 114 |
-
for message in st.session_state.messages:
|
| 115 |
-
with st.chat_message(message['role']):
|
| 116 |
-
st.write(message['content'])
|
| 117 |
|
| 118 |
if __name__ == "__main__":
|
| 119 |
main()
|
|
|
|
| 86 |
chain = get_conversational_chain()
|
| 87 |
response = chain({"input_documents": doc, "question": query}, return_only_outputs=True)
|
| 88 |
print(response)
|
| 89 |
+
st.write("Reply: ", response["output_text"])
|
|
|
|
| 90 |
|
| 91 |
|
| 92 |
|
|
|
|
| 96 |
st.title("Menu:")
|
| 97 |
pdf_docs = st.file_uploader("Upload your PDF File and Click on the Submit & Process Button", accept_multiple_files=False, key="pdf_uploader")
|
| 98 |
query = st.text_input("Ask a Question from the PDF File", key="query")
|
|
|
|
|
|
|
| 99 |
if st.button("Submit & Process", key="process_button"):
|
| 100 |
with st.spinner("Processing..."):
|
| 101 |
raw_text = get_pdf(pdf_docs)
|
|
|
|
| 103 |
if query:
|
| 104 |
embedding(text_chunks,query)
|
| 105 |
st.success("Done")
|
| 106 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
if __name__ == "__main__":
|
| 109 |
main()
|