Skip to content

Commit adf284a

Browse files
authored
Merge pull request #1900 from weaviate/bugfix/model-integration-parameters
feat: add taskType parameter to google vectorizer
2 parents 8de1d74 + 03adaad commit adf284a

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

weaviate/collections/classes/config_named_vectors.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,7 @@ def text2vec_palm(
981981
modelId=model_id,
982982
vectorizeClassName=vectorize_collection_name,
983983
titleProperty=title_property,
984+
taskType=None,
984985
),
985986
vector_index_config=vector_index_config,
986987
)
@@ -1026,6 +1027,7 @@ def text2vec_google(
10261027
modelId=model_id,
10271028
vectorizeClassName=vectorize_collection_name,
10281029
titleProperty=title_property,
1030+
taskType=None,
10291031
),
10301032
vector_index_config=vector_index_config,
10311033
)
@@ -1067,6 +1069,7 @@ def text2vec_google_aistudio(
10671069
modelId=model_id,
10681070
vectorizeClassName=vectorize_collection_name,
10691071
titleProperty=title_property,
1072+
taskType=None,
10701073
),
10711074
vector_index_config=vector_index_config,
10721075
)

weaviate/collections/classes/config_vectorizers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ class _Text2VecGoogleConfig(_VectorizerConfigCreate):
351351
modelId: Optional[str]
352352
vectorizeClassName: bool
353353
titleProperty: Optional[str]
354+
taskType: Optional[str]
354355

355356

356357
class _Text2VecTransformersConfig(_VectorizerConfigCreate):
@@ -1149,6 +1150,7 @@ def text2vec_palm(
11491150
modelId=model_id,
11501151
vectorizeClassName=vectorize_collection_name,
11511152
titleProperty=title_property,
1153+
taskType=None,
11521154
)
11531155

11541156
@staticmethod
@@ -1177,6 +1179,7 @@ def text2vec_google_aistudio(
11771179
modelId=model_id,
11781180
vectorizeClassName=vectorize_collection_name,
11791181
titleProperty=title_property,
1182+
taskType=None,
11801183
)
11811184

11821185
@staticmethod
@@ -1210,6 +1213,7 @@ def text2vec_google(
12101213
modelId=model_id,
12111214
vectorizeClassName=vectorize_collection_name,
12121215
titleProperty=title_property,
1216+
taskType=None,
12131217
)
12141218

12151219
@staticmethod

weaviate/collections/classes/config_vectors.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ def multi(
175175
return _IndexWrappers.single(vector_index_config, quantizer)
176176

177177

178+
# TODO: Consider refactoring to move the default values to the pydantic classes themselves (e.g. _VectorConfigCreate, _Text2VecCohereConfig, etc.)
178179
class _MultiVectors:
179180
@staticmethod
180181
def self_provided(
@@ -1188,6 +1189,7 @@ def text2vec_google(
11881189
model: Optional[str] = None,
11891190
project_id: str,
11901191
title_property: Optional[str] = None,
1192+
task_type: Optional[str] = None,
11911193
source_properties: Optional[List[str]] = None,
11921194
vector_index_config: Optional[_VectorIndexConfigCreate] = None,
11931195
vectorize_collection_name: bool = True,
@@ -1205,6 +1207,7 @@ def text2vec_google(
12051207
model: The model to use. Defaults to `None`, which uses the server-defined default.
12061208
project_id: The project ID to use, REQUIRED.
12071209
title_property: The Weaviate property name for the `gecko-002` or `gecko-003` model to use as the title.
1210+
task_type: The task type to use (e.g. `RETRIEVAL_QUERY`, `RETRIEVAL_DOCUMENT`). Defaults to `None`, which uses the server-defined default.
12081211
source_properties: Which properties should be included when vectorizing. By default all text properties are included.
12091212
vector_index_config: The configuration for Weaviate's vector index. Use `wvc.config.Configure.VectorIndex` to create a vector index configuration. None by default.
12101213
vectorize_collection_name: Whether to vectorize the collection name. Defaults to `True`.
@@ -1222,6 +1225,7 @@ def text2vec_google(
12221225
modelId=model,
12231226
vectorizeClassName=vectorize_collection_name,
12241227
titleProperty=title_property,
1228+
taskType=task_type,
12251229
),
12261230
vector_index_config=_IndexWrappers.single(vector_index_config, quantizer),
12271231
)
@@ -1234,6 +1238,7 @@ def text2vec_google_aistudio(
12341238
dimensions: Optional[int] = None,
12351239
model: Optional[str] = None,
12361240
title_property: Optional[str] = None,
1241+
task_type: Optional[str] = None,
12371242
source_properties: Optional[List[str]] = None,
12381243
vector_index_config: Optional[_VectorIndexConfigCreate] = None,
12391244
vectorize_collection_name: bool = True,
@@ -1249,6 +1254,7 @@ def text2vec_google_aistudio(
12491254
dimenions: The dimensionality of the vectors. Defaults to `None`, which uses the server-defined default.
12501255
model: The model to use. Defaults to `None`, which uses the server-defined default.
12511256
title_property: The Weaviate property name for the `gecko-002` or `gecko-003` model to use as the title.
1257+
task_type: The task type to use (e.g. `RETRIEVAL_QUERY`, `RETRIEVAL_DOCUMENT`). Defaults to `None`, which uses the server-defined default.
12521258
source_properties: Which properties should be included when vectorizing. By default all text properties are included.
12531259
vector_index_config: The configuration for Weaviate's vector index. Use `wvc.config.Configure.VectorIndex` to create a vector index configuration. None by default
12541260
vectorize_collection_name: Whether to vectorize the collection name. Defaults to `True`.
@@ -1266,6 +1272,7 @@ def text2vec_google_aistudio(
12661272
modelId=model,
12671273
vectorizeClassName=vectorize_collection_name,
12681274
titleProperty=title_property,
1275+
taskType=task_type,
12691276
),
12701277
vector_index_config=_IndexWrappers.single(vector_index_config, quantizer),
12711278
)

0 commit comments

Comments
 (0)