rtabrizi commited on
Commit
6a8529c
1 Parent(s): 7c29777

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -4
app.py CHANGED
@@ -173,10 +173,28 @@ rag = RAG(file_path, device)
173
 
174
  st.title("RAG Model Query Interface")
175
 
176
- # offer to ask a question and get an answer. make it so they can ask as many questions as they want
 
 
 
 
177
 
178
- question = st.text_input("Ask a question", "What is another name for self-attention?")
179
 
180
  if st.button("Ask"):
181
- answer = rag.extractive_query(question)
182
- st.write(answer)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
 
174
  st.title("RAG Model Query Interface")
175
 
176
+ # Initialize session state to keep track of the list of answers and questions
177
+ if 'questions' not in st.session_state:
178
+ st.session_state.questions = []
179
+ if 'answers' not in st.session_state:
180
+ st.session_state.answers = []
181
 
182
+ question = st.text_input("Ask a question", "")
183
 
184
  if st.button("Ask"):
185
+ # Fetch the answer for the question
186
+ answer = rag.extractive_query(question)
187
+
188
+ # Store the question and its answer in session state
189
+ st.session_state.questions.append(question)
190
+ st.session_state.answers.append(answer)
191
+
192
+ # Display the questions and their answers
193
+ for q, a in zip(st.session_state.questions, st.session_state.answers):
194
+ st.write(f"Q: {q}\nA: {a}")
195
+
196
+ # Button to ask another question which simply refreshes the page to get a new question input
197
+ if st.button("Ask another question"):
198
+ st.session_state.questions = []
199
+ st.session_state.answers = []
200
+ st.experimental_rerun()