Spaces:
Sleeping
Sleeping
add spinner
Browse files
app.py
CHANGED
@@ -173,25 +173,26 @@ if prompt := st.chat_input("Tell me about YSA"):
|
|
173 |
|
174 |
question = prompt
|
175 |
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
|
|
195 |
|
196 |
# Display assistant response in chat message container
|
197 |
with st.chat_message("assistant"):
|
|
|
173 |
|
174 |
question = prompt
|
175 |
|
176 |
+
with st.spinner("Wait for it..."):
|
177 |
+
docs = db.similarity_search(question)
|
178 |
+
docs_2 = db.similarity_search_with_score(question)
|
179 |
+
docs_2_table = pd.DataFrame(
|
180 |
+
{
|
181 |
+
"source": [docs_2[i][0].metadata["source"] for i in range(len(docs))],
|
182 |
+
"content": [docs_2[i][0].page_content for i in range(len(docs))],
|
183 |
+
"distances": [docs_2[i][1] for i in range(len(docs))],
|
184 |
+
}
|
185 |
+
)
|
186 |
+
ref_from_db_search = docs_2_table["content"]
|
187 |
+
|
188 |
+
engineered_prompt = f"""
|
189 |
+
Based on the context: {ref_from_db_search},
|
190 |
+
answer the user question: {question}.
|
191 |
+
Answer the question directly (don't say "based on the context, ...")
|
192 |
+
"""
|
193 |
+
|
194 |
+
answer = call_chatgpt(engineered_prompt)
|
195 |
+
response = answer
|
196 |
|
197 |
# Display assistant response in chat message container
|
198 |
with st.chat_message("assistant"):
|