Skip to content
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

community: Cassandra Vector Store: extend metadata-related methods #27078

Conversation

hemidactylus
Copy link
Contributor

@hemidactylus hemidactylus commented Oct 3, 2024

Description: this PR adds a set of methods to deal with metadata associated to the vector store entries. These, while essential to the Graph-related extension of the Cassandra vector store, are also useful in themselves. These are (all come in their sync+async versions):

  • [a]delete_by_metadata_filter
  • [a]replace_metadata
  • [a]get_by_document_id
  • [a]metadata_search

Additionally, a [a]similarity_search_with_embedding_id_by_vector method is introduced to better serve the store's internal working (esp. related to reranking logic).

Issue: no issue number, but now all Document's returned bear their .id consistently (as a consequence of a slight refactoring in how the raw entries read from DB are made back into Document instances).

Dependencies: (no new deps: packaging comes through langchain-core already; cassio is now required to be version 0.1.10+)

Add tests and docs
Added integration tests for the relevant newly-introduced methods.
(Docs will be updated in a separate PR).

Lint and test Lint and (updated) test all pass.

Copy link

vercel bot commented Oct 3, 2024

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

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Oct 9, 2024 6:36am

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. community Related to langchain-community Ɑ: vector store Related to vector store module labels Oct 3, 2024
@epinzur
Copy link
Contributor

epinzur commented Oct 4, 2024

I helped work on this code. The changes here are a prerequisite needed for upcoming changes to the Cassandra Graph Vector Store.

@hemidactylus
Copy link
Contributor Author

@efriis may I ask you to take a look, please? This enhancement will enable the upcoming improvements to the Graph Vector Store. 🙏

@dosubot dosubot bot added the lgtm PR looks good. Use to confirm that a PR is ready for merging. label Oct 9, 2024
@efriis efriis enabled auto-merge (squash) October 9, 2024 06:36
@efriis efriis merged commit d05fdd9 into langchain-ai:master Oct 9, 2024
18 checks passed
@hemidactylus hemidactylus deleted the SL-cassandra-vectorstore-metadata-methods branch October 9, 2024 07:37
efriis added a commit that referenced this pull request Oct 22, 2024
**Description:** 

This PR updates `CassandraGraphVectorStore` to be based off
`CassandraVectorStore`, instead of using a custom CQL implementation.
This allows users using a `CassandraVectorStore` to upgrade to a
`GraphVectorStore` without having to change their database schema or
re-embed documents.

This PR also updates the documentation of the `GraphVectorStore` base
class and contains native async implementations for the standard graph
methods: `traversal_search` and `mmr_traversal_search` in
`CassandraVectorStore`.

**Issue:** No issue number.

**Dependencies:** #27078
(already-merged)

**Lint and test**: 
- Lint and tests all pass, including existing
`CassandraGraphVectorStore` tests.
- Also added numerous additional tests based of the tests in
`langchain-astradb` which cover many more scenarios than the existing
tests for `Cassandra` and `CassandraGraphVectorStore`

** BREAKING CHANGE**

Note that this is a breaking change for existing users of
`CassandraGraphVectorStore`. They will need to wipe their database table
and restart.

However:
- The interfaces have not changed. Just the underlying storage
mechanism.
- Any one using `langchain_community.vectorstores.Cassandra` can instead
use `langchain_community.graph_vectorstores.CassandraGraphVectorStore`
and they will gain Graph capabilities without having to re-embed their
existing documents. This is the primary goal of this PR.

---------

Co-authored-by: Erick Friis <erick@langchain.dev>
ccurme pushed a commit that referenced this pull request Oct 22, 2024
**Description:** 

This PR updates `CassandraGraphVectorStore` to be based off
`CassandraVectorStore`, instead of using a custom CQL implementation.
This allows users using a `CassandraVectorStore` to upgrade to a
`GraphVectorStore` without having to change their database schema or
re-embed documents.

This PR also updates the documentation of the `GraphVectorStore` base
class and contains native async implementations for the standard graph
methods: `traversal_search` and `mmr_traversal_search` in
`CassandraVectorStore`.

**Issue:** No issue number.

**Dependencies:** #27078
(already-merged)

**Lint and test**: 
- Lint and tests all pass, including existing
`CassandraGraphVectorStore` tests.
- Also added numerous additional tests based of the tests in
`langchain-astradb` which cover many more scenarios than the existing
tests for `Cassandra` and `CassandraGraphVectorStore`

** BREAKING CHANGE**

Note that this is a breaking change for existing users of
`CassandraGraphVectorStore`. They will need to wipe their database table
and restart.

However:
- The interfaces have not changed. Just the underlying storage
mechanism.
- Any one using `langchain_community.vectorstores.Cassandra` can instead
use `langchain_community.graph_vectorstores.CassandraGraphVectorStore`
and they will gain Graph capabilities without having to re-embed their
existing documents. This is the primary goal of this PR.

---------

Co-authored-by: Erick Friis <erick@langchain.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Related to langchain-community lgtm PR looks good. Use to confirm that a PR is ready for merging. size:L This PR changes 100-499 lines, ignoring generated files. Ɑ: vector store Related to vector store module
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants