Skip to content

Initial add IBM DB2 vector store . #68

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 9 commits into
base: main
Choose a base branch
from

Conversation

yiweiHeOSS
Copy link
Collaborator

@yiweiHeOSS yiweiHeOSS commented Mar 28, 2025

This PR adds a new folder under libs for the DB2 vector store langchain connector code, i.e., libs/langchain-db2.
Other companies are doing the same things for their vector store (e.g. Google, AWS and Azure). Thanks for @ccurme to give me some guidance about where to put the code and @MateuszOssGit gave me the access to this repo .

Later, I will create a package on Pypi of the vector store connector, i.e. pip install langchain-db2. Note that it should have no impact on the current package pip install langchain-ibm. I just need a separate directory libs/langchain-db2 to put open-source code.

The major changes in this PR are in the files below:

  • libs/langchain-db2/langchain_db2/db2vs.py - this is the source file of the db2 vector store
  • libs/langchain-db2/docs/db2.ipynb - this is the Jupyter notebook for the demo and steps on how to use the db2 vector store
  • libs/langchain-db2/tests/integration_tests/test_db2vs.py - This is the integration test

@yiweiHeOSS yiweiHeOSS self-assigned this Mar 28, 2025
@yiweiHeOSS yiweiHeOSS requested a review from shaikhq May 29, 2025 22:12
return True


def _get_distance_function(distance_strategy: DistanceStrategy) -> str:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add support for all 6 distance strategies that we support at Db2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw the db2 support:

metric

Identifies the metric used to compute the distance between vector1 and vector2. The supported metrics are:

COSINE
DOT
EUCLIDEAN
EUCLIDEAN_SQUARED
HAMMING
MANHATTAN

However, the langchain I only found:

class DistanceStrategy(str, Enum):
    """Enumerator of the Distance strategies for calculating distances
    between vectors."""

    EUCLIDEAN_DISTANCE = "EUCLIDEAN_DISTANCE"
    MAX_INNER_PRODUCT = "MAX_INNER_PRODUCT"
    DOT_PRODUCT = "DOT_PRODUCT"
    JACCARD = "JACCARD"
    COSINE = "COSINE"

So I guess I can only add the 3 strategies as I did now. Please tell me if I am wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants