Update app.py
Browse files
app.py
CHANGED
|
@@ -173,10 +173,28 @@ rag = RAG(file_path, device)
|
|
| 173 |
|
| 174 |
st.title("RAG Model Query Interface")
|
| 175 |
|
| 176 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
|
| 178 |
-
question = st.text_input("Ask a question", "
|
| 179 |
|
| 180 |
if st.button("Ask"):
|
| 181 |
-
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|