Rebuild the task as a single LangGraph code-review reflection graph with structured scores, targeted rewrite, max_rounds guard, and CLI demo.: update README.md

This commit is contained in:
2026-06-18 13:23:10 +00:00
parent 98d68b10d6
commit 061d1c231e
+40 -13
View File
@@ -1,29 +1,56 @@
# README.md
# LangGraph Code Review Agent
# LangGraph Code Review Reflection Agent
This repository implements a **LangGraph** agent that takes a Python function as input and produces a code review. The review is evaluated by a critic node that scores it on four criteria:
Этот проект реализует `LangGraph`-агента, который:
1. **PEP8 compliance**
2. **Type hints**
3. **Edge case handling**
4. **Naming conventions**
1. берёт Python-функцию;
2. пишет первичный code review;
3. отдельным узлом-критиком оценивает review по 4 критериям:
- `pep8`
- `type_hints`
- `edge_cases`
- `naming`
4. если verdict равен `needs_revision`, запускает `rewrite` и усиливает самое слабое место;
5. завершает работу после `ok` или по достижении `max_rounds`.
If the critic returns **`needs_revision`** the rewrite node improves the weakest part of the review. The process repeats up to ``max_rounds`` times.
## Стек
The implementation uses only the technologies specified in the assignment: ``langgraph`` and ``langchain-ollama`` (or ``langchain-openai`` if you prefer). No vector database is used.
- Python 3.10+
- `langgraph`
- `langchain-openai`
- `python-dotenv`
## Installation
## Установка
```bash
pip install -r requirements.txt
```
## Demo
Заполните `.env`:
Run the demo with:
```bash
OPENAI_API_KEY=...
OPENAI_BASE_URL=...
OPENAI_MODEL=...
```
## Запуск
```bash
python main.py
```
It will review the example function ``sort_numbers`` and print the draft review, scores, and verdict.
## Что видно в демо
- исходный код функции `sort_numbers`
- первичный `draft_review`
- баллы критика по 4 критериям
- `weakest_criterion`
- при необходимости переписанный review
- финальный результат и число использованных раундов
## Соответствие заданию
- `CodeReviewState` содержит все требуемые поля
- `reflect` использует structured output
- `rewrite` дорабатывает review по `weakest_criterion`
- цикл `rewrite -> reflect` ограничен через `max_rounds`