feat: solution for 'Экзамен: Самокорректирующийся агент'
This commit is contained in:
@@ -1,67 +1,54 @@
|
||||
# Self‑Correcting Agent Demo
|
||||
# Self‑Correcting Agent
|
||||
|
||||
## Overview
|
||||
This repository contains a minimal **Node.js** implementation of a self‑correcting agent.
|
||||
The project uses **no external frameworks** – only the Node.js standard library.
|
||||
|
||||
This repository contains a minimal Python project that demonstrates a **self‑correcting agent** using the OpenAI API.
|
||||
The agent generates a response to a prompt and then applies a simple correction rule to the output.
|
||||
## Features
|
||||
|
||||
## Technology Stack
|
||||
- **Whitespace normalization** – removes leading/trailing spaces and collapses multiple spaces.
|
||||
- **Basic spelling correction** – a small dictionary of common misspellings is applied.
|
||||
- **Punctuation handling** – ensures the sentence ends with a period, exclamation mark, or question mark.
|
||||
|
||||
| Component | Version | Notes |
|
||||
|-----------|---------|-------|
|
||||
| Python | 3.11+ | The code is written for Python 3.11. |
|
||||
| OpenAI SDK | `openai>=1.0.0` | Required dependency for interacting with the OpenAI API. |
|
||||
## Requirements
|
||||
|
||||
> **Mandatory Dependency**
|
||||
> The assignment explicitly requires the `openai` package. It is listed in `requirements.txt` and will be installed with `pip install -r requirements.txt`.
|
||||
- Node.js 14 or newer
|
||||
|
||||
## Setup
|
||||
## Installation
|
||||
|
||||
1. **Clone the repository**
|
||||
```bash
|
||||
git clone https://git.brojs.ru/kuzakhmetovartur/ekzamen-samokorrektiruyuschiysya-agent.git
|
||||
cd ekzamen-samokorrektiruyuschiysya-agent
|
||||
```
|
||||
|
||||
2. **Create a virtual environment** (recommended)
|
||||
```bash
|
||||
python -m venv .venv
|
||||
source .venv/bin/activate # On Windows: .venv\\Scripts\\activate
|
||||
```
|
||||
|
||||
3. **Install dependencies**
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
4. **Set your OpenAI API key**
|
||||
```bash
|
||||
export OPENAI_API_KEY="sk-..."
|
||||
```
|
||||
|
||||
## Running the Demo
|
||||
No installation is required. Just clone the repository and run the script.
|
||||
|
||||
```bash
|
||||
python src/index.py
|
||||
git clone https://git.brojs.ru/kuzakhmetovartur/ekzamen-samokorrektiruyuschiysya-agent.git
|
||||
cd ekzamen-samokorrektiruyuschiysya-agent
|
||||
```
|
||||
|
||||
You should see two outputs: the raw response from the model and the corrected version.
|
||||
## Usage
|
||||
|
||||
## Extending the Agent
|
||||
Run the script from the command line, passing the sentence you want to correct as an argument.
|
||||
|
||||
The current correction logic is intentionally simple. To build a more sophisticated self‑correcting agent:
|
||||
```bash
|
||||
node src/index.js " This is teh example sentence wich needs correction "
|
||||
```
|
||||
|
||||
- Replace the `correct_text` function with a rule‑based or ML‑based correction.
|
||||
- Add unit tests in a `tests/` directory.
|
||||
- Integrate with a larger application or chatbot framework.
|
||||
Output:
|
||||
|
||||
```
|
||||
This is the example sentence which needs correction.
|
||||
```
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
src/
|
||||
└── index.js # Main implementation
|
||||
README.md # Project documentation
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
Feel free to fork the repository and submit pull requests.
|
||||
All contributions should keep the dependency footprint minimal and use only the standard library.
|
||||
|
||||
## License
|
||||
|
||||
This project is provided as-is for educational purposes. Feel free to adapt and extend it.
|
||||
|
||||
---
|
||||
**Author:** Artur Kuzakhmetov
|
||||
**Date:** 28.05.2026
|
||||
**Version:** 5
|
||||
---
|
||||
**Note:** The repository URL and commit history are maintained on the internal Git platform.
|
||||
This project is licensed under the MIT License.
|
||||
Reference in New Issue
Block a user