Update app.py
Browse files
app.py
CHANGED
@@ -24,6 +24,7 @@ from PIL import Image
|
|
24 |
from langchain.vectorstores import FAISS
|
25 |
import transformers
|
26 |
from pydub import AudioSegment
|
|
|
27 |
|
28 |
user_session_id = uuid.uuid4()
|
29 |
|
@@ -183,11 +184,20 @@ if prompt := st.chat_input("How can I help you today?"):
|
|
183 |
|
184 |
st.session_state['reference'] = '/home/user/app/pdf2image/default_output.png'
|
185 |
st.session_state['audio'] = ''
|
|
|
|
|
|
|
|
|
|
|
186 |
|
|
|
|
|
|
|
|
|
|
|
187 |
for item in output:
|
188 |
full_response += item
|
189 |
-
message_placeholder.markdown(
|
190 |
-
message_placeholder.markdown(full_response)
|
191 |
|
192 |
|
193 |
sound_file = BytesIO()
|
|
|
24 |
from langchain.vectorstores import FAISS
|
25 |
import transformers
|
26 |
from pydub import AudioSegment
|
27 |
+
from streamlit_extras.streaming_write import write
|
28 |
|
29 |
user_session_id = uuid.uuid4()
|
30 |
|
|
|
184 |
|
185 |
st.session_state['reference'] = '/home/user/app/pdf2image/default_output.png'
|
186 |
st.session_state['audio'] = ''
|
187 |
+
|
188 |
+
def stream_example():
|
189 |
+
for word in result['result'].split():
|
190 |
+
yield word + " "
|
191 |
+
time.sleep(0.1)
|
192 |
|
193 |
+
# for item in output:
|
194 |
+
# full_response += item
|
195 |
+
# message_placeholder.markdown(full_response + "▌")
|
196 |
+
# message_placeholder.markdown(full_response)
|
197 |
+
|
198 |
for item in output:
|
199 |
full_response += item
|
200 |
+
message_placeholder.markdown(write(stream_example))
|
|
|
201 |
|
202 |
|
203 |
sound_file = BytesIO()
|