@@ -160,7 +160,7 @@ def render_custom_audio_player(
160
160
b64 = base64 .b64encode (data ).decode ()
161
161
md = f"""
162
162
<audio controls { autoplay } { hidden } preload="metadata">
163
- <source src="data:audio/mp3;base64,{ b64 } #" type="audio/mp3 ">
163
+ <source src="data:audio/mp3;base64,{ b64 } #" type="audio/mpeg ">
164
164
</audio>
165
165
"""
166
166
parent_element = parent_element or st
@@ -259,7 +259,10 @@ def render_chat_history(self):
259
259
continue
260
260
with st .chat_message (role , avatar = self .avatars .get (role )):
261
261
with contextlib .suppress (KeyError ):
262
- st .caption (f"{ message ['chat_model' ]} , { message ['timestamp' ]} " )
262
+ if role == "assistant" :
263
+ st .caption (message ["chat_model" ])
264
+ else :
265
+ st .caption (message ["timestamp" ])
263
266
st .markdown (message ["content" ])
264
267
with contextlib .suppress (KeyError ):
265
268
if audio := message .get ("reply_audio_file_path" ):
@@ -285,7 +288,7 @@ def voice_output(self) -> bool:
285
288
"""Return the state of the voice output toggle."""
286
289
return st .session_state .get ("toggle_voice_output" , False )
287
290
288
- def play_chime (self , chime_type : str = "correct-answer-tone " , parent_element = None ):
291
+ def play_chime (self , chime_type : str = "success " , parent_element = None ):
289
292
"""Sound a chime to send notificatons to the user."""
290
293
chime = load_chime (chime_type )
291
294
self .render_custom_audio_player (
@@ -294,13 +297,12 @@ def play_chime(self, chime_type: str = "correct-answer-tone", parent_element=Non
294
297
295
298
def render_title (self ):
296
299
"""Render the title of the chatbot page."""
297
- with st .container (height = 70 , border = False ):
300
+ with st .container (height = 145 , border = False ):
298
301
self .title_container = st .empty ()
299
- with st . container ( height = 50 , border = False ):
302
+ self . title_container . subheader ( self . title , divider = "rainbow" )
300
303
left , _ = st .columns ([0.7 , 0.3 ])
301
304
with left :
302
305
self .status_msg_container = st .empty ()
303
- self .title_container .subheader (self .title , divider = "rainbow" )
304
306
305
307
@property
306
308
def direct_text_prompt (self ):
@@ -310,13 +312,14 @@ def direct_text_prompt(self):
310
312
)
311
313
text_from_manual_audio_recorder = ""
312
314
with st .container ():
313
- left , right = st .columns ([0.95 , 0.05 ])
315
+ left , right = st .columns ([0.9 , 0.1 ])
314
316
with left :
315
317
text_from_chat_input_widget = st .chat_input (placeholder = placeholder )
316
318
with right :
317
319
if not st .session_state .get ("toggle_continuous_voice_input" ):
318
320
audio = self .manual_switch_mic_recorder ()
319
321
text_from_manual_audio_recorder = self .chat_obj .stt (audio ).text
322
+
320
323
return text_from_chat_input_widget or text_from_manual_audio_recorder
321
324
322
325
@property
@@ -334,7 +337,7 @@ def continuous_text_prompt(self):
334
337
335
338
logger .debug ("Running on continuous audio prompt. Waiting user input..." )
336
339
with self .status_msg_container :
337
- self .play_chime ()
340
+ self .play_chime (chime_type = "warning" )
338
341
with st .spinner (f"{ self .chat_obj .assistant_name } is listening..." ):
339
342
while True :
340
343
with self .parent .text_prompt_queue .mutex :
@@ -361,7 +364,7 @@ def _render_chatbot_page(self): # noqa: PLR0915
361
364
self .chat_obj .reply_only_as_text = not self .voice_output
362
365
363
366
self .render_title ()
364
- chat_msgs_container = st .container (height = 600 , border = False )
367
+ chat_msgs_container = st .container (height = 550 , border = False )
365
368
with chat_msgs_container :
366
369
self .render_chat_history ()
367
370
@@ -377,7 +380,7 @@ def _render_chatbot_page(self): # noqa: PLR0915
377
380
self .parent .reply_ongoing .set ()
378
381
379
382
if continuous_stt_prompt :
380
- self .play_chime ("option-select " )
383
+ self .play_chime ("success " )
381
384
self .status_msg_container .success ("Got your message!" )
382
385
time .sleep (0.5 )
383
386
elif continuous_stt_prompt :
@@ -403,7 +406,6 @@ def _render_chatbot_page(self): # noqa: PLR0915
403
406
"name" : self .chat_obj .username ,
404
407
"content" : prompt ,
405
408
"timestamp" : time_now ,
406
- "chat_model" : self .chat_obj .model ,
407
409
}
408
410
)
409
411
@@ -418,6 +420,7 @@ def _render_chatbot_page(self): # noqa: PLR0915
418
420
"name" : self .chat_obj .assistant_name ,
419
421
"content" : reply ["text" ],
420
422
"reply_audio_file_path" : reply ["audio" ],
423
+ "chat_model" : self .chat_obj .model ,
421
424
}
422
425
)
423
426
0 commit comments