Create pipeline.py
Browse files- pipeline.py +41 -0
pipeline.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from questions import questions
|
2 |
+
from chain_reports import generate_short_report_for_session
|
3 |
+
from chain_problems import analyze_problems_with_chain
|
4 |
+
from chain_recommendations import generate_recommendations
|
5 |
+
from chain_summary import generate_final_summary, shorten_summary
|
6 |
+
from typing import Dict
|
7 |
+
|
8 |
+
def process_answers_pipeline(responses: Dict[str, str]) -> Dict[str, any]:
|
9 |
+
"""
|
10 |
+
Orchestrates the entire pipeline:
|
11 |
+
1. Generates a short wellness report based on responses.
|
12 |
+
2. Analyzes problems using the generated report.
|
13 |
+
3. Generates package recommendations.
|
14 |
+
4. Creates a final summary for video narration.
|
15 |
+
5. Shortens the final summary for concise video creation.
|
16 |
+
|
17 |
+
Returns a dictionary containing all outputs.
|
18 |
+
"""
|
19 |
+
# Step 1: Generate Report
|
20 |
+
report = generate_short_report_for_session(responses)
|
21 |
+
|
22 |
+
# Step 2: Analyze Problem Severity
|
23 |
+
problems = analyze_problems_with_chain(responses, report)
|
24 |
+
|
25 |
+
# Step 3: Generate Recommendations
|
26 |
+
recommendation = generate_recommendations(problems)
|
27 |
+
|
28 |
+
# Step 4: Generate Final Summary
|
29 |
+
final_summary = generate_final_summary(report, problems, recommendation)
|
30 |
+
|
31 |
+
# Step 5: Shorten Summary for Video
|
32 |
+
shortened_summary = shorten_summary(final_summary)
|
33 |
+
|
34 |
+
# Compile all results
|
35 |
+
return {
|
36 |
+
"report": report,
|
37 |
+
"problems": problems,
|
38 |
+
"recommendation": recommendation,
|
39 |
+
"final_summary": final_summary,
|
40 |
+
"shortened_summary": shortened_summary
|
41 |
+
}
|