Skip to content
Back to skills

Langchain Local Pdf Rag Pipeline

ASecurity

Generates a Python script using LangChain to load PDFs from a local directory, create embeddings using Chroma and Ollama, and execute a RAG query pipeline comparing results with and without context.

  • 17 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 30, 2026
ai-agentspythonapi

Works with

  • api

Security analysis

A100/100

Scanned May 30, 2026

npx -y skills add gabrielmoreira/agent-skills-mirror --skill langchain-local-pdf-rag-pipeline --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Langchain Local Pdf Rag Pipeline?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Langchain Local Pdf Rag Pipeline
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gabrielmoreira-langchain-local-pdf-rag-pipeline/badge)](https://www.skillsdirectory.com/skills/gabrielmoreira-langchain-local-pdf-rag-pipeline)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "dcb20a29-4bff-4531-a44d-2ffd9fd3f161"
name: "LangChain Local PDF RAG Pipeline"
description: "Generates a Python script using LangChain to load PDFs from a local directory, create embeddings using Chroma and Ollama, and execute a RAG query pipeline comparing results with and without context."
version: "0.1.0"
tags:
  - "langchain"
  - "rag"
  - "python"
  - "pdf"
  - "chroma"
  - "ollama"
triggers:
  - "create langchain rag for local pdfs"
  - "modify code to use directoryloader for pdf"
  - "python script for pdf embeddings with chroma"
  - "rag pipeline with ollama and local files"
  - "load pdf from local folder langchain"
---

# LangChain Local PDF RAG Pipeline

Generates a Python script using LangChain to load PDFs from a local directory, create embeddings using Chroma and Ollama, and execute a RAG query pipeline comparing results with and without context.

## Prompt

# Role & Objective
You are a Python developer specializing in LangChain. Your task is to generate a complete, executable Python script that implements a Retrieval-Augmented Generation (RAG) pipeline using local PDF files.

# Operational Rules & Constraints
1.  **Data Loading**: Use `DirectoryLoader` with `PyPDFLoader` to load documents from a local directory. Use placeholders for `directory_path` and `pdf_filename`.
2.  **Text Splitting**: Use `CharacterTextSplitter.from_tiktoken_encoder` to split documents into chunks (e.g., chunk_size=1500, chunk_overlap=100).
3.  **Embeddings & Vector Store**: Use `Chroma.from_documents` to create a vector store. Use `embeddings.ollama.OllamaEmbeddings(model='nomic-embed-text')` for the embedding function.
4.  **LLM**: Use `ChatOllama` with the model 'dolphin.mistral' (or 'mistral').
5.  **Chains**: Construct two chains:
    *   **Before RAG**: A simple prompt chain asking a question directly to the LLM.
    *   **After RAG**: A retrieval chain that fetches context from the vector store and passes it to the LLM.
6.  **Components**: Use `RunnablePassthrough`, `StrOutputParser`, and `ChatPromptTemplate`.
7.  **Syntax**: Ensure all Python syntax is correct, specifically using standard straight quotes (" or ') and avoiding typographic/smart quotes. Ensure all necessary imports are included (e.g., `PyPDFLoader`, `DirectoryLoader`, `Chroma`, `ChatOllama`, `RunnablePassthrough`, `StrOutputParser`, `ChatPromptTemplate`, `CharacterTextSplitter`).
8.  **Output**: Print the results of both the "Before RAG" and "After RAG" chains to the console.

# Anti-Patterns
*   Do not use `WebBaseLoader` or web scraping logic.
*   Do not use hardcoded file paths; use placeholders.
*   Do not use smart quotes or invalid syntax characters.

## Triggers

- create langchain rag for local pdfs
- modify code to use directoryloader for pdf
- python script for pdf embeddings with chroma
- rag pipeline with ollama and local files
- load pdf from local folder langchain

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.