Skip to content

staminna/RAG-PDF-LangGraph-plus-LangChain

Repository files navigation

LangGraph RAG Application

This is a Retrieval-Augmented Generation (RAG) application built using LangGraph and LangChain.

Project Structure

rag_app/
├── utils/                # Utilities for the graph
│   ├── __init__.py
│   ├── tools.py          # Tools for document loading and processing
│   ├── nodes.py          # Node functions for the graph
│   └── state.py          # State definition for the graph
├── __init__.py
├── agent.py              # Graph construction code
└── cli.py                # Command-line interface

Setup

Local Development

  1. Create a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install the package in development mode:
pip install -e .
  1. Create a .env file with your API keys (if needed):
HUGGINGFACEHUB_API_TOKEN=your_token_here
  1. Create a data directory for storing your documents:
mkdir -p data

Using Docker

  1. Build and start the Docker container:
docker-compose up -d
  1. Stop the container:
docker-compose down

Usage

Command-line Interface

Process a local PDF file:

rag-app file path/to/your/file.pdf --query "Your query here"

Process a PDF from a URL:

rag-app url "https://example.com/document.pdf" --query "Your query here"

If you don't provide a query, the system will run default queries to summarize the document.

LangGraph Server

Start the LangGraph server:

langgraph serve -t rag

Or using Docker:

docker-compose up -d

Then you can interact with the server using HTTP requests:

curl -X POST http://localhost:8000/rag/invoke \
  -H "Content-Type: application/json" \
  -d '{"query": "What is systems engineering?"}'

Development

Running Tests

pytest

Building the Package

python setup.py sdist bdist_wheel

License

MIT

About

This is a Retrieval-Augmented Generation (RAG) project built using LangGraph and LangChain.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors