136e69e967981c8c1b1a58342fc78665e012865d
RAG Agent with ChromaDB and Web Search
This project implements a Retrieval-Augmented Generation (RAG) agent that:
- Stores and retrieves embeddings from ChromaDB.
- Performs web search using DuckDuckGo to fetch additional context.
- Generates answers with an Ollama language model.
Prerequisites
- Node.js v20 or newer
- ChromaDB server running locally (default URL:
chromadb://localhost:8000) - Ollama server running locally (default URL:
http://localhost:11434)
Setup
-
Clone the repository
git clone https://git.brojs.ru/kuzakhmetovartur/ekzamen-rag-agent-s-chromadb-i-veb-poisk.git cd ekzamen-rag-agent-s-chromadb-i-veb-poisk -
Install dependencies
npm install -
Configure environment variables
Create a
.envfile in the project root (or modify the existing one):CHROMA_URL=chromadb://localhost:8000 CHROMA_COLLECTION=rag_collection OLLAMA_HOST=http://localhost:11434 OLLAMA_MODEL=llama3 OLLAMA_EMBEDDING_MODEL=nomic-embed-text ADD_SAMPLE_DOCS=trueCHROMA_URL: URL of your ChromaDB instance.CHROMA_COLLECTION: Name of the collection to use.OLLAMA_HOST: URL of your Ollama server.OLLAMA_MODEL: Ollama model for generation.OLLAMA_EMBEDDING_MODEL: Ollama model for embeddings.ADD_SAMPLE_DOCS: Set totrueto automatically add a few sample documents on startup.
-
Run the agent
npm start -- "Your question here"Example:
npm start -- "What is LangChain?"The agent will:
- Search the local ChromaDB collection.
- Perform a DuckDuckGo web search.
- Combine the results and generate an answer using Ollama.
Project Structure
.
├── src
│ ├── agent.js # Agent logic (retrieval + generation)
│ ├── index.js # CLI entry point
│ ├── vectorStore.js # ChromaDB wrapper
│ └── webSearch.js # DuckDuckGo search helper
├── .env # Environment configuration
├── package.json # Dependencies and scripts
└── README.md # Documentation
Notes
- The agent uses LangChain 1.x APIs.
- No Qdrant references are present; only ChromaDB is used.
- The web search is performed via DuckDuckGo’s public JSON API (no API key required).
- The Ollama LLM is used for both embeddings and generation.
Feel free to extend the agent with additional retrievers or custom prompts as needed.
Description
Languages
Python
82.6%
JavaScript
16.6%
Dockerfile
0.8%