File size: 1,775 Bytes
66971d1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# 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()