Spaces:
Runtime error
Runtime error
sanjeevbora
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -86,22 +86,22 @@ def test_rag(qa, query):
|
|
86 |
|
87 |
user_prompt = st.chat_input("Ask me anything about the content of the PDF(s):")
|
88 |
print("user input:", user_prompt)
|
89 |
-
if st.button("Submit"):
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
|
106 |
for message in st.session_state.messages:
|
107 |
with st.chat_message(message['role']):
|
|
|
86 |
|
87 |
user_prompt = st.chat_input("Ask me anything about the content of the PDF(s):")
|
88 |
print("user input:", user_prompt)
|
89 |
+
# if st.button("Submit"):
|
90 |
+
# print("user input after submit button: ", user_prompt)
|
91 |
+
if user_prompt:
|
92 |
+
print("user input after if user prompt condition: ", user_prompt)
|
93 |
+
st.session_state.messages.append({'role': 'user', "content": user_prompt})
|
94 |
+
books_retriever = test_rag(books_db_client_retriever, user_prompt)
|
95 |
+
print("books retriver:",books_retriever)
|
96 |
+
# Extracting the relevant answer using regex
|
97 |
+
corrected_text_match = re.search(r"Helpful Answer:(.*)", books_retriever, re.DOTALL)
|
98 |
+
print("corrected text match:", corrected_text_match)
|
99 |
+
if corrected_text_match:
|
100 |
+
corrected_text_books = corrected_text_match.group(1).strip()
|
101 |
+
else:
|
102 |
+
corrected_text_books = "No helpful answer found."
|
103 |
+
print("corrected text books: ",corrected_text_books)
|
104 |
+
st.session_state.messages.append({'role': 'assistant', "content": corrected_text_books})
|
105 |
|
106 |
for message in st.session_state.messages:
|
107 |
with st.chat_message(message['role']):
|