Spaces:
Sleeping
Sleeping
Commit ·
6dd9f4f
1
Parent(s): 6e8ba4d
Cursor fix
Browse files- inference.py +12 -31
inference.py
CHANGED
|
@@ -30,9 +30,9 @@ from models import (
|
|
| 30 |
dump_model,
|
| 31 |
)
|
| 32 |
|
| 33 |
-
API_BASE_URL = os.
|
| 34 |
-
MODEL_NAME = os.
|
| 35 |
-
HF_TOKEN = os.
|
| 36 |
|
| 37 |
BENCHMARK = "store"
|
| 38 |
|
|
@@ -64,13 +64,7 @@ ENV_URL = os.environ.get("ENV_URL", "http://localhost:8000")
|
|
| 64 |
|
| 65 |
|
| 66 |
def log_start(*, task: str, env: str, model: str) -> None:
|
| 67 |
-
print(
|
| 68 |
-
json.dumps(
|
| 69 |
-
{"type": "START", "task": task, "env": env, "model": model},
|
| 70 |
-
separators=(",", ":"),
|
| 71 |
-
),
|
| 72 |
-
flush=True,
|
| 73 |
-
)
|
| 74 |
|
| 75 |
|
| 76 |
def log_step(
|
|
@@ -81,18 +75,11 @@ def log_step(
|
|
| 81 |
done: bool,
|
| 82 |
error: str | None,
|
| 83 |
) -> None:
|
|
|
|
|
|
|
| 84 |
print(
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
"type": "STEP",
|
| 88 |
-
"step": step,
|
| 89 |
-
"action": action,
|
| 90 |
-
"reward": reward,
|
| 91 |
-
"done": done,
|
| 92 |
-
"error": error,
|
| 93 |
-
},
|
| 94 |
-
separators=(",", ":"),
|
| 95 |
-
),
|
| 96 |
flush=True,
|
| 97 |
)
|
| 98 |
|
|
@@ -104,17 +91,11 @@ def log_end(
|
|
| 104 |
score: float,
|
| 105 |
rewards: list[float],
|
| 106 |
) -> None:
|
|
|
|
|
|
|
| 107 |
print(
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
"type": "END",
|
| 111 |
-
"success": success,
|
| 112 |
-
"steps": steps,
|
| 113 |
-
"score": score,
|
| 114 |
-
"rewards": rewards,
|
| 115 |
-
},
|
| 116 |
-
separators=(",", ":"),
|
| 117 |
-
),
|
| 118 |
flush=True,
|
| 119 |
)
|
| 120 |
|
|
|
|
| 30 |
dump_model,
|
| 31 |
)
|
| 32 |
|
| 33 |
+
API_BASE_URL = os.getenv("API_BASE_URL", "https://router.huggingface.co/v1")
|
| 34 |
+
MODEL_NAME = os.getenv("MODEL_NAME", "Qwen/Qwen3.5-397B-A17B")
|
| 35 |
+
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 36 |
|
| 37 |
BENCHMARK = "store"
|
| 38 |
|
|
|
|
| 64 |
|
| 65 |
|
| 66 |
def log_start(*, task: str, env: str, model: str) -> None:
|
| 67 |
+
print(f"[START] task={task} env={env} model={model}", flush=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
|
| 70 |
def log_step(
|
|
|
|
| 75 |
done: bool,
|
| 76 |
error: str | None,
|
| 77 |
) -> None:
|
| 78 |
+
done_str = "true" if done else "false"
|
| 79 |
+
error_str = error if error else "null"
|
| 80 |
print(
|
| 81 |
+
f"[STEP] step={step} action={action} reward={reward:.2f} "
|
| 82 |
+
f"done={done_str} error={error_str}",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
flush=True,
|
| 84 |
)
|
| 85 |
|
|
|
|
| 91 |
score: float,
|
| 92 |
rewards: list[float],
|
| 93 |
) -> None:
|
| 94 |
+
success_str = "true" if success else "false"
|
| 95 |
+
rewards_str = ",".join(f"{r:.2f}" for r in rewards)
|
| 96 |
print(
|
| 97 |
+
f"[END] success={success_str} steps={steps} score={score:.2f} "
|
| 98 |
+
f"rewards={rewards_str}",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
flush=True,
|
| 100 |
)
|
| 101 |
|