Tejasva commited on
Commit
d68f67f
·
1 Parent(s): ae190ad

refactor: strict compliance with submission checklist

Browse files
Files changed (2) hide show
  1. env/tasks.py +11 -4
  2. inference.py +7 -4
env/tasks.py CHANGED
@@ -23,11 +23,18 @@ TASKS = [
23
  "task_id": "hard_async_race",
24
  "difficulty": "hard",
25
  "code": """import asyncio
26
- import requests
27
 
28
- async def fetch(url):
29
- data = requests.get(url).json() # no await
30
- return data
 
 
 
 
 
 
 
31
 
32
  class DataCache:
33
  def __init__(self):
 
23
  "task_id": "hard_async_race",
24
  "difficulty": "hard",
25
  "code": """import asyncio
26
+ from openai import OpenAI
27
 
28
+ async def fetch(url, client):
29
+ try:
30
+ response = await client.chat.completions.create(
31
+ model="gpt-3.5-turbo",
32
+ messages=[{"role": "user", "content": f"Fetch data from: {url}"}],
33
+ max_tokens=100
34
+ )
35
+ return {"data": response.choices[0].message.content}
36
+ except Exception as e:
37
+ return {"error": str(e)}
38
 
39
  class DataCache:
40
  def __init__(self):
inference.py CHANGED
@@ -247,8 +247,7 @@ def run_episode(env: CodeGuardianEnv, client: OpenAI, model_name: str, agent_sta
247
  step_type = step_types[current_step]
248
 
249
  step_count += 1
250
- print(f"STEP: {step_type}")
251
- print(f"STEP: {step_count} - {step_type} - task_id={obs.task_id}")
252
  logger.info(f"[STEP] step_number={step_count} step_type={step_type} task_id={obs.task_id}")
253
 
254
  # Create adaptive prompt
@@ -409,8 +408,12 @@ def train_agent(num_episodes: int = 10) -> AgentState:
409
  def main():
410
  """Main inference loop with RL training."""
411
  try:
412
- # Required log at beginning
413
- print("START: inference")
 
 
 
 
414
 
415
  # Run RL training
416
  agent_state = train_agent(num_episodes=10)
 
247
  step_type = step_types[current_step]
248
 
249
  step_count += 1
250
+ print(f"STEP: {step_type} - task_id={obs.task_id}")
 
251
  logger.info(f"[STEP] step_number={step_count} step_type={step_type} task_id={obs.task_id}")
252
 
253
  # Create adaptive prompt
 
408
  def main():
409
  """Main inference loop with RL training."""
410
  try:
411
+ # Optional Docker support
412
+ local_image = os.getenv("LOCAL_IMAGE_NAME")
413
+ if local_image:
414
+ print(f"START: inference (Docker image: {local_image})")
415
+ else:
416
+ print("START: inference")
417
 
418
  # Run RL training
419
  agent_state = train_agent(num_episodes=10)