Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files
server/rust_coder_environment.py
CHANGED
|
@@ -160,7 +160,10 @@ class RustCoderEnvironment(Environment):
|
|
| 160 |
if not code.strip():
|
| 161 |
# Some UIs may "step" without providing an action payload.
|
| 162 |
# Optionally auto-generate code via LLM so the UI can still progress.
|
| 163 |
-
|
|
|
|
|
|
|
|
|
|
| 164 |
if auto_llm:
|
| 165 |
model = os.getenv("MODEL_NAME") or "Qwen/Qwen2.5-72B-Instruct"
|
| 166 |
base_url = os.getenv("API_BASE_URL") or "https://router.huggingface.co/v1"
|
|
@@ -176,6 +179,13 @@ class RustCoderEnvironment(Environment):
|
|
| 176 |
"AUTO_LLM_ON_EMPTY_STEP enabled; attempting LLM generation",
|
| 177 |
{"model": model, "base_url": base_url, "prompt_chars": len(prompt), "token_present": bool(token)},
|
| 178 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
|
| 180 |
if not token:
|
| 181 |
self._logger.error("AUTO_LLM_ON_EMPTY_STEP enabled but HF_TOKEN/API_KEY missing.")
|
|
@@ -219,6 +229,7 @@ class RustCoderEnvironment(Environment):
|
|
| 219 |
"LLM produced non-empty code; continuing evaluation",
|
| 220 |
{"code_chars": len(code)},
|
| 221 |
)
|
|
|
|
| 222 |
else:
|
| 223 |
self._dbg(
|
| 224 |
"H5",
|
|
@@ -226,6 +237,7 @@ class RustCoderEnvironment(Environment):
|
|
| 226 |
"LLM returned empty after cleanup; falling back to empty submission behavior",
|
| 227 |
{"raw_chars": len((completion.choices[0].message.content or ""))},
|
| 228 |
)
|
|
|
|
| 229 |
except Exception as e:
|
| 230 |
self._dbg(
|
| 231 |
"H5",
|
|
@@ -233,6 +245,7 @@ class RustCoderEnvironment(Environment):
|
|
| 233 |
"LLM call failed; falling back to empty submission behavior",
|
| 234 |
{"error": str(e)},
|
| 235 |
)
|
|
|
|
| 236 |
|
| 237 |
if not code.strip():
|
| 238 |
# Invalid/empty submission: do not advance the problem index.
|
|
|
|
| 160 |
if not code.strip():
|
| 161 |
# Some UIs may "step" without providing an action payload.
|
| 162 |
# Optionally auto-generate code via LLM so the UI can still progress.
|
| 163 |
+
# Default ON (because the hosted UI "Step" provides no code).
|
| 164 |
+
# To disable: set AUTO_LLM_ON_EMPTY_STEP=0/false/no.
|
| 165 |
+
auto_llm_cfg = (os.getenv("AUTO_LLM_ON_EMPTY_STEP") or "1").strip().lower()
|
| 166 |
+
auto_llm = auto_llm_cfg not in {"0", "false", "no", "n", "off"}
|
| 167 |
if auto_llm:
|
| 168 |
model = os.getenv("MODEL_NAME") or "Qwen/Qwen2.5-72B-Instruct"
|
| 169 |
base_url = os.getenv("API_BASE_URL") or "https://router.huggingface.co/v1"
|
|
|
|
| 179 |
"AUTO_LLM_ON_EMPTY_STEP enabled; attempting LLM generation",
|
| 180 |
{"model": model, "base_url": base_url, "prompt_chars": len(prompt), "token_present": bool(token)},
|
| 181 |
)
|
| 182 |
+
self._logger.info(
|
| 183 |
+
"Auto-LLM on empty step: model=%s base_url=%s prompt_chars=%d token_present=%s",
|
| 184 |
+
model,
|
| 185 |
+
base_url,
|
| 186 |
+
len(prompt),
|
| 187 |
+
bool(token),
|
| 188 |
+
)
|
| 189 |
|
| 190 |
if not token:
|
| 191 |
self._logger.error("AUTO_LLM_ON_EMPTY_STEP enabled but HF_TOKEN/API_KEY missing.")
|
|
|
|
| 229 |
"LLM produced non-empty code; continuing evaluation",
|
| 230 |
{"code_chars": len(code)},
|
| 231 |
)
|
| 232 |
+
self._logger.info("Auto-LLM generated code chars=%d", len(code))
|
| 233 |
else:
|
| 234 |
self._dbg(
|
| 235 |
"H5",
|
|
|
|
| 237 |
"LLM returned empty after cleanup; falling back to empty submission behavior",
|
| 238 |
{"raw_chars": len((completion.choices[0].message.content or ""))},
|
| 239 |
)
|
| 240 |
+
self._logger.warning("Auto-LLM returned empty after cleanup.")
|
| 241 |
except Exception as e:
|
| 242 |
self._dbg(
|
| 243 |
"H5",
|
|
|
|
| 245 |
"LLM call failed; falling back to empty submission behavior",
|
| 246 |
{"error": str(e)},
|
| 247 |
)
|
| 248 |
+
self._logger.exception("Auto-LLM call failed.")
|
| 249 |
|
| 250 |
if not code.strip():
|
| 251 |
# Invalid/empty submission: do not advance the problem index.
|