Hide needs selector until Stage 5 - clean opening page
Browse files
app.py
CHANGED
|
@@ -337,12 +337,14 @@ def process_message(user_input, history, stage, session_data, somatic_enabled, s
|
|
| 337 |
if response is None:
|
| 338 |
error_msg = "**Setup Required:** Please add ANTHROPIC_API_KEY in Space Settings > Repository secrets, then restart."
|
| 339 |
history.append({"user": user_input, "assistant": error_msg})
|
| 340 |
-
|
|
|
|
| 341 |
|
| 342 |
except Exception as e:
|
| 343 |
error_msg = f"**Error:** {str(e)}"
|
| 344 |
history.append({"user": user_input, "assistant": error_msg})
|
| 345 |
-
|
|
|
|
| 346 |
|
| 347 |
# Update session data
|
| 348 |
if stage == 1:
|
|
@@ -366,13 +368,17 @@ def process_message(user_input, history, stage, session_data, somatic_enabled, s
|
|
| 366 |
next_stage = 1
|
| 367 |
session_data = {}
|
| 368 |
|
|
|
|
|
|
|
|
|
|
| 369 |
return (
|
| 370 |
format_history(history),
|
| 371 |
"",
|
| 372 |
history,
|
| 373 |
next_stage,
|
| 374 |
session_data,
|
| 375 |
-
f"Stage {next_stage}/13: {STAGE_NAMES[next_stage]}"
|
|
|
|
| 376 |
)
|
| 377 |
|
| 378 |
def reset_session():
|
|
@@ -384,6 +390,7 @@ def reset_session():
|
|
| 384 |
1,
|
| 385 |
{},
|
| 386 |
"Stage 1/13: Share Your Message",
|
|
|
|
| 387 |
[], [], [], []
|
| 388 |
)
|
| 389 |
|
|
@@ -426,16 +433,16 @@ with gr.Blocks(
|
|
| 426 |
label="Conversation"
|
| 427 |
)
|
| 428 |
|
| 429 |
-
# Needs selector (
|
| 430 |
-
with gr.Accordion("Select Your Needs
|
| 431 |
-
gr.Markdown("**Select needs that resonate:**")
|
| 432 |
with gr.Row():
|
| 433 |
-
needs1 = gr.CheckboxGroup(NEEDS_LIST["Emotional Needs"], label="Emotional")
|
| 434 |
-
needs2 = gr.CheckboxGroup(NEEDS_LIST["Relational Needs"], label="Relational")
|
| 435 |
with gr.Row():
|
| 436 |
-
needs3 = gr.CheckboxGroup(NEEDS_LIST["Value Needs"], label="
|
| 437 |
-
needs4 = gr.CheckboxGroup(NEEDS_LIST["Lifestyle Needs"], label="Lifestyle")
|
| 438 |
-
selected_needs = gr.Textbox(label="Selected Needs", interactive=False)
|
| 439 |
|
| 440 |
# Input
|
| 441 |
user_input = gr.Textbox(
|
|
@@ -482,13 +489,13 @@ with gr.Blocks(
|
|
| 482 |
submit_btn.click(
|
| 483 |
process_message,
|
| 484 |
[user_input, history_state, stage_state, session_state, somatic_check, selected_needs],
|
| 485 |
-
[conversation, user_input, history_state, stage_state, session_state, stage_display]
|
| 486 |
)
|
| 487 |
|
| 488 |
user_input.submit(
|
| 489 |
process_message,
|
| 490 |
[user_input, history_state, stage_state, session_state, somatic_check, selected_needs],
|
| 491 |
-
[conversation, user_input, history_state, stage_state, session_state, stage_display]
|
| 492 |
)
|
| 493 |
|
| 494 |
# Reset handler
|
|
@@ -496,7 +503,7 @@ with gr.Blocks(
|
|
| 496 |
reset_session,
|
| 497 |
[],
|
| 498 |
[conversation, user_input, history_state, stage_state, session_state, stage_display,
|
| 499 |
-
needs1, needs2, needs3, needs4]
|
| 500 |
)
|
| 501 |
|
| 502 |
if __name__ == "__main__":
|
|
|
|
| 337 |
if response is None:
|
| 338 |
error_msg = "**Setup Required:** Please add ANTHROPIC_API_KEY in Space Settings > Repository secrets, then restart."
|
| 339 |
history.append({"user": user_input, "assistant": error_msg})
|
| 340 |
+
show_needs = (stage == 5)
|
| 341 |
+
return format_history(history), "", history, stage, session_data, f"Stage {stage}: {STAGE_NAMES[stage]}", gr.update(visible=show_needs)
|
| 342 |
|
| 343 |
except Exception as e:
|
| 344 |
error_msg = f"**Error:** {str(e)}"
|
| 345 |
history.append({"user": user_input, "assistant": error_msg})
|
| 346 |
+
show_needs = (stage == 5)
|
| 347 |
+
return format_history(history), "", history, stage, session_data, f"Stage {stage}: {STAGE_NAMES[stage]}", gr.update(visible=show_needs)
|
| 348 |
|
| 349 |
# Update session data
|
| 350 |
if stage == 1:
|
|
|
|
| 368 |
next_stage = 1
|
| 369 |
session_data = {}
|
| 370 |
|
| 371 |
+
# Show needs selector only at stage 5
|
| 372 |
+
show_needs = (next_stage == 5)
|
| 373 |
+
|
| 374 |
return (
|
| 375 |
format_history(history),
|
| 376 |
"",
|
| 377 |
history,
|
| 378 |
next_stage,
|
| 379 |
session_data,
|
| 380 |
+
f"Stage {next_stage}/13: {STAGE_NAMES[next_stage]}",
|
| 381 |
+
gr.update(visible=show_needs)
|
| 382 |
)
|
| 383 |
|
| 384 |
def reset_session():
|
|
|
|
| 390 |
1,
|
| 391 |
{},
|
| 392 |
"Stage 1/13: Share Your Message",
|
| 393 |
+
gr.update(visible=False),
|
| 394 |
[], [], [], []
|
| 395 |
)
|
| 396 |
|
|
|
|
| 433 |
label="Conversation"
|
| 434 |
)
|
| 435 |
|
| 436 |
+
# Needs selector (hidden until Stage 5)
|
| 437 |
+
with gr.Accordion("Select Your Needs", open=True, visible=False) as needs_accordion:
|
| 438 |
+
gr.Markdown("**Select 1-3 needs that resonate most deeply:**")
|
| 439 |
with gr.Row():
|
| 440 |
+
needs1 = gr.CheckboxGroup(NEEDS_LIST["Emotional Needs"], label="Emotional Needs")
|
| 441 |
+
needs2 = gr.CheckboxGroup(NEEDS_LIST["Relational Needs"], label="Relational Needs")
|
| 442 |
with gr.Row():
|
| 443 |
+
needs3 = gr.CheckboxGroup(NEEDS_LIST["Value Needs"], label="Value Needs")
|
| 444 |
+
needs4 = gr.CheckboxGroup(NEEDS_LIST["Lifestyle Needs"], label="Lifestyle Needs")
|
| 445 |
+
selected_needs = gr.Textbox(label="Your Selected Needs", interactive=False)
|
| 446 |
|
| 447 |
# Input
|
| 448 |
user_input = gr.Textbox(
|
|
|
|
| 489 |
submit_btn.click(
|
| 490 |
process_message,
|
| 491 |
[user_input, history_state, stage_state, session_state, somatic_check, selected_needs],
|
| 492 |
+
[conversation, user_input, history_state, stage_state, session_state, stage_display, needs_accordion]
|
| 493 |
)
|
| 494 |
|
| 495 |
user_input.submit(
|
| 496 |
process_message,
|
| 497 |
[user_input, history_state, stage_state, session_state, somatic_check, selected_needs],
|
| 498 |
+
[conversation, user_input, history_state, stage_state, session_state, stage_display, needs_accordion]
|
| 499 |
)
|
| 500 |
|
| 501 |
# Reset handler
|
|
|
|
| 503 |
reset_session,
|
| 504 |
[],
|
| 505 |
[conversation, user_input, history_state, stage_state, session_state, stage_display,
|
| 506 |
+
needs_accordion, needs1, needs2, needs3, needs4]
|
| 507 |
)
|
| 508 |
|
| 509 |
if __name__ == "__main__":
|