Skip to content
yashsdoshiPublic

About

Agentic RAG assistant for research papers: chat with PDFs, web pages and arXiv papers, and check whether a paper's claims have been superseded by newer work. Built with LangGraph, Qdrant, OpenAI, Tavily and Streamlit

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

📚 PaperLens

An agentic RAG research assistant. Chat with your research papers, pull in arXiv and web sources, and check whether a paper's claims still hold up against newer research.

LangGraph OpenAI Qdrant Tavily Streamlit Python 3.12+

Note

Note from the Owner: Every chat session gets its own knowledge base. Papers you load in one chat are not visible in any other chat.


✨ What can it do?

  • Ask questions about your papers: upload PDF, TXT or Markdown files, load web pages, or pull papers straight from arXiv by ID or title.
  • Verify a claim: paste a claim from a paper and PaperLens searches the web and arXiv for newer work that challenges or supersedes it, with links.
  • Search the web: questions about current events or recent developments are answered with live Tavily results.
  • /btw side questions: start a message with /btw to ask something off-topic without adding it to the session history.
  • Persistent sessions: chats are saved with SQLite checkpoints and auto-named from your first message.
  • Inspect the agent: every answer has a 📊 Graph state panel showing the route taken, the retrieved chunks and the retry counts.

🧠 How it works

PaperLens LangGraph workflow
Node What it does
router Classifies the question as retrieve, verify_claim or direct_answer.
agent_node Picks a tool (your papers or web search) and writes the search query. Capped at 3 tool calls per question.
retrieval Runs the tool: a Qdrant similarity search over your papers, or a Tavily web search.
relevancy_check Checks whether the retrieved chunks actually answer the question.
query_rewrite If they don't, rewrites the query once and sends it back to the agent.
verify_claim Searches the web and arXiv for newer work and returns a verdict with up to 3 superseding papers.
generate_answer Writes the final answer and streams it to the UI.
PaperLens/
├── app.py                     # Streamlit UI (sessions, document loaders, chat)
├── backend/
│   ├── rag_graph.py           # LangGraph workflow (router, agent, tools, claim verification)
│   ├── vector_store.py        # Qdrant collections + cached OpenAI embeddings
│   ├── paper_loader.py        # PDF / TXT / Markdown / web page / arXiv loaders and chunking
│   ├── btw_handler.py         # /btw side-channel answers
│   └── models.py              # Pydantic schemas for structured LLM outputs
├── evaluate.py                # DeepEval evaluation of the RAG pipeline
├── goldens.json               # Question/answer pairs used by the evaluation
├── eval_results.json          # Latest evaluation results
├── documents/                 # Sample report used by evaluate.py
├── graph.png                  # Workflow diagram (above)
├── pyproject.toml / uv.lock   # Dependencies (uv)
├── requirements.txt           # Dependencies (pip / Docker)
├── Dockerfile
├── DOCKER_GUIDE.md            # Docker Hub + EC2 deployment guide
├── docker_install_on_AWS.txt  # Installing Docker on an Ubuntu EC2 instance
└── qdrant_login_steps.md      # Getting Qdrant Cloud credentials

Step 0 — Prerequisites

Accounts & Keys
  • OpenAI API Key from platform.openai.com (PaperLens uses gpt-5.4-mini, gpt-5-mini and text-embedding-3-small)
  • Tavily API Key from tavily.com (the free tier is enough)
  • (Optional) Qdrant Cloud cluster, only if you don't want to run Qdrant locally (see qdrant_login_steps.md)
Local Tools
  • Python 3.12+ & uv: dependency management and running the app
  • Docker Desktop: runs Qdrant locally
  • Git: cloning the repo

Step 1 — Local Setup

1.1 Clone the repo
git clone https://github.com/yashsdoshi/PaperLens.git
cd PaperLens
1.2 Install dependencies
uv sync

This creates a .venv folder and installs everything from uv.lock.

1.3 Start Qdrant

Option A: Local (Docker). Make sure Docker Desktop is running, then:

docker run -d --name paperlens-qdrant -p 6333:6333 -v paperlens_qdrant:/qdrant/storage qdrant/qdrant

