Skip to content

hardik5520/Langgraph-chatbot

Repository files navigation

LangGraph Examples

A collection of LangGraph workflow examples and chatbot implementations built with OpenAI and LangChain.

Project Structure

.
├── sequential_workflow/       # Step-by-step LLM pipelines
│   ├── simple_llm_workflow.py
│   ├── prompt_chaining.py
│   └── bmi_workflow.ipynb
├── parallel_workflow/         # Concurrent node execution
│   ├── cricket.py
│   └── upsc_essay.py
├── conditional_workflow/      # Dynamic routing based on state
│   ├── quadratic_equation_workflow.py
│   └── review_workflow.py
├── iterative_workflow/        # Looping until a condition is met
│   └── x_post_generator.py
├── Chatbot/
│   ├── basic_shell_chatbot.py          # Shell chatbot with in-memory persistence
│   ├── InMemoryChatbot/                # Chatbot with MemorySaver checkpointer
│   └── ChatbotWithDB/                  # Chatbot with SQLite persistence and tools
└── MCP Server/
    └── calculator_server.py            # FastMCP calculator server

Workflow Patterns

Pattern Description
Sequential Nodes execute one after another in a fixed chain
Parallel Multiple nodes run concurrently and results are merged
Conditional Routing decisions are made based on the current graph state
Iterative A loop runs until a stopping condition is reached

Chatbot Features

  • InMemoryChatbot — conversation history kept in memory for the session
  • ChatbotWithDB — persistent history stored in SQLite across sessions
  • backend_with_tools — LLM can call external tools during a conversation
  • chatbot_mcp — chatbot integrated with an MCP server

MCP Server

MCP Server/calculator_server.py exposes arithmetic operations (add, subtract, multiply, divide, power, modulo) as tools via the Model Context Protocol.

Setup

  1. Create and activate a virtual environment:

    python -m venv langgraph
    source langgraph/bin/activate
  2. Install dependencies:

    pip install langgraph langchain langchain-openai langchain-community fastmcp
  3. Copy .env.example to .env and fill in your keys:

    OPENAI_API_KEY=your_key_here
    LANGCHAIN_API_KEY=your_key_here
    LANGCHAIN_TRACING_V2=true
    LANGCHAIN_PROJECT=chatbot-project
    

Usage

Run any example directly:

python sequential_workflow/simple_llm_workflow.py
python iterative_workflow/x_post_generator.py
python Chatbot/basic_shell_chatbot.py

Start the MCP calculator server:

python "MCP Server/calculator_server.py"

About

LangGraph workflow examples and chatbot implementations — sequential, parallel, conditional, and iterative patterns using OpenAI and LangChain, with Streamlit-based chat UIs.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors