This project demonstrates the use of LangGraph and LangChain to build various AI agents for document drafting, mathematical operations, and PDF processing using OpenAI models.
- Document Drafter Agent: Interactively helps users draft, update, and save documents using natural language.
- Math Agents: Perform arithmetic operations (addition, subtraction, multiplication, division) via conversational interface.
- PDF Agent: Loads and processes PDF files, enabling AI-powered analysis and interaction with document content.
- Streaming and Tool Integration: Uses LangGraph's streaming and tool node capabilities for dynamic, multi-step workflows.
main.py: Entry point for running agents.5_agent_1.py,6_agent_2.py,7_agent_3.py,8_agent_4.py,8_1_agent_4.py,9_agent_5.py: Example agent scripts.1_first-graph.ipynb,2_second-graph.ipynb, ...: Jupyter notebooks demonstrating agent usage.logging.txt: Log file for agent runs.pyproject.toml,uv.lock: Dependency and environment management.
- Python 3.8+
- OpenAI API key (set in
.env) - Required packages:
langchain-corelangchain-openailanggraphlangchain-communitypython-dotenvpypdfIPythonopenaiuv(for dependency management)
- Clone the repository.
- Create a virtual environment:
python -m venv .venv
- Activate the environment:
- Windows:
./.venv/Scripts/activate - macOS/Linux:
source .venv/bin/activate
- Windows:
- Install dependencies:
Or, if using
pip install -r requirements.txt
uv:uv pip install -r requirements.txt
- Set your OpenAI API key in a
.envfile:OPENAI_API_KEY=your-key-here
- Run a specific agent script:
python 8_agent_4.py
- Interact with the PDF agent:
Ensure
Stock_Market_Performance_2024.pdfis present in the project directory, then run:python 9_agent_5.py
- Jupyter Notebooks: Open and run the
.ipynbfiles for step-by-step demonstrations.
python 5_agent_1.py
# Enter your message when prompted to interact with the agent.- If you see an error like
'pypdf' package not found, install it:pip install pypdf
- For missing modules, ensure all dependencies are installed and your virtual environment is activated.