Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- inference.py +4 -1
- server/rust_coder_environment.py +2 -2
inference.py
CHANGED
|
@@ -56,7 +56,10 @@ async def get_model_code(prompt: str, client: OpenAI) -> str:
|
|
| 56 |
text = text.split("```rust")[1].split("```")[0]
|
| 57 |
elif "```" in text:
|
| 58 |
text = text.split("```")[1].split("```")[0]
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
| 60 |
except Exception as e:
|
| 61 |
print(f"[DEBUG] LLM Request failed: {e}", flush=True)
|
| 62 |
return f"// Error: {e}"
|
|
|
|
| 56 |
text = text.split("```rust")[1].split("```")[0]
|
| 57 |
elif "```" in text:
|
| 58 |
text = text.split("```")[1].split("```")[0]
|
| 59 |
+
text = text.strip()
|
| 60 |
+
if not text:
|
| 61 |
+
return "// Error: empty response (no code returned)."
|
| 62 |
+
return text
|
| 63 |
except Exception as e:
|
| 64 |
print(f"[DEBUG] LLM Request failed: {e}", flush=True)
|
| 65 |
return f"// Error: {e}"
|
server/rust_coder_environment.py
CHANGED
|
@@ -102,7 +102,7 @@ class RustCoderEnvironment(Environment):
|
|
| 102 |
|
| 103 |
return RustCoderObservation(
|
| 104 |
problem_description=problem["description"],
|
| 105 |
-
starter_code=problem
|
| 106 |
compilation_success=False,
|
| 107 |
compilation_output="",
|
| 108 |
test_results=[],
|
|
@@ -195,7 +195,7 @@ class RustCoderEnvironment(Environment):
|
|
| 195 |
if not done:
|
| 196 |
next_prob = self.problems[self.current_problem_idx]
|
| 197 |
next_prob_desc = f"--- NEXT TASK: {next_prob['title']} ---\n\n{next_prob['description']}"
|
| 198 |
-
next_starter = next_prob
|
| 199 |
|
| 200 |
return RustCoderObservation(
|
| 201 |
problem_description=next_prob_desc,
|
|
|
|
| 102 |
|
| 103 |
return RustCoderObservation(
|
| 104 |
problem_description=problem["description"],
|
| 105 |
+
starter_code=problem.get("starter_code", ""),
|
| 106 |
compilation_success=False,
|
| 107 |
compilation_output="",
|
| 108 |
test_results=[],
|
|
|
|
| 195 |
if not done:
|
| 196 |
next_prob = self.problems[self.current_problem_idx]
|
| 197 |
next_prob_desc = f"--- NEXT TASK: {next_prob['title']} ---\n\n{next_prob['description']}"
|
| 198 |
+
next_starter = next_prob.get("starter_code", "")
|
| 199 |
|
| 200 |
return RustCoderObservation(
|
| 201 |
problem_description=next_prob_desc,
|