feat: solution for 'Повторный экзамен: Граф с рефлексией и доработкой'

This commit is contained in:
2026-06-30 14:34:54 +03:00
parent 9ab33ca6a8
commit babdcf160b
5 changed files with 126 additions and 82 deletions
+22 -25
View File
@@ -1,40 +1,37 @@
# Self-Correcting Agent
# Graph Reflexivity Project
This repository contains a simple implementation of a selfcorrecting agent using **LangGraph**.
The agent follows these steps:
1. **Ask** Generates an answer to the users question.
2. **Check** Evaluates the answers quality.
3. **Correct** If the answer is flagged as poor, it rewrites it.
4. **Final** Returns the final answer.
This project demonstrates a simple graph implementation in JavaScript that supports reflexivity (adding self-loops to all nodes). It uses the `graphlib` library for graph data structures and `lodash` for utility functions.
## Installation
```bash
pip install -r requirements.txt
npm install
```
> **Note**: The implementation uses deterministic placeholders instead of real LLM calls, so no API keys are required.
## Running the Example
## Usage
```python
from src.agent import run_agent
question = "What is the capital of France?"
answer = run_agent(question)
print(answer)
```bash
node src/index.js
```
## Project Structure
You will see the adjacency list before and after applying reflexivity.
## Testing
Run the test suite with:
```bash
npm test
```
├── requirements.txt
├── src
│ └── agent.py
└── README.md
```
The tests cover basic graph operations, reflexivity, and adjacency list generation.
## Dependencies
- **graphlib** Provides the underlying graph data structure.
- **lodash** Utility library (used for potential future extensions).
- **jest** Testing framework (dev dependency).
## License
MIT License
MIT