1.4 KiB
1.4 KiB
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 viarequirements.txt)langgraphlangchainopenai
Install the dependencies:
pip install -r requirements.txt
Configuration
Set your OpenAI API key as an environment variable:
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:
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!