community[patch]: changed default for VertexAIEmbeddings (#14614)

Replace this entire comment with:
- **Description:** @kurtisvg has raised a point that it's a good idea to
have a fixed version for embeddings (since otherwise a user might run a
query with one version vs a vectorstore where another version was used).
In order to avoid breaking changes, I'd suggest to give users a warning,
and make a `model_name` a required argument in 1.5 months.
This commit is contained in:
Leonid Kuligin
2023-12-21 18:15:19 +01:00
committed by GitHub
parent 138bc49759
commit b99274c9d8
2 changed files with 25 additions and 3 deletions

View File

@@ -5,6 +5,8 @@ pip install google-cloud-aiplatform>=1.35.0
Your end-user credentials would be used to make the calls (make sure you've run
`gcloud auth login` first).
"""
import pytest
from langchain_community.embeddings import VertexAIEmbeddings
@@ -15,6 +17,7 @@ def test_embedding_documents() -> None:
assert len(output) == 1
assert len(output[0]) == 768
assert model.model_name == model.client._model_id
assert model.model_name == "textembedding-gecko@001"
def test_embedding_query() -> None:
@@ -50,3 +53,15 @@ def test_paginated_texts() -> None:
assert len(output) == 8
assert len(output[0]) == 768
assert model.model_name == model.client._model_id
def test_warning(caplog: pytest.LogCaptureFixture) -> None:
_ = VertexAIEmbeddings()
assert len(caplog.records) == 1
record = caplog.records[0]
assert record.levelname == "WARNING"
expected_message = (
"Model_name will become a required arg for VertexAIEmbeddings starting from "
"Feb-01-2024. Currently the default is set to textembedding-gecko@001"
)
assert record.message == expected_message