File size: 2,743 Bytes
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
# app.py
import gradio as gr
from chains import questions
from chain_reports import generate_short_report_for_session
from chain_problems import analyze_problems_with_chain
from chain_recommendations import generate_recommendations
from chain_summary import generate_final_summary, shorten_summary

def process_answers(
    sleep: str,
    exercise: str,
    stress: str,
    goals: str,
    diet: str,
    eating: str,
    relaxation: str,
    health_issues: str,
    manage_stress: str,
    routine: str
):
    # Map user inputs to questions
    responses = {
        questions[0]: sleep,
        questions[1]: exercise,
        questions[2]: stress,
        questions[3]: goals,
        questions[4]: diet,
        questions[5]: eating,
        questions[6]: relaxation,
        questions[7]: health_issues,
        questions[8]: manage_stress,
        questions[9]: routine
    }

    report = generate_short_report_for_session(responses)
    problems = analyze_problems_with_chain(responses, report)
    recommendation = generate_recommendations(problems)
    final_summary = generate_final_summary(report, problems, recommendation)
    shortened_summary = shorten_summary(final_summary)

    wellness_report = f"**Wellness Report**\n------------------\n{report.strip()}"
    identified_problems = (
        "**Identified Problems**\n"
        "-----------------------\n"
        f"Sleep Problem: {problems.get('sleep_problem', 'N/A')}%\n"
        f"Exercise Problem: {problems.get('exercise_problem', 'N/A')}%\n"
        f"Stress Problem: {problems.get('stress_problem', 'N/A')}%\n"
        f"Diet Problem: {problems.get('diet_problem', 'N/A')}%"
    )
    recommendations = (
        "**Recommendations**\n"
        "--------------------\n"
        f"{recommendation.strip()}"
    )
    summary_shown = (
        "**Summary (SHOWN TO USER)**\n"
        "-----------------\n"
        f"{final_summary.strip()}"
    )
    final_summary_video = (
        "**Final Summary (FOR VIDEO CREATION)**\n"
        "-----------------\n"
        f"{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()