Spaces:
Running
Running
File size: 1,941 Bytes
abbca25 effb609 abbca25 df58858 6e7ce30 df58858 6e7ce30 df58858 6e7ce30 df58858 6e7ce30 df58858 6e7ce30 df58858 6e7ce30 df58858 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | ---
title: Codereview Env
emoji: 🔥
colorFrom: red
colorTo: green
sdk: docker
sdk_version: "1.0"
app_port: 7860
app_file: app.py
pinned: false
license: mit
short_description: OpenEnv environment for code review tasks.
tags:
- openenv
---
# CodeReviewEnv
A realistic OpenEnv environment where an AI agent performs code review on Python code snippets.
## Real-world utility
Code review is a daily task for software engineers. Automating parts of it can save time and catch bugs early. This environment allows training agents to identify bugs, style issues, security flaws, performance problems, and documentation gaps.
## Action & Observation Spaces
- **Observation**: Contains the source code, step count, and feedback from previous step.
- **Action**: A list of issues (line number, category, description) and a `final` flag to submit.
## Tasks (Easy → Medium → Hard)
| Task | Issues | Description |
|--------|--------|-------------|
| Easy | 2 | Missing zero-division guard and missing docstring |
| Medium | 3 | Logic error (wrong dict key), hardcoded API key, missing type hints |
| Hard | 5 | Race condition, O(n²) anti-pattern, eval() security hole, missing docstrings |
Graders compute F1 score based on exact (line, category) matches.
## Setup
```bash
git clone <your-space-url>
cd codereview-env
docker build -t codereview-env .
docker run -p 7860:7860 codereview-env
```
## Baseline Inference
```bash
export GROQ_API_KEY=your_key
export ENV_URL=http://localhost:7860
python inference.py
```
Expected baseline scores (Llama-3-70B-8192):
- Easy: ~0.95
- Medium: ~0.82
- Hard: ~0.60
## Deploy to HF Spaces
Create a Space with Docker, push this repo, and set environment variables `API_BASE_URL`, `MODEL_NAME`, `HF_TOKEN`.
---
This implementation satisfies all OpenEnv requirements, including real-world utility, varying difficulty, 0.0-1.0 grading, and reproducible baseline inference.
|