# AI_OJ **Repository Path**: wang-guangke/ai_-oj ## Basic Information - **Project Name**: AI_OJ - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-03-26 - **Last Updated**: 2026-03-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ๐ŸŒŒ Smart OJ โ€” AI-Powered Dispatch Platform > Multi-Agent Collaboration ยท Physical Sandbox Isolation ยท Real-Time Algorithm Reasoning ## Introduction **Smart OJ** is an intelligent programming assistant platform powered by large language models. It adopts a Multi-Agent collaborative architecture and supports two core working modes: - **Algorithm OJ Tutoring Mode**: Users submit their own code. An AI algorithm tutor reviews and annotates mistakes, then a coding agent rewrites the solution. The result is validated in a sandboxed environment and a high-quality Release version is produced. - **Custom Function Mode**: Users describe their requirements. The system automatically handles the full pipeline: requirement decomposition โ†’ code writing โ†’ security review โ†’ sandbox testing. All code is executed inside **Docker physically-isolated sandboxes**, completely preventing malicious code from harming the host machine. --- ## Architecture This project is built on [LangGraph](https://github.com/langchain-ai/langgraph) as a star-topology multi-agent dispatch network. All agents report back to the **Supervisor**, which dynamically routes tasks based on global state, forming a closed-loop iteration. ``` User Request โ”‚ โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Supervisor โ”‚ โ† Global state machine, dynamic routing โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ–ผ โ–ผ โ–ผ โ–ผ โ–ผ Planner Coder Reviewer Tester Tutor ``` ### Agent Responsibilities | Agent | Responsibility | |-------|----------------| | **Supervisor** | Project manager; reads global state and decides the next node | | **Planner** | Architect; decomposes user requirements into executable steps | | **Coder** | Developer; writes code from scratch or fixes bugs based on feedback | | **Reviewer** | Security auditor; blocks dangerous or malicious code | | **Tester** | Sandbox evaluator; injects code into Docker and returns test reports | | **Tutor** | Algorithm tutor; reviews student code and provides in-depth analysis | ### Supported Languages - Python - C++ (compiled with g++) - Java (compiled with javac) --- ## Tech Stack | Category | Technology | |----------|------------| | Frontend | [Streamlit](https://streamlit.io) + streamlit-antd-components | | AI Framework | [LangChain](https://www.langchain.com) + [LangGraph](https://github.com/langchain-ai/langgraph) | | LLM | Anthropic Claude (claude-sonnet) | | Code Sandbox | Docker physically-isolated containers | | Tracing | LangSmith (auto-activated via `.env`) | --- ## Deployment ### 1. Requirements - Python 3.10+ - Docker (installed and running, required for sandbox execution) - Anthropic API Key or compatible proxy ### 2. Clone the Repository ```bash git clone https://gitee.com/wang-guangke/ai_-oj.git cd ai_-oj ``` ### 3. Install Dependencies ```bash pip install -r requirements.txt ``` ### 4. Configure Environment Variables Create a `.env` file in the project root: ```env # Anthropic API ANTHROPIC_API_KEY=your_api_key_here ANTHROPIC_BASE_URL=https://api.anthropic.com # LangSmith tracing (optional) LANGSMITH_API_KEY=your_langsmith_key LANGSMITH_PROJECT=AI_OJ LANGCHAIN_TRACING_V2=true ``` ### 5. Start the Application ```bash streamlit run app.py ``` Open your browser and visit `http://localhost:8501`. --- ## Usage 1. **Select Mode**: Choose "Algorithm OJ Tutoring" or "Custom Function" mode in the left panel. 2. **Describe Requirements**: Enter the problem description or feature requirements and select a target language (Python / C++ / Java). 3. **(OJ Mode) Paste Your Code**: Paste your original code into the input box for the AI tutor to review. 4. **Provide Test Cases** (optional): Add input/output samples; the system will combine them with AI-generated edge cases for testing. 5. **Submit**: Click "Start". The real-time terminal on the right shows each agent's execution logs. 6. **View Results**: After completion, the final Release code and tutor analysis are saved to the "Knowledge History" section at the bottom. --- ## Project Structure ``` AI_OJ/ โ”œโ”€โ”€ app.py # Streamlit entry point, UI and event handling โ”œโ”€โ”€ requirements.txt # Python dependencies โ”œโ”€โ”€ core/ โ”‚ โ”œโ”€โ”€ graph.py # LangGraph multi-agent network build & compile โ”‚ โ”œโ”€โ”€ state.py # Global state schema (AIOJState) โ”‚ โ””โ”€โ”€ agents/ โ”‚ โ”œโ”€โ”€ supervisor.py # Dispatch brain โ”‚ โ”œโ”€โ”€ planner.py # Architecture planning โ”‚ โ”œโ”€โ”€ coder.py # Code writing & bug fixing โ”‚ โ”œโ”€โ”€ reviewer.py # Security code review โ”‚ โ””โ”€โ”€ tutor.py # Algorithm tutoring โ”œโ”€โ”€ sandbox/ โ”‚ โ”œโ”€โ”€ executor.py # Sandbox orchestrator node โ”‚ โ””โ”€โ”€ runners/ โ”‚ โ”œโ”€โ”€ python_runner.py โ”‚ โ”œโ”€โ”€ cpp_runner.py โ”‚ โ””โ”€โ”€ java_runner.py โ””โ”€โ”€ tools/ โ”œโ”€โ”€ rag_engine.py # RAG knowledge retrieval engine โ””โ”€โ”€ tool_registry.py # Tool registry ``` --- ## Contributing 1. Fork this repository 2. Create a new branch `feat/your-feature` 3. Commit your changes 4. Open a Pull Request --- ## License MIT License