Download agents/brain.py from MBG0903/Procelevate_Agentic_Warehouse_Operator: direct link, hf CLI and curl.
- Browser
- Download file 3.05 kB
-
https://huggingface.co/spaces/MBG0903/Procelevate_Agentic_Warehouse_Operator/resolve/main/agents/brain.py
- Command line
-
hf download hf://spaces/MBG0903/Procelevate_Agentic_Warehouse_Operator/agents/brain.py
-
curl -L -o brain.py https://huggingface.co/spaces/MBG0903/Procelevate_Agentic_Warehouse_Operator/resolve/main/agents/brain.py
3.05 kB
| from agents.planner import detect_intent | |
| from agents.reasoner import ( | |
| run_slotting_analysis, | |
| run_picking_optimization | |
| ) | |
| import pandas as pd | |
| class AutoWarehouseAgent: | |
| def run(self, message, slotting_df, picking_df): | |
| """ | |
| Returns a structured dictionary: | |
| { | |
| "report": markdown text, | |
| "route_image": image or None, | |
| "slotting_table": dataframe or empty df | |
| } | |
| """ | |
| task = detect_intent(message.lower().strip()) | |
| # Debug prints | |
| print(f"π§ DETECTED TASK: {task}") | |
| print("π¦ Slotting DF:", slotting_df) | |
| print("π Picking DF:", picking_df) | |
| # ------------------------------------------------------ | |
| # 1οΈβ£ SLOTTING | |
| # ------------------------------------------------------ | |
| if task == "slotting": | |
| explanation, slot_plan = run_slotting_analysis(message, slotting_df) | |
| return { | |
| "report": f"### π¦ Slotting Optimization Report\n\n{explanation}", | |
| "route_image": None, | |
| "slotting_table": slot_plan | |
| } | |
| # ------------------------------------------------------ | |
| # 2οΈβ£ PICKING | |
| # ------------------------------------------------------ | |
| if task == "picking": | |
| explanation, route_img = run_picking_optimization(message, picking_df) | |
| return { | |
| "report": f"### π Picking Route Optimization\n\n{explanation}", | |
| "route_image": route_img, | |
| "slotting_table": pd.DataFrame() | |
| } | |
| # ------------------------------------------------------ | |
| # 3οΈβ£ FULL REPORT (both slotting + picking) | |
| # ------------------------------------------------------ | |
| if task == "report": | |
| exp1, slot_plan = run_slotting_analysis(message, slotting_df) | |
| exp2, route_img = run_picking_optimization(message, picking_df) | |
| combined_report = ( | |
| "### π§Ύ Full Warehouse Intelligence Report\n\n" | |
| "#### π¦ Slotting Optimization\n" | |
| + exp1 + | |
| "\n\n---\n\n" | |
| "#### π Picking Optimization\n" | |
| + exp2 | |
| ) | |
| return { | |
| "report": combined_report, | |
| "route_image": route_img, | |
| "slotting_table": slot_plan | |
| } | |
| # ------------------------------------------------------ | |
| # β FALLBACK | |
| # ------------------------------------------------------ | |
| return { | |
| "report": ( | |
| "### β Unable to Understand Request\n" | |
| "I couldn't determine whether your request is about:\n" | |
| "- Slotting optimization\n" | |
| "- Picking route planning\n" | |
| "- Full warehouse report\n\n" | |
| "Try rewriting your query." | |
| ), | |
| "route_image": None, | |
| "slotting_table": pd.DataFrame() | |
| } | |