Nitish commited on
Commit
0b0f159
Β·
1 Parent(s): e30d231

fix(inference): use HF_TOKEN as API key per sample inference.py spec, add API_BASE_URL default

Browse files
Files changed (1) hide show
  1. inference.py +5 -5
inference.py CHANGED
@@ -171,15 +171,15 @@ def run_task(task_id: str, task_num: int, client: OpenAI) -> dict:
171
  # ── Main ──────────────────────────────────────────────────────────────────────
172
 
173
  def main():
174
- # Read proxy config directly from environment β€” NO fallbacks, NO .env loading
175
- api_base = os.environ.get("API_BASE_URL", "").strip()
176
- api_key = os.environ.get("API_KEY", "").strip()
177
 
178
- # Validate β€” crash with a clear message if the grader didn't inject values
179
  if not api_base:
180
  raise RuntimeError("API_BASE_URL is empty or not set")
181
  if not api_key:
182
- raise RuntimeError("API_KEY is empty or not set")
183
 
184
  # Ensure base_url ends with / (httpx requires it)
185
  if not api_base.endswith("/"):
 
171
  # ── Main ──────────────────────────────────────────────────────────────────────
172
 
173
  def main():
174
+ # Read proxy config exactly as the sample inference.py specifies
175
+ api_base = os.getenv("API_BASE_URL", "https://api.openai.com/v1").strip()
176
+ api_key = os.getenv("HF_TOKEN", "").strip() or os.getenv("API_KEY", "").strip()
177
 
178
+ # Validate β€” crash with a clear message if the grader didn't inject a key
179
  if not api_base:
180
  raise RuntimeError("API_BASE_URL is empty or not set")
181
  if not api_key:
182
+ raise RuntimeError("Neither HF_TOKEN nor API_KEY is set")
183
 
184
  # Ensure base_url ends with / (httpx requires it)
185
  if not api_base.endswith("/"):