feat: solution for 'Экзамен: Самокорректирующийся агент'

This commit is contained in:
2026-07-01 14:23:07 +03:00
parent cfe5d77a10
commit baf18c5876
2 changed files with 28 additions and 75 deletions
+7 -40
View File
@@ -1,47 +1,14 @@
# Graph with Reflection and Rewrite Nodes
# Project Requirements
This project provides a minimal directed graph implementation that supports two special node types:
This project requires the following Python packages:
- **ReflectionNode** passes its input unchanged to its output.
- **RewriteNode** transforms its input using a usersupplied function.
- `langgraph`
- `langchain-openai`
## Installation
Install them using:
```bash
npm install
pip install -r requirements.txt
```
## Usage
```js
import { Graph, ReflectionNode, RewriteNode } from './src/index.js';
const graph = new Graph();
// Create nodes
const start = new ReflectionNode('start');
const rewrite = new RewriteNode('rewrite', (x) => x * 2);
// Add nodes to graph
graph.addNode(start);
graph.addNode(rewrite);
// Connect nodes
graph.addEdge('start', 'rewrite');
// Evaluate graph
const result = graph.evaluate();
console.log(result); // { start: undefined, rewrite: 0 } (example)
```
## Running Tests
A simple test script (`test.js`) can be added to validate functionality. Run:
```bash
npm test
```
## License
MIT
Ensure you have a compatible Python environment before running the project.