RAG and AI Agents
70 words
1 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# RAG and AI Agents [Join Discord](https://discord.gg/gE2m4Qrdqv) [Previous**Prompt Engineering**](/notes/04-degree-electives-bsda4001-ds-ai-lab-week06-06-prompt-engineering)[Next**Data Visualization**](/notes/04-degree-electives-bsda4001-ds-ai-lab-week08-08-data-viz-lab)

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)