Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,7 @@
|
|
1 |
# app.py
|
2 |
import gradio as gr
|
3 |
-
from
|
4 |
-
from
|
5 |
-
from chain_problems import analyze_problems_with_chain
|
6 |
-
from chain_recommendations import generate_recommendations
|
7 |
-
from chain_summary import generate_final_summary, shorten_summary
|
8 |
|
9 |
def process_answers(
|
10 |
sleep: str,
|
@@ -18,7 +15,7 @@ def process_answers(
|
|
18 |
manage_stress: str,
|
19 |
routine: str
|
20 |
):
|
21 |
-
# Map user inputs to questions
|
22 |
responses = {
|
23 |
questions[0]: sleep,
|
24 |
questions[1]: exercise,
|
@@ -32,35 +29,37 @@ def process_answers(
|
|
32 |
questions[9]: routine
|
33 |
}
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
|
41 |
-
wellness_report = f"**Wellness Report**\n------------------\n{report.strip()}"
|
42 |
identified_problems = (
|
43 |
"**Identified Problems**\n"
|
44 |
"-----------------------\n"
|
45 |
-
f"Sleep Problem: {problems.get('sleep_problem', 'N/A')}%\n"
|
46 |
-
f"Exercise Problem: {problems.get('exercise_problem', 'N/A')}%\n"
|
47 |
-
f"Stress Problem: {problems.get('stress_problem', 'N/A')}%\n"
|
48 |
-
f"Diet Problem: {problems.get('diet_problem', 'N/A')}%"
|
49 |
)
|
|
|
50 |
recommendations = (
|
51 |
"**Recommendations**\n"
|
52 |
"--------------------\n"
|
53 |
-
f"{recommendation.strip()}"
|
54 |
)
|
|
|
55 |
summary_shown = (
|
56 |
"**Summary (SHOWN TO USER)**\n"
|
57 |
"-----------------\n"
|
58 |
-
f"{final_summary.strip()}"
|
59 |
)
|
|
|
60 |
final_summary_video = (
|
61 |
"**Final Summary (FOR VIDEO CREATION)**\n"
|
62 |
"-----------------\n"
|
63 |
-
f"{shortened_summary.strip()}"
|
64 |
)
|
65 |
|
66 |
return wellness_report, identified_problems, recommendations, summary_shown, final_summary_video
|
|
|
1 |
# app.py
|
2 |
import gradio as gr
|
3 |
+
from pipeline import process_answers_pipeline # Import the centralized pipeline function
|
4 |
+
from questions import questions # Import questions list
|
|
|
|
|
|
|
5 |
|
6 |
def process_answers(
|
7 |
sleep: str,
|
|
|
15 |
manage_stress: str,
|
16 |
routine: str
|
17 |
):
|
18 |
+
# Map user inputs to corresponding questions
|
19 |
responses = {
|
20 |
questions[0]: sleep,
|
21 |
questions[1]: exercise,
|
|
|
29 |
questions[9]: routine
|
30 |
}
|
31 |
|
32 |
+
# Use the centralized pipeline to process all responses
|
33 |
+
results = process_answers_pipeline(responses)
|
34 |
+
|
35 |
+
# Format outputs using results from the pipeline
|
36 |
+
wellness_report = f"**Wellness Report**\n------------------\n{results['report'].strip()}"
|
37 |
|
|
|
38 |
identified_problems = (
|
39 |
"**Identified Problems**\n"
|
40 |
"-----------------------\n"
|
41 |
+
f"Sleep Problem: {results['problems'].get('sleep_problem', 'N/A')}%\n"
|
42 |
+
f"Exercise Problem: {results['problems'].get('exercise_problem', 'N/A')}%\n"
|
43 |
+
f"Stress Problem: {results['problems'].get('stress_problem', 'N/A')}%\n"
|
44 |
+
f"Diet Problem: {results['problems'].get('diet_problem', 'N/A')}%"
|
45 |
)
|
46 |
+
|
47 |
recommendations = (
|
48 |
"**Recommendations**\n"
|
49 |
"--------------------\n"
|
50 |
+
f"{results['recommendation'].strip()}"
|
51 |
)
|
52 |
+
|
53 |
summary_shown = (
|
54 |
"**Summary (SHOWN TO USER)**\n"
|
55 |
"-----------------\n"
|
56 |
+
f"{results['final_summary'].strip()}"
|
57 |
)
|
58 |
+
|
59 |
final_summary_video = (
|
60 |
"**Final Summary (FOR VIDEO CREATION)**\n"
|
61 |
"-----------------\n"
|
62 |
+
f"{results['shortened_summary'].strip()}"
|
63 |
)
|
64 |
|
65 |
return wellness_report, identified_problems, recommendations, summary_shown, final_summary_video
|