# 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: 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 corresponding 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 } # Use the centralized pipeline to process all responses 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()