Update app.py
Browse files
app.py
CHANGED
@@ -161,30 +161,25 @@ question_model_name = "facebook/dpr-question_encoder-single-nq-base"
|
|
161 |
|
162 |
rag = RAG(file_path, device)
|
163 |
|
164 |
-
st.title("RAG Model Query Interface")
|
165 |
|
166 |
# Initialize session state to keep track of the list of answers and questions
|
167 |
-
if '
|
168 |
-
st.session_state.
|
169 |
-
if 'answers' not in st.session_state:
|
170 |
-
st.session_state.answers = []
|
171 |
|
172 |
-
question = st.text_input("
|
173 |
|
174 |
if st.button("Ask"):
|
175 |
# Fetch the answer for the question
|
176 |
answer = rag.extractive_query(question)
|
177 |
|
178 |
-
#
|
179 |
-
st.session_state.
|
180 |
-
st.session_state.
|
181 |
-
|
182 |
-
# Display the
|
183 |
-
for
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
st.session_state.questions = []
|
189 |
-
st.session_state.answers = []
|
190 |
-
st.experimental_rerun()
|
|
|
161 |
|
162 |
rag = RAG(file_path, device)
|
163 |
|
164 |
+
st.title("RAG Model Query Interface Chatbot")
|
165 |
|
166 |
# Initialize session state to keep track of the list of answers and questions
|
167 |
+
if 'history' not in st.session_state:
|
168 |
+
st.session_state.history = []
|
|
|
|
|
169 |
|
170 |
+
question = st.text_input("Enter your question:")
|
171 |
|
172 |
if st.button("Ask"):
|
173 |
# Fetch the answer for the question
|
174 |
answer = rag.extractive_query(question)
|
175 |
|
176 |
+
# Add the question and its answer to the history
|
177 |
+
st.session_state.history.append({"type": "question", "content": question})
|
178 |
+
st.session_state.history.append({"type": "answer", "content": answer})
|
179 |
+
|
180 |
+
# Display the chat history
|
181 |
+
for item in st.session_state.history:
|
182 |
+
if item["type"] == "question":
|
183 |
+
st.write(f"🧑 You: {item['content']}")
|
184 |
+
else:
|
185 |
+
st.write(f"🤖 Bot: {item['content']}")
|
|
|
|
|
|