MBG0903 commited on
Commit
0c9726f
·
verified ·
1 Parent(s): 560c288

Update agents/brain.py

Browse files
Files changed (1) hide show
  1. agents/brain.py +55 -22
agents/brain.py CHANGED
@@ -3,7 +3,10 @@ from agents.reasoner import (
3
  run_slotting_analysis,
4
  run_picking_optimization,
5
  run_demand_forecast,
6
- run_replenishment_analysis
 
 
 
7
  )
8
  import pandas as pd
9
 
@@ -12,6 +15,7 @@ class AutoWarehouseAgent:
12
 
13
  def run(self, message, slotting_df, picking_df):
14
  """
 
15
  Returns a structured dictionary:
16
  {
17
  "report": markdown text,
@@ -28,31 +32,29 @@ class AutoWarehouseAgent:
28
  print("🚚 Picking DF:", picking_df)
29
 
30
  # ------------------------------------------------------
31
- # 1️⃣ SLOTTING
32
  # ------------------------------------------------------
33
  if task == "slotting":
34
  explanation, slot_plan = run_slotting_analysis(message, slotting_df)
35
-
36
  return {
37
- "report": f"### 📦 Slotting Optimization Report\n\n{explanation}",
38
  "route_image": None,
39
  "slotting_table": slot_plan
40
  }
41
 
42
  # ------------------------------------------------------
43
- # 2️⃣ PICKING
44
  # ------------------------------------------------------
45
  if task == "picking":
46
  explanation, route_img = run_picking_optimization(message, picking_df)
47
-
48
  return {
49
- "report": f"### 🚚 Picking Route Optimization\n\n{explanation}",
50
  "route_image": route_img,
51
  "slotting_table": pd.DataFrame()
52
  }
53
 
54
  # ------------------------------------------------------
55
- # 3️⃣ FULL REPORT (slotting + picking)
56
  # ------------------------------------------------------
57
  if task == "report":
58
  exp1, slot_plan = run_slotting_analysis(message, slotting_df)
@@ -60,11 +62,9 @@ class AutoWarehouseAgent:
60
 
61
  combined_report = (
62
  "### 🧾 Full Warehouse Intelligence Report\n\n"
63
- "#### 📦 Slotting Optimization\n"
64
- + exp1 +
65
  "\n\n---\n\n"
66
- "#### 🚚 Picking Optimization\n"
67
- + exp2
68
  )
69
 
70
  return {
@@ -78,7 +78,6 @@ class AutoWarehouseAgent:
78
  # ------------------------------------------------------
79
  if task == "forecast":
80
  explanation, forecast_plot, forecast_table = run_demand_forecast(message, slotting_df)
81
-
82
  return {
83
  "report": explanation,
84
  "route_image": forecast_plot,
@@ -86,11 +85,10 @@ class AutoWarehouseAgent:
86
  }
87
 
88
  # ------------------------------------------------------
89
- # 5️⃣ REPLENISHMENT ANALYSIS (NEW)
90
  # ------------------------------------------------------
91
  if task == "replenishment":
92
  explanation, repl_table = run_replenishment_analysis(message, slotting_df)
93
-
94
  return {
95
  "report": explanation,
96
  "route_image": None,
@@ -98,18 +96,53 @@ class AutoWarehouseAgent:
98
  }
99
 
100
  # ------------------------------------------------------
101
- # FALLBACK
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  # ------------------------------------------------------
103
  return {
104
  "report": (
105
- "### ❓ Unable to Understand Request\n"
106
- "I couldn't determine whether your request is about:\n"
107
  "- Slotting optimization\n"
108
  "- Picking optimization\n"
109
- "- Demand forecasting\n"
110
- "- Replenishment needs\n"
111
- "- Full warehouse report\n\n"
112
- "Try rephrasing your query."
 
 
113
  ),
114
  "route_image": None,
115
  "slotting_table": pd.DataFrame()
 
3
  run_slotting_analysis,
4
  run_picking_optimization,
5
  run_demand_forecast,
6
+ run_replenishment_analysis,
7
+ run_rebalancing_analysis,
8
+ run_workforce_optimization,
9
+ run_dock_scheduling
10
  )
11
  import pandas as pd
12
 
 
15
 
16
  def run(self, message, slotting_df, picking_df):
17
  """
