|
import streamlit as st |
|
st.set_page_config( |
|
layout="wide", |
|
initial_sidebar_state="expanded") |
|
|
|
|
|
if "messages" not in st.session_state: |
|
st.session_state.messages = [] |
|
|
|
def main(): |
|
cs_sidebar() |
|
cs_body() |
|
|
|
|
|
def cs_sidebar(): |
|
st.sidebar.header('Sessions') |
|
return None |
|
|
|
|
|
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') |
|
|
|
|
|
if prompt := st.chat_input("How Can I Help?"): |
|
with chat.chat_message("user"): |
|
st.markdown(prompt) |
|
|
|
with st.chat_message("assistant"): |
|
message_placeholder = st.empty() |
|
message_placeholder.write("I am working..") |
|
|
|
for message in reversed(st.session_state.messages): |
|
with st.chat_message(message["role"]): |
|
|
|
if message["type"] == "text": |
|
st.markdown(message["content"]) |
|
|
|
if message["type"] == "dataframe": |
|
st.dataframe(message["content"]) |
|
|
|
|
|
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() |
|
|
|
|
|
|