1.8 KiB
1.8 KiB
RAG Agent with ChromaDB and Web Search
This project demonstrates a Retrieval-Augmented Generation (RAG) agent built with LangChain 1.x, ChromaDB as the vector store, and SerpAPI for web search integration.
Features
- Stores documents in ChromaDB and generates embeddings using OpenAI.
- Retrieves relevant documents via a vector store tool.
- Performs live web searches with SerpAPI.
- Combines both sources to answer user queries.
Prerequisites
- Node.js v18+ (ES modules support)
- A running ChromaDB instance (default:
localhost:8000) - OpenAI API key
- SerpAPI key
Setup
-
Clone the repository
git clone https://github.com/your-username/rag-agent-chromadb-websearch.git cd rag-agent-chromadb-websearch -
Install dependencies
npm install -
Configure environment variables
Create a
.envfile in the project root:OPENAI_API_KEY=your_openai_api_key CHROMA_HOST=localhost CHROMA_PORT=8000 SERPAPI_KEY=your_serpapi_key -
Run the agent
npm startThe agent will add sample documents to ChromaDB, then answer a sample query using both the vector store and web search.
Project Structure
src/
├── index.js # Entry point
├── agent.js # Agent construction
├── vectorStore.js # ChromaDB interactions
└── webSearch.js # SerpAPI web search
Customization
- Adding Documents: Use
addDocumentsfromvectorStore.jsto add your own documents. - Changing LLM: Replace
OpenAIwith another LLM provider supported by LangChain. - Adjusting Retrieval: Modify the number of results returned by the vector store or web search.
License
MIT License
Happy coding!