This project is a terminal-based AI chatbot built with LangChain, LangGraph, and OpenAI. It uses the modern ReAct agent architecture and supports streaming responses directly to the terminal for a smooth and interactive experience.
- Uses LangGraph's latest
create_react_agent - Supports real-time streaming responses
- Simple and clean terminal interface
- Easily expandable to include tools, memory, or additional models
- Uses the latest OpenAI
gpt-4o-minimodel - Environment variables loaded using
python-dotenv
Install the required libraries:
pip install langchain langgraph langchain-openai python-dotenv- Create an
.envfile in the project directory. - Add your OpenAI API key:
OPENAI_API_KEY=your_api_key_here
- Run the script:
python main.py- Type messages in the terminal and the chatbot will respond.
- Type
exitorquitto close the program.
/project-folder
main.py
README.md
.env
ChatOpenAIloads the OpenAI model for the chatbot.create_react_agentcreates a modern ReAct agent using LangGraph.- The agent streams output using
agent.stream. HumanMessageis used for sending user input to the model.
You: Hello
Bot: Hi, how can I assist you?
- Add memory support
- Add custom tools (search, calculator, file operations)
- Add voice input and text-to-speech output
- Create a full GUI or web interface