|
35 | 35 | VibeAgileFusionEngine, VibeContext, VibeIntensity, AgilePhase, |
36 | 36 | get_human_interaction_dialog |
37 | 37 | ) |
| 38 | + from utils.agile.enhanced_phase_dialogues import ( |
| 39 | + get_enhanced_phase_dialogue, DialogueQuestion, QuestionType |
| 40 | + ) |
38 | 41 | VIBE_AGILE_AVAILABLE = True |
39 | 42 | except ImportError: |
40 | 43 | VibeAgileFusionEngine = None |
41 | 44 | VibeContext = None |
42 | 45 | VibeIntensity = None |
43 | 46 | AgilePhase = None |
44 | 47 | get_human_interaction_dialog = None |
| 48 | + get_enhanced_phase_dialogue = None |
| 49 | + DialogueQuestion = None |
| 50 | + QuestionType = None |
45 | 51 | VIBE_AGILE_AVAILABLE = False |
46 | 52 |
|
47 | 53 | # Page configuration |
@@ -2499,14 +2505,21 @@ def display_human_interaction_dialog(): |
2499 | 2505 | phase = interaction['phase'] |
2500 | 2506 | vibe_context = interaction['vibe_context'] |
2501 | 2507 |
|
2502 | | - # Get dialog configuration for current phase |
| 2508 | + # Get enhanced dialog configuration for current phase |
2503 | 2509 | try: |
2504 | | - dialog_config = get_human_interaction_dialog(phase, vibe_context) |
| 2510 | + if get_enhanced_phase_dialogue: |
| 2511 | + dialog_config = get_enhanced_phase_dialogue(phase, vibe_context) |
| 2512 | + else: |
| 2513 | + dialog_config = get_human_interaction_dialog(phase, vibe_context) |
2505 | 2514 | except Exception as e: |
2506 | 2515 | st.error(f"Error getting dialog configuration: {str(e)}") |
2507 | 2516 | dialog_config = { |
2508 | 2517 | 'phase': phase, |
2509 | | - 'questions': ["How do you feel about the current progress?"], |
| 2518 | + 'questions': [DialogueQuestion( |
| 2519 | + text="How do you feel about the current progress?", |
| 2520 | + question_type=QuestionType.SCALE if QuestionType else "scale", |
| 2521 | + scale_range=(1, 10) |
| 2522 | + )], |
2510 | 2523 | 'duration': "10 minutes", |
2511 | 2524 | 'success_criteria': ["Clear feedback provided"], |
2512 | 2525 | 'emotional_context': vibe_context.get('intensity', 'focused'), |
@@ -2538,21 +2551,50 @@ def display_human_interaction_dialog(): |
2538 | 2551 | questions = dialog_config.get('questions', []) |
2539 | 2552 |
|
2540 | 2553 | for i, question in enumerate(questions): |
2541 | | - st.markdown(f"**Question {i+1}**: {question}") |
2542 | | - |
2543 | | - # Adapt input type based on question content |
2544 | | - if 'rate' in question.lower() or 'scale' in question.lower(): |
2545 | | - response = st.slider(f"Response {i+1}", 1, 10, 5, key=f"q_{i}") |
2546 | | - elif 'yes' in question.lower() or 'no' in question.lower(): |
2547 | | - response = st.radio(f"Response {i+1}", ["Yes", "No", "Maybe"], key=f"q_{i}") |
2548 | | - elif 'choose' in question.lower() or 'select' in question.lower(): |
2549 | | - response = st.selectbox(f"Response {i+1}", |
2550 | | - ["Option A", "Option B", "Option C", "Other"], |
2551 | | - key=f"q_{i}") |
2552 | | - else: |
2553 | | - response = st.text_area(f"Your thoughts", |
2554 | | - placeholder="Share your detailed feedback...", |
2555 | | - height=100, key=f"q_{i}") |
| 2554 | + # Handle both DialogueQuestion objects and simple strings |
| 2555 | + if hasattr(question, 'text'): # Enhanced DialogueQuestion object |
| 2556 | + question_text = question.text |
| 2557 | + question_type = question.question_type |
| 2558 | + help_text = question.help_text |
| 2559 | + |
| 2560 | + st.markdown(f"**Question {i+1}**: {question_text}") |
| 2561 | + if help_text: |
| 2562 | + st.markdown(f"*{help_text}*") |
| 2563 | + |
| 2564 | + # Use specific question type for UI element |
| 2565 | + if question_type == QuestionType.SCALE or (hasattr(question_type, 'value') and question_type.value == 'scale'): |
| 2566 | + scale_range = getattr(question, 'scale_range', (1, 10)) |
| 2567 | + response = st.slider(f"Response {i+1}", scale_range[0], scale_range[1], |
| 2568 | + (scale_range[0] + scale_range[1]) // 2, key=f"q_{i}") |
| 2569 | + elif question_type == QuestionType.YES_NO or (hasattr(question_type, 'value') and question_type.value == 'yes_no'): |
| 2570 | + response = st.radio(f"Response {i+1}", ["Yes", "No", "Maybe"], key=f"q_{i}") |
| 2571 | + elif question_type == QuestionType.CHOICE or (hasattr(question_type, 'value') and question_type.value == 'choice'): |
| 2572 | + options = getattr(question, 'options', ["Option A", "Option B", "Option C", "Other"]) |
| 2573 | + response = st.selectbox(f"Response {i+1}", options, key=f"q_{i}") |
| 2574 | + elif question_type == QuestionType.MULTI_SELECT or (hasattr(question_type, 'value') and question_type.value == 'multi_select'): |
| 2575 | + options = getattr(question, 'options', ["Option 1", "Option 2", "Option 3"]) |
| 2576 | + response = st.multiselect(f"Response {i+1}", options, key=f"q_{i}") |
| 2577 | + else: # TEXT type or fallback |
| 2578 | + response = st.text_area(f"Your thoughts", |
| 2579 | + placeholder="Share your detailed feedback...", |
| 2580 | + height=100, key=f"q_{i}") |
| 2581 | + else: # Simple string question (fallback) |
| 2582 | + question_text = str(question) |
| 2583 | + st.markdown(f"**Question {i+1}**: {question_text}") |
| 2584 | + |
| 2585 | + # Adapt input type based on question content |
| 2586 | + if 'rate' in question_text.lower() or 'scale' in question_text.lower(): |
| 2587 | + response = st.slider(f"Response {i+1}", 1, 10, 5, key=f"q_{i}") |
| 2588 | + elif 'yes' in question_text.lower() or 'no' in question_text.lower(): |
| 2589 | + response = st.radio(f"Response {i+1}", ["Yes", "No", "Maybe"], key=f"q_{i}") |
| 2590 | + elif 'choose' in question_text.lower() or 'select' in question_text.lower(): |
| 2591 | + response = st.selectbox(f"Response {i+1}", |
| 2592 | + ["Option A", "Option B", "Option C", "Other"], |
| 2593 | + key=f"q_{i}") |
| 2594 | + else: |
| 2595 | + response = st.text_area(f"Your thoughts", |
| 2596 | + placeholder="Share your detailed feedback...", |
| 2597 | + height=100, key=f"q_{i}") |
2556 | 2598 |
|
2557 | 2599 | responses[f"question_{i+1}"] = response |
2558 | 2600 |
|
|
0 commit comments