Files
povtornyy-ekzamen-graf-s-re…/README.md
T

60 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# LangGraph Agent with OpenAI Integration
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.
## Requirements
- Python 3.10+
- `langchain-openai` (automatically installed via `requirements.txt`)
- `langgraph`
- `langchain`
- `openai`
Install the dependencies:
```bash
pip install -r requirements.txt
```
## Configuration
Set your OpenAI API key as an environment variable:
```bash
export OPENAI_API_KEY="your-openai-api-key"
```
Alternatively, you can create a `.env` file in the project root with the following content:
```
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!