Spaces:
Running
Running
|
Download README.md from Boobesh007/code-review: direct link, hf CLI and curl.
- Browser
- Download file 4.17 kB
-
https://huggingface.co/spaces/Boobesh007/code-review/resolve/main/README.md
- Command line
-
hf download hf://spaces/Boobesh007/code-review/README.md
-
curl -L -o README.md https://huggingface.co/spaces/Boobesh007/code-review/resolve/main/README.md
4.17 kB
metadata
title: AI Code Review Environment
emoji: ๐ป
colorFrom: blue
colorTo: green
sdk: docker
pinned: false
tags:
- openenv
- code-review
- reinforcement-learning
- ai-agent
๐ป AI Code Review Environment
A production-grade OpenEnv environment where AI agents learn to review code like senior software engineers.
๐ฏ Overview
This environment simulates real-world code review โ one of the most critical tasks in software engineering. An AI agent is presented with code snippets and must identify bugs, security vulnerabilities, and quality issues across multiple programming languages.
This is not a toy problem. Code review is a skill that takes years for humans to master. This environment provides a structured way to train and evaluate AI agents on this task.
๐ Supported Languages
| Language | Coverage |
|---|---|
| Python ๐ | Syntax, quality, security, bugs |
| JavaScript ๐ | Security, quality, best practices |
| Java โ | Null safety, resource management |
๐ Task Difficulty Levels
๐ข Easy โ Syntax Detection
Agent must identify basic syntax errors.
- Missing colons, brackets, parentheses
- Baseline score: 0.85
๐ก Medium โ Code Quality
Agent must identify quality issues.
- Poor naming, too many parameters
- Functions doing too many things
- Baseline score: 0.65
๐ด Hard โ Security & Bugs
Agent must identify critical issues.
- SQL injection vulnerabilities
- Hardcoded passwords
- Division by zero
- Null pointer exceptions
- No error handling
- Baseline score: 0.45
๐ฎ Action Space
| Field | Type | Range | Description |
|---|---|---|---|
| has_syntax_error | bool | true/false | Does code have syntax errors? |
| quality_score | float | 0.01-0.99 | Overall code quality |
| issues | list | 1-5 items | List of issues found |
| severity | str | low/medium/high | Overall severity |
๐๏ธ Observation Space
| Field | Type | Description |
|---|---|---|
| code_snippet | str | Code to review |
| language | str | Programming language |
| task_type | str | easy/medium/hard |
| task_description | str | What to look for |
| score | float | Score for last action |
| feedback | str | Detailed feedback |
| episode_step | int | Current step number |
๐ Reward Function
| Correct Action | Reward |
|---|---|
| Syntax detection | +0.30 |
| Severity assessment | +0.20 |
| Issues identified | +0.50 |
| Maximum per step | 0.99 |
| Minimum per step | 0.01 |
๐ Baseline Results
| Task | Baseline Score | Difficulty |
|---|---|---|
| Easy | 0.85 | Beginner |
| Medium | 0.65 | Intermediate |
| Hard | 0.45 | Expert |
| Average | 0.65 | - |
๐ API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /reset | Start new episode |
| POST | /step | Execute action |
| GET | /state | Get current state |
| GET | /schema | Get action/observation schemas |
| GET | /health | Health check |
| GET | /docs | Swagger UI |
๐ ๏ธ Setup & Installation
pip install openenv-core
openenv init code_review
uvicorn server.app:app --host 0.0.0.0 --port 7860
๐ค Example Agent Interaction
import requests
# Reset environment
obs = requests.post('https://boobesh007-code-review.hf.space/reset').json()
# Take action
action = {
'has_syntax_error': True,
'quality_score': 0.8,
'issues': ['missing colon after function definition'],
'severity': 'high'
}
result = requests.post('https://boobesh007-code-review.hf.space/step', json=action).json()
print(result['reward'])
๐ Project Structure
code_review/
โโโ models.py # Action and Observation models
โโโ inference.py # Baseline inference script
โโโ server/
โ โโโ app.py # FastAPI application
โ โโโ code_review_environment.py # Environment logic
โโโ Dockerfile # Container configuration
โโโ README.md # Documentation
๐จโ๐ป Built With
Python 3.11
FastAPI
OpenEnv Core
Pydantic
Docker
Hugging Face Spaces
๐ License
BSD-3-Clause