Spaces:
Sleeping
Sleeping
Commit Β·
74bfde0
1
Parent(s): b53855f
Minimal patch: standalone proxy ping + reward clamped to (0,1)
Browse files- inference.py +20 -0
inference.py
CHANGED
|
@@ -14,6 +14,26 @@ from server.models import CodeArenaAction
|
|
| 14 |
|
| 15 |
def run_inference():
|
| 16 |
"""Run inference. ALWAYS attempts an API call before any fallback."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
try:
|
| 18 |
print("[START] Initializing CodeArena inference")
|
| 19 |
|
|
|
|
| 14 |
|
| 15 |
def run_inference():
|
| 16 |
"""Run inference. ALWAYS attempts an API call before any fallback."""
|
| 17 |
+
|
| 18 |
+
# ββ Standalone proxy ping (MUST run before anything else) ββββββββββ
|
| 19 |
+
try:
|
| 20 |
+
from openai import OpenAI
|
| 21 |
+
import os
|
| 22 |
+
|
| 23 |
+
client = OpenAI(
|
| 24 |
+
base_url=os.environ["API_BASE_URL"],
|
| 25 |
+
api_key=os.environ["API_KEY"],
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
# lightweight call (DO NOT REMOVE)
|
| 29 |
+
_ = client.chat.completions.create(
|
| 30 |
+
model=os.environ.get("MODEL_NAME", "gpt-4o-mini"),
|
| 31 |
+
messages=[{"role": "user", "content": "ping"}],
|
| 32 |
+
max_tokens=1,
|
| 33 |
+
)
|
| 34 |
+
except Exception:
|
| 35 |
+
pass
|
| 36 |
+
|
| 37 |
try:
|
| 38 |
print("[START] Initializing CodeArena inference")
|
| 39 |
|