Skip to content

Commit 6ff0a78

Browse files
committed
feat: add optional location to text2vec-google vectorizer
1 parent e774135 commit 6ff0a78

4 files changed

Lines changed: 55 additions & 1 deletion

File tree

src/Weaviate.Client.Tests/Unit/TestVectorizers.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,4 +496,41 @@ public void Test_Text2VecDigitalOcean_Omits_Unset_BaseURL()
496496
Assert.Contains("\"model\":\"qwen3-embedding-0.6b\"", json);
497497
Assert.DoesNotContain("\"baseURL\"", json);
498498
}
499+
500+
/// <summary>
501+
/// Tests that Text2VecGoogle omits <c>location</c> when unset so the server can apply its
502+
/// default.
503+
/// </summary>
504+
[Fact]
505+
[System.Diagnostics.CodeAnalysis.SuppressMessage(
506+
"Performance",
507+
"CA1869:Cache and reuse 'JsonSerializerOptions' instances",
508+
Justification = "<Pending>"
509+
)]
510+
public void Test_Text2VecGoogle_Omits_Unset_Location()
511+
{
512+
// Arrange
513+
var vc = Configure.Vector("default", v => v.Text2VecGoogleVertex(projectId: "my-project"));
514+
515+
// Act
516+
var dto = vc.Vectorizer?.ToDto() ?? default;
517+
var json = JsonSerializer.Serialize(
518+
dto,
519+
new JsonSerializerOptions
520+
{
521+
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
522+
DefaultIgnoreCondition = System
523+
.Text
524+
.Json
525+
.Serialization
526+
.JsonIgnoreCondition
527+
.WhenWritingNull,
528+
WriteIndented = false,
529+
}
530+
);
531+
532+
// Assert
533+
Assert.Contains("\"text2vec-google\"", json);
534+
Assert.DoesNotContain("\"location\"", json);
535+
}
499536
}

src/Weaviate.Client/Configure/VectorizerFactory.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,7 @@ public VectorizerConfig Text2VecOpenAI(
863863
/// <param name="dimensions">The dimensions</param>
864864
/// <param name="taskType">The task type</param>
865865
/// <param name="vectorizeCollectionName">The vectorize collection name</param>
866+
/// <param name="location">The Google Vertex AI region; optional, server-defaulted when null</param>
866867
/// <returns>The vectorizer config</returns>
867868
public VectorizerConfig Text2VecGoogleVertex(
868869
string? apiEndpoint = null,
@@ -871,7 +872,8 @@ public VectorizerConfig Text2VecGoogleVertex(
871872
string? titleProperty = null,
872873
int? dimensions = null,
873874
string? taskType = null,
874-
bool? vectorizeCollectionName = null
875+
bool? vectorizeCollectionName = null,
876+
string? location = null
875877
) =>
876878
new Text2VecGoogle
877879
{
@@ -882,6 +884,7 @@ public VectorizerConfig Text2VecGoogleVertex(
882884
Dimensions = dimensions,
883885
TaskType = taskType,
884886
VectorizeCollectionName = vectorizeCollectionName,
887+
Location = location,
885888
};
886889

887890
/// <summary>
@@ -909,6 +912,9 @@ public VectorizerConfig Text2VecGoogleGemini(
909912
Dimensions = dimensions,
910913
TaskType = taskType,
911914
VectorizeCollectionName = vectorizeCollectionName,
915+
// Location (Vertex AI region) is not applicable to the Gemini
916+
// (generative-language) API; left null so it is omitted on the wire.
917+
Location = null,
912918
};
913919

914920
/// <summary>

src/Weaviate.Client/Models/Vectorizer.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,13 @@ internal Text2VecGoogle() { }
12721272
/// </summary>
12731273
public string? TaskType { get; set; } = null;
12741274

1275+
/// <summary>
1276+
/// Gets or sets the Google Vertex AI region.
1277+
/// Optional; when omitted the server applies its default.
1278+
/// Serialized as the lowercase <c>location</c> module-config key.
1279+
/// </summary>
1280+
public string? Location { get; set; } = null;
1281+
12751282
/// <summary>
12761283
/// Gets or sets the value of the vectorize collection name
12771284
/// </summary>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
#nullable enable
2+
*REMOVED*Weaviate.Client.VectorizerFactory.Text2VecGoogleVertex(string? apiEndpoint = null, string? model = null, string? projectId = null, string? titleProperty = null, int? dimensions = null, string? taskType = null, bool? vectorizeCollectionName = null) -> Weaviate.Client.Models.VectorizerConfig!
3+
Weaviate.Client.Models.Vectorizer.Text2VecGoogle.Location.get -> string?
4+
Weaviate.Client.Models.Vectorizer.Text2VecGoogle.Location.set -> void
5+
Weaviate.Client.VectorizerFactory.Text2VecGoogleVertex(string? apiEndpoint = null, string? model = null, string? projectId = null, string? titleProperty = null, int? dimensions = null, string? taskType = null, bool? vectorizeCollectionName = null, string? location = null) -> Weaviate.Client.Models.VectorizerConfig!

0 commit comments

Comments
 (0)