HUB
Sign inSign up

meisam19/agentic-chatbot-langgraph

By meisam19

•Updated about 2 months ago

Image
0

75

meisam19/agentic-chatbot-langgraph repository overview

⁠Agentic Chatbot with LangGraph

A deployment-ready, Dockerized agentic AI chatbot built with LangGraph, LangChain, Streamlit, and an OpenAI-compatible LLM API.

The application supports multi-turn conversations, external tool usage, PDF-based Retrieval-Augmented Generation (RAG), persistent conversation memory, streaming responses, and human-in-the-loop approval for sensitive actions.


⁠Features

  • Agentic workflow orchestration with LangGraph
  • Interactive Streamlit chat interface
  • Multi-turn conversation memory
  • Persistent conversation threads
  • PDF upload and Retrieval-Augmented Generation (RAG)
  • FAISS vector similarity search
  • OpenAI-compatible chat model support
  • OpenAI text-embedding-3-large embeddings
  • Web search using Tavily
  • Real-time weather lookup
  • Stock price lookup
  • Human-in-the-loop approval workflow
  • Streaming LLM responses
  • Tool execution status display
  • Dockerized deployment
  • Environment-based secret management

⁠Architecture

                         ┌─────────────────────┐
                         │        User         │
                         └──────────┬──────────┘
                                    │
                                    ▼
                         ┌─────────────────────┐
                         │ Streamlit Frontend  │
                         └──────────┬──────────┘
                                    │
                                    ▼
                         ┌─────────────────────┐
                         │   LangGraph Agent   │
                         └──────────┬──────────┘
                                    │
              ┌─────────────────────┼─────────────────────┐
              │                     │                     │
              ▼                     ▼                     ▼
      ┌───────────────┐     ┌───────────────┐     ┌───────────────┐
      │      LLM      │     │ External Tools│     │    PDF RAG    │
      │ OpenAI-style  │     │               │     │               │
      └───────────────┘     │ Tavily Search │     │ PDF Loader    │
                            │ Weather API   │     │ Chunking      │
                            │ Stock API     │     │ Embeddings    │
                            │ Calculator    │     │ FAISS         │
                            └───────────────┘     └───────────────┘
                                     │
                                     ▼
                            ┌──────────────────┐
                            │ Human Approval   │
                            │ Interrupt/Resume │
                            └──────────────────┘

⁠Tech Stack

  • Python
  • LangChain
  • LangGraph
  • Streamlit
  • OpenAI-compatible APIs
  • OpenAI Embeddings
  • FAISS
  • Tavily
  • SQLite
  • Docker

⁠Pull the Docker Image

Pull the latest image from Docker Hub:

docker pull meisam19/agentic-chatbot-langgraph:latest

To use a specific version:

docker pull meisam19/agentic-chatbot-langgraph:1.0

⁠Environment Variables

The Docker image does not contain API keys or private credentials.

Create a local .env file with your own configuration:

OPENAI_API_KEY=your_openai_api_key
BASE_URL=your_openai_compatible_base_url
TAVILY_API_KEY=your_tavily_api_key
OPENWEATHER_API_KEY=your_openweather_api_key

Depending on your setup, additional environment variables may also be required.

Do not add spaces around = in the .env file.

Correct:

OPENAI_API_KEY=my_key

Incorrect:

OPENAI_API_KEY = "my_key"

⁠Run the Container

Run the application using your .env file:

docker run --rm \
  --env-file .env \
  -e PORT=8501 \
  -p 8501:8501 \
  meisam19/agentic-chatbot-langgraph:latest

On Windows PowerShell:

docker run --rm --env-file .env -e PORT=8501 -p 8501:8501 meisam19/agentic-chatbot-langgraph:latest

Then open:

http://localhost:8501

⁠Run in Detached Mode

To run the chatbot in the background:

docker run -d \
  --name agentic-chatbot \
  --env-file .env \
  -e PORT=8501 \
  -p 8501:8501 \
  meisam19/agentic-chatbot-langgraph:latest

View the running container:

docker ps

View application logs:

docker logs -f agentic-chatbot

Stop the application:

docker stop agentic-chatbot

Remove the container:

docker rm agentic-chatbot

⁠PDF Retrieval-Augmented Generation

The application supports PDF-based question answering.

Users can upload a PDF directly from the Streamlit chat interface.

The RAG pipeline performs the following steps:

  1. Loads the uploaded PDF
  2. Extracts the document text
  3. Splits the document into overlapping chunks
  4. Generates embeddings using text-embedding-3-large
  5. Stores document vectors in FAISS
  6. Retrieves the most relevant chunks for a user query
  7. Provides the retrieved context to the LLM
  8. Generates a grounded response

The simplified RAG architecture is:

PDF
 │
 ▼
PyPDFLoader
 │
 ▼
Text Chunking
 │
 ▼
OpenAI Embeddings
 │
 ▼
FAISS Vector Store
 │
 ▼
Similarity Retrieval
 │
 ▼
