MBG0903 commited on
Commit
175ce2d
·
verified ·
1 Parent(s): ea18098

Create brain.py

Browse files
Files changed (1) hide show
  1. agents/brain.py +92 -0
agents/brain.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import asyncio
2
+ from agents.planner import detect_intent
3
+ from agents.reasoner import (
4
+ run_slotting_analysis,
5
+ run_picking_analysis,
6
+ build_operational_report
7
+ )
8
+ from tools.heatmap import generate_heatmap
9
+ from tools.report import build_final_report
10
+
11
+
12
+ class AutoWarehouseAgent:
13
+ """
14
+ AutoGPT-style agent for warehouse operations.
15
+ Internal thoughts are hidden from the user.
16
+ """
17
+
18
+ def __init__(self):
19
+ self.memory = {}
20
+
21
+ async def run(self, user_query, slotting_df, picking_df):
22
+ """
23
+ Main entry point.
24
+ Receives a user query and returns a clean professional output.
25
+ """
26
+ intent = detect_intent(user_query)
27
+
28
+ # Store inputs in memory
29
+ self.memory["slotting_data"] = slotting_df
30
+ self.memory["picking_data"] = picking_df
31
+
32
+ # Hidden reasoning and step selection
33
+ if intent == "slotting_analysis":
34
+ result = self._execute_slotting()
35
+ elif intent == "picking_route":
36
+ result = self._execute_picking()
37
+ elif intent == "full_warehouse_assessment":
38
+ result = self._execute_full_assessment()
39
+ else:
40
+ result = "I can help analyze slotting, picking, or produce a full warehouse intelligence report. Please specify your request."
41
+
42
+ return result
43
+
44
+ # ---------------- INTERNAL (HIDDEN) AGENT TASKS ---------------- #
45
+
46
+ def _execute_slotting(self):
47
+ slotting_df = self.memory["slotting_data"]
48
+ slot_output, slot_insights = run_slotting_analysis(slotting_df)
49
+
50
+ final_report = build_final_report(
51
+ section_title="Slotting Optimization Summary",
52
+ slotting_table=slot_output,
53
+ picking_table=None,
54
+ insights=slot_insights,
55
+ heatmap_path=None
56
+ )
57
+
58
+ return final_report
59
+
60
+ def _execute_picking(self):
61
+ picking_df = self.memory["picking_data"]
62
+ route_plot_path, picking_summary = run_picking_analysis(picking_df)
63
+
64
+ final_report = build_final_report(
65
+ section_title="Picking Route Optimization",
66
+ slotting_table=None,
67
+ picking_table=picking_summary,
68
+ insights=None,
69
+ heatmap_path=route_plot_path
70
+ )
71
+
72
+ return final_report
73
+
74
+ def _execute_full_assessment(self):
75
+ slotting_df = self.memory["slotting_data"]
76
+ picking_df = self.memory["picking_data"]
77
+
78
+ # Hidden multi-step execution
79
+ slot_output, slot_insights = run_slotting_analysis(slotting_df)
80
+ route_plot_path, picking_summary = run_picking_analysis(picking_df)
81
+
82
+ heatmap_path = generate_heatmap(slot_output)
83
+
84
+ # Executive-level compiled report
85
+ final_report = build_operational_report(
86
+ slotting_table=slot_output,
87
+ picking_table=picking_summary,
88
+ insights=slot_insights,
89
+ heatmap_path=heatmap_path
90
+ )
91
+
92
+ return final_report