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

This commit is contained in:
2026-06-30 14:32:06 +03:00
parent 0b29fa82f0
commit 9ab33ca6a8
3 changed files with 173 additions and 17 deletions
+29 -14
View File
@@ -1,25 +1,40 @@
# Самокорректирующийся агент
# Self-Correcting Agent
This repository contains a minimal setup for a self-correcting agent using LangChain and OpenAI.
The `requirements.txt` file includes all necessary dependencies.
This repository contains a simple implementation of a selfcorrecting agent using **LangGraph**.
The agent follows these steps:
## Setup
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.
## Installation
```bash
# 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
```
## Running the Test Script
> **Note**: The implementation uses deterministic placeholders instead of real LLM calls, so no API keys are required.
```bash
python main.py
## Usage
```python
from src.agent import run_agent
question = "What is the capital of France?"
answer = run_agent(question)
print(answer)
```
You should see a message confirming that the LangChain OpenAI import was successful and an LLM instance was created.
## Project Structure
---
```
├── requirements.txt
├── src
│ └── agent.py
└── README.md
```
## License
MIT License