eagle0504 commited on
Commit
dff518b
1 Parent(s): 2eef354

add spinner

Browse files
Files changed (1) hide show
  1. app.py +20 -19
app.py CHANGED
@@ -173,25 +173,26 @@ if prompt := st.chat_input("Tell me about YSA"):
173
 
174
  question = prompt
175
 
176
- docs = db.similarity_search(question)
177
- docs_2 = db.similarity_search_with_score(question)
178
- docs_2_table = pd.DataFrame(
179
- {
180
- "source": [docs_2[i][0].metadata["source"] for i in range(len(docs))],
181
- "content": [docs_2[i][0].page_content for i in range(len(docs))],
182
- "distances": [docs_2[i][1] for i in range(len(docs))],
183
- }
184
- )
185
- ref_from_db_search = docs_2_table["content"]
186
-
187
- engineered_prompt = f"""
188
- Based on the context: {ref_from_db_search},
189
- answer the user question: {question}.
190
- Answer the question directly (don't say "based on the context, ...")
191
- """
192
-
193
- answer = call_chatgpt(engineered_prompt)
194
- response = answer
 
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"):