Rohannk commited on
Commit
cd049f4
·
verified ·
1 Parent(s): b12d942

Update inference.py

Browse files
Files changed (1) hide show
  1. inference.py +23 -3
inference.py CHANGED
@@ -11,7 +11,7 @@ API_BASE_URL = os.getenv("API_BASE_URL", "https://generativelanguage.googleapis.
11
  MODEL_NAME = os.getenv("MODEL_NAME", "gemini-2.5-flash")
12
 
13
  # 2. Put your REAL Gemini key right here (starts with AIza...)
14
- GEMINI_API_KEY = os.getenv("GEMINI_API_KEY", "HF_TOKENS")
15
 
16
  # 3. Your live Hugging Face Space URL
17
  ENV_URL = os.getenv("ENV_URL", "https://rohannk-datacenter-openenv.hf.space")
@@ -30,9 +30,15 @@ def run_inference():
30
  except Exception as e:
31
  print(f"Error connecting to environment: {e}")
32
  return
33
-
 
 
 
34
  done = False
 
 
35
  while not done:
 
36
  # Prepare prompt with current state
37
  prompt = f"""
38
  You are an AI managing a Data Center Cooling System.
@@ -62,7 +68,19 @@ def run_inference():
62
 
63
  state_resp = step_resp['state']
64
  done = step_resp['done']
65
- print(f"Current Scores: {step_resp['scores']}\n")
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
  # Pause to prevent rate limits
68
  time.sleep(8)
@@ -71,5 +89,7 @@ def run_inference():
71
  print(f"API Error: {e}")
72
  break
73
 
 
 
74
  if __name__ == "__main__":
75
  run_inference()
 
11
  MODEL_NAME = os.getenv("MODEL_NAME", "gemini-2.5-flash")
12
 
13
  # 2. Put your REAL Gemini key right here (starts with AIza...)
14
+ GEMINI_API_KEY = os.getenv("GEMINI_API_KEY", "KEYS_HERE")
15
 
16
  # 3. Your live Hugging Face Space URL
17
  ENV_URL = os.getenv("ENV_URL", "https://rohannk-datacenter-openenv.hf.space")
 
30
  except Exception as e:
31
  print(f"Error connecting to environment: {e}")
32
  return
33
+
34
+ task_name = "DatacenterCooling"
35
+ print(f"[START] task={task_name}", flush=True)
36
+
37
  done = False
38
+ step = 0
39
+ total_current_score = 0.0
40
  while not done:
41
+ step += 1
42
  # Prepare prompt with current state
43
  prompt = f"""
44
  You are an AI managing a Data Center Cooling System.
 
68
 
69
  state_resp = step_resp['state']
70
  done = step_resp['done']
71
+
72
+ scores = step_resp.get('scores', {})
73
+ if isinstance(scores, dict):
74
+ current_reward = sum(scores.values())
75
+ elif isinstance(scores, (int, float)):
76
+ current_reward = float(scores)
77
+ else:
78
+ current_reward = 0.0
79
+
80
+ total_current_score += current_reward
81
+
82
+ print(f"[STEP] step={step} reward={current_reward}", flush=True)
83
+ print(f"Current Scores: {scores}\n")
84
 
85
  # Pause to prevent rate limits
86
  time.sleep(8)
 
89
  print(f"API Error: {e}")
90
  break
91
 
92
+ print(f"[END] task={task_name} score={total_current_score} steps={step}", flush=True)
93
+
94
  if __name__ == "__main__":
95
  run_inference()