dschandra's picture
Create app.py
66971d1 verified
# app.py
import gradio as gr
from ai_model import generate_daily_checklist
from sf_mock import log_reflection, get_engagement_score
from utils import plot_engagement_graph, generate_pdf_summary
# UI Logic
def coach_interface(role, project_id, milestones, reflection):
checklist, tips = generate_daily_checklist(role, project_id, milestones, reflection)
log_reflection(role, project_id, reflection)
score = get_engagement_score(role, project_id)
graph_path = plot_engagement_graph(score)
return checklist, tips, score, graph_path
def download_summary(role, project_id):
return generate_pdf_summary(role, project_id)
with gr.Blocks() as demo:
gr.Markdown("# AI Coach for Site Supervisors")
with gr.Row():
role = gr.Textbox(label="Supervisor Role", placeholder="e.g. Electrical Lead")
project_id = gr.Textbox(label="Project ID")
milestones = gr.Textbox(label="Project Milestones", placeholder="e.g. Foundation, Framing, Wiring...")
reflection = gr.Textbox(label="Reflection Log", lines=4)
submit_btn = gr.Button("Get Today's Coaching")
checklist = gr.Textbox(label="Daily Checklist", lines=4)
tips = gr.Textbox(label="Top 3 Focus Tips", lines=3)
score = gr.Number(label="Engagement Score")
graph = gr.Image(label="Engagement Trend")
submit_btn.click(coach_interface,
inputs=[role, project_id, milestones, reflection],
outputs=[checklist, tips, score, graph])
gr.Markdown("---")
gr.Markdown("## Download Weekly Summary")
download_btn = gr.Button("Download PDF Summary")
summary_file = gr.File()
download_btn.click(download_summary, inputs=[role, project_id], outputs=summary_file)
if __name__ == "__main__":
demo.launch()