feat: solution for 'Экзамен: Самокорректирующийся агент'
This commit is contained in:
@@ -1,25 +1,26 @@
|
||||
# LangGraph Reflection & Rewriting Demo
|
||||
# Self‑Correcting Agent
|
||||
|
||||
This project demonstrates a simple LangGraph state machine that includes:
|
||||
- **Reflection node** – logs the current state.
|
||||
- **Rewriting node** – transforms the input string to uppercase.
|
||||
- **End node** – logs the final state.
|
||||
This repository demonstrates a minimal setup for a self‑correcting agent using **langgraph** and **langchain‑openai**.
|
||||
The project includes:
|
||||
|
||||
- `package.json` – declares the required dependencies and a start script.
|
||||
- `src/index.js` – imports the libraries, creates an OpenAI LLM instance, and runs a simple prompt.
|
||||
|
||||
## Setup
|
||||
|
||||
```bash
|
||||
# Install dependencies
|
||||
npm install
|
||||
npm run build
|
||||
|
||||
# Run the example
|
||||
npm start
|
||||
```
|
||||
|
||||
The output will show the state at each node and the final transformed result.
|
||||
> **Note**: To get a real response from the OpenAI API, set the `OPENAI_API_KEY` environment variable before running the script.
|
||||
|
||||
## Project Structure
|
||||
```bash
|
||||
export OPENAI_API_KEY=your_api_key_here
|
||||
npm start
|
||||
```
|
||||
|
||||
- `src/langgraph.ts` – Defines the state type, node functions, and constructs the graph.
|
||||
- `src/index.ts` – Entry point that runs the graph with an example input.
|
||||
- `package.json` – Project metadata and dependencies.
|
||||
- `tsconfig.json` – TypeScript compiler configuration.
|
||||
|
||||
No JavaScript files are present; the entire project is written in TypeScript.
|
||||
The script will log the loaded modules and the response from the LLM.
|
||||
Reference in New Issue
Block a user