wop commited on
Commit
0b24926
·
verified ·
1 Parent(s): c3700a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -122,13 +122,13 @@ with col2:
122
  )
123
 
124
  with col3:
125
- prompt_selection = st.selectbox(
 
126
  "Choose a prompt:",
127
  options=list(prompts.keys()),
128
  format_func=lambda x: x,
129
- index=0,
130
- key="prompt_selectbox"
131
- )
132
 
133
  # Display chat messages from history on app rerun
134
  for message in st.session_state.messages:
@@ -179,8 +179,8 @@ if prompt := st.chat_input("Enter your prompt here..."):
179
  {"role": "assistant", "content": combined_response}
180
  )
181
 
182
- if prompt := prompts.get(prompt_selection):
183
- st.session_state.prompt_selectbox = "none"
184
 
185
  st.session_state.messages.append({"role": "user", "content": prompt})
186
  with st.chat_message("user", avatar="❓"):
 
122
  )
123
 
124
  with col3:
125
+ if "prompt_selectbox" not in st.session_state:
126
+ st.session_state["prompt_selectbox"] = st.selectbox(
127
  "Choose a prompt:",
128
  options=list(prompts.keys()),
129
  format_func=lambda x: x,
130
+ index=0
131
+ )
 
132
 
133
  # Display chat messages from history on app rerun
134
  for message in st.session_state.messages:
 
179
  {"role": "assistant", "content": combined_response}
180
  )
181
 
182
+ if prompt := prompts.get(st.session_state["prompt_selectbox"]):
183
+ st.session_state["prompt_selectbox"].option("none")
184
 
185
  st.session_state.messages.append({"role": "user", "content": prompt})
186
  with st.chat_message("user", avatar="❓"):