Registry Synced

RAG and AI Agents

70 words
1 min read

RAG and AI Agents

python
# Simple RAG using LangChain
from langchain.embeddings import OpenAIEmbeddings
from langchain.vectorstores import FAISS
from langchain.chains import RetrievalQA
from langchain.llms import OpenAI
# Create vector store
documents = ["Doc 1 text...", "Doc 2 text..."]
embeddings = OpenAIEmbeddings()
vectorstore = FAISS.from_texts(documents, embeddings)
# RAG chain
qa = RetrievalQA.from_chain_type(
    llm=OpenAI(),
    chain_type="stuff",
    retriever=vectorstore.as_retriever()
)
response = qa.run("What is doc 1 about?")
print(response)
Document outline

Keep your place and jump directly to a heading.

Table of contents

No note selected

Open a chapter to see its outline, backlinks, and sources here.