From 061d1c231ef85102b39a5071250ff0fd6287d352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D0=B8=D0=BD=D0=B0=D1=80=20=D0=9C=D0=B8=D1=80=D0=B7?= =?UTF-8?q?=D0=B0=D0=B3=D0=B8=D1=82=D0=BE=D0=B2?= Date: Thu, 18 Jun 2026 13:23:10 +0000 Subject: [PATCH] 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 --- README.md | 53 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 15cbaa2..161c40a 100644 --- a/README.md +++ b/README.md @@ -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`