[!TIP] Your papers are stored in the paperlens_qdrant volume, so they survive restarts. Next time, just run docker start paperlens-qdrant.

Option B: Qdrant Cloud. Follow qdrant_login_steps.md to get your cluster URL and API key.

1.4 Create the .env file

Create an empty .env file in the project root:

Windows (CMD):

type nul > .env

macOS / Linux:

touch .env

Then add your keys:

OPENAI_API_KEY=sk-proj-...
TAVILY_API_KEY=tvly-...
QDRANT_URL=http://localhost:6333
QDRANT_API_KEY=

[!IMPORTANT] Keep the QDRANT_API_KEY= line even when it's empty (local Qdrant). The app reads it at startup and fails if the line is missing. For Qdrant Cloud, use your cluster's URL and API key instead.

1.5 Run the app
uv run streamlit run app.py

Open http://localhost:8501 in your browser.


Step 2 — Using PaperLens

2.1 Load your documents

Use the sidebar to add documents to the current chat:

Source How
Files Upload PDF, TXT or Markdown files, then click Add Files.
Web Pages Paste URLs (one per line), then click Load URLs.
ArXiv Papers Enter an arXiv ID (1706.03762) or a title (Attention Is All You Need), then click Load ArXiv Paper.

Documents are split into 1,000-character chunks (200 overlap) and embedded with text-embedding-3-small. Embeddings are cached in embedding_cache/, so loading the same paper again doesn't re-embed it.

2.2 Ask questions

The router picks the right path for you. Some examples:

You type Route
What dataset did the authors use for training? retrieve: searches your papers
What are the latest developments in retrieval-augmented generation? retrieve: searches the web
Is this claim still accurate: "LSTMs outperform transformers on machine translation" verify_claim: finds newer papers
What is softmax? direct_answer: no retrieval needed
/btw What is attention? side channel: not saved to the session

Step 3 — Evaluating the RAG Pipeline

3.1 Run the evaluation

evaluate.py uses DeepEval to test the pipeline against the sample report in documents/. Each question in goldens.json runs through the full graph in a fresh session, and the answers are scored on 5 metrics (threshold 0.7, judged by gpt-5.4-mini). If goldens.json is missing, new question/answer pairs are generated from the report first.

uv run evaluate.py

Results are saved to eval_results.json.

[!WARNING] The evaluation makes a lot of OpenAI calls, so it costs money. Each test case also creates its own Qdrant collection.

3.2 Latest results

10 test cases from goldens.json:

Metric Avg score Passed
Contextual Precision 0.98 10/10
Contextual Recall 1.00 10/10
Contextual Relevancy 0.58 5/10
Answer Relevancy 0.99 10/10
Faithfulness 0.98 10/10

Step 4 — Running with Docker

4.1 Build and run the image
docker build -t paperlens .
docker run -d -p 8501:8501 --env-file .env --name paperlens paperlens

[!IMPORTANT] Inside the container, localhost points to the container itself. If Qdrant is running locally in Docker Desktop, set QDRANT_URL=http://host.docker.internal:6333 in your .env.

4.2 Deploy to AWS EC2

Troubleshooting

Error Cause Fix
openai.OpenAIError: Missing credentials or KeyError: 'QDRANT_URL' .env is missing, or the app was started from another folder Create .env in the project root (Step 1.4) and run the app from there
Could not load document list — try refreshing. Qdrant isn't running docker start paperlens-qdrant
open //./pipe/dockerDesktopLinuxEngine: The system cannot find the file specified Docker Desktop isn't running Start Docker Desktop, wait until it's ready, then retry
model_not_found from OpenAI Your key doesn't have access to gpt-5.4-mini or gpt-5-mini Change the model names in backend/rag_graph.py, backend/btw_handler.py and app.py

Don't forget to leave a star ⭐️

About

Agentic RAG assistant for research papers: chat with PDFs, web pages and arXiv papers, and check whether a paper's claims have been superseded by newer work. Built with LangGraph, Qdrant, OpenAI, Tavily and Streamlit

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages