anvisinghh commited on
Commit
3589eeb
·
verified ·
1 Parent(s): 47cb4f0

Upload inference.py

Browse files
Files changed (1) hide show
  1. inference.py +12 -5
inference.py CHANGED
@@ -10,6 +10,7 @@ from models import MyEnvV4Action
10
  API_BASE_URL = os.getenv("API_BASE_URL") or "https://generativelanguage.googleapis.com/v1beta/openai/"
11
  API_KEY = os.getenv("GEMINI_API_KEY") or os.getenv("OPENAI_API_KEY") or ""
12
  MODEL_NAME = "gemini-2.0-flash"
 
13
 
14
  SYSTEM_PROMPT = """
15
  You are an Advanced Email Security Agent. Analyze the metadata, URLs, and content.
@@ -28,14 +29,16 @@ Respond in strict JSON:
28
 
29
  async def main():
30
  if not API_KEY:
31
- print("[ERROR] No API key found. Please set GEMINI_API_KEY.")
32
  return
33
 
34
  client = OpenAI(base_url=API_BASE_URL, api_key=API_KEY)
35
  env = MyEnvV4Env()
36
 
37
  rewards = []
38
- print(f"[START] Running Security Triage Evaluation...")
 
 
39
 
40
  # OpenEnv Reset
41
  result = await env.reset()
@@ -72,17 +75,21 @@ async def main():
72
  result = await env.step(action)
73
  rewards.append(result.reward)
74
 
75
- print(f"[STEP {step_idx}] Result: {action.message} | Reward: {result.reward:.2f}")
 
76
  step_idx += 1
77
 
78
  # Sleep to respect rate limits (Gemini 2.0 Flash)
79
  await asyncio.sleep(2)
80
  except Exception as e:
81
- print(f"[ERROR] Step {step_idx}: {e}")
82
  break
83
 
84
  final_score = sum(rewards) / len(rewards) if rewards else 0
85
- print(f"[END] Evaluation Complete. Final Score: {final_score:.3f}")
 
 
 
86
 
87
 
88
  if __name__ == "__main__":
 
10
  API_BASE_URL = os.getenv("API_BASE_URL") or "https://generativelanguage.googleapis.com/v1beta/openai/"
11
  API_KEY = os.getenv("GEMINI_API_KEY") or os.getenv("OPENAI_API_KEY") or ""
12
  MODEL_NAME = "gemini-2.0-flash"
13
+ TASK_NAME = "mail-triage-v4-security-eval"
14
 
15
  SYSTEM_PROMPT = """
16
  You are an Advanced Email Security Agent. Analyze the metadata, URLs, and content.
 
29
 
30
  async def main():
31
  if not API_KEY:
32
+ print("[ERROR] No API key found. Please set GEMINI_API_KEY.", flush=True)
33
  return
34
 
35
  client = OpenAI(base_url=API_BASE_URL, api_key=API_KEY)
36
  env = MyEnvV4Env()
37
 
38
  rewards = []
39
+
40
+ # REQUIRED PHASE 2 START BLOCK
41
+ print(f"[START] task={TASK_NAME}", flush=True)
42
 
43
  # OpenEnv Reset
44
  result = await env.reset()
 
75
  result = await env.step(action)
76
  rewards.append(result.reward)
77
 
78
+ # REQUIRED PHASE 2 STEP BLOCK
79
+ print(f"[STEP] step={step_idx} reward={result.reward}", flush=True)
80
  step_idx += 1
81
 
82
  # Sleep to respect rate limits (Gemini 2.0 Flash)
83
  await asyncio.sleep(2)
84
  except Exception as e:
85
+ print(f"[ERROR] Step {step_idx}: {e}", flush=True)
86
  break
87
 
88
  final_score = sum(rewards) / len(rewards) if rewards else 0
89
+ total_steps = step_idx - 1
90
+
91
+ # REQUIRED PHASE 2 END BLOCK
92
+ print(f"[END] task={TASK_NAME} score={final_score} steps={total_steps}", flush=True)
93
 
94
 
95
  if __name__ == "__main__":