Update src/streamlit_app.py
Browse files- src/streamlit_app.py +4 -8
src/streamlit_app.py
CHANGED
|
@@ -15,7 +15,6 @@ st.set_page_config(page_title="Mindful Decision-Making Coach", page_icon=":balan
|
|
| 15 |
st.title("Mindful Decision-Making Coach")
|
| 16 |
st.markdown("_A chatbot for mindful legal decisions, inspired by Ellen Langer_")
|
| 17 |
|
| 18 |
-
|
| 19 |
# Initialize session state
|
| 20 |
if "messages" not in st.session_state:
|
| 21 |
st.session_state.messages = []
|
|
@@ -33,9 +32,8 @@ for msg in st.session_state.messages:
|
|
| 33 |
user_input = None
|
| 34 |
if st.session_state.awaiting_first:
|
| 35 |
user_input = st.chat_input("Describe your legal decision or dilemma...")
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
user_input = st.chat_input("Your response...")
|
| 39 |
|
| 40 |
if user_input:
|
| 41 |
if st.session_state.awaiting_first:
|
|
@@ -47,10 +45,8 @@ if user_input:
|
|
| 47 |
st.session_state.messages.append({"role": "user", "content": user_input})
|
| 48 |
st.session_state.messages.append({"role": "assistant", "content": PROMPTS[st.session_state.prompt_idx]})
|
| 49 |
st.session_state.prompt_idx += 1
|
| 50 |
-
|
| 51 |
-
# Force Streamlit to rerun by updating query params
|
| 52 |
-
st.query_params["dummy"] = str(st.session_state.prompt_idx) # Fixed here
|
| 53 |
|
| 54 |
# Final message after all prompts
|
| 55 |
if not st.session_state.awaiting_first and st.session_state.prompt_idx >= len(PROMPTS):
|
| 56 |
-
st.markdown("**Thank you for sharing your decision. I have logged your responses and will remind you to reflect on the outcome in a few weeks.**")
|
|
|
|
| 15 |
st.title("Mindful Decision-Making Coach")
|
| 16 |
st.markdown("_A chatbot for mindful legal decisions, inspired by Ellen Langer_")
|
| 17 |
|
|
|
|
| 18 |
# Initialize session state
|
| 19 |
if "messages" not in st.session_state:
|
| 20 |
st.session_state.messages = []
|
|
|
|
| 32 |
user_input = None
|
| 33 |
if st.session_state.awaiting_first:
|
| 34 |
user_input = st.chat_input("Describe your legal decision or dilemma...")
|
| 35 |
+
elif st.session_state.prompt_idx < len(PROMPTS):
|
| 36 |
+
user_input = st.chat_input("Your response...")
|
|
|
|
| 37 |
|
| 38 |
if user_input:
|
| 39 |
if st.session_state.awaiting_first:
|
|
|
|
| 45 |
st.session_state.messages.append({"role": "user", "content": user_input})
|
| 46 |
st.session_state.messages.append({"role": "assistant", "content": PROMPTS[st.session_state.prompt_idx]})
|
| 47 |
st.session_state.prompt_idx += 1
|
| 48 |
+
# No need for any rerun or query param tricks!
|
|
|
|
|
|
|
| 49 |
|
| 50 |
# Final message after all prompts
|
| 51 |
if not st.session_state.awaiting_first and st.session_state.prompt_idx >= len(PROMPTS):
|
| 52 |
+
st.markdown("**Thank you for sharing your decision. I have logged your responses and will remind you to reflect on the outcome in a few weeks.**")
|