Nice / pages /992_streamlit_chat.py
betterme
update
b966bc9
raw
history blame
859 Bytes
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Project : Python.
# @File : 991_streamlit_apex_charts
# @Time : 2022/10/17 上午10:48
# @Author : yuanjie
# @WeChat : meutils
# @Software : PyCharm
# @Description :
import streamlit as st
from streamlit_chat import message
message_history = ["你好!我是你的电影小助手,很高兴为您服务。"]
for message_ in message_history:
message(message_, avatar_style='adventurer') # display all the previous message
placeholder = st.empty() # placeholder for latest message
input_ = st.text_input("请向我提问:")
message_history.append(input_)
with placeholder.container():
# message(message_history[-1], avatar_style='adventurer') # display the latest message
message(message_history[-1], is_user=True) # align's the message to the right