code-review / README.md
Boobesh007's picture
Upload README.md with huggingface_hub
eb2459b verified
|
Raw History Blame Contribute Delete
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