Spaces:
Sleeping
Sleeping
Léo Bourrel
commited on
Commit
·
f060825
1
Parent(s):
0802dfc
fix: avoid duplicated messages
Browse files
app.py
CHANGED
@@ -62,7 +62,9 @@ def initialize_session_state():
|
|
62 |
def on_click_callback():
|
63 |
with st.spinner('Wait for it...'):
|
64 |
with get_openai_callback() as cb:
|
65 |
-
human_prompt = st.session_state.human_prompt
|
|
|
|
|
66 |
llm_response = st.session_state.conversation(human_prompt)
|
67 |
st.session_state.history.append(Message("human", human_prompt))
|
68 |
st.session_state.history.append(
|
@@ -80,8 +82,8 @@ initialize_session_state()
|
|
80 |
|
81 |
with chat_column:
|
82 |
chat_placeholder = st.container()
|
83 |
-
prompt_placeholder = st.form("chat-form")
|
84 |
-
information_placeholder = st.
|
85 |
|
86 |
with chat_placeholder:
|
87 |
for chat in st.session_state.history:
|
@@ -108,7 +110,6 @@ with chat_column:
|
|
108 |
cols = st.columns((6, 1))
|
109 |
cols[0].text_input(
|
110 |
"Chat",
|
111 |
-
value="Hello Sorbobot !",
|
112 |
label_visibility="collapsed",
|
113 |
key="human_prompt",
|
114 |
)
|
|
|
62 |
def on_click_callback():
|
63 |
with st.spinner('Wait for it...'):
|
64 |
with get_openai_callback() as cb:
|
65 |
+
human_prompt = st.session_state.human_prompt.strip()
|
66 |
+
if len(human_prompt) == 0:
|
67 |
+
return
|
68 |
llm_response = st.session_state.conversation(human_prompt)
|
69 |
st.session_state.history.append(Message("human", human_prompt))
|
70 |
st.session_state.history.append(
|
|
|
82 |
|
83 |
with chat_column:
|
84 |
chat_placeholder = st.container()
|
85 |
+
prompt_placeholder = st.form("chat-form", clear_on_submit=True)
|
86 |
+
information_placeholder = st.container()
|
87 |
|
88 |
with chat_placeholder:
|
89 |
for chat in st.session_state.history:
|
|
|
110 |
cols = st.columns((6, 1))
|
111 |
cols[0].text_input(
|
112 |
"Chat",
|
|
|
113 |
label_visibility="collapsed",
|
114 |
key="human_prompt",
|
115 |
)
|