Nitish commited on
Commit
b24cf4c
Β·
1 Parent(s): 3583511

chore: initialize python virtual environment and dependencies

Browse files
server/__init__.py ADDED
File without changes
app.py β†’ server/app.py RENAMED
@@ -3,7 +3,7 @@ import uvicorn
3
  from fastapi import FastAPI, HTTPException, Query
4
  from fastapi.middleware.cors import CORSMiddleware
5
 
6
- from .models import CodeReviewAction, CodeReviewState, StepResponse, ResetResponse
7
  from .environment import CodeReviewEnvironment
8
 
9
  app = FastAPI(
 
3
  from fastapi import FastAPI, HTTPException, Query
4
  from fastapi.middleware.cors import CORSMiddleware
5
 
6
+ from .server.models import CodeReviewAction, CodeReviewState, StepResponse, ResetResponse
7
  from .environment import CodeReviewEnvironment
8
 
9
  app = FastAPI(
environment.py β†’ server/environment.py RENAMED
@@ -1,15 +1,14 @@
1
  from typing import Dict, Any, Tuple, Optional
2
- from .models import CodeReviewAction, CodeReviewObservation, CodeReviewState
3
 
4
  MAX_STEPS = 3
5
 
6
- # ──────────────────────────────────────────────
7
  # TASK DEFINITIONS
8
- # ──────────────────────────────────────────────
9
 
10
  TASKS: Dict[str, dict] = {
11
 
12
- # ── EASY ─────────────────────────────────
13
  "easy": {
14
  "id": "task_easy_001",
15
  "difficulty": "easy",
@@ -50,7 +49,7 @@ TASKS: Dict[str, dict] = {
50
  },
51
  },
52
 
53
- # ── MEDIUM ────────────────────────────────
54
  "medium": {
55
  "id": "task_medium_001",
56
  "difficulty": "medium",
@@ -148,9 +147,9 @@ TASKS: Dict[str, dict] = {
148
  }
149
 
150
 
151
- # ──────────────────────────────────────────────
152
  # GRADER
153
- # ──────────────────────────────────────────────
154
 
155
  def grade_action(action: CodeReviewAction, task: dict) -> Tuple[float, Dict]:
156
  """
@@ -239,10 +238,8 @@ def grade_action(action: CodeReviewAction, task: dict) -> Tuple[float, Dict]:
239
 
240
  return total, {"breakdown": breakdown, "total_score": total, "feedback": feedback}
241
 
242
-
243
- # ──────────────────────────────────────────────
244
  # ENVIRONMENT
245
- # ──────────────────────────────────────────────
246
 
247
  class CodeReviewEnvironment:
248
  def __init__(self):
@@ -293,7 +290,7 @@ class CodeReviewEnvironment:
293
  )
294
  return self._state
295
 
296
- # ── helpers ───────────────────────────────
297
 
298
  def _build_obs(self, step_number: int, previous_feedback: Optional[str]) -> CodeReviewObservation:
299
  t = self._current_task
@@ -306,4 +303,4 @@ class CodeReviewEnvironment:
306
  step_number=step_number,
307
  max_steps=MAX_STEPS,
308
  previous_feedback=previous_feedback,
309
- )
 
1
  from typing import Dict, Any, Tuple, Optional
2
+ from .server.models import CodeReviewAction, CodeReviewObservation, CodeReviewState
3
 
4
  MAX_STEPS = 3
5
 
 
6
  # TASK DEFINITIONS
7
+
8
 
9
  TASKS: Dict[str, dict] = {
10
 
11
+ # EASY
12
  "easy": {
13
  "id": "task_easy_001",
14
  "difficulty": "easy",
 
49
  },
50
  },
51
 
52
+ #MEDIUM
53
  "medium": {
54
  "id": "task_medium_001",
55
  "difficulty": "medium",
 
147
  }
148
 
149
 
150
+
151
  # GRADER
152
+
153
 
154
  def grade_action(action: CodeReviewAction, task: dict) -> Tuple[float, Dict]:
155
  """
 
238
 
239
  return total, {"breakdown": breakdown, "total_score": total, "feedback": feedback}
240
 
 
 
241
  # ENVIRONMENT
242
+
243
 
244
  class CodeReviewEnvironment:
245
  def __init__(self):
 
290
  )
291
  return self._state
292
 
293
+ # helpers
294
 
295
  def _build_obs(self, step_number: int, previous_feedback: Optional[str]) -> CodeReviewObservation:
296
  t = self._current_task
 
303
  step_number=step_number,
304
  max_steps=MAX_STEPS,
305
  previous_feedback=previous_feedback,
306
+ )
models.py β†’ server/models.py RENAMED
@@ -6,7 +6,7 @@ class CodeReviewAction(BaseModel):
6
  """Action taken by the agent: a structured code review."""
7
  bug_identified: bool = Field(..., description="Whether a bug was found")
8
  bug_location: str = Field(..., description="Location of the bug (function, line, variable)")
9
- bug_type: str = Field(..., description="Type: off-by-one | logic-error | security-vulnerability | none")
10
  bug_description: str = Field(..., description="Detailed explanation of why this is a bug")
11
  severity: str = Field(..., description="Severity: none | low | medium | high | critical")
12
  suggested_fix: str = Field(..., description="The corrected code or a description of how to fix it")
@@ -18,8 +18,8 @@ class CodeReviewObservation(BaseModel):
18
  language: str = Field(..., description="Programming language")
19
  task_description: str = Field(..., description="What the code is supposed to do")
20
  task_id: str = Field(..., description="Unique task identifier")
21
- difficulty: str = Field(..., description="easy | medium | hard")
22
- step_number: int = Field(..., description="Current step within this episode")
23
  max_steps: int = Field(..., description="Maximum steps allowed per episode")
24
  previous_feedback: Optional[str] = Field(None, description="Feedback from previous step if any")
25
 
 
6
  """Action taken by the agent: a structured code review."""
7
  bug_identified: bool = Field(..., description="Whether a bug was found")
8
  bug_location: str = Field(..., description="Location of the bug (function, line, variable)")
9
+ bug_type: str = Field(..., description="Type: off-by-one | logic-error | security-vulnerability | null-dereference | none")
10
  bug_description: str = Field(..., description="Detailed explanation of why this is a bug")
11
  severity: str = Field(..., description="Severity: none | low | medium | high | critical")
12
  suggested_fix: str = Field(..., description="The corrected code or a description of how to fix it")
 
18
  language: str = Field(..., description="Programming language")
19
  task_description: str = Field(..., description="What the code is supposed to do")
20
  task_id: str = Field(..., description="Unique task identifier")
21
+ difficulty: str = Field(..., description="Level: easy | medium | hard")
22
+ step_number: int = Field(..., description="Current step number within this episode")
23
  max_steps: int = Field(..., description="Maximum steps allowed per episode")
24
  previous_feedback: Optional[str] = Field(None, description="Feedback from previous step if any")
25