Skip to content

Commit ebdfc7b

Browse files
mpartipiloclaude
andcommitted
Make model required on Text2VecDigitalOcean factory
The server requires `model` (e.g. `qwen3-embedding-0.6b`); the factory should require it too rather than silently sending a payload the server will reject. - `VectorizerFactory.Text2VecDigitalOcean(string model, string? baseURL = null, bool? vectorizeCollectionName = null)` — `model` is now required and reordered to the first position, since C# requires non-default params before default params. - `PublicAPI.Unshipped.txt` updated to reflect the new signature (`string! model` first). - `Test_Text2VecDigitalOcean_Omits_Unset_Optionals` renamed to `Test_Text2VecDigitalOcean_Omits_Unset_BaseURL`. It now passes `model` and only asserts that `baseURL` is omitted when unset. The old "model is also omitted when unset" assertion was inconsistent with the spec (`model` is required by the server) and would no longer be reachable through the factory anyway. The `Text2VecDigitalOcean` record's `Model` property remains nullable at the type level (matching the `Text2VecMistral` record); required-ness is enforced at the factory entry point, which is the documented user-facing API. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent a86462c commit ebdfc7b

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,8 @@ public void Test_Text2VecDigitalOcean_Serializes_BaseURL_And_Model()
431431
"default",
432432
v =>
433433
v.Text2VecDigitalOcean(
434-
baseURL: "https://inference.do-ai.run",
435434
model: "qwen3-embedding-0.6b",
435+
baseURL: "https://inference.do-ai.run",
436436
vectorizeCollectionName: false
437437
)
438438
);
@@ -457,18 +457,22 @@ public void Test_Text2VecDigitalOcean_Serializes_BaseURL_And_Model()
457457

458458
/// <summary>
459459
/// Tests that Text2VecDigitalOcean omits unset optional fields so the server can apply
460-
/// its defaults (no <c>baseURL</c>, no <c>model</c>).
460+
/// its defaults (no <c>baseURL</c>). <c>model</c> is required by the factory so it is
461+
/// always present.
461462
/// </summary>
462463
[Fact]
463464
[System.Diagnostics.CodeAnalysis.SuppressMessage(
464465
"Performance",
465466
"CA1869:Cache and reuse 'JsonSerializerOptions' instances",
466467
Justification = "<Pending>"
467468
)]
468-
public void Test_Text2VecDigitalOcean_Omits_Unset_Optionals()
469+
public void Test_Text2VecDigitalOcean_Omits_Unset_BaseURL()
469470
{
470471
// Arrange
471-
var vc = Configure.Vector("default", v => v.Text2VecDigitalOcean());
472+
var vc = Configure.Vector(
473+
"default",
474+
v => v.Text2VecDigitalOcean(model: "qwen3-embedding-0.6b")
475+
);
472476

473477
// Act
474478
var dto = vc.Vectorizer?.ToDto() ?? default;
@@ -489,7 +493,7 @@ public void Test_Text2VecDigitalOcean_Omits_Unset_Optionals()
489493

490494
// Assert
491495
Assert.Contains("\"text2vec-digitalocean\"", json);
496+
Assert.Contains("\"model\":\"qwen3-embedding-0.6b\"", json);
492497
Assert.DoesNotContain("\"baseURL\"", json);
493-
Assert.DoesNotContain("\"model\"", json);
494498
}
495499
}

src/Weaviate.Client/Configure/VectorizerFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,13 +755,13 @@ public VectorizerConfig Text2VecMistral(
755755
/// See the <a href="https://weaviate.io/developers/weaviate/model-providers/digitalocean/embeddings">documentation</a>
756756
/// for detailed usage.
757757
/// </summary>
758-
/// <param name="baseURL">The base URL where API requests should go. Defaults to <c>null</c>, which uses the server-defined default of <c>https://inference.do-ai.run</c>.</param>
759758
/// <param name="model">The model to use, e.g. <c>qwen3-embedding-0.6b</c>. Required by the server.</param>
759+
/// <param name="baseURL">The base URL where API requests should go. Defaults to <c>null</c>, which uses the server-defined default of <c>https://inference.do-ai.run</c>.</param>
760760
/// <param name="vectorizeCollectionName">Whether to vectorize the collection name.</param>
761761
/// <returns>The vectorizer config</returns>
762762
public VectorizerConfig Text2VecDigitalOcean(
763+
string model,
763764
string? baseURL = null,
764-
string? model = null,
765765
bool? vectorizeCollectionName = null
766766
) =>
767767
new Text2VecDigitalOcean

src/Weaviate.Client/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ Weaviate.Client.Models.Vectorizer.Text2VecDigitalOcean.Model.set -> void
1717
Weaviate.Client.Models.Vectorizer.Text2VecDigitalOcean.Text2VecDigitalOcean(Weaviate.Client.Models.Vectorizer.Text2VecDigitalOcean! original) -> void
1818
Weaviate.Client.Models.Vectorizer.Text2VecDigitalOcean.VectorizeCollectionName.get -> bool?
1919
Weaviate.Client.Models.Vectorizer.Text2VecDigitalOcean.VectorizeCollectionName.set -> void
20-
Weaviate.Client.VectorizerFactory.Text2VecDigitalOcean(string? baseURL = null, string? model = null, bool? vectorizeCollectionName = null) -> Weaviate.Client.Models.VectorizerConfig!
20+
Weaviate.Client.VectorizerFactory.Text2VecDigitalOcean(string! model, string? baseURL = null, bool? vectorizeCollectionName = null) -> Weaviate.Client.Models.VectorizerConfig!

0 commit comments

Comments
 (0)