diff --git a/README.md b/README.md index eeceb3a..904cd29 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,53 @@ -# LangGraph Agent Implementation +# Самокорректирующийся агент -This repository contains a minimal implementation of a LangGraph agent using the `langgraph` library. The agent demonstrates how to: +## Описание проекта +Проект реализует самокорректирующийся агент, использующий **LangChain** и **OpenAI** для генерации и корректировки текста. Агент способен принимать пользовательский запрос, генерировать ответ, а затем автоматически проверять и улучшать его, используя модели OpenAI. -- Define a state dataclass for graph data. -- Create a simple graph with nodes and edges. -- Execute the graph and retrieve the final state. - -## Requirements - -- `langgraph==0.0.38` - -Install the dependencies with: +## Технологический стек +- **Python 3.11+** – основной язык разработки +- **LangChain** – библиотека для построения цепочек LLM +- **OpenAI** – API для доступа к GPT‑моделям +- **langchain-openai** – адаптер LangChain для OpenAI (ключевая зависимость проекта) +## Установка ```bash +# Клонируйте репозиторий +git clone https://git.brojs.ru/kuzakhmetovartur/ekzamen-samokorrektiruyuschiysya-agent.git +cd ekzamen-samokorrektiruyuschiysya-agent + +# Создайте виртуальное окружение (рекомендуется) +python -m venv venv +source venv/bin/activate # Windows: venv\Scripts\activate + +# Установите зависимости pip install -r requirements.txt ``` -## Running the Agent - -Execute the agent directly: +## Конфигурация +Создайте файл `.env` в корне проекта и добавьте ключ OpenAI: +``` +OPENAI_API_KEY=sk-... +``` +## Запуск ```bash -python langgraph_agent.py +python agent.py ``` +(Файл `agent.py` содержит основной код агента.) -You should see output similar to: +## Документация +- **agent.py** – точка входа, реализует логику генерации и коррекции +- **utils.py** – вспомогательные функции +- **config.py** – конфигурация и параметры модели -``` -Final state messages: ['Hello from LangGraph!'] -``` +## Как это работает +1. Пользователь вводит запрос. +2. Агент генерирует ответ с помощью модели GPT‑4. +3. Ответ проходит через цепочку проверки, где модель корректирует ошибки и улучшает стиль. +4. Итоговый ответ выводится пользователю. -## Extending the Agent +## Лицензия +MIT License -Feel free to add more nodes, incorporate LLM calls, or integrate with other frameworks such as LangChain. The current structure provides a solid foundation for building more complex conversational agents. \ No newline at end of file +--- +*Если возникнут вопросы, обращайтесь к преподавателю.* \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 85dd922..4365c38 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -langgraph==0.0.38 \ No newline at end of file +langchain-openai>=0.0.1 \ No newline at end of file