
Langchain Rag
Wire document loaders, chunking, embeddings, and vector stores into a LangChain RAG pipeline for your agent or app.
Overview
langchain-rag is an agent skill for the Build phase that implements LangChain RAG pipelines with loaders, splitters, OpenAI embeddings, and vector stores.
Install
npx skills add https://github.com/langchain-ai/langchain-skills --skill langchain-ragWhat is this skill?
- End-to-end pipeline: Index (load → split → embed → store), Retrieve, and Generate
- Document loaders, RecursiveCharacterTextSplitter, and OpenAI embeddings
- Vector store guidance for InMemory, FAISS, Chroma, and Pinecone with persistence notes
- Runnable Python example using LangChain OpenAI chat, embeddings, and InMemoryVectorStore
- Invoke explicitly when building any retrieval-augmented generation system
- Three-step RAG pipeline: Index, Retrieve, and Generate
- Four vector store options documented: InMemory, FAISS, Chroma, and Pinecone
- Four key component groups: loaders, splitters, embeddings, and vector stores
Adoption & trust: 8.1k installs on skills.sh; 782 GitHub stars; 2/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
What problem does it solve?
You need LLM answers grounded in your files or data but do not have a clear ingest–retrieve–generate stack chosen or coded.
Who is it for?
Indie builders adding doc Q&A, support bots, or agent tools on LangChain with OpenAI embeddings.
Skip if: Teams that only need chat completions with no external corpus, or shops standardized on non-LangChain RAG frameworks without migration intent.
When should I use this skill?
INVOKE THIS SKILL when building ANY retrieval-augmented generation (RAG) system.
What do I get? / Deliverables
You get a working LangChain RAG pattern with chunking, embeddings, vector storage, and retrieval hooked into generation so you can iterate toward production stores like Pinecone.
- Runnable RAG indexing and query flow in LangChain
- Vector store choice aligned to dev versus production persistence needs
Recommended Skills
Journey fit
RAG is product infrastructure you implement while connecting LLMs to external knowledge—not a launch or growth tactic. Canonical shelf is integrations because the skill centers on loaders, embedders, and vector-store wiring rather than UI or pure agent prompts alone.
How it compares
Use as a procedural LangChain RAG blueprint, not as a hosted vector DB product or generic prompt pack.
Common Questions / FAQ
Who is langchain-rag for?
Solo and indie developers building retrieval-augmented features in Python with LangChain, OpenAI embeddings, and common vector stores.
When should I use langchain-rag?
During Build when you are connecting document sources to an LLM—prototyping with Chroma or FAISS locally, or shaping a production path with Pinecone.
Is langchain-rag safe to install?
Review the Security Audits panel on this Prism page and inspect the skill bundle before granting your agent network or API access to embeddings and stores.
SKILL.md
READMESKILL.md - Langchain Rag
<overview> Retrieval Augmented Generation (RAG) enhances LLM responses by fetching relevant context from external knowledge sources. **Pipeline:** 1. **Index**: Load → Split → Embed → Store 2. **Retrieve**: Query → Embed → Search → Return docs 3. **Generate**: Docs + Query → LLM → Response **Key Components:** - **Document Loaders**: Ingest data from files, web, databases - **Text Splitters**: Break documents into chunks - **Embeddings**: Convert text to vectors - **Vector Stores**: Store and search embeddings </overview> <vectorstore-selection> | Vector Store | Use Case | Persistence | |--------------|----------|-------------| | **InMemory** | Testing | Memory only | | **FAISS** | Local, high performance | Disk | | **Chroma** | Development | Disk | | **Pinecone** | Production, managed | Cloud | </vectorstore-selection> --- ## Complete RAG Pipeline <ex-basic-rag-setup> <python> End-to-end RAG pipeline: load documents, split into chunks, embed, store, retrieve, and generate a response. ```python from langchain_openai import ChatOpenAI, OpenAIEmbeddings from langchain_community.vectorstores import InMemoryVectorStore from langchain_text_splitters import RecursiveCharacterTextSplitter from langchain_core.documents import Document # 1. Load documents docs = [ Document(page_content="LangChain is a framework for LLM apps.", metadata={}), Document(page_content="RAG = Retrieval Augmented Generation.", metadata={}), ] # 2. Split documents splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=50) splits = splitter.split_documents(docs) # 3. Create embeddings and store embeddings = OpenAIEmbeddings(model="text-embedding-3-small") vectorstore = InMemoryVectorStore.from_documents(splits, embeddings) # 4. Create retriever retriever = vectorstore.as_retriever(search_kwargs={"k": 4}) # 5. Use in RAG model = ChatOpenAI(model="gpt-4.1") query = "What is RAG?" relevant_docs = retriever.invoke(query) context = "\n\n".join([doc.page_content for doc in relevant_docs]) response = model.invoke([ {"role": "system", "content": f"Use this context:\n\n{context}"}, {"role": "user", "content": query}, ]) ``` </python> <typescript> End-to-end RAG pipeline: load documents, split into chunks, embed, store, retrieve, and generate a response. ```typescript import { ChatOpenAI, OpenAIEmbeddings } from "@langchain/openai"; import { MemoryVectorStore } from "@langchain/classic/vectorstores/memory"; import { RecursiveCharacterTextSplitter } from "@langchain/textsplitters"; import { Document } from "@langchain/core/documents"; // 1. Load documents const docs = [ new Document({ pageContent: "LangChain is a framework for LLM apps.", metadata: {} }), new Document({ pageContent: "RAG = Retrieval Augmented Generation.", metadata: {} }), ]; // 2. Split documents const splitter = new RecursiveCharacterTextSplitter({ chunkSize: 500, chunkOverlap: 50 }); const splits = await splitter.splitDocuments(docs); // 3. Create embeddings and store const embeddings = new OpenAIEmbeddings({ model: "text-embedding-3-small" }); const vectorstore = await MemoryVectorStore.fromDocuments(splits, embeddings); // 4. Create retriever const retriever = vectorstore.asRetriever({ k: 4 }); // 5. Use in RAG const model = new ChatOpenAI({ model: "gpt-4.1" }); const query = "What is RAG?"; const relevantDocs = await retriever.invoke(query); const context = relevantDocs.map(doc => doc.pageContent).join("\n\n"); const response = await model.invoke([ { role: "system", content: `Use this context:\n\n${context}` }, { role: "user", content: query }, ]); ``` </typescript> </ex-basic-rag-setup> --- ## Document Loaders <ex-loading-pdf> <python> Load a PDF file and extract each page as a separate docum