e95da4c2952c0ea9d5d6a640810db512342487e4
CI / build (push) Has been cancelled
Agent with RAG Memory (ChromaDB)
This project implements a Retrieval-Augmented Generation (RAG) agent that uses ChromaDB as its sole vector store. The agent can ingest documents, store their embeddings, retrieve relevant passages, and generate answers using OpenAI’s GPT models.
Features
- Vector Store – Uses ChromaDB for storing and querying embeddings.
- Embeddings – Generated with OpenAI’s
text-embedding-ada-002. - Chat – Generates responses with OpenAI’s
gpt-3.5-turbo. - Public API – The
Agentclass exposesinit,ingest, andaskmethods, keeping the original interface unchanged.
Setup
-
Clone the repository
git clone https://git.brojs.ru/kuzakhmetovartur/agent-s-rag-pamyatyu.git cd agent-s-rag-pamyatyu -
Install dependencies
npm install -
Configure environment variables
Create a
.envfile in the project root (or export the variables in your shell):# ChromaDB CHROMA_URL=localhost CHROMA_PORT=8000 # OpenAI OPENAI_API_KEY=YOUR_OPENAI_API_KEYCHROMA_URLandCHROMA_PORTpoint to your ChromaDB instance.OPENAI_API_KEYis required for embeddings and chat completions.
-
Run ChromaDB
Ensure a ChromaDB server is running on the specified host/port. You can start a local instance with Docker:
docker run -d -p 8000:8000 chromadb/chroma
Usage
const { Agent } = require('./src');
(async () => {
const agent = new Agent();
await agent.init();
// Ingest documents
await agent.ingest('The quick brown fox jumps over the lazy dog.', { source: 'example.txt' });
// Ask a question
const answer = await agent.ask('What did the fox do?');
console.log(answer);
})();
API
| Method | Description |
|---|---|
init() |
Initializes the vector store (creates collection if needed). |
ingest(text, metadata) |
Adds a document to the vector store. |
ask(question) |
Retrieves relevant passages and generates an answer. |
Testing
If you have a test suite, run:
npm test
All tests should pass after the ChromaDB integration.
Notes
- The agent’s public API remains unchanged; only the underlying vector store implementation has been swapped to ChromaDB.
- No new external services are introduced beyond ChromaDB and the existing OpenAI usage.
- Ensure that the ChromaDB server is reachable; otherwise, the agent will throw connection errors.
Happy coding!
Description
Languages
Python
67.1%
TypeScript
16.6%
JavaScript
15.4%
Dockerfile
0.9%