Skip to content

venkatonjava/langgraph-learning

Repository files navigation

LangGraph Agents Project

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.

Features

  • 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.

Project Structure

  • 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.

Requirements

  • Python 3.8+
  • OpenAI API key (set in .env)
  • Required packages:
    • langchain-core
    • langchain-openai
    • langgraph
    • langchain-community
    • python-dotenv
    • pypdf
    • IPython
    • openai
    • uv (for dependency management)

Installation

  1. Clone the repository.
  2. Create a virtual environment:
    python -m venv .venv
  3. Activate the environment:
    • Windows: ./.venv/Scripts/activate
    • macOS/Linux: source .venv/bin/activate
  4. Install dependencies:
    pip install -r requirements.txt
    Or, if using uv:
    uv pip install -r requirements.txt
  5. Set your OpenAI API key in a .env file:
    OPENAI_API_KEY=your-key-here
    

Usage

  • Run a specific agent script:
     python 8_agent_4.py
  • Interact with the PDF agent: Ensure Stock_Market_Performance_2024.pdf is present in the project directory, then run:
     python 9_agent_5.py
  • Jupyter Notebooks: Open and run the .ipynb files for step-by-step demonstrations.

Example

python 5_agent_1.py
# Enter your message when prompted to interact with the agent.

Troubleshooting

  • 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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published