Update app.py
Browse files
app.py
CHANGED
|
@@ -28,36 +28,25 @@ def cs_body():
|
|
| 28 |
with chat:
|
| 29 |
st.title('ChatOps')
|
| 30 |
|
| 31 |
-
# Display the messages in the session state
|
| 32 |
-
#for message in st.session_state.messages:
|
| 33 |
-
# with st.chat_message(message["role"]):
|
| 34 |
-
# # if type is text
|
| 35 |
-
# if message["type"] == "text":
|
| 36 |
-
# st.markdown(message["content"])
|
| 37 |
-
# # if type is dataframe
|
| 38 |
-
# if message["type"] == "dataframe":
|
| 39 |
-
# st.dataframe(message["content"])
|
| 40 |
-
|
| 41 |
# Chat input
|
| 42 |
if prompt := st.chat_input("How Can I Help?"):
|
| 43 |
-
# st.session_state.messages.append({"role": "user", "content": prompt, "type": "text"})
|
| 44 |
with chat.chat_message("user"):
|
| 45 |
st.markdown(prompt)
|
| 46 |
-
# Assistant
|
| 47 |
with st.chat_message("assistant"):
|
| 48 |
message_placeholder = st.empty()
|
| 49 |
message_placeholder.write("I am working..")
|
| 50 |
-
|
| 51 |
-
|
| 52 |
for message in reversed(st.session_state.messages):
|
| 53 |
with st.chat_message(message["role"]):
|
| 54 |
-
#
|
| 55 |
if message["type"] == "text":
|
| 56 |
st.markdown(message["content"])
|
| 57 |
-
#
|
| 58 |
if message["type"] == "dataframe":
|
| 59 |
st.dataframe(message["content"])
|
| 60 |
-
|
|
|
|
| 61 |
st.session_state.messages.append({"role": "assistant", "content": "I am working..", "type": "text"})
|
| 62 |
st.session_state.messages.append({"role": "user", "content": prompt, "type": "text"})
|
| 63 |
|
|
|
|
| 28 |
with chat:
|
| 29 |
st.title('ChatOps')
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
# Chat input
|
| 32 |
if prompt := st.chat_input("How Can I Help?"):
|
|
|
|
| 33 |
with chat.chat_message("user"):
|
| 34 |
st.markdown(prompt)
|
| 35 |
+
# Assistant Response
|
| 36 |
with st.chat_message("assistant"):
|
| 37 |
message_placeholder = st.empty()
|
| 38 |
message_placeholder.write("I am working..")
|
| 39 |
+
# Chat History
|
|
|
|
| 40 |
for message in reversed(st.session_state.messages):
|
| 41 |
with st.chat_message(message["role"]):
|
| 42 |
+
# Text Response
|
| 43 |
if message["type"] == "text":
|
| 44 |
st.markdown(message["content"])
|
| 45 |
+
# Data Response
|
| 46 |
if message["type"] == "dataframe":
|
| 47 |
st.dataframe(message["content"])
|
| 48 |
+
|
| 49 |
+
# Add input and response to chat history
|
| 50 |
st.session_state.messages.append({"role": "assistant", "content": "I am working..", "type": "text"})
|
| 51 |
st.session_state.messages.append({"role": "user", "content": prompt, "type": "text"})
|
| 52 |
|