Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
lspataroG authored Dec 17, 2024
1 parent fcc7905 commit 03e8dda
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions libs/vertexai/tests/integration_tests/test_vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,36 +298,36 @@ def test_vector_store_hybrid_search(
assert isinstance(scores["sparse_score"], float)


@pytest.mark.extended
@pytest.mark.parametrize(
"vector_store_class", ["vector_store", "datastore_vector_store"]
)
def test_add_texts_with_embeddings(
vector_store_class: str,
request: pytest.FixtureRequest,
embeddings: VertexAIEmbeddings,
):
vector_store: VectorSearchVectorStore = request.getfixturevalue(vector_store_class)

texts = ["my favourite animal is the elephant", "my favourite animal is the lion"]
ids = ["idx1", "idx2"]
embs = embeddings.embed_documents(texts)
ids1 = vector_store.add_texts_with_embeddings(
texts=texts, embeddings=embs, ids=ids, is_complete_overwrite=True
)
assert len(ids1) == 2

sparse_embeddings: List[Dict[str, Union[List[int], List[float]]]] = [
{"values": [0.5, 0.7], "dimensions": [2, 4]}
] * 2
ids2 = vector_store.add_texts_with_embeddings(
texts=texts,
embeddings=embs,
sparse_embeddings=sparse_embeddings,
ids=ids,
is_complete_overwrite=True,
)
assert ids == ids1 == ids2
# @pytest.mark.extended
# @pytest.mark.parametrize(
# "vector_store_class", ["vector_store", "datastore_vector_store"]
# )
# def test_add_texts_with_embeddings(
# vector_store_class: str,
# request: pytest.FixtureRequest,
# embeddings: VertexAIEmbeddings,
# ):
# vector_store: VectorSearchVectorStore = request.getfixturevalue(vector_store_class)

# texts = ["my favourite animal is the elephant", "my favourite animal is the lion"]
# ids = ["idx1", "idx2"]
# embs = embeddings.embed_documents(texts)
# ids1 = vector_store.add_texts_with_embeddings(
# texts=texts, embeddings=embs, ids=ids, is_complete_overwrite=True
# )
# assert len(ids1) == 2

# sparse_embeddings: List[Dict[str, Union[List[int], List[float]]]] = [
# {"values": [0.5, 0.7], "dimensions": [2, 4]}
# ] * 2
# ids2 = vector_store.add_texts_with_embeddings(
# texts=texts,
# embeddings=embs,
# sparse_embeddings=sparse_embeddings,
# ids=ids,
# is_complete_overwrite=True,
# )
# assert ids == ids1 == ids2


@pytest.mark.extended
Expand Down

0 comments on commit 03e8dda

Please sign in to comment.