60 lines
1.4 KiB
Markdown
60 lines
1.4 KiB
Markdown
# 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! |