feat: solution for 'Экзамен: Самокорректирующийся агент'
This commit is contained in:
@@ -1,54 +1,79 @@
|
||||
# Self‑Correcting Agent
|
||||
|
||||
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.
|
||||
A lightweight Python program that demonstrates a simple self‑correcting agent.
|
||||
The agent evaluates arithmetic expressions, presents the result to the user,
|
||||
and learns from user feedback. Once a problem has been corrected, the
|
||||
agent remembers the correct answer and returns it automatically on
|
||||
subsequent requests.
|
||||
|
||||
> **Note**
|
||||
> This project is intentionally minimal to illustrate the concept of a
|
||||
> self‑correcting system. It is not intended for production use.
|
||||
|
||||
## Features
|
||||
|
||||
- **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.
|
||||
|
||||
## Requirements
|
||||
|
||||
- Node.js 14 or newer
|
||||
- **Safe evaluation** of arithmetic expressions (`+`, `-`, `*`, `-`, `**`).
|
||||
- **Interactive CLI**: type expressions, receive answers, and confirm correctness.
|
||||
- **Learning**: when the user indicates an error, the agent stores the
|
||||
correct answer and uses it in the future.
|
||||
- **Persistence**: learned knowledge is saved to `knowledge.json` in the
|
||||
current working directory.
|
||||
|
||||
## Installation
|
||||
|
||||
No installation is required. Just clone the repository and run the script.
|
||||
The project requires Python 3.8 or newer.
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone https://git.brojs.ru/kuzakhmetovartur/ekzamen-samokorrektiruyuschiysya-agent.git
|
||||
cd ekzamen-samokorrektiruyuschiysya-agent
|
||||
|
||||
# (Optional) Create a virtual environment
|
||||
python -m venv .venv
|
||||
source .venv/bin/activate # On Windows: .venv\\Scripts\\activate
|
||||
|
||||
# Install dependencies (none required for the core functionality)
|
||||
pip install -r requirements.txt # Empty file, kept for compatibility
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Run the script from the command line, passing the sentence you want to correct as an argument.
|
||||
Run the program from the command line:
|
||||
|
||||
```bash
|
||||
node src/index.js " This is teh example sentence wich needs correction "
|
||||
python -m src.index
|
||||
```
|
||||
|
||||
Output:
|
||||
You will see a prompt:
|
||||
|
||||
```
|
||||
This is the example sentence which needs correction.
|
||||
Self‑Correcting Agent
|
||||
Type 'exit' to quit.
|
||||
Enter problem:
|
||||
```
|
||||
|
||||
## Project Structure
|
||||
Enter an arithmetic expression, e.g.:
|
||||
|
||||
```
|
||||
src/
|
||||
└── index.js # Main implementation
|
||||
README.md # Project documentation
|
||||
Enter problem: 2 + 3 * 4
|
||||
````
|
||||
|
||||
The program will output:
|
||||
|
||||
````
|
||||
|
||||
Answer: 14
|
||||
Is this correct? (y/n):
|
||||
````
|
||||
|
||||
- **y** if the answer is correct.
|
||||
- **n** and then provide the correct answer if the program made a mistake.
|
||||
|
||||
To exit, type **exit** or **quit**.
|
||||
|
||||
## Example Session
|
||||
|
||||
```
|
||||
|
||||
## 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 licensed under the MIT License.
|
||||
Self‑Correcting Agent
|
||||
Type … (truncated for brevity)
|
||||
```
|
||||
Reference in New Issue
Block a user