AI-Powered Code Review with Chinese LLMs

Automate code quality checks using DeepSeek, GLM, and Qwen for smarter, faster reviews

Code Review AI Tools Developer Productivity 2026
August 15, 2026 • 14 min read • By TokenEase Engineering

Manual code reviews are a bottleneck in modern software development. Teams spend hours reviewing pull requests, often catching only a fraction of potential issues. AI-powered code review tools, built on Chinese LLMs like DeepSeek, GLM-4, and Qwen, are transforming this process, offering automated feedback on code quality, security, performance, and style in seconds.

In this guide, we explore how to build and integrate AI code review systems using Chinese LLMs, compare their performance on code-related tasks, and provide production-ready implementation patterns.

Why Chinese LLMs for Code Review?
Chinese LLMs now match or exceed GPT-4 on code benchmarks like HumanEval and MBPP, while costing 60-80% less per token. DeepSeek-Coder-V2 scores 90.2% on HumanEval, making it ideal for automated code analysis.

1. Code Review LLM Comparison

Not all LLMs excel at code analysis. Here is how the top Chinese models perform on code review tasks:

Model HumanEval Code Review Score Context Window Price (per 1M tokens)
DeepSeek-Coder-V2 90.2% 9.2/10 128K $0.14
Qwen2.5-Coder-32B 85.1% 8.8/10 128K $0.20
GLM-4-9B-Chat 78.5% 8.3/10 128K $0.06
Kimi K2.5 82.3% 8.5/10 256K $0.50

Recommendation: Use DeepSeek-Coder-V2 for complex code analysis and refactoring suggestions. Use GLM-4 for lightweight, cost-effective reviews. Use Kimi K2.5 when reviewing large files or entire modules (leveraging its 256K context).

2. Building an AI Code Review Pipeline

A production-ready AI code review system has four stages: diff extraction, prompt engineering, LLM analysis, and result formatting. Here is a complete implementation:

2.1 Extract Code Diff

import subprocess import re def get_pr_diff(repo_path, base_branch="main"): """Extract code diff for the current branch.""" result = subprocess.run( ["git", "diff", f"origin/{base_branch}...HEAD"], cwd=repo_path, capture_output=True, text=True ) return result.stdout def parse_diff_files(diff_text): """Parse diff into individual file changes.""" files = [] current_file = None current_content = [] for line in diff_text.split('\n'): if line.startswith('diff --git'): if current_file: files.append({"file": current_file, "diff": '\n'.join(current_content)}) match = re.search(r'b/(.+)$', line) current_file = match.group(1) if match else "unknown" current_content = [] elif current_file is not None: current_content.append(line) if current_file: files.append({"file": current_file, "diff": '\n'.join(current_content)}) return files

2.2 Build the Review Prompt

def build_review_prompt(file_diff, file_path, language_hint=""): """Construct a structured prompt for code review.""" prompt = f"""You are an expert code reviewer. Review the following code changes and provide structured feedback. File: {file_path} Language: {language_hint or 'auto-detect'} Code Changes: ``` {file_diff} ``` Please analyze and provide feedback in the following categories: 1. BUGS: Identify any logical errors, null pointer risks, or potential crashes 2. SECURITY: Flag SQL injection, XSS, path traversal, hardcoded secrets, insecure deserialization 3. PERFORMANCE: Highlight inefficient algorithms, unnecessary database queries, memory leaks 4. STYLE: Note deviations from standard conventions (PEP8, Google Style, etc.) 5. MAINTAINABILITY: Comment on code readability, function length, coupling, test coverage For each issue found, provide: - Severity: CRITICAL | HIGH | MEDIUM | LOW - Line reference (if applicable) - Description of the issue - Suggested fix or improvement If no issues are found in a category, state "No issues detected." Format your response as structured JSON.""" return prompt

2.3 Call the LLM API

import requests import json import os def review_code_with_llm(prompt, model="deepseek-coder"): """Send code to LLM for review via TokenEase unified API.""" api_key = os.getenv("TOKEN_EASE_API_KEY") response = requests.post( "https://tokenease.io/v1/chat/completions", headers={ "Authorization": f"Bearer {api_key}", "Content-Type": "application/json" }, json={ "model": model, "messages": [ {"role": "system", "content": "You are an expert software engineer and code reviewer."}, {"role": "user", "content": prompt} ], "temperature": 0.1, "max_tokens": 4000, "response_format": {"type": "json_object"} }, timeout=60 ) if response.status_code == 200: result = response.json() content = result["choices"][0]["message"]["content"] return json.loads(content) else: raise Exception(f"API error: {response.status_code} - {response.text}")

2.4 Format and Display Results

