feat: solution for 'Повторный экзамен: Граф с рефлексией и доработкой'

This commit is contained in:
2026-07-01 15:56:21 +03:00
parent 9dcbcc6619
commit 2b6ecd84d0
4 changed files with 148 additions and 144 deletions
+48 -7
View File
@@ -1,19 +1,60 @@
# Project Title
# LangGraph Agent with OpenAI Integration
This project demonstrates a simple usage of the `langgraph` library.
This project demonstrates a simple LangGraph agent that integrates with the OpenAI LLM via the `langchain-openai` package. The agent processes a single prompt and returns the model's response.
## Setup
## Requirements
- Python 3.10+
- `langchain-openai` (automatically installed via `requirements.txt`)
- `langgraph`
- `langchain`
- `openai`
Install the dependencies:
```bash
pip install -r requirements.txt
```
## Run
## Configuration
Set your OpenAI API key as an environment variable:
```bash
python main.py
export OPENAI_API_KEY="your-openai-api-key"
```
## Notes
Alternatively, you can create a `.env` file in the project root with the following content:
The `langgraph` package is required for this project. It is specified in `requirements.txt` with a minimum version of 0.0.1.
```
OPENAI_API_KEY=your-openai-api-key
```
## Running the Agent
You can run the agent from the command line:
```bash
python -m src.agent "Hello, how are you?"
```
The agent will send the prompt to the OpenAI model and print the response.
## Project Structure
```
├── requirements.txt
├── src
│ └── agent.py
└── README.md
```
- `requirements.txt` lists all Python package dependencies.
- `src/agent.py` contains the LangGraph agent implementation and a simple CLI.
- `README.md` this documentation file.
## Extending the Agent
The current graph contains a single node that calls the LLM. You can extend it by adding more nodes (e.g., for tool usage, memory, or custom logic) and connecting them in the graph.
Happy coding!