Spaces:
Sleeping
Sleeping
File size: 3,799 Bytes
2ea2a1a 1c1c01f 2ea2a1a f7f11ae 2ea2a1a f7f11ae 2ea2a1a f7f11ae 2ea2a1a f7f11ae 1c1c01f 2ea2a1a 1c1c01f 2ea2a1a 1c1c01f 2ea2a1a 1c1c01f 2ea2a1a 1c1c01f 2ea2a1a 1c1c01f 2ea2a1a 1c1c01f 2ea2a1a 1c1c01f 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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# 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,
eating_habits,
relaxation_time,
health_issues,
stress_management,
daily_routine,
bedtime_routine,
water_intake,
mindfulness_frequency,
mindset,
personal_growth_reflection,
break_frequency,
relaxation_activities,
self_care_time,
outdoor_activity_frequency,
gratitude_practice,
home_cooked_meals,
uninterrupted_sleep,
gratitude_feelings,
connection_rating,
activity_tracking,
strength_training,
energy_rating
):
# Explicit mapping of responses to corresponding questions
responses = {
questions[0]: sleep,
questions[1]: exercise,
questions[2]: mood,
questions[3]: stress_level,
questions[4]: wellness_goals,
questions[5]: dietary_restrictions,
questions[6]: eating_habits,
questions[7]: relaxation_time,
questions[8]: health_issues,
questions[9]: stress_management,
questions[10]: daily_routine,
questions[11]: bedtime_routine,
questions[12]: water_intake,
questions[13]: mindfulness_frequency,
questions[14]: mindset,
questions[15]: personal_growth_reflection,
questions[16]: break_frequency,
questions[17]: relaxation_activities,
questions[18]: self_care_time,
questions[19]: outdoor_activity_frequency,
questions[20]: gratitude_practice,
questions[21]: home_cooked_meals,
questions[22]: uninterrupted_sleep,
questions[23]: gratitude_feelings,
questions[24]: connection_rating,
questions[25]: activity_tracking,
questions[26]: strength_training,
questions[27]: energy_rating
}
# 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"Sleep Problem: {results['problems'].get('sleep_problem', 'N/A')}%\n"
f"Exercise Problem: {results['problems'].get('exercise_problem', 'N/A')}%\n"
f"Stress Problem: {results['problems'].get('stress_problem', 'N/A')}%\n"
f"Diet Problem: {results['problems'].get('diet_problem', '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
iface = gr.Interface(
fn=process_answers,
inputs=[gr.Textbox(label=q) for q in questions],
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()
|