21 lines
891 B
Python
21 lines
891 B
Python
import streamlit as st
|
|
|
|
def render_chat():
|
|
st.subheader("Chat with AI Assistant")
|
|
|
|
if st.session_state.chat_history:
|
|
for message in st.session_state.chat_history:
|
|
st.markdown(f"**{message['role'].capitalize()}:** {message['content']}")
|
|
|
|
user_input = st.text_input("Type your message here:", key="chat_input")
|
|
|
|
if st.button("Send", key="send_button") and user_input:
|
|
st.session_state.chat_history.append({"role": "user", "content": user_input})
|
|
# Here you would typically call your AI assistant to get a response
|
|
# For demonstration, we'll just echo the user's message
|
|
ai_response = f"Echo: {user_input}"
|
|
st.session_state.chat_history.append({"role": "assistant", "content": ai_response})
|
|
st.session_state.chat_input = "" # Clear input after sending
|
|
|
|
if __name__ == "__main__":
|
|
render_chat() |