TheBobBob commited on
Commit
53df176
·
verified ·
1 Parent(s): 9952114

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -181,7 +181,6 @@ def create_vector_db(final_items):
181
 
182
  return db
183
 
184
-
185
  def generate_response(db, query_text, previous_context):
186
  query_results = db.query(
187
  query_texts=query_text,
@@ -230,12 +229,18 @@ def generate_response(db, query_text, previous_context):
230
 
231
  # Use Streamlit to stream the response in real-time
232
  temp_response = ""
 
 
 
233
  for token in output_stream:
234
  token_text = token["choices"][0]["text"]
 
235
  temp_response += token_text
236
- st.write(temp_response) # Update the Streamlit UI with the current response
237
-
238
- return temp_response
 
 
239
 
240
  def streamlit_app():
241
  st.title("BioModelsRAG")
@@ -295,3 +300,4 @@ def streamlit_app():
295
 
296
  if __name__ == "__main__":
297
  streamlit_app()
 
 
181
 
182
  return db
183
 
 
184
  def generate_response(db, query_text, previous_context):
185
  query_results = db.query(
186
  query_texts=query_text,
 
229
 
230
  # Use Streamlit to stream the response in real-time
231
  temp_response = ""
232
+ full_response = ""
233
+
234
+ response_placeholder = st.empty() # Create a placeholder for streaming output
235
  for token in output_stream:
236
  token_text = token["choices"][0]["text"]
237
+ full_response += token_text # Keep the entire response for future context
238
  temp_response += token_text
239
+
240
+ # Update the placeholder in real-time with the new token
241
+ response_placeholder.write(temp_response)
242
+
243
+ return full_response
244
 
245
  def streamlit_app():
246
  st.title("BioModelsRAG")
 
300
 
301
  if __name__ == "__main__":
302
  streamlit_app()
303
+