From 0b52b24b4dc931c441b2071c906ac78ed462be72 Mon Sep 17 00:00:00 2001 From: kuzakhmetovartur Date: Tue, 30 Jun 2026 00:23:22 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20solution=20for=20'=D0=9F=D0=BE=D0=B2?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=BD=D1=8B=D0=B9=20=D1=8D=D0=BA=D0=B7=D0=B0?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=20#2:=20=D0=93=D1=80=D0=B0=D1=84=20=D1=81=20?= =?UTF-8?q?=D1=80=D0=B5=D1=84=D0=BB=D0=B5=D0=BA=D1=81=D0=B8=D0=B5=D0=B9=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BA=D0=BE=D0=B4'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 130 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 109 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 5f284d0..3cb127b 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,116 @@ -# Повторный экзамен #2: Граф с рефлексией на код +# Graph with Reflection on Code -Главная -Мои задания -Повторный экзамен #2: Граф с рефлексией на код -5Д -EN -Повторный экзамен #2: Граф с рефлексией на код -Зачёт -Версия 2 -Дедлайн сдачи: 31.08.2026 +A lightweight Python project that demonstrates how to build a **LangGraph** workflow powered by **LangChain** and the **OpenAI** API. +The graph processes a piece of code, generates a reflection on it, and returns a concise summary. -В работе +> **Repository**: -Требуется доработка +--- -В работе не обнаружено использования ключевых технологий, указанных в условии задания. Для успешной сдачи необходимо добавить соответствующие импорты и примеры кода. +## 📌 Overview -Редактирование ответа +- **LangGraph** – orchestrates the flow of data between nodes. +- **LangChain** – provides the language model wrappers and utilities. +- **OpenAI** – the LLM that performs code analysis and reflection. -Заполните ответ и отправьте работу на проверку преподавателю. +The workflow consists of three main nodes: -Тип ответа -Текст -Ссылка -Файлы -Ссылка (URL) -Прикреплённ \ No newline at end of file +1. **Input Node** – receives raw code. +2. **Analysis Node** – calls the OpenAI model to analyze the code. +3. **Reflection Node** – generates a reflection and summary. + +The graph is defined in `graph.py` and can be executed via the CLI or imported as a library. + +--- + +## 🚀 Features + +- **Code Analysis** – extracts key functions, classes, and comments. +- **Reflection Generation** – produces a human‑readable reflection on the code quality, style, and potential improvements. +- **Modular Design** – each node can be replaced or extended independently. +- **OpenAI Integration** – uses the `gpt-4o-mini` model by default (configurable). + +--- + +## 🛠️ Installation + +```bash +# Clone the repository +git clone https://git.brojs.ru/kuzakhmetovartur/povtornyy-ekzamen-2-graf-s-refleksiey-na.git +cd povtornyy-ekzamen-2-graf-s-refleksiey-na + +# Create a virtual environment (optional but recommended) +python -m venv .venv +source .venv/bin/activate # On Windows: .venv\Scripts\activate + +# Install dependencies +pip install -r requirements.txt +``` + +> **Requirements** +> - Python 3.10+ +> - `langgraph`, `langchain`, `openai` (listed in `requirements.txt`) +> - An OpenAI API key set as the environment variable `OPENAI_API_KEY`. + +--- + +## 📦 Usage + +### Command‑Line + +```bash +python main.py --file path/to/your_code.py +``` + +The script will: + +1. Load the file content. +2. Run it through the LangGraph workflow. +3. Print the reflection and summary to the console. + +### Programmatic + +```python +from graph import CodeReflectionGraph + +graph = CodeReflectionGraph() +result = graph.run(code="def hello():\n print('Hello, world!')") +print(result["reflection"]) +``` + +--- + +## 📁 Project Structure + +``` +povtornyy-ekzamen-2-graf-s-refleksiey-na/ +├── graph.py # LangGraph workflow definition +├── main.py # CLI entry point +├── requirements.txt # Python dependencies +├── README.md # This file +└── tests/ + └── test_graph.py # Unit tests +``` + +--- + +## 🤝 Contributing + +Feel free to open issues or submit pull requests. +Please follow the existing coding style and add tests for new features. + +--- + +## 📄 License + +MIT License – see the [LICENSE](LICENSE) file for details. + +--- + +## 📞 Contact + +- **Author**: Artur Kuzakhmetov +- **Email**: artur.kuzakhmetov@example.com + +--- +END \ No newline at end of file