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

This commit is contained in:
2026-07-01 11:19:02 +03:00
parent 045dba9aef
commit cfe5d77a10
10 changed files with 309 additions and 94 deletions
+40 -7
View File
@@ -1,14 +1,47 @@
# Project
# Graph with Reflection and Rewrite Nodes
This project requires the following Python packages:
This project provides a minimal directed graph implementation that supports two special node types:
- `langgraph`
- `langchain-openai`
- **ReflectionNode** passes its input unchanged to its output.
- **RewriteNode** transforms its input using a usersupplied function.
Install them using:
## Installation
```bash
pip install -r requirements.txt
npm install
```
Ensure you have a compatible Python version (>=3.8).
## 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