Spaces:
Sleeping
Sleeping
sync inference.py with HF_TOKEN mandatory check
Browse files- inference.py +5 -5
inference.py
CHANGED
|
@@ -95,10 +95,10 @@ def log_step(step: int, action: str, reward: float, done: bool, error: Optional[
|
|
| 95 |
)
|
| 96 |
|
| 97 |
|
| 98 |
-
def log_end(success: bool, steps: int,
|
| 99 |
rewards_str = ",".join(f"{r:.2f}" for r in rewards)
|
| 100 |
print(
|
| 101 |
-
f"[END] success={str(success).lower()} steps={steps}
|
| 102 |
flush=True,
|
| 103 |
)
|
| 104 |
|
|
@@ -222,7 +222,7 @@ def run_task(env: RedVeilEnvironment, client: OpenAI, task_id: str) -> dict:
|
|
| 222 |
score = min(max(score, 0.0), 1.0)
|
| 223 |
success = score > 0.0
|
| 224 |
|
| 225 |
-
log_end(success=success, steps=step_num,
|
| 226 |
|
| 227 |
return {
|
| 228 |
"task_id": task_id,
|
|
@@ -237,9 +237,9 @@ def run_task(env: RedVeilEnvironment, client: OpenAI, task_id: str) -> dict:
|
|
| 237 |
|
| 238 |
def main():
|
| 239 |
if not API_KEY:
|
| 240 |
-
|
| 241 |
|
| 242 |
-
client = OpenAI(base_url=API_BASE_URL, api_key=API_KEY
|
| 243 |
|
| 244 |
env = RedVeilEnvironment()
|
| 245 |
|
|
|
|
| 95 |
)
|
| 96 |
|
| 97 |
|
| 98 |
+
def log_end(success: bool, steps: int, rewards: List[float]) -> None:
|
| 99 |
rewards_str = ",".join(f"{r:.2f}" for r in rewards)
|
| 100 |
print(
|
| 101 |
+
f"[END] success={str(success).lower()} steps={steps} rewards={rewards_str}",
|
| 102 |
flush=True,
|
| 103 |
)
|
| 104 |
|
|
|
|
| 222 |
score = min(max(score, 0.0), 1.0)
|
| 223 |
success = score > 0.0
|
| 224 |
|
| 225 |
+
log_end(success=success, steps=step_num, rewards=rewards)
|
| 226 |
|
| 227 |
return {
|
| 228 |
"task_id": task_id,
|
|
|
|
| 237 |
|
| 238 |
def main():
|
| 239 |
if not API_KEY:
|
| 240 |
+
raise ValueError("HF_TOKEN environment variable is required")
|
| 241 |
|
| 242 |
+
client = OpenAI(base_url=API_BASE_URL, api_key=API_KEY)
|
| 243 |
|
| 244 |
env = RedVeilEnvironment()
|
| 245 |
|