|
|
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()) |
|
|
|
|
|
|
|
|
print(f"π§ DETECTED TASK: {task}") |
|
|
print("π¦ Slotting DF:", slotting_df) |
|
|
print("π Picking DF:", picking_df) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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() |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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() |
|
|
} |
|
|
|