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

test: Vector Store Implementation Integration Tests #16

Merged
merged 12 commits into from
Feb 22, 2024
2 changes: 2 additions & 0 deletions src/langchain_google_spanner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
SecondaryIndex,
SpannerVectorStore,
TableColumn,
DistanceStrategy,
)

from .version import __version__
Expand All @@ -27,4 +28,5 @@
"TableColumn",
"SecondaryIndex",
"QueryParameters",
"DistanceStrategy",
]
11 changes: 7 additions & 4 deletions src/langchain_google_spanner/vector_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,12 +672,12 @@ def add_texts(
if number_of_records == 0:
return []

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

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

values.append(value)

delete_row_count = 0
gauravpurohit06 marked this conversation as resolved.
Show resolved Hide resolved

def delete_records(transaction):
# ToDo: Debug why not working
base_delete_statement = "DELETE FROM {} WHERE ".format(self._table_name)
Expand All @@ -798,7 +800,6 @@ def delete_records(transaction):
sql_delete = base_delete_statement + where_clause

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

self._database.run_in_transaction(delete_records)

return True
if delete_row_count > 0:
return True
return None

def similarity_search_with_score_by_vector(
self,
Expand Down
Loading
Loading