shank commited on
Commit ·
212d2d9
1
Parent(s): cd968e7
Update: Dockerfile and inference.py
Browse files- Dockerfile +1 -1
- inference.py +5 -5
Dockerfile
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
FROM python:3.10-slim
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
|
|
|
| 1 |
+
FROM python:3.10.14-slim-bookworm
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
inference.py
CHANGED
|
@@ -82,7 +82,7 @@ def get_completion(messages: list, model: str = MODEL_NAME, max_retries: int = 5
|
|
| 82 |
return completion.choices[0].message.content
|
| 83 |
except (RateLimitError, APIConnectionError, APITimeoutError) as e:
|
| 84 |
if attempt == max_retries - 1:
|
| 85 |
-
|
| 86 |
wait_time = (2 ** attempt) + random.random()
|
| 87 |
print(f" [!] API Error ({type(e).__name__}). Retrying in {wait_time:.1f}s... (Attempt {attempt+1}/{max_retries})")
|
| 88 |
time.sleep(wait_time)
|
|
@@ -90,11 +90,11 @@ def get_completion(messages: list, model: str = MODEL_NAME, max_retries: int = 5
|
|
| 90 |
# For general API errors, log and potentially retry if it's a 5xx
|
| 91 |
print(f" [!] OpenAI API Error: {e}")
|
| 92 |
if attempt == max_retries - 1:
|
| 93 |
-
|
| 94 |
time.sleep(2)
|
| 95 |
except Exception as e:
|
| 96 |
print(f" [!] Unexpected error during completion: {e}")
|
| 97 |
-
|
| 98 |
return ""
|
| 99 |
|
| 100 |
|
|
@@ -166,7 +166,7 @@ def run_episode(task_id: str) -> dict:
|
|
| 166 |
"""Run one complete debugging episode. Returns result dict."""
|
| 167 |
|
| 168 |
# Reset environment
|
| 169 |
-
reset_resp = requests.post(f"{ENV_BASE_URL}/reset", json={"task_id": task_id})
|
| 170 |
reset_resp.raise_for_status()
|
| 171 |
obs = reset_resp.json()
|
| 172 |
|
|
@@ -201,7 +201,7 @@ def run_episode(task_id: str) -> dict:
|
|
| 201 |
raw = json.dumps(action)
|
| 202 |
|
| 203 |
# Submit action to environment
|
| 204 |
-
step_resp = requests.post(f"{ENV_BASE_URL}/step", json=action)
|
| 205 |
step_resp.raise_for_status()
|
| 206 |
result = step_resp.json()
|
| 207 |
|
|
|
|
| 82 |
return completion.choices[0].message.content
|
| 83 |
except (RateLimitError, APIConnectionError, APITimeoutError) as e:
|
| 84 |
if attempt == max_retries - 1:
|
| 85 |
+
return ""
|
| 86 |
wait_time = (2 ** attempt) + random.random()
|
| 87 |
print(f" [!] API Error ({type(e).__name__}). Retrying in {wait_time:.1f}s... (Attempt {attempt+1}/{max_retries})")
|
| 88 |
time.sleep(wait_time)
|
|
|
|
| 90 |
# For general API errors, log and potentially retry if it's a 5xx
|
| 91 |
print(f" [!] OpenAI API Error: {e}")
|
| 92 |
if attempt == max_retries - 1:
|
| 93 |
+
return ""
|
| 94 |
time.sleep(2)
|
| 95 |
except Exception as e:
|
| 96 |
print(f" [!] Unexpected error during completion: {e}")
|
| 97 |
+
return ""
|
| 98 |
return ""
|
| 99 |
|
| 100 |
|
|
|
|
| 166 |
"""Run one complete debugging episode. Returns result dict."""
|
| 167 |
|
| 168 |
# Reset environment
|
| 169 |
+
reset_resp = requests.post(f"{ENV_BASE_URL}/reset", json={"task_id": task_id}, timeout=60)
|
| 170 |
reset_resp.raise_for_status()
|
| 171 |
obs = reset_resp.json()
|
| 172 |
|
|
|
|
| 201 |
raw = json.dumps(action)
|
| 202 |
|
| 203 |
# Submit action to environment
|
| 204 |
+
step_resp = requests.post(f"{ENV_BASE_URL}/step", json=action, timeout=60)
|
| 205 |
step_resp.raise_for_status()
|
| 206 |
result = step_resp.json()
|
| 207 |
|