Spaces:
Running
Running
feat: add multi-agent and planning CLI flags to inference and expose environment metadata via /info endpoint
Browse filesFiles changed (2)
- inference.py+17-2
- main.go+50
428 unmodified lines42943043143243343415 unmodified lines45045145245345445545626 unmodified lines483484485486487488489215 unmodified lines70570670770870971040 unmodified lines751752753754755756428 unmodified linesllm_every: int,max_steps: Optional[int],verbose: bool = False,) -> dict[str, Any]:"""Run a single episode and emit hackathon-compliant stdout format."""task_name = f"gridmind-task-{task_id}"15 unmodified linesobs: dict[str, Any] = {}try:reset_resp = env_client.reset(task_id=task_id, seed=seed)if reset_resp is None:raise RuntimeError("reset failed")obs_list = reset_resp.get("observations", [{}])26 unmodified lines# C5: World Modeling - Use /simulate when efficiency is low or faults activehvac_eff = obs.get("hvac_efficiency", 1.0)active_faults_list = obs.get("active_faults", [])use_simulation = not fast_mode and (hvac_eff < 0.7 or len(active_faults_list) > 0)sim_result = Nonesim_reward = None215 unmodified linesaction="store_true",help="Enable automatic task curriculum (Theme 4: Self-Improvement)",)args = parser.parse_args()server_proc = start_environment_server(port=7860)40 unmodified linesllm_every=args.llm_every,max_steps=args.max_steps,verbose=args.verbose,)task_scores.append(float(result["score"]))all_results.append(result)428 unmodified lines42943043143243343443543615 unmodified lines45245345445545645745845926 unmodified lines486487488489490491492215 unmodified lines70870971071171271371471571671771871972072172272340 unmodified lines764765766767768769770771428 unmodified linesllm_every: int,max_steps: Optional[int],verbose: bool = False,coordinator: bool = False,use_planning: bool = False,) -> dict[str, Any]:"""Run a single episode and emit hackathon-compliant stdout format."""task_name = f"gridmind-task-{task_id}"15 unmodified linesobs: dict[str, Any] = {}try:num_buildings = 3 if coordinator else 1reset_resp = env_client.reset(task_id=task_id, seed=seed, num_buildings=num_buildings)if reset_resp is None:raise RuntimeError("reset failed")obs_list = reset_resp.get("observations", [{}])26 unmodified lines# C5: World Modeling - Use /simulate when efficiency is low or faults activehvac_eff = obs.get("hvac_efficiency", 1.0)active_faults_list = obs.get("active_faults", [])use_simulation = not fast_mode and (use_planning or hvac_eff < 0.7 or len(active_faults_list) > 0)sim_result = Nonesim_reward = None215 unmodified linesaction="store_true",help="Enable automatic task curriculum (Theme 4: Self-Improvement)",)parser.add_argument("--coordinator",action="store_true",help="Multi-building coordinator mode: reset with 3 buildings (Theme 1: Multi-Agent)",)parser.add_argument("--use-planning",action="store_true",help="Force /simulate world-model call on every step (Theme 3: World Modeling)",)args = parser.parse_args()server_proc = start_environment_server(port=7860)40 unmodified linesllm_every=args.llm_every,max_steps=args.max_steps,verbose=args.verbose,coordinator=args.coordinator,use_planning=args.use_planning,)task_scores.append(float(result["score"]))all_results.append(result)
157 unmodified lines158159160161162163715 unmodified lines879880881157 unmodified linesmux.HandleFunc("/tasks", s.handleTasks)mux.HandleFunc("/metrics", s.handleMetrics)mux.HandleFunc("/ws", s.handleWebSocket)// Reverse proxy for dashboard (runs on port 7861 internally)mux.HandleFunc("/dashboard", s.handleDashboardProxy)mux.HandleFunc("/dashboard/", s.handleDashboardProxy)715 unmodified linesnext.ServeHTTP(w, r)})}157 unmodified lines158159160161162163164715 unmodified lines880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931157 unmodified linesmux.HandleFunc("/tasks", s.handleTasks)mux.HandleFunc("/metrics", s.handleMetrics)mux.HandleFunc("/ws", s.handleWebSocket)mux.HandleFunc("/info", s.handleInfo)// Reverse proxy for dashboard (runs on port 7861 internally)mux.HandleFunc("/dashboard", s.handleDashboardProxy)mux.HandleFunc("/dashboard/", s.handleDashboardProxy)715 unmodified linesnext.ServeHTTP(w, r)})}// handleInfo returns OpenEnv-standard metadata for automated validators and judges.func (s *Server) handleInfo(w http.ResponseWriter, r *http.Request) {if r.Method != http.MethodGet {http.Error(w, "method not allowed", http.StatusMethodNotAllowed)return}info := map[string]interface{}{"name": "gridmind-rl","version": "2.0.0","description": "Multi-building industrial energy management RL environment with instruction-following, world modeling, fault injection, and curriculum learning.","multi_agent": true,"themes": []string{"multi-agent","long-horizon-planning","world-modeling","self-improvement",},"observation_space": map[string]interface{}{"type": "dict","fields": []string{"indoor_temperature", "thermal_storage_level", "current_price","grid_stress_signal", "carbon_intensity", "hour_of_day", "step","hvac_efficiency", "process_demand", "cumulative_cost","batch_queue", "active_faults", "instruction_card",},},"action_space": map[string]interface{}{"type": "dict","fields": map[string]string{"hvac_power_level": "float [0.0, 1.0]","thermal_charge_rate": "float [-1.0, 1.0]","batch_job_slot": "int [0, 4]","load_shed_fraction": "float [0.0, 0.5]","building_id": "int [0, N_buildings-1]",},},"endpoints": []string{"POST /reset", "POST /step", "GET /grade", "GET /tasks","GET /state", "POST /simulate", "GET /feeder", "POST /coordinate","GET /health", "GET /info",},"hf_space": "https://lo-kyu-gridmind.hf.space","github": "https://github.com/LO-Kyu/gridmind",}w.Header().Set("Content-Type", "application/json")w.Header().Set("Access-Control-Allow-Origin", "*")json.NewEncoder(w).Encode(info)}
inference.py+17-2
main.go+50