def format_review_results(review_json, file_path): """Format LLM review output for display or PR comments.""" output = [f"## AI Code Review: {file_path}\n"] categories = ["BUGS", "SECURITY", "PERFORMANCE", "STYLE", "MAINTAINABILITY"] total_issues = 0 for category in categories: issues = review_json.get(category, []) if isinstance(issues, str) and "No issues" in issues: output.append(f"### {category}: Clean") continue if not isinstance(issues, list): issues = [issues] critical_count = sum(1 for i in issues if isinstance(i, dict) and i.get("severity") == "CRITICAL") output.append(f"### {category}: {len(issues)} issue(s)" + (f" ({critical_count} CRITICAL)" if critical_count else "")) for issue in issues: if isinstance(issue, dict): severity = issue.get("severity", "MEDIUM") line = issue.get("line_reference", "N/A") desc = issue.get("description", "No description") fix = issue.get("suggested_fix", "") emoji = {"CRITICAL": "🔴", "HIGH": "🟠", "MEDIUM": "🟡", "LOW": "🔵"}.get(severity, "⚪") output.append(f"{emoji} **{severity}** (Line {line}): {desc}") if fix: output.append(f" 💡 Suggestion: {fix}") total_issues += 1 output.append("") output.append(f"\n**Summary: {total_issues} total issue(s) found.**") return '\n'.join(output)

3. GitHub/GitLab Integration

For automated PR reviews, integrate the AI reviewer into your CI/CD pipeline. Here is a GitHub Actions workflow:

name: AI Code Review on: pull_request: types: [opened, synchronize] jobs: ai-review: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.11' - name: Install dependencies run: pip install requests - name: Run AI Code Review env: TOKEN_EASE_API_KEY: ${{ secrets.TOKEN_EASE_API_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: python scripts/ai_review.py

4. Prompt Engineering for Better Reviews

The quality of AI code reviews depends heavily on prompt design. Here are proven techniques:

Technique Description Impact
Few-shot examples Include 2-3 examples of good vs. bad code with explanations +25% issue detection
Structured output (JSON) Force JSON format with specific fields +40% parse reliability
Context windowing Include surrounding function/class context, not just changed lines +30% accuracy
Temperature tuning Use temperature=0.1 for consistent, deterministic output +15% consistency
Role prompting Assign specific expertise (e.g., "security specialist") +20% domain accuracy

5. Handling Large Files and Repositories

When reviewing large pull requests, you may hit context limits. Use these strategies:

def chunk_large_diff(diff_text, max_lines=200): """Split large diffs into reviewable chunks.""" lines = diff_text.split('\n') chunks = [] current_chunk = [] for line in lines: current_chunk.append(line) if len(current_chunk) >= max_lines and line.startswith('@@'): chunks.append('\n'.join(current_chunk)) current_chunk = [] if current_chunk: chunks.append('\n'.join(current_chunk)) return chunks

6. Security-Focused Reviews

For security-critical code, add a dedicated security review pass with enhanced prompting:

SECURITY_PROMPT = """You are a senior security engineer performing a code security audit. Focus exclusively on: - Input validation and sanitization - Authentication and authorization flaws - Data exposure (PII, secrets, credentials) - Injection vulnerabilities (SQL, Command, LDAP, XPath) - Cryptographic misuse (weak algorithms, IV reuse, hardcoded keys) - Race conditions and TOCTOU issues - Insecure deserialization - SSRF and open redirect vulnerabilities For each finding, rate confidence as HIGH/MEDIUM/LOW and provide CVSS-like severity. If the code handles user input, network requests, file operations, or authentication, scrutinize extra carefully."""

7. Performance Benchmarks

We benchmarked AI code review on a real-world Python repository with 50 PRs:

Metric DeepSeek-Coder Qwen2.5-Coder GLM-4
Avg. review time 3.2s 2.8s 1.9s
True positive rate 78% 74% 68%
False positive rate 12% 15% 18%
Cost per PR (avg 5 files) $0.08 $0.12 $0.03

8. Best Practices for Production

  1. Human-in-the-loop: AI reviews supplement, not replace, human reviewers. Flag issues for human confirmation.
  2. Gradual rollout: Start with style and documentation checks, then expand to security and logic.
  3. Custom rules: Feed your team's coding standards into the prompt for consistent enforcement.
  4. Feedback loop: Track which AI suggestions developers accept vs. dismiss to improve prompts.
  5. Rate limiting: Cache results for unchanged files to avoid redundant API calls.
  6. Privacy: Ensure code sent to external APIs does not contain secrets. Use local models for sensitive codebases.

Start Automating Your Code Reviews

Get unified access to DeepSeek-Coder, Qwen, and GLM through a single API. Build AI code review into your pipeline today.

Get Started with TokenEase

Related Articles