Skip to content

Commit dffcdcb

Browse files
authored
Merge pull request #2075 from weaviate/feat/text2vec-google-location
feat: add optional location parameter to text2vec-google vectorizer
2 parents 50df61f + cec15ca commit dffcdcb

4 files changed

Lines changed: 44 additions & 0 deletions

File tree

test/collection/test_config.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2429,6 +2429,31 @@ def test_config_with_named_vectors(
24292429
}
24302430
},
24312431
),
2432+
(
2433+
[
2434+
Configure.Vectors.text2vec_google_vertex(
2435+
name="test",
2436+
project_id="project",
2437+
source_properties=["prop"],
2438+
dimensions=768,
2439+
location="europe-west1",
2440+
)
2441+
],
2442+
{
2443+
"test": {
2444+
"vectorizer": {
2445+
"text2vec-palm": {
2446+
"projectId": "project",
2447+
"location": "europe-west1",
2448+
"properties": ["prop"],
2449+
"vectorizeClassName": True,
2450+
"dimensions": 768,
2451+
}
2452+
},
2453+
"vectorIndexType": "hnsw",
2454+
}
2455+
},
2456+
),
24322457
(
24332458
[
24342459
Configure.Vectors.text2vec_google_gemini(

weaviate/collections/classes/config_named_vectors.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,7 @@ def text2vec_palm(
991991
vectorizeClassName=vectorize_collection_name,
992992
titleProperty=title_property,
993993
taskType=None,
994+
location=None,
994995
),
995996
vector_index_config=vector_index_config,
996997
)
@@ -1006,6 +1007,7 @@ def text2vec_google(
10061007
source_properties: Optional[List[str]] = None,
10071008
vector_index_config: Optional[_VectorIndexConfigCreate] = None,
10081009
vectorize_collection_name: bool = True,
1010+
location: Optional[str] = None,
10091011
) -> _NamedVectorConfigCreate:
10101012
"""Create a named vector using the `text2vec_palm` model.
10111013
@@ -1022,6 +1024,7 @@ def text2vec_google(
10221024
api_endpoint: The API endpoint to use without a leading scheme such as `http://`. Defaults to `None`, which uses the server-defined default
10231025
model_id: The model ID to use. Defaults to `None`, which uses the server-defined default.
10241026
title_property: The Weaviate property name for the `gecko-002` or `gecko-003` model to use as the title.
1027+
location: The Google Vertex AI region to run the model in. Defaults to `None`, which uses the server-defined default.
10251028
10261029
Raises:
10271030
pydantic.ValidationError: If `api_endpoint` is not a valid URL.
@@ -1037,6 +1040,7 @@ def text2vec_google(
10371040
vectorizeClassName=vectorize_collection_name,
10381041
titleProperty=title_property,
10391042
taskType=None,
1043+
location=location,
10401044
),
10411045
vector_index_config=vector_index_config,
10421046
)
@@ -1079,6 +1083,7 @@ def text2vec_google_aistudio(
10791083
vectorizeClassName=vectorize_collection_name,
10801084
titleProperty=title_property,
10811085
taskType=None,
1086+
location=None,
10821087
),
10831088
vector_index_config=vector_index_config,
10841089
)

weaviate/collections/classes/config_vectorizers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ class _Text2VecGoogleConfig(_VectorizerConfigCreate):
378378
vectorizeClassName: bool
379379
titleProperty: Optional[str]
380380
taskType: Optional[str]
381+
location: Optional[str]
381382

382383

383384
class _Text2VecTransformersConfig(_VectorizerConfigCreate):
@@ -1199,6 +1200,7 @@ def text2vec_palm(
11991200
vectorizeClassName=vectorize_collection_name,
12001201
titleProperty=title_property,
12011202
taskType=None,
1203+
location=None,
12021204
)
12031205

12041206
@staticmethod
@@ -1228,6 +1230,7 @@ def text2vec_google_aistudio(
12281230
vectorizeClassName=vectorize_collection_name,
12291231
titleProperty=title_property,
12301232
taskType=None,
1233+
location=None,
12311234
)
12321235

12331236
@staticmethod
@@ -1237,6 +1240,7 @@ def text2vec_google(
12371240
model_id: Optional[str] = None,
12381241
title_property: Optional[str] = None,
12391242
vectorize_collection_name: bool = True,
1243+
location: Optional[str] = None,
12401244
) -> _VectorizerConfigCreate:
12411245
"""Create a `_Text2VecGoogleConfig` object for use when vectorizing using the `text2vec-google` model.
12421246
@@ -1250,6 +1254,7 @@ def text2vec_google(
12501254
title_property: The Weaviate property name for the `gecko-002` or `gecko-003` model to use as the title.
12511255
vectorize_collection_name: Whether to vectorize the collection name. Defaults to `True`.
12521256
dimensions: The dimensionality of the vectors. Defaults to `None`, which uses the server-defined default.
1257+
location: The Google Vertex AI region to run the model in. Defaults to `None`, which uses the server-defined default.
12531258
12541259
Raises:
12551260
pydantic.ValidationError: If `api_endpoint` is not a valid URL.
@@ -1262,6 +1267,7 @@ def text2vec_google(
12621267
vectorizeClassName=vectorize_collection_name,
12631268
titleProperty=title_property,
12641269
taskType=None,
1270+
location=location,
12651271
)
12661272

12671273
@staticmethod

weaviate/collections/classes/config_vectors.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,7 @@ def text2vec_google(
14771477
source_properties: Optional[List[str]] = None,
14781478
vector_index_config: Optional[_VectorIndexConfigCreate] = None,
14791479
vectorize_collection_name: bool = True,
1480+
location: Optional[str] = None,
14801481
) -> _VectorConfigCreate:
14811482
"""Create a vector using the `text2vec-google` model.
14821483
@@ -1495,6 +1496,7 @@ def text2vec_google(
14951496
source_properties: Which properties should be included when vectorizing. By default all text properties are included.
14961497
vector_index_config: The configuration for Weaviate's vector index. Use `wvc.config.Configure.VectorIndex` to create a vector index configuration. None by default.
14971498
vectorize_collection_name: Whether to vectorize the collection name. Defaults to `True`.
1499+
location: The Google Vertex AI region to run the model in. Defaults to `None`, which uses the server-defined default.
14981500
14991501
Raises:
15001502
pydantic.ValidationError: If `api_endpoint` is not a valid URL.
@@ -1510,6 +1512,7 @@ def text2vec_google(
15101512
vectorizeClassName=vectorize_collection_name,
15111513
titleProperty=title_property,
15121514
taskType=task_type,
1515+
location=location,
15131516
),
15141517
vector_index_config=_IndexWrappers.single(vector_index_config, quantizer),
15151518
)
@@ -1560,6 +1563,7 @@ def text2vec_google_aistudio(
15601563
vectorizeClassName=vectorize_collection_name,
15611564
titleProperty=title_property,
15621565
taskType=task_type,
1566+
location=None,
15631567
),
15641568
vector_index_config=_IndexWrappers.single(vector_index_config, quantizer),
15651569
)
@@ -1607,6 +1611,7 @@ def text2vec_google_gemini(
16071611
vectorizeClassName=vectorize_collection_name,
16081612
titleProperty=title_property,
16091613
taskType=task_type,
1614+
location=None,
16101615
),
16111616
vector_index_config=_IndexWrappers.single(vector_index_config, quantizer),
16121617
)
@@ -1625,6 +1630,7 @@ def text2vec_google_vertex(
16251630
source_properties: Optional[List[str]] = None,
16261631
vector_index_config: Optional[_VectorIndexConfigCreate] = None,
16271632
vectorize_collection_name: bool = True,
1633+
location: Optional[str] = None,
16281634
) -> _VectorConfigCreate:
16291635
"""Create a vector using the `text2vec-google` model.
16301636
@@ -1643,6 +1649,7 @@ def text2vec_google_vertex(
16431649
source_properties: Which properties should be included when vectorizing. By default all text properties are included.
16441650
vector_index_config: The configuration for Weaviate's vector index. Use `wvc.config.Configure.VectorIndex` to create a vector index configuration. None by default.
16451651
vectorize_collection_name: Whether to vectorize the collection name. Defaults to `True`.
1652+
location: The Google Vertex AI region to run the model in. Defaults to `None`, which uses the server-defined default.
16461653
16471654
Raises:
16481655
pydantic.ValidationError: If `api_endpoint` is not a valid URL.
@@ -1658,6 +1665,7 @@ def text2vec_google_vertex(
16581665
vectorizeClassName=vectorize_collection_name,
16591666
titleProperty=title_property,
16601667
taskType=task_type,
1668+
location=location,
16611669
),
16621670
vector_index_config=_IndexWrappers.single(vector_index_config, quantizer),
16631671
)

0 commit comments

Comments
 (0)