Create brain.py
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192import asynciofrom .planner import detect_intentfrom agents.reasoner import ( run_slotting_analysis, run_picking_analysis, build_operational_report)from tools.heatmap import generate_heatmapfrom tools.report import build_final_report
class AutoWarehouseAgent: """ AutoGPT-style agent for warehouse operations. Internal thoughts are hidden from the user. """
def __init__(self): self.memory = {}
async def run(self, user_query, slotting_df, picking_df): """ Main entry point. Receives a user query and returns a clean professional output. """ intent = detect_intent(user_query)
# Store inputs in memory self.memory["slotting_data"] = slotting_df self.memory["picking_data"] = picking_df
# Hidden reasoning and step selection if intent == "slotting_analysis": result = self._execute_slotting() elif intent == "picking_route": result = self._execute_picking() elif intent == "full_warehouse_assessment": result = self._execute_full_assessment() else: result = "I can help analyze slotting, picking, or produce a full warehouse intelligence report. Please specify your request."
return result
# ---------------- INTERNAL (HIDDEN) AGENT TASKS ---------------- #
def _execute_slotting(self): slotting_df = self.memory["slotting_data"] slot_output, slot_insights = run_slotting_analysis(slotting_df)
final_report = build_final_report( section_title="Slotting Optimization Summary", slotting_table=slot_output, picking_table=None, insights=slot_insights, heatmap_path=None )
return final_report
def _execute_picking(self): picking_df = self.memory["picking_data"] route_plot_path, picking_summary = run_picking_analysis(picking_df)
final_report = build_final_report( section_title="Picking Route Optimization", slotting_table=None, picking_table=picking_summary, insights=None, heatmap_path=route_plot_path )
return final_report
def _execute_full_assessment(self): slotting_df = self.memory["slotting_data"] picking_df = self.memory["picking_data"]
# Hidden multi-step execution slot_output, slot_insights = run_slotting_analysis(slotting_df) route_plot_path, picking_summary = run_picking_analysis(picking_df)
heatmap_path = generate_heatmap(slot_output)
# Executive-level compiled report final_report = build_operational_report( slotting_table=slot_output, picking_table=picking_summary, insights=slot_insights, heatmap_path=heatmap_path )
return final_reportagents/brain.pyAdded+92