MBG0903 commited on
Commit
ef25e70
Β·
verified Β·
1 Parent(s): 270176f

Update agents/brain.py

Browse files
Files changed (1) hide show
  1. agents/brain.py +68 -7
agents/brain.py CHANGED
@@ -3,25 +3,86 @@ 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, slotting_plan
 
 
 
 
 
16
 
 
 
 
17
  if task == "picking":
18
  explanation, route_img = run_picking_optimization(message, picking_df)
19
- return explanation, route_img, None
20
 
 
 
 
 
 
 
 
 
 
21
  if task == "report":
22
  exp1, slot_plan = run_slotting_analysis(message, slotting_df)
23
  exp2, route_img = run_picking_optimization(message, picking_df)
24
- full_exp = exp1 + "\n\n" + exp2
25
- return full_exp, route_img, slot_plan
26
 
27
- return "Sorry, I could not understand your request.", None, None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  run_slotting_analysis,
4
  run_picking_optimization
5
  )
6
+ import pandas as pd
7
+
8
 
9
  class AutoWarehouseAgent:
10
 
11
  def run(self, message, slotting_df, picking_df):
12
+ """
13
+ Returns a structured dictionary:
14
+ {
15
+ "report": markdown text,
16
+ "route_image": image or None,
17
+ "slotting_table": dataframe or empty df
18
+ }
19
+ """
20
+
21
+ task = detect_intent(message.lower().strip())
22
 
23
+ # Debug prints
24
+ print(f"🧠 DETECTED TASK: {task}")
25
+ print("πŸ“¦ Slotting DF:", slotting_df)
26
+ print("🚚 Picking DF:", picking_df)
27
 
28
+ # ------------------------------------------------------
29
+ # 1️⃣ SLOTTING
30
+ # ------------------------------------------------------
31
  if task == "slotting":
32
+ explanation, slot_plan = run_slotting_analysis(message, slotting_df)
33
+
34
+ return {
35
+ "report": f"### πŸ“¦ Slotting Optimization Report\n\n{explanation}",
36
+ "route_image": None,
37
+ "slotting_table": slot_plan
38
+ }
39
 
40
+ # ------------------------------------------------------
41
+ # 2️⃣ PICKING
42
+ # ------------------------------------------------------
43
  if task == "picking":
44
  explanation, route_img = run_picking_optimization(message, picking_df)
 
45
 
46
+ return {
47
+ "report": f"### 🚚 Picking Route Optimization\n\n{explanation}",
48
+ "route_image": route_img,
49
+ "slotting_table": pd.DataFrame()
50
+ }
51
+
52
+ # ------------------------------------------------------
53
+ # 3️⃣ FULL REPORT (both slotting + picking)
54
+ # ------------------------------------------------------
55
  if task == "report":
56
  exp1, slot_plan = run_slotting_analysis(message, slotting_df)
57
  exp2, route_img = run_picking_optimization(message, picking_df)
 
 
58
 
59
+ combined_report = (
60
+ "### 🧾 Full Warehouse Intelligence Report\n\n"
61
+ "#### πŸ“¦ Slotting Optimization\n"
62
+ + exp1 +
63
+ "\n\n---\n\n"
64
+ "#### 🚚 Picking Optimization\n"
65
+ + exp2
66
+ )
67
+
68
+ return {
69
+ "report": combined_report,
70
+ "route_image": route_img,
71
+ "slotting_table": slot_plan
72
+ }
73
+
74
+ # ------------------------------------------------------
75
+ # ❌ FALLBACK
76
+ # ------------------------------------------------------
77
+ return {
78
+ "report": (
79
+ "### ❓ Unable to Understand Request\n"
80
+ "I couldn't determine whether your request is about:\n"
81
+ "- Slotting optimization\n"
82
+ "- Picking route planning\n"
83
+ "- Full warehouse report\n\n"
84
+ "Try rewriting your query."
85
+ ),
86
+ "route_image": None,
87
+ "slotting_table": pd.DataFrame()
88
+ }