18
+ Central warehouse AI engine.
19
  Returns a structured dictionary:
20
  {
21
  "report": markdown text,
 
32
  print("🚚 Picking DF:", picking_df)
33
 
34
  # ------------------------------------------------------
35
+ # 1️⃣ SLOTING OPTIMIZATION
36
  # ------------------------------------------------------
37
  if task == "slotting":
38
  explanation, slot_plan = run_slotting_analysis(message, slotting_df)
 
39
  return {
40
+ "report": explanation,
41
  "route_image": None,
42
  "slotting_table": slot_plan
43
  }
44
 
45
  # ------------------------------------------------------
46
+ # 2️⃣ PICKING ROUTE OPTIMIZATION
47
  # ------------------------------------------------------
48
  if task == "picking":
49
  explanation, route_img = run_picking_optimization(message, picking_df)
 
50
  return {
51
+ "report": explanation,
52
  "route_image": route_img,
53
  "slotting_table": pd.DataFrame()
54
  }
55
 
56
  # ------------------------------------------------------
57
+ # 3️⃣ FULL REPORT Slotting + Picking
58
  # ------------------------------------------------------
59
  if task == "report":
60
  exp1, slot_plan = run_slotting_analysis(message, slotting_df)
 
62
 
63
  combined_report = (
64
  "### 🧾 Full Warehouse Intelligence Report\n\n"
65
+ "#### 📦 Slotting Optimization\n" + exp1 +
 
66
  "\n\n---\n\n"
67
+ "#### 🚚 Picking Optimization\n" + exp2
 
68
  )
69
 
70
  return {
 
78
  # ------------------------------------------------------
79
  if task == "forecast":
80
  explanation, forecast_plot, forecast_table = run_demand_forecast(message, slotting_df)
 
81
  return {
82
  "report": explanation,
83
  "route_image": forecast_plot,
 
85
  }
86
 
87
  # ------------------------------------------------------
88
+ # 5️⃣ REPLENISHMENT ANALYSIS
89
  # ------------------------------------------------------
90
  if task == "replenishment":
91
  explanation, repl_table = run_replenishment_analysis(message, slotting_df)
 
92
  return {
93
  "report": explanation,
94
  "route_image": None,
 
96
  }
97
 
98
  # ------------------------------------------------------
99
+ # 6️⃣ INVENTORY REBALANCING
100
+ # ------------------------------------------------------
101
+ if task == "rebalancing":
102
+ explanation, move_table = run_rebalancing_analysis(message, slotting_df)
103
+ return {
104
+ "report": explanation,
105
+ "route_image": None,
106
+ "slotting_table": move_table
107
+ }
108
+
109
+ # ------------------------------------------------------
110
+ # 7️⃣ WORKFORCE OPTIMIZATION
111
+ # ------------------------------------------------------
112
+ if task == "workforce":
113
+ explanation, workforce_table = run_workforce_optimization(message, slotting_df)
114
+ return {
115
+ "report": explanation,
116
+ "route_image": None,
117
+ "slotting_table": workforce_table
118
+ }
119
+
120
+ # ------------------------------------------------------
121
+ # 8️⃣ DOCK SCHEDULING OPTIMIZATION
122
+ # ------------------------------------------------------
123
+ if task == "dock":
124
+ explanation, dock_table = run_dock_scheduling(message, slotting_df)
125
+ return {
126
+ "report": explanation,
127
+ "route_image": None,
128
+ "slotting_table": dock_table
129
+ }
130
+
131
+ # ------------------------------------------------------
132
+ # ❌ FALLBACK HANDLER
133
  # ------------------------------------------------------
134
  return {
135
  "report": (
136
+ "### ❓ Unable to Understand Your Request\n"
137
+ "Please try queries related to:\n"
138
  "- Slotting optimization\n"
139
  "- Picking optimization\n"
140
+ "- Forecasting\n"
141
+ "- Replenishment\n"
142
+ "- Inventory rebalancing\n"
143
+ "- Workforce planning\n"
144
+ "- Dock scheduling\n"
145
+ "- Full warehouse report\n"
146
  ),
147
  "route_image": None,
148
  "slotting_table": pd.DataFrame()