Update agents/brain.py
Browse files- agents/brain.py +18 -78
agents/brain.py
CHANGED
|
@@ -1,88 +1,28 @@
|
|
| 1 |
-
|
| 2 |
-
from .
|
| 3 |
-
from .reasoner import (
|
| 4 |
run_slotting_analysis,
|
| 5 |
-
|
| 6 |
-
build_operational_report
|
| 7 |
)
|
| 8 |
-
from tools.heatmap import generate_heatmap
|
| 9 |
-
|
| 10 |
|
| 11 |
class AutoWarehouseAgent:
|
| 12 |
|
| 13 |
-
def
|
| 14 |
-
self.memory = {}
|
| 15 |
-
|
| 16 |
-
def run(self, user_query, slotting_df, picking_df):
|
| 17 |
-
"""
|
| 18 |
-
Autonomous agent interface.
|
| 19 |
-
Always returns 4 outputs:
|
| 20 |
-
- report text
|
| 21 |
-
- picking route image path
|
| 22 |
-
- heatmap image path
|
| 23 |
-
- slotting dataframe
|
| 24 |
-
"""
|
| 25 |
-
|
| 26 |
-
intent = detect_intent(user_query)
|
| 27 |
-
self.memory["slotting"] = slotting_df
|
| 28 |
-
self.memory["picking"] = picking_df
|
| 29 |
-
|
| 30 |
-
if intent == "slotting_analysis":
|
| 31 |
-
return self._do_slotting()
|
| 32 |
-
|
| 33 |
-
elif intent == "picking_route":
|
| 34 |
-
return self._do_picking()
|
| 35 |
-
|
| 36 |
-
elif intent == "full_warehouse_assessment":
|
| 37 |
-
return self._do_full_assessment()
|
| 38 |
-
|
| 39 |
-
return (
|
| 40 |
-
"I can help with slotting, picking route optimization, or full warehouse assessment.",
|
| 41 |
-
None, None, pd.DataFrame()
|
| 42 |
-
)
|
| 43 |
-
|
| 44 |
-
# ---------------- INTERNAL ---------------- #
|
| 45 |
-
|
| 46 |
-
def _do_slotting(self):
|
| 47 |
-
slot_df = self.memory["slotting"]
|
| 48 |
-
slot_output, insights = run_slotting_analysis(slot_df)
|
| 49 |
-
|
| 50 |
-
return (
|
| 51 |
-
f"### Slotting Optimization Report\n{insights}",
|
| 52 |
-
None,
|
| 53 |
-
None,
|
| 54 |
-
slot_output
|
| 55 |
-
)
|
| 56 |
-
|
| 57 |
-
def _do_picking(self):
|
| 58 |
-
picking_df = self.memory["picking"]
|
| 59 |
-
route_img, picking_summary = run_picking_analysis(picking_df)
|
| 60 |
|
| 61 |
-
|
| 62 |
-
"### Picking Route Optimization Completed",
|
| 63 |
-
route_img,
|
| 64 |
-
None,
|
| 65 |
-
picking_summary
|
| 66 |
-
)
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
|
| 83 |
-
return
|
| 84 |
-
report,
|
| 85 |
-
route_img,
|
| 86 |
-
heatmap_img,
|
| 87 |
-
slot_output
|
| 88 |
-
)
|
|
|
|
| 1 |
+
from agents.planner import detect_intent
|
| 2 |
+
from agents.reasoner import (
|
|
|
|
| 3 |
run_slotting_analysis,
|
| 4 |
+
run_picking_optimization
|
|
|
|
| 5 |
)
|
|
|
|
|
|
|
| 6 |
|
| 7 |
class AutoWarehouseAgent:
|
| 8 |
|
| 9 |
+
def run(self, message, slotting_df, picking_df):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
task = detect_intent(message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
if task == "slotting":
|
| 14 |
+
explanation, slotting_plan, _ = run_slotting_analysis(message, slotting_df)
|
| 15 |
+
return explanation, None, None, slotting_plan
|
| 16 |
|
| 17 |
+
if task == "picking":
|
| 18 |
+
explanation, route_img = run_picking_optimization(message, picking_df)
|
| 19 |
+
return explanation, route_img, None, None
|
| 20 |
|
| 21 |
+
if task == "report":
|
| 22 |
+
# Combine both
|
| 23 |
+
exp1, slot_plan, _ = run_slotting_analysis(message, slotting_df)
|
| 24 |
+
exp2, route_img = run_picking_optimization(message, picking_df)
|
| 25 |
+
full_exp = exp1 + "\n\n" + exp2
|
| 26 |
+
return full_exp, route_img, None, slot_plan
|
| 27 |
|
| 28 |
+
return "Sorry, I could not understand your request.", None, None, None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|