make chat messages easier to style in streamlit
streamlit-chitchat lets you style messages from the user and responses from a bot differently. you can also update an existing message, so that streamed tokens render as they are received.
Open a terminal and run:
$ pip install streamlit-chitchat
in your streamlit app, insert:
from streamlit-chitchat.chitchat import message
message('hello, how are you?', is_user=True)
bot=message()
for w in 'excellent! have any plans for tonight?'.split(' '):
bot.write(w+' ')
message('hello, how are you?', is_user=True, avatar='images/test.png')
you can also use image urls, svg code or svg files
message('hello, how are you?', is_user=True, background='rgb(150,160,150)')
In order to make the color lighter, you can use rgb with alpha value: background='rgb(130,120,100, 0.5)'
message('hello, how are you?', is_user=True, font_size='1rem')
font color, width , or margin
message('hello', color='rgb(20,20,30)', width='70%', margin='5px')