logistics-hackathon-env / test_client.py
Jerry
Upgrade: Premium Dashboard, Multi-Agent capacity logic, and GRPO training updates
c276e2c
Raw
History Blame Contribute Delete
1.58 kB
import asyncio
import sys, os
sys.path.insert(0, os.path.dirname(__file__))
from models import LogisticsAction
from client import LogisticsShipmentEnv
async def main():
print("πŸš› Connecting to Logistics Environment...")
# Connects to the local FastAPI server we'll start on port 8000
async with LogisticsShipmentEnv(base_url="http://127.0.0.1:8000") as env:
# 1. Reset the environment (starts a new 5-hour crisis episode)
obs = await env.reset()
print("\n--- πŸ“‘ INITIAL SNAPSHOT ---")
print(obs.network_snapshot)
print(f"Active Disruptions: {obs.active_disruptions_count}")
print(f"Delayed Shipments: {obs.delayed_shipments}")
# 2. Make a dummy AI decision
print("\n--- πŸ€– SENDING AI ACTION ---")
action = LogisticsAction(
reasoning="The situation looks bad. Let's fast-track shipment SHIP-001 and hope for the best.",
rerouting_decisions={},
priority_shipments=["SHIP-001"],
customer_communications={"SHIP-001": "Hang tight, we are prioritizing your shipment!"},
escalations=[]
)
# 3. Step the environment forward 1 hour
result = await env.step(action)
print("\n--- πŸ† STEP RESULT ---")
print(f"Feedback: {result.observation.previous_action_feedback}")
print(f"Reward Score: {result.reward:.3f} / 1.0")
print(f"Delay Saved (Hours): {result.observation.total_delay_saved_hours}")
if __name__ == "__main__":
asyncio.run(main())