LangGraph Agent
 │
 ▼
LLM Response

⁠Agent Tools

The LangGraph agent can dynamically decide when external tools are required.

Available tools include:

Uses Tavily Search for recent or external information.

Typical use cases:

  • Recent events
  • Current information
  • Information not available in the model context
⁠Calculator

Provides controlled mathematical calculation support.

Example:

sqrt(16)
10 * 5
2 + 2
⁠Weather Tool

Retrieves current weather information using the OpenWeather API.

Example queries:

What is the weather in Berlin?
What is the current temperature in London?
⁠Stock Price Tool

Retrieves current stock market information.

Example:

What is the current price of AAPL?
⁠PDF RAG Tool

Retrieves relevant information from uploaded PDF documents.

Example:

Summarize the main result of the uploaded paper.

⁠Human-in-the-Loop

The chatbot contains a human-in-the-loop workflow implemented using LangGraph interrupts.

Sensitive actions can pause graph execution and wait for explicit user approval.

For example:

User
 │
 │ "Buy 10 shares of AAPL"
 ▼
LangGraph Agent
 │
 ▼
purchase_stock tool
 │
 ▼
LangGraph interrupt()
 │
 ▼
Human Approval Required
 │
 ├── Approve
 │
 └── Reject
 │
 ▼
Graph resumes execution

This demonstrates how agentic systems can combine autonomous reasoning with explicit human control.


⁠Conversation Memory

The chatbot uses a LangGraph checkpoint system backed by SQLite.

Each conversation receives a unique thread ID.

This enables:

  • Persistent chat history
  • Multiple independent conversations
  • Switching between previous threads
  • Resuming interrupted workflows
  • Human-in-the-loop state recovery

⁠Streaming Responses

The frontend streams assistant responses incrementally using Streamlit.

This provides a more responsive user experience compared with waiting for the complete model response.

The interface also displays tool activity during execution.

Example:

Using search_tool...
Using get_current_weather...
Waiting for human approval...

⁠Docker Image Tags

Available image tags include:

latest
1.0

For normal use:

docker pull meisam19/agentic-chatbot-langgraph:latest

For reproducible environments, use a fixed version:

docker pull meisam19/agentic-chatbot-langgraph:1.0

Using a fixed version is recommended for production and reproducible deployments because the latest tag may change over time.


⁠Docker Deployment Flow

The application is distributed as a Docker image.

Source Code
    │
    ▼
Dockerfile
    │
    ▼
docker build
    │
    ▼
Docker Image
    │
    ▼
Docker Hub
    │
    ▼
docker pull
    │
    ▼
Docker Container
    │
    ▼
Streamlit Application

⁠Security

API keys and credentials are not included in the Docker image.

Users must provide their own secrets at runtime.

Recommended practices:

  • Do not commit .env files to GitHub
  • Do not include .env files in Docker images
  • Store credentials using environment variables
  • Use secret-management services in production
  • Rotate exposed credentials immediately
  • Avoid hard-coded API keys in source code

A recommended .dockerignore configuration includes:

.env
.git/
__pycache__/
*.pyc
.venv/
venv/

⁠Example Project Structure

Agentic-Chatbot-with-LangGraph/
│
├── app_professional.py
├── backend_professional.py
├── requirements.txt
├── Dockerfile
├── .dockerignore
├── .gitignore
├── README.md
└── LICENSE

⁠Use Cases

This project can be used as a reference implementation for:

  • Agentic AI applications
  • LangGraph workflows
  • LangChain applications
  • Tool-using LLM agents
  • Human-in-the-loop AI systems
  • Retrieval-Augmented Generation
  • PDF question answering
  • Streamlit AI interfaces
  • Multi-agent and tool orchestration experiments
  • Dockerized AI applications
  • CI/CD learning
  • MLOps deployment experiments
  • Cloud deployment of LLM applications

⁠Source Code

The full source code is available on GitHub:

https://github.com/mghasemi19/Agentic-Chatbot-with-LangGraph⁠


⁠Docker Hub

Docker image:

https://hub.docker.com/r/meisam19/agentic-chatbot-langgraph⁠


⁠Quick Start

⁠1. Pull the image
docker pull meisam19/agentic-chatbot-langgraph:latest
⁠2. Create .env
OPENAI_API_KEY=your_openai_api_key
BASE_URL=your_openai_compatible_base_url
TAVILY_API_KEY=your_tavily_api_key
OPENWEATHER_API_KEY=your_openweather_api_key
⁠3. Run
docker run --rm \
  --env-file .env \
  -e PORT=8501 \
  -p 8501:8501 \
  meisam19/agentic-chatbot-langgraph:latest
⁠4. Open the application
http://localhost:8501

⁠License

This project is distributed under the license provided in the GitHub repository.

See the LICENSE file for details.

Tag summary

Content type

Image

Digest

sha256:561bf7d9b…

Size

3.3 GB

Last updated

about 2 months ago

docker pull meisam19/agentic-chatbot-langgraph