Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# app.py
|
2 |
+
import gradio as gr
|
3 |
+
from ai_model import generate_daily_checklist
|
4 |
+
from sf_mock import log_reflection, get_engagement_score
|
5 |
+
from utils import plot_engagement_graph, generate_pdf_summary
|
6 |
+
|
7 |
+
# UI Logic
|
8 |
+
def coach_interface(role, project_id, milestones, reflection):
|
9 |
+
checklist, tips = generate_daily_checklist(role, project_id, milestones, reflection)
|
10 |
+
log_reflection(role, project_id, reflection)
|
11 |
+
score = get_engagement_score(role, project_id)
|
12 |
+
graph_path = plot_engagement_graph(score)
|
13 |
+
return checklist, tips, score, graph_path
|
14 |
+
|
15 |
+
def download_summary(role, project_id):
|
16 |
+
return generate_pdf_summary(role, project_id)
|
17 |
+
|
18 |
+
with gr.Blocks() as demo:
|
19 |
+
gr.Markdown("# AI Coach for Site Supervisors")
|
20 |
+
|
21 |
+
with gr.Row():
|
22 |
+
role = gr.Textbox(label="Supervisor Role", placeholder="e.g. Electrical Lead")
|
23 |
+
project_id = gr.Textbox(label="Project ID")
|
24 |
+
|
25 |
+
milestones = gr.Textbox(label="Project Milestones", placeholder="e.g. Foundation, Framing, Wiring...")
|
26 |
+
reflection = gr.Textbox(label="Reflection Log", lines=4)
|
27 |
+
|
28 |
+
submit_btn = gr.Button("Get Today's Coaching")
|
29 |
+
|
30 |
+
checklist = gr.Textbox(label="Daily Checklist", lines=4)
|
31 |
+
tips = gr.Textbox(label="Top 3 Focus Tips", lines=3)
|
32 |
+
score = gr.Number(label="Engagement Score")
|
33 |
+
graph = gr.Image(label="Engagement Trend")
|
34 |
+
|
35 |
+
submit_btn.click(coach_interface,
|
36 |
+
inputs=[role, project_id, milestones, reflection],
|
37 |
+
outputs=[checklist, tips, score, graph])
|
38 |
+
|
39 |
+
gr.Markdown("---")
|
40 |
+
gr.Markdown("## Download Weekly Summary")
|
41 |
+
download_btn = gr.Button("Download PDF Summary")
|
42 |
+
summary_file = gr.File()
|
43 |
+
download_btn.click(download_summary, inputs=[role, project_id], outputs=summary_file)
|
44 |
+
|
45 |
+
if __name__ == "__main__":
|
46 |
+
demo.launch()
|