import streamlit as st st.set_page_config( layout="wide", initial_sidebar_state="expanded") # Create a session state to store the messages if "messages" not in st.session_state: st.session_state.messages = [] def main(): cs_sidebar() cs_body() # Sidebar def cs_sidebar(): st.sidebar.header('Sessions') return None # Body def cs_body(): """ Function to display the ChatOps interface and handle user input. Returns: None """ chat, env = st.columns([3,1]) with chat: st.title('ChatOps') # Chat input if prompt := st.chat_input("How Can I Help?"): with chat.chat_message("user"): st.markdown(prompt) # Assistant Response with st.chat_message("assistant"): message_placeholder = st.empty() message_placeholder.write("I am working..") # Chat History for message in reversed(st.session_state.messages): with st.chat_message(message["role"]): # Text Response if message["type"] == "text": st.markdown(message["content"]) # Data Response if message["type"] == "dataframe": st.dataframe(message["content"]) # Add input and response to chat history st.session_state.messages.append({"role": "assistant", "content": "I am working..", "type": "text"}) st.session_state.messages.append({"role": "user", "content": prompt, "type": "text"}) env.subheader('Enviornment:') return None if __name__ == '__main__': main()