# import streamlit as st # # Load CSS # def load_css(file_name): # with open(file_name) as f: # st.markdown(f"", unsafe_allow_html=True) # load_css("style.css") # # Your Streamlit chat input component # with st.form("my_form"): # text_input = st.text_input("Enter your message:") # submit_button = st.form_submit_button("Send") # import streamlit as st # # Load CSS # def load_css(file_name): # with open(file_name) as f: # st.markdown(f"", unsafe_allow_html=True) # load_css("style.css") # # Create a container for the chat # chat_container = st.container() # with chat_container: # with st.form("my_form"): # text_input = st.text_input("Enter your message:") # submit_button = st.form_submit_button("Send") import streamlit as st from streamlit_chat import message # Initialize session state if "history" not in st.session_state: st.session_state.history = [] # Styling (adjust as needed) st.markdown(""" """, unsafe_allow_html=True) def generate_response(input_message): # Placeholder for now; you'll likely plug in an AI model here return f"Echo: {input_message}" def display_chat(): for i, chat in enumerate(st.session_state.history): if chat['is_user']: message(chat['message'], key=str(i) + "_user", is_user=True, avatar_style="sender") else: message(chat['message'], key=str(i) + "_bot", avatar_style="receiver") # App Layout st.title("Social Messenger Demo") col1, col2 = st.columns(2) with col1: user_input = st.text_input("Enter your message", key="input") if st.button("Send", key="send"): st.session_state.history.append({"message": user_input, "is_user": True}) with col2: if user_input: response = generate_response(user_input) st.session_state.history.append({"message": response, "is_user": False}) # Display the chat history display_chat()