Skip to content

Commit 4933407

Browse files
yiweiHeOSSccurmeMateuszOssGit
authored
Initial add IBM DB2 vector store . (#68)
* Initial add db2 vector store. * Update readme for db2vs. * Add dependency sentence-transformers * Improve error handling and comments. * Improve error handling. * Improve the code and testcase. * Small change. * Remove the debug message in code. * Change the term to Db2. Update the sample document. * Update the insert code to use bulk insert. * update CI script * add a test * auto format (run [ "." = "" ] || poetry run ruff format . 8 files left unchanged [ "." = "" ] || poetry run ruff check --select I --fix . All checks passed!) * Resolve ccurme's comments. * Update poetry.lock * Run format. * add test for compiling integration tests * make format and make lint * Revert a change in integration_tests/test_db2vs.py * Resolve comments. --------- Co-authored-by: Chester Curme <[email protected]> Co-authored-by: Mateusz Szewczyk <[email protected]>
1 parent 0782aa8 commit 4933407

File tree

20 files changed

+5949
-3
lines changed

20 files changed

+5949
-3
lines changed

.github/scripts/check_diff.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sys
33
from typing import Dict
44

5-
LIB_DIRS = ["libs/ibm"]
5+
LIB_DIRS = ["libs/ibm", "libs/langchain-db2"]
66

77
if __name__ == "__main__":
88
files = sys.argv[1:]

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
# 🦜️🔗 LangChain IBM Watsonx
1+
# 🦜️🔗 LangChain IBM
22

3-
This repository contains 1 package with IBM integrations with LangChain:
3+
This repository contains 2 package with IBM integrations with LangChain:
44

55
- [langchain-ibm](https://pypi.org/project/langchain-ibm/) integrates [IBM Watsonx](https://www.ibm.com/watsonx).
6+
7+
- [langchain-db2](https://pypi.org/project/langchain-db2/)(will be uploaded very soon) integrates IBM Db2 database vector store and vector search.

libs/langchain-db2/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__pycache__

libs/langchain-db2/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 LangChain, Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

libs/langchain-db2/Makefile

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
.PHONY: all format lint test tests integration_tests docker_tests help extended_tests
2+
3+
# Default target executed when no arguments are given to make.
4+
all: help
5+
6+
# Define a variable for the test file path.
7+
TEST_FILE ?= tests/unit_tests/
8+
integration_test integration_tests: TEST_FILE = tests/integration_tests/
9+
10+
11+
# unit tests are run with the --disable-socket flag to prevent network calls
12+
test tests:
13+
poetry run pytest --disable-socket --allow-unix-socket $(TEST_FILE)
14+
15+
test_watch:
16+
poetry run ptw --snapshot-update --now . -- -vv $(TEST_FILE)
17+
18+
# integration tests are run without the --disable-socket flag to allow network calls
19+
integration_test integration_tests:
20+
poetry run pytest $(TEST_FILE)
21+
22+
######################
23+
# LINTING AND FORMATTING
24+
######################
25+
26+
# Define a variable for Python and notebook files.
27+
PYTHON_FILES=.
28+
MYPY_CACHE=.mypy_cache
29+
lint format: PYTHON_FILES=.
30+
lint_diff format_diff: PYTHON_FILES=$(shell git diff --relative=libs/partners/db2 --name-only --diff-filter=d master | grep -E '\.py$$|\.ipynb$$')
31+
lint_package: PYTHON_FILES=langchain_db2
32+
lint_tests: PYTHON_FILES=tests
33+
lint_tests: MYPY_CACHE=.mypy_cache_test
34+
35+
lint lint_diff lint_package lint_tests:
36+
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff check $(PYTHON_FILES)
37+
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff format $(PYTHON_FILES) --diff
38+
[ "$(PYTHON_FILES)" = "" ] || mkdir -p $(MYPY_CACHE) && poetry run mypy $(PYTHON_FILES) --cache-dir $(MYPY_CACHE)
39+
40+
format format_diff:
41+
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff format $(PYTHON_FILES)
42+
[ "$(PYTHON_FILES)" = "" ] || poetry run ruff check --select I --fix $(PYTHON_FILES)
43+
44+
spell_check:
45+
poetry run codespell --toml pyproject.toml
46+
47+
spell_fix:
48+
poetry run codespell --toml pyproject.toml -w
49+
50+
check_imports: $(shell find langchain_db2 -name '*.py')
51+
poetry run python ./scripts/check_imports.py $^
52+
53+
######################
54+
# HELP
55+
######################
56+
57+
help:
58+
@echo '----'
59+
@echo 'check_imports - check imports'
60+
@echo 'format - run code formatters'
61+
@echo 'lint - run linters'
62+
@echo 'test - run unit tests'
63+
@echo 'tests - run unit tests'
64+
@echo 'test TEST_FILE=<test_file> - run all tests in file'

libs/langchain-db2/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# langchain-db2
2+
3+
This package contains the LangChain integration with the connector to Db2 vector store. This will allow user to leverage the vector store and vector search ablility of the IBM Db2 relational datebase.
4+
5+
## Installation
6+
7+
```bash
8+
pip install -U langchain-db2
9+
```
10+
11+
See more details of how to use it in the Jupyter Notebook: langchain-db2/docs/db2.ipynb (This link will be updated https://github.com/langchain-ai/langchain-ibm/blob/756f43fe392f70f6c4b755d7966ea8ee1cc42759/libs/langchain-db2/docs/db2.ipynb)
12+

0 commit comments

Comments
 (0)