Skip to content

Commit c828930

Browse files
test: Vector Store Implementation Integration Tests (#16)
* test: Adding integration tests for static utility to create vector embeddings table. * test: Adding add,search,delete integration tests for VectorStore. * test: lint * test: lint * style: lint * style: lint * Empty-Commit to trigger tests * test: addressing review comments. * test: test fix * adding bs4 in test dependencies --------- Co-authored-by: Averi Kitsch <akitsch@google.com>
1 parent e303ddc commit c828930

File tree

4 files changed

+586
-5
lines changed

4 files changed

+586
-5
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Changelog = "https://github.com/googleapis/langchain-google-spanner-python/blob/
2222
[project.optional-dependencies]
2323
test = [
2424
"black[jupyter]==23.12.0",
25+
"bs4==0.0.2",
2526
"isort==5.13.2",
2627
"mypy==1.7.1",
2728
"pytest==7.4.4",

src/langchain_google_spanner/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
from langchain_google_spanner.vector_store import (
16+
DistanceStrategy,
1617
QueryParameters,
1718
SecondaryIndex,
1819
SpannerVectorStore,
@@ -27,4 +28,5 @@
2728
"TableColumn",
2829
"SecondaryIndex",
2930
"QueryParameters",
31+
"DistanceStrategy",
3032
]

src/langchain_google_spanner/vector_store.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -672,12 +672,12 @@ def add_texts(
672672
if number_of_records == 0:
673673
return []
674674

675-
if ids is not None:
675+
if ids is not None and len(ids) != number_of_records:
676676
raise ValueError(
677677
f"size of list of IDs should be equals to number of documents. Expected: {number_of_records} but found {len(ids)}"
678678
)
679679

680-
if metadatas is not None:
680+
if metadatas is not None and len(metadatas) != number_of_records:
681681
raise ValueError(
682682
f"size of list of metadatas should be equals to number of documents. Expected: {number_of_records} but found {len(metadatas)}"
683683
)
@@ -785,8 +785,10 @@ def delete(
785785

786786
values.append(value)
787787

788+
delete_row_count: int = 0
789+
788790
def delete_records(transaction):
789-
# ToDo: Debug why not working
791+
nonlocal delete_row_count
790792
base_delete_statement = "DELETE FROM {} WHERE ".format(self._table_name)
791793

792794
(
@@ -798,7 +800,6 @@ def delete_records(transaction):
798800
sql_delete = base_delete_statement + where_clause
799801

800802
# Iterate over the list of lists of values
801-
delete_row_count = 0
802803
for value_tuple in values:
803804
# Construct the params dictionary
804805
values_tuple_param = (
@@ -817,7 +818,9 @@ def delete_records(transaction):
817818

818819
self._database.run_in_transaction(delete_records)
819820

820-
return True
821+
if delete_row_count > 0:
822+
return True
823+
return None
821824

822825
def similarity_search_with_score_by_vector(
823826
self,

0 commit comments

Comments
 (0)