Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/Weaviate.Client.Tests/Unit/TestVectorizers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,43 @@ public void Test_Text2VecDigitalOcean_Omits_Unset_BaseURL()
Assert.DoesNotContain("\"baseURL\"", json);
}

/// <summary>
/// Tests that Text2VecGoogle omits <c>location</c> when unset so the server can apply its
/// default.
/// </summary>
[Fact]
[System.Diagnostics.CodeAnalysis.SuppressMessage(
"Performance",
"CA1869:Cache and reuse 'JsonSerializerOptions' instances",
Justification = "<Pending>"
)]
public void Test_Text2VecGoogle_Omits_Unset_Location()
{
// Arrange
var vc = Configure.Vector("default", v => v.Text2VecGoogleVertex(projectId: "my-project"));

// Act
var dto = vc.Vectorizer?.ToDto() ?? default;
var json = JsonSerializer.Serialize(
dto,
new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
DefaultIgnoreCondition = System
.Text
.Json
.Serialization
.JsonIgnoreCondition
.WhenWritingNull,
WriteIndented = false,
}
);

// Assert
Assert.Contains("\"text2vec-google\"", json);
Assert.DoesNotContain("\"location\"", json);
}

/// <summary>
/// Tests that Text2VecAWS serializes <c>dimensions</c> as a JSON number (not a string) when it
/// is set via the Bedrock factory.
Expand Down
8 changes: 7 additions & 1 deletion src/Weaviate.Client/Configure/VectorizerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,7 @@ public VectorizerConfig Text2VecOpenAI(
/// <param name="dimensions">The dimensions</param>
/// <param name="taskType">The task type</param>
/// <param name="vectorizeCollectionName">The vectorize collection name</param>
/// <param name="location">The Google Vertex AI region; optional, server-defaulted when null</param>
/// <returns>The vectorizer config</returns>
public VectorizerConfig Text2VecGoogleVertex(
string? apiEndpoint = null,
Expand All @@ -877,7 +878,8 @@ public VectorizerConfig Text2VecGoogleVertex(
string? titleProperty = null,
int? dimensions = null,
string? taskType = null,
bool? vectorizeCollectionName = null
bool? vectorizeCollectionName = null,
string? location = null
) =>
new Text2VecGoogle
{
Expand All @@ -888,6 +890,7 @@ public VectorizerConfig Text2VecGoogleVertex(
Dimensions = dimensions,
TaskType = taskType,
VectorizeCollectionName = vectorizeCollectionName,
Location = location,
};

/// <summary>
Expand Down Expand Up @@ -915,6 +918,9 @@ public VectorizerConfig Text2VecGoogleGemini(
Dimensions = dimensions,
TaskType = taskType,
VectorizeCollectionName = vectorizeCollectionName,
// Location (Vertex AI region) is not applicable to the Gemini
// (generative-language) API; left null so it is omitted on the wire.
Location = null,
};

/// <summary>
Expand Down
7 changes: 7 additions & 0 deletions src/Weaviate.Client/Models/Vectorizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,13 @@ internal Text2VecGoogle() { }
/// </summary>
public string? TaskType { get; set; } = null;

/// <summary>
/// Gets or sets the Google Vertex AI region.
/// Optional; when omitted the server applies its default.
/// Serialized as the lowercase <c>location</c> module-config key.
/// </summary>
public string? Location { get; set; } = null;

/// <summary>
/// Gets or sets the value of the vectorize collection name
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions src/Weaviate.Client/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#nullable enable
*REMOVED*Weaviate.Client.VectorizerFactory.Text2VecAWSBedrock(string! region, string! model, bool? vectorizeCollectionName = null) -> Weaviate.Client.Models.VectorizerConfig!
*REMOVED*Weaviate.Client.VectorizerFactory.Text2VecAWSSagemaker(string! region, string! endpoint, string? targetModel = null, string? targetVariant = null, bool? vectorizeCollectionName = null) -> Weaviate.Client.Models.VectorizerConfig!
*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!
Weaviate.Client.Models.Vectorizer.Text2VecAWS.Dimensions.get -> int?
Weaviate.Client.Models.Vectorizer.Text2VecAWS.Dimensions.set -> void
Weaviate.Client.Models.Vectorizer.Text2VecGoogle.Location.get -> string?
Weaviate.Client.Models.Vectorizer.Text2VecGoogle.Location.set -> void
Weaviate.Client.VectorizerFactory.Text2VecAWSBedrock(string! region, string! model, int? dimensions = null, bool? vectorizeCollectionName = null) -> Weaviate.Client.Models.VectorizerConfig!
Weaviate.Client.VectorizerFactory.Text2VecAWSSagemaker(string! region, string! endpoint, string? targetModel = null, string? targetVariant = null, int? dimensions = null, bool? vectorizeCollectionName = null) -> Weaviate.Client.Models.VectorizerConfig!
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!
Loading