kaleidoskop-hug
commited on
Commit
•
8f8cd23
1
Parent(s):
74d52e7
Update app.py
Browse files
app.py
CHANGED
@@ -64,10 +64,14 @@ st.sidebar.button('Reset Chat', on_click=reset_conversation) #Reset button
|
|
64 |
st.sidebar.write(f"You're now chatting with **{selected_model}**")
|
65 |
st.sidebar.markdown("*Generated content may be inaccurate or false.*")
|
66 |
|
|
|
|
|
|
|
67 |
def remove_message(position):
|
68 |
st.toast("try to remove message no: " + str(position-1) + " and "+ str(position))
|
69 |
del st.session_state.messages[position-2:position]
|
70 |
|
|
|
71 |
st.subheader(f'{selected_model}')
|
72 |
|
73 |
# Initialize chat history
|
@@ -81,6 +85,7 @@ for message in st.session_state.messages:
|
|
81 |
with st.chat_message(message["role"]):
|
82 |
col1, col2 = st.columns([9,1])
|
83 |
col1.markdown(message["content"])
|
|
|
84 |
if message["role"] == "assistant":
|
85 |
col2.button("remove-"+str(pos), key="button_remove_message_"+str(pos), args=[pos], on_click=remove_message)
|
86 |
|
@@ -91,7 +96,7 @@ if prompt := st.chat_input(f"Hi I'm {selected_model}, ask me a question"):
|
|
91 |
with st.chat_message("user"):
|
92 |
col1, col2 = st.columns([9,1])
|
93 |
col1.markdown(prompt)
|
94 |
-
|
95 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
96 |
|
97 |
# Display assistant response in chat message container
|
@@ -101,6 +106,7 @@ if prompt := st.chat_input(f"Hi I'm {selected_model}, ask me a question"):
|
|
101 |
with st.chat_message("assistant"):
|
102 |
col1, col2 = st.columns([9,1])
|
103 |
response = col1.write_stream(assistant["stream"])
|
|
|
104 |
col2.button("remove-"+str(pos), key="button_remove_message_"+str(pos), args=[pos], on_click=remove_message)
|
105 |
else:
|
106 |
with st.chat_message("assistant"):
|
|
|
64 |
st.sidebar.write(f"You're now chatting with **{selected_model}**")
|
65 |
st.sidebar.markdown("*Generated content may be inaccurate or false.*")
|
66 |
|
67 |
+
def edit_message(position):
|
68 |
+
st.toast("try to edit message no: " + str(position))
|
69 |
+
|
70 |
def remove_message(position):
|
71 |
st.toast("try to remove message no: " + str(position-1) + " and "+ str(position))
|
72 |
del st.session_state.messages[position-2:position]
|
73 |
|
74 |
+
|
75 |
st.subheader(f'{selected_model}')
|
76 |
|
77 |
# Initialize chat history
|
|
|
85 |
with st.chat_message(message["role"]):
|
86 |
col1, col2 = st.columns([9,1])
|
87 |
col1.markdown(message["content"])
|
88 |
+
col2.button("edit-"+str(pos), key="button_edit_message_"+str(pos), args=[pos], on_click=edit_message)
|
89 |
if message["role"] == "assistant":
|
90 |
col2.button("remove-"+str(pos), key="button_remove_message_"+str(pos), args=[pos], on_click=remove_message)
|
91 |
|
|
|
96 |
with st.chat_message("user"):
|
97 |
col1, col2 = st.columns([9,1])
|
98 |
col1.markdown(prompt)
|
99 |
+
col2.button("edit-"+str(pos), key="button_edit_message_"+str(pos), args=[pos], on_click=edit_message)
|
100 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
101 |
|
102 |
# Display assistant response in chat message container
|
|
|
106 |
with st.chat_message("assistant"):
|
107 |
col1, col2 = st.columns([9,1])
|
108 |
response = col1.write_stream(assistant["stream"])
|
109 |
+
col2.button("edit-"+str(pos), key="button_edit_message_"+str(pos), args=[pos], on_click=edit_message)
|
110 |
col2.button("remove-"+str(pos), key="button_remove_message_"+str(pos), args=[pos], on_click=remove_message)
|
111 |
else:
|
112 |
with st.chat_message("assistant"):
|