Skip to main content

Vector stores and chat history

Every IntelliNode vector store has the same five methods, so you can start with an in-memory store and move to a database later without changing the rest of your code. The Assistant uses these stores for documents and memory, and you can also use them on their own.

The shared interface​

const { QdrantVectorStore } = require('intellinode');

const store = new QdrantVectorStore({
url: 'http://localhost:6333',
collection: 'docs',
embedder: { provider: 'openai', apiKey: process.env.OPENAI_API_KEY },
});

await store.addDocuments([{ id: 'a', text: 'IntelliNode supports Gemini.', metadata: { lang: 'en' } }]);
const hits = await store.search('Which models are supported?', 3, { lang: 'en' });
// [{ id, score, text, metadata }]
MethodWhat it does
addDocuments(docs)Embeds the text with the store's embedder and saves it under your ids.
upsert(items)Saves vectors you made yourself: { id, vector, text, metadata }.
search(text, topK, filter)Finds the closest documents to a question.
query({ text or vector, topK, filter })The same search, with an object.
delete(ids)Removes documents by id.

score is a similarity, so higher means closer. filter matches metadata values exactly, and an array means "one of". For anything more, pass the database's own filter as nativeFilter.

Pick an embedder​

The embedder turns text into vectors:

{ provider: 'openai', apiKey }                                   // text-embedding-3-small
{ provider: 'gemini', apiKey } // 3072 numbers
{ provider: 'vertex', apiKey, dimensions: 768 } // gemini-embedding-001 on Vertex AI
{ provider: 'cohere', apiKey }
{ provider: 'ollama', model: 'nomic-embed-text', options: { baseUrl: 'http://localhost:11434/v1' } }
async (texts) => myVectors(texts) // your own function

Keep the same embedder for the life of a store. A different model or dimensions makes the saved vectors useless.

Pick a store​

ClassUse it forNeeds
MemoryVectorStore({ path })Local apps, tests and the browser, up to a few thousand chunksNothing. path saves it to a JSON file.
PineconeVectorStore({ apiKey, indexHost })Managed vector searchAn index with the right dimension
QdrantVectorStore({ url, apiKey, collection })Self-hosted or Qdrant CloudA Qdrant server
ChromaVectorStore({ url, collection })Local developmentchroma run or Chroma Cloud
WeaviateVectorStore({ url, apiKey, className })Weaviate 1.2x and laterA capitalized class name
MilvusVectorStore({ url, token, collection, dimension })Milvus or ZillizMilvus 2.5 or later
ElasticsearchVectorStore({ url, apiKey, index, dimension })An existing Elasticsearch clusterElasticsearch 8 or later
PgVectorStore({ client, dimension })Postgres, AlloyDB, Cloud SQL, Supabase, Neonnpm i pg and the pgvector extension
MongoDBAtlasVectorStore({ collection })MongoDB Atlasnpm i mongodb and an Atlas vector index
FirestoreVectorStore({ projectId, collection })Data next to your Firestore app dataGoogle Cloud OAuth and a vector index
VertexRAGStore({ projectId, location, corpus })Google parses, chunks and embeds your filesGoogle Cloud OAuth
VertexVectorSearchStore({ projectId, collection })Vertex AI Vector Search 2.0Google Cloud OAuth

PgVectorStore creates its table and index on first use, and Qdrant creates its collection on the first write.

Google Cloud stores​

Firestore, RAG Engine and Vector Search don't accept API keys. For local development, sign in once:

gcloud auth application-default login

On Cloud Run, GKE or Compute Engine the token comes from the environment. Anywhere else, point GOOGLE_APPLICATION_CREDENTIALS at a service account key file, or pass accessToken.

Firestore also needs a vector index. store.indexCommand(768) prints the gcloud command that creates it.

Chat history​

The Assistant saves conversations through one of these:

ClassWhere it savesGood for
MemoryChatHistory()Process memory, lost on restartTests. It is the default.
FileChatHistory({ dir })One JSON file per conversationLocal apps and desktop tools
FirestoreChatHistory({ projectId, collection })FirestoreServers with many users

With Firestore for both history and memory, a user's conversations stay in your Google Cloud project:

const { Assistant, FirestoreChatHistory, FirestoreVectorStore } = require('intellinode');

const embedder = { provider: 'vertex', apiKey: process.env.VERTEX_API_KEY, dimensions: 768 };
const assistant = new Assistant({
provider: 'vertex',
apiKey: process.env.VERTEX_API_KEY,
history: new FirestoreChatHistory({ projectId }),
memory: new FirestoreVectorStore({ projectId, collection: 'memories', embedder }),
});

For another database, such as Redis or DynamoDB, extend ChatHistory and write its seven methods: getMessages, addMessages, getConversation, saveConversation, listConversations, deleteConversation and deleteLastMessages.