# 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 1. **Clone the repository** ```bash git clone https://github.com/your-username/rag-agent-chromadb-websearch.git cd rag-agent-chromadb-websearch ``` 2. **Install dependencies** ```bash npm install ``` 3. **Configure environment variables** Create a `.env` file in the project root: ```dotenv OPENAI_API_KEY=your_openai_api_key CHROMA_HOST=localhost CHROMA_PORT=8000 SERPAPI_KEY=your_serpapi_key ``` 4. **Run the agent** ```bash npm start ``` The 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 `addDocuments` from `vectorStore.js` to add your own documents. - **Changing LLM**: Replace `OpenAI` with 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!