Download app.py from MBG0903/Procelevate_Agentic_Warehouse_Operator: direct link, hf CLI and curl.
- Browser
- Download file 2.93 kB
-
https://huggingface.co/spaces/MBG0903/Procelevate_Agentic_Warehouse_Operator/resolve/main/app.py
- Command line
-
hf download hf://spaces/MBG0903/Procelevate_Agentic_Warehouse_Operator/app.py
-
curl -L -o app.py https://huggingface.co/spaces/MBG0903/Procelevate_Agentic_Warehouse_Operator/resolve/main/app.py
2.93 kB
| import gradio as gr | |
| import pandas as pd | |
| from agents.brain import AutoWarehouseAgent | |
| agent = AutoWarehouseAgent() | |
| def df_from_input(df): | |
| return pd.DataFrame(df) if df else pd.DataFrame() | |
| def run_agent(message, slotting_df, picking_df): | |
| print("π₯ INPUT MESSAGE:", message) | |
| print("π SLOT DATA:", slotting_df) | |
| print("π PICKING DATA:", picking_df) | |
| try: | |
| raw = agent.run(message, slotting_df, picking_df) | |
| print("β RAW RESULT FROM AGENT:", raw) | |
| # ----------------------------------------------------- | |
| # π STANDARDIZE OUTPUT FORMAT | |
| # ----------------------------------------------------- | |
| if isinstance(raw, str): | |
| # Agent returned text only β convert to dictionary | |
| result = { | |
| "report": raw, | |
| "route_image": None, | |
| "slotting_table": pd.DataFrame(), | |
| } | |
| elif isinstance(raw, dict): | |
| # Fill missing pieces | |
| result = { | |
| "report": raw.get("report", "No report generated."), | |
| "route_image": raw.get("route_image", None), | |
| "slotting_table": raw.get("slotting_table", pd.DataFrame()), | |
| } | |
| else: | |
| # Unexpected return type | |
| result = { | |
| "report": "β οΈ Invalid agent output format.", | |
| "route_image": None, | |
| "slotting_table": pd.DataFrame(), | |
| } | |
| # Return EXACTLY 3 items to match UI outputs | |
| return ( | |
| result["report"], | |
| result["route_image"], | |
| result["slotting_table"], | |
| ) | |
| except Exception as e: | |
| import traceback | |
| print("β ERROR OCCURRED:") | |
| traceback.print_exc() | |
| return ( | |
| f"### β Error\n{str(e)}", | |
| None, | |
| pd.DataFrame(), | |
| ) | |
| def build_ui(): | |
| with gr.Blocks() as demo: | |
| gr.Markdown( | |
| "<h1 style='color:#FF6A00;'>Procelevate Autonomous Warehouse Operator</h1>" | |
| ) | |
| query = gr.Textbox(label="Enter your request") | |
| gr.Markdown("### Slotting Data") | |
| slot_df = gr.Dataframe( | |
| headers=["SKU", "Velocity", "Frequency"], | |
| value=[ | |
| ["A123", "Fast", 120], | |
| ["B555", "Medium", 60], | |
| ["C888", "Slow", 8], | |
| ], | |
| ) | |
| gr.Markdown("### Picking Data") | |
| pick_df = gr.Dataframe( | |
| headers=["Aisle", "Rack"], | |
| value=[[5, 14], [3, 10], [12, 7]], | |
| ) | |
| btn = gr.Button("Run Agent", variant="primary") | |
| out_report = gr.Markdown() | |
| out_route = gr.Image() | |
| out_slot = gr.Dataframe() | |
| btn.click( | |
| run_agent, | |
| inputs=[query, slot_df, pick_df], | |
| outputs=[out_report, out_route, out_slot], | |
| ) | |
| return demo | |
| demo = build_ui() | |
| demo.launch() | |