aadi-joshi commited on
Commit
02f8b38
·
1 Parent(s): a92cbbf

Add defaults for API_BASE_URL and MODEL_NAME per submission checklist

Browse files

Checklist requires defaults for API_BASE_URL and MODEL_NAME but NOT
for HF_TOKEN. Also tightened the missing-var check in main() to only
gate on HF_TOKEN since the other two now have sensible defaults.

Files changed (1) hide show
  1. inference.py +6 -11
inference.py CHANGED
@@ -37,8 +37,8 @@ from openai import OpenAI
37
 
38
  # Configuration
39
 
40
- API_BASE_URL: Optional[str] = os.environ.get("API_BASE_URL")
41
- MODEL_NAME: Optional[str] = os.environ.get("MODEL_NAME")
42
  HF_TOKEN: Optional[str] = os.environ.get("HF_TOKEN")
43
  ENV_BASE_URL: Optional[str] = os.environ.get("ENV_BASE_URL")
44
  MAX_STEPS: int = int(os.environ.get("MAX_STEPS", "40"))
@@ -418,16 +418,11 @@ def _agent_loop(initial_obs, step_fn, task_id: int, env_type: str) -> float:
418
  def main() -> None:
419
  global llm_client
420
 
421
- # Validate required environment variables before doing anything else.
422
- _missing = [name for name in ("API_BASE_URL", "MODEL_NAME", "HF_TOKEN")
423
- if not os.environ.get(name)]
424
- if _missing:
425
  print(
426
- "ERROR: The following required environment variables are not set:\n"
427
- + "".join(f" {n}\n" for n in _missing)
428
- + "\nSet them before running:\n"
429
- " export API_BASE_URL=https://api-inference.huggingface.co/v1\n"
430
- " export MODEL_NAME=meta-llama/Llama-3.3-70B-Instruct\n"
431
  " export HF_TOKEN=hf_your_token\n"
432
  " python inference.py",
433
  file=sys.stderr,
 
37
 
38
  # Configuration
39
 
40
+ API_BASE_URL: str = os.environ.get("API_BASE_URL", "https://api-inference.huggingface.co/v1")
41
+ MODEL_NAME: str = os.environ.get("MODEL_NAME", "meta-llama/Llama-3.3-70B-Instruct")
42
  HF_TOKEN: Optional[str] = os.environ.get("HF_TOKEN")
43
  ENV_BASE_URL: Optional[str] = os.environ.get("ENV_BASE_URL")
44
  MAX_STEPS: int = int(os.environ.get("MAX_STEPS", "40"))
 
418
  def main() -> None:
419
  global llm_client
420
 
421
+ # HF_TOKEN has no default and is required to authenticate with the LLM endpoint.
422
+ if not HF_TOKEN:
 
 
423
  print(
424
+ "ERROR: HF_TOKEN environment variable is not set.\n"
425
+ "Set it before running:\n"
 
 
 
426
  " export HF_TOKEN=hf_your_token\n"
427
  " python inference.py",
428
  file=sys.stderr,