sanjeevbora commited on
Commit
ff2f6f2
·
verified ·
1 Parent(s): ce101e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -14
app.py CHANGED
@@ -86,20 +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 user_prompt:
90
- print("user input after if condition: ", user_prompt)
91
- st.session_state.messages.append({'role': 'user', "content": user_prompt})
92
- books_retriever = test_rag(books_db_client_retriever, user_prompt)
93
- print("books retriver:",books_retriever)
94
- # Extracting the relevant answer using regex
95
- corrected_text_match = re.search(r"Helpful Answer:(.*)", books_retriever, re.DOTALL)
96
- print("corrected text match:", corrected_text_match)
97
- if corrected_text_match:
98
- corrected_text_books = corrected_text_match.group(1).strip()
99
- else:
100
- corrected_text_books = "No helpful answer found."
101
- print("corrected text books: ",corrected_text_books)
102
- st.session_state.messages.append({'role': 'assistant', "content": corrected_text_books})
 
 
103
 
104
  for message in st.session_state.messages:
105
  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']):