File size: 4,452 Bytes
2ea2a1a
 
1c1c01f
 
2ea2a1a
 
f7f11ae
 
 
 
 
 
 
 
 
 
 
 
2ea2a1a
21934c8
2ea2a1a
21934c8
 
 
 
 
 
 
 
 
 
 
 
2ea2a1a
 
f7f11ae
1c1c01f
 
 
 
2ea2a1a
 
 
 
94cf6c8
 
 
 
 
 
 
 
2ea2a1a
1c1c01f
2ea2a1a
 
 
1c1c01f
2ea2a1a
1c1c01f
2ea2a1a
 
 
1c1c01f
2ea2a1a
1c1c01f
2ea2a1a
 
 
1c1c01f
2ea2a1a
 
 
 
21934c8
2ea2a1a
 
21934c8
 
 
 
 
 
 
 
 
 
 
 
 
 
2ea2a1a
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# app.py
import gradio as gr
from pipeline import process_answers_pipeline  # Import the centralized pipeline function
from questions import questions  # Import questions list

def process_answers(
    sleep,
    exercise,
    mood,
    stress_level,
    wellness_goals,
    dietary_restrictions,
    relaxation_time,
    health_issues,
    water_intake,
    gratitude_feelings,
    connection_rating,
    energy_rating
):
    # Map the selected responses to their corresponding questions
    responses = {
        questions[0]: sleep,                     # How many hours of sleep do you get each night?
        questions[1]: exercise,                  # How often do you exercise in a week?
        questions[2]: mood,                      # On a scale of 1 to 10, how would you rate your mood today?
        questions[3]: stress_level,              # What is your current stress level on a scale from 1 to 10?
        questions[4]: wellness_goals,            # What are your primary wellness goals?
        questions[5]: dietary_restrictions,      # Do you follow any specific diet or have any dietary restrictions?
        questions[7]: relaxation_time,           # How much time do you spend on relaxation or mindfulness activities daily?
        questions[8]: health_issues,             # Do you experience any recurring health issues or pain?
        questions[12]: water_intake,             # How much water do you drink on average per day?
        questions[23]: gratitude_feelings,       # How often do you experience feelings of gratitude or happiness?
        questions[24]: connection_rating,        # On a scale from 1 to 10, how connected do you feel to your friends and family?
        questions[27]: energy_rating             # On a scale from 1 to 10, how would you rate your energy levels throughout the day?
    }

    # Process responses using the centralized pipeline
    results = process_answers_pipeline(responses)

    # Format outputs using results from the pipeline
    wellness_report = f"**Wellness Report**\n------------------\n{results['report'].strip()}"

    identified_problems = (
        "**Identified Problems**\n"
        "-----------------------\n"
        f"Stress Management: {results['problems'].get('stress_management', 'N/A')}%\n"
        f"Low Therapy: {results['problems'].get('low_therapy', 'N/A')}%\n"
        f"Balanced Weight: {results['problems'].get('balanced_weight', 'N/A')}%\n"
        f"Restless Night: {results['problems'].get('restless_night', 'N/A')}%\n"
        f"Lack of Motivation: {results['problems'].get('lack_of_motivation', 'N/A')}%\n"
        f"Gut Health: {results['problems'].get('gut_health', 'N/A')}%\n"
        f"Anxiety: {results['problems'].get('anxiety', 'N/A')}%\n"
        f"Burnout: {results['problems'].get('burnout', 'N/A')}%"
    )

    recommendations = (
        "**Recommendations**\n"
        "--------------------\n"
        f"{results['recommendation'].strip()}"
    )

    summary_shown = (
        "**Summary (SHOWN TO USER)**\n"
        "-----------------\n"
        f"{results['final_summary'].strip()}"
    )

    final_summary_video = (
        "**Final Summary (FOR VIDEO CREATION)**\n"
        "-----------------\n"
        f"{results['shortened_summary'].strip()}"
    )

    return wellness_report, identified_problems, recommendations, summary_shown, final_summary_video

# Define the Gradio interface using only the 12 selected questions
iface = gr.Interface(
    fn=process_answers,
    inputs=[
        gr.Textbox(label=questions[0]),
        gr.Textbox(label=questions[1]),
        gr.Textbox(label=questions[2]),
        gr.Textbox(label=questions[3]),
        gr.Textbox(label=questions[4]),
        gr.Textbox(label=questions[5]),
        gr.Textbox(label=questions[7]),
        gr.Textbox(label=questions[8]),
        gr.Textbox(label=questions[12]),
        gr.Textbox(label=questions[23]),
        gr.Textbox(label=questions[24]),
        gr.Textbox(label=questions[27])
    ],
    outputs=[
        gr.Markdown(label="Wellness Report"),
        gr.Markdown(label="Identified Problems"),
        gr.Markdown(label="Recommendations"),
        gr.Markdown(label="Summary (SHOWN TO USER)"),
        gr.Markdown(label="Final Summary (FOR VIDEO CREATION)")
    ],
    title="Wellness Report Generator",
    description="Answer the questions to generate a wellness report, problem analysis, recommendations, and a final summary."
)

iface.launch()