aika42 commited on
Commit
b8b022a
·
verified ·
1 Parent(s): 80fb06b

Update rag_engine.py

Browse files
Files changed (1) hide show
  1. rag_engine.py +7 -5
rag_engine.py CHANGED
@@ -126,8 +126,10 @@ class RAGEngine:
126
  return answer
127
 
128
  def stream_answer(self, query):
129
- """Streamed generation for Streamlit."""
130
- answer = self.answer_query(query)
131
- for word in answer.split():
132
- yield word + " "
133
- time.sleep(0.02) # Feel free to tweak typing speed
 
 
 
126
  return answer
127
 
128
  def stream_answer(self, query):
129
+ # Simulate streaming response, yielding chunks of text
130
+ # (This is just an example of how you'd stream chunks of data)
131
+ result = self.get_answer(query) # Retrieve the full answer
132
+ # Here you can yield chunks of the answer instead of returning it all at once.
133
+ chunk_size = 1000 # Define the chunk size
134
+ for i in range(0, len(result), chunk_size):
135
+ yield result[i:i + chunk_size] # Yield parts of the response