Spaces:
Running
Running
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- 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
|
| 175 |
-
api_base = os.
|
| 176 |
-
api_key = os.
|
| 177 |
|
| 178 |
-
# Validate β crash with a clear message if the grader didn't inject
|
| 179 |
if not api_base:
|
| 180 |
raise RuntimeError("API_BASE_URL is empty or not set")
|
| 181 |
if not api_key:
|
| 182 |
-
raise RuntimeError("
|
| 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("/"):
|