File size: 1,690 Bytes
939493f efc71dd c0781c7 efc71dd aa5d738 efc71dd 540a813 c0781c7 63a4f93 c0781c7 a398626 c0781c7 57d350a a398626 ac250d4 4012705 a398626 4012705 a398626 4012705 a398626 ac250d4 786c870 ac250d4 c0781c7 57d350a 9b73f28 efc71dd 9b73f28 efc71dd 939493f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
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()
|