Skip to content

feat(vectorstores): add Chromia vectorstore integration and examples #8041

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

liho00
Copy link

@liho00 liho00 commented Apr 18, 2025

Chromia Vector DB for LangChain.js

Chromia integration as a vector store for LangChain.js, built on top of [postchain-client](https://www.npmjs.com/package/postchain-client). This package enables you to use a Chromia blockchain as a persistent and verifiable vector store for document embeddings.


Features

  • ✅ Add vectors/documents
  • ✅ Perform similarity search
  • ✅ Delete documents
  • 🔜 Filtering support (interface added, not yet implemented)
  • ✅ Written in TypeScript with full types and documentation

Quickstart

1. Clone and Start a Local Chromia Node

docker run --rm -it -p 7740:7740 registry.gitlab.com/chromaway/example-projects/directory1-example/managed-single:latest
git clone https://github.com/liho00/vector-db-chromia.git
cd vector-db-chromia/chromia/rell
chr build
pmc blockchain add -bc build/vector_example.xml -c dapp -n vector_blockchain

This spins up a local Chromia node using Docker with a default blockchain configuration that supports vector storage.

Note: Ensure Docker is installed and running on your machine.


2. Install the Vector Store

npm install @langchain/community
npm install postchain-client

3. Usage Example

import { Chromia } from '@langchain/community/vectorstores/chromia';
import { OpenAIEmbeddings } from '@langchain/openai';
import { createPostchainClient } from 'postchain-client'; // Your own wrapper or raw setup

// Setup postchain client
const postchainClient = createPostchainClient({
  blockchainRID: 'your-blockchain-rid',
  nodeUrl: 'http://localhost:7740', // default RPC for Chromia dev node
});

const embeddings = new OpenAIEmbeddings({
  model: 'text-embedding-3-small',
});

const vectorStore = new Chromia(embeddings, {
  client: postchainClient,
  numDimensions: embeddings.dimensions,
});

// Add document
await vectorStore.addDocuments([
  { pageContent: 'sample text', metadata: { source: 'doc1' } },
]);

// Perform a similarity search
const results = await vectorStore.similaritySearch('query', 1);
console.log(results);

Copy link

vercel bot commented Apr 18, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview May 26, 2025 6:39am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) May 26, 2025 6:39am

@Prem95
Copy link

Prem95 commented Apr 28, 2025

Hi @jacoblee93 Can you please help to take a look at this PR? Thank you!

@benjamincburns
Copy link
Contributor

benjamincburns commented Apr 28, 2025

@Prem95 this is in draft status - we generally wait until it's no longer a draft to review unless you have specific questions. If you think this is ready, please click the "Ready for review" button and we'll have a look.

Edit: Oh, I see this isn't your PR - @liho00 will need to update the PR status when they're ready for us.

@Prem95
Copy link

Prem95 commented Apr 29, 2025

@Prem95 this is in draft status - we generally wait until it's no longer a draft to review unless you have specific questions. If you think this is ready, please click the "Ready for review" button and we'll have a look.

Edit: Oh, I see this isn't your PR - @liho00 will need to update the PR status when they're ready for us.

Thanks @benjamincburns for the information. It will be updated

@liho00 liho00 marked this pull request as ready for review May 1, 2025 16:37
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. auto:documentation Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder auto:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features labels May 1, 2025
@liho00
Copy link
Author

liho00 commented May 1, 2025

Hi @benjamincburns, @jacoblee93 its ready for review now.

@liho00
Copy link
Author

liho00 commented May 6, 2025

Hi @benjamincburns, @jacoblee93 its ready for review now.

1 similar comment
@liho00
Copy link
Author

liho00 commented May 19, 2025

Hi @benjamincburns, @jacoblee93 its ready for review now.

@Prem95
Copy link

Prem95 commented May 23, 2025

Hi @benjamincburns, please review this, thanks!

@benjamincburns
Copy link
Contributor

Hi @liho00,

The community package has become rather unwieldy, and we recommend against using it in production applications.

Is this something that you want people to be able to use in production? If so, I'd recommend repackaging your changes into a standalone NPM module. You can keep this in your own GitHub repo and publish it to NPM yourself without our involvement, but to make it discoverable you can still create a PR that adds a page about it in our integration docs.

Otherwise if you think that community is the best home for this, we'll leave it open and review it when we're able. Unfortunately adding new features to community isn't a high priority for us right now, so this may take a little while.

@liho00
Copy link
Author

liho00 commented May 26, 2025

Hi @liho00,

The community package has become rather unwieldy, and we recommend against using it in production applications.

Is this something that you want people to be able to use in production? If so, I'd recommend repackaging your changes into a standalone NPM module. You can keep this in your own GitHub repo and publish it to NPM yourself without our involvement, but to make it discoverable you can still create a PR that adds a page about it in our integration docs.

Otherwise if you think that community is the best home for this, we'll leave it open and review it when we're able. Unfortunately adding new features to community isn't a high priority for us right now, so this may take a little while.

https://www.npmjs.com/package/@liholiho/community?activeTab=readme

We have published for our own use, but we still need this to be merged for better endorsement for users.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:documentation Changes to documentation and examples, like .md, .rst, .ipynb files. Changes to the docs/ folder auto:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants