Delete app.py
Browse files
app.py
DELETED
|
@@ -1,161 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import pandas as pd
|
| 3 |
-
|
| 4 |
-
from agents.planner import interpret_user_intent
|
| 5 |
-
from agents.reasoner import generate_consulting_report
|
| 6 |
-
from tools.slotting import run_slotting
|
| 7 |
-
from tools.picking import run_picking
|
| 8 |
-
from tools.heatmap import generate_heatmap
|
| 9 |
-
from tools.insights import generate_insights
|
| 10 |
-
from tools.report import build_full_report
|
| 11 |
-
|
| 12 |
-
PRIMARY_COLOR = "#0f2c59"
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
# ---------------------------------------------------------
|
| 16 |
-
# MAIN AGENT CONTROLLER — DECIDES & EXECUTES ACTIONS
|
| 17 |
-
# ---------------------------------------------------------
|
| 18 |
-
def agent_controller(user_message, slotting_df, picking_df):
|
| 19 |
-
|
| 20 |
-
intent = interpret_user_intent(user_message)
|
| 21 |
-
|
| 22 |
-
# ---------------------------------------------------------
|
| 23 |
-
# SLOTING REQUEST
|
| 24 |
-
# ---------------------------------------------------------
|
| 25 |
-
if intent == "slotting":
|
| 26 |
-
slotting_result = run_slotting(slotting_df)
|
| 27 |
-
heatmap_img = generate_heatmap(slotting_result)
|
| 28 |
-
insights = generate_insights(slotting_result)
|
| 29 |
-
|
| 30 |
-
final_report = generate_consulting_report(
|
| 31 |
-
task="Slotting Optimization",
|
| 32 |
-
slotting=slotting_result,
|
| 33 |
-
picking=None,
|
| 34 |
-
heatmap=True,
|
| 35 |
-
insights=insights
|
| 36 |
-
)
|
| 37 |
-
|
| 38 |
-
return final_report, heatmap_img
|
| 39 |
-
|
| 40 |
-
# ---------------------------------------------------------
|
| 41 |
-
# PICKING ROUTE REQUEST
|
| 42 |
-
# ---------------------------------------------------------
|
| 43 |
-
elif intent == "picking":
|
| 44 |
-
picking_result, picking_plot = run_picking(picking_df)
|
| 45 |
-
|
| 46 |
-
final_report = generate_consulting_report(
|
| 47 |
-
task="Picking Route Optimization",
|
| 48 |
-
slotting=None,
|
| 49 |
-
picking=picking_result,
|
| 50 |
-
heatmap=False,
|
| 51 |
-
insights=None
|
| 52 |
-
)
|
| 53 |
-
|
| 54 |
-
return final_report, picking_plot
|
| 55 |
-
|
| 56 |
-
# ---------------------------------------------------------
|
| 57 |
-
# FULL WAREHOUSE REPORT
|
| 58 |
-
# ---------------------------------------------------------
|
| 59 |
-
elif intent == "report":
|
| 60 |
-
slotting_result = run_slotting(slotting_df)
|
| 61 |
-
heatmap_img = generate_heatmap(slotting_result)
|
| 62 |
-
picking_result, picking_plot = run_picking(picking_df)
|
| 63 |
-
insights = generate_insights(slotting_result)
|
| 64 |
-
|
| 65 |
-
full_report = build_full_report(
|
| 66 |
-
slotting_result, picking_result, insights
|
| 67 |
-
)
|
| 68 |
-
|
| 69 |
-
return full_report, heatmap_img
|
| 70 |
-
|
| 71 |
-
# ---------------------------------------------------------
|
| 72 |
-
# UNKNOWN INTENT
|
| 73 |
-
# ---------------------------------------------------------
|
| 74 |
-
else:
|
| 75 |
-
return (
|
| 76 |
-
"Unable to determine the warehouse task. Try examples like:\n"
|
| 77 |
-
"- 'Optimize slotting for fast movers'\n"
|
| 78 |
-
"- 'Show picking route'\n"
|
| 79 |
-
"- 'Generate full warehouse report'",
|
| 80 |
-
None
|
| 81 |
-
)
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
# ---------------------------------------------------------
|
| 85 |
-
# ENTERPRISE UI LAYOUT
|
| 86 |
-
# ---------------------------------------------------------
|
| 87 |
-
def build_ui():
|
| 88 |
-
|
| 89 |
-
with gr.Blocks() as demo:
|
| 90 |
-
|
| 91 |
-
# Inject CSS styling
|
| 92 |
-
gr.HTML(f"""
|
| 93 |
-
<style>
|
| 94 |
-
h1 {{
|
| 95 |
-
color: {PRIMARY_COLOR};
|
| 96 |
-
font-weight: 700;
|
| 97 |
-
}}
|
| 98 |
-
.procelevate-box {{
|
| 99 |
-
border: 2px solid {PRIMARY_COLOR};
|
| 100 |
-
border-radius: 8px;
|
| 101 |
-
padding: 12px;
|
| 102 |
-
}}
|
| 103 |
-
</style>
|
| 104 |
-
""")
|
| 105 |
-
|
| 106 |
-
# Title and description
|
| 107 |
-
gr.Markdown("""
|
| 108 |
-
<h1>Procelevate Autonomous Warehouse Operator</h1>
|
| 109 |
-
<p style='font-size:16px;'>
|
| 110 |
-
Enterprise-grade Agentic AI system that optimizes slotting, picking, and warehouse operations.
|
| 111 |
-
</p>
|
| 112 |
-
""")
|
| 113 |
-
|
| 114 |
-
# User query input
|
| 115 |
-
user_input = gr.Textbox(
|
| 116 |
-
label="Ask the Warehouse Operator",
|
| 117 |
-
placeholder="Example: Optimize slotting for fast movers",
|
| 118 |
-
)
|
| 119 |
-
|
| 120 |
-
# Slotting & picking data input tables
|
| 121 |
-
with gr.Row():
|
| 122 |
-
slotting_df = gr.DataFrame(
|
| 123 |
-
headers=["SKU", "Velocity", "Frequency"],
|
| 124 |
-
value=[
|
| 125 |
-
["A123", "Fast", 120],
|
| 126 |
-
["B555", "Medium", 60],
|
| 127 |
-
["C888", "Slow", 8],
|
| 128 |
-
],
|
| 129 |
-
label="Slotting Data"
|
| 130 |
-
)
|
| 131 |
-
|
| 132 |
-
picking_df = gr.DataFrame(
|
| 133 |
-
headers=["Aisle", "Rack"],
|
| 134 |
-
value=[
|
| 135 |
-
[5, 14],
|
| 136 |
-
[3, 10],
|
| 137 |
-
[12, 7],
|
| 138 |
-
],
|
| 139 |
-
label="Picking Path Data"
|
| 140 |
-
)
|
| 141 |
-
|
| 142 |
-
# Run button
|
| 143 |
-
run_btn = gr.Button("Run Agent", variant="primary")
|
| 144 |
-
|
| 145 |
-
# Output containers
|
| 146 |
-
report_output = gr.Markdown(label="Procelevate Analysis Report")
|
| 147 |
-
visual_output = gr.Image(type="pil", label="Visualization")
|
| 148 |
-
|
| 149 |
-
# Wire button → agent controller
|
| 150 |
-
run_btn.click(
|
| 151 |
-
fn=agent_controller,
|
| 152 |
-
inputs=[user_input, slotting_df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