diff --git a/Directory.Packages.props b/Directory.Packages.props index 2a88b69da3e..5975e2b9a33 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -36,7 +36,7 @@ - + @@ -51,14 +51,14 @@ - + - - + + diff --git a/src/EFCore.Cosmos/Extensions/DistanceFunction.cs b/src/EFCore.Cosmos/Extensions/DistanceFunction.cs deleted file mode 100644 index 2df582e5ca1..00000000000 --- a/src/EFCore.Cosmos/Extensions/DistanceFunction.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics.CodeAnalysis; -using System.Runtime.Serialization; - -// ReSharper disable once CheckNamespace -namespace Microsoft.Azure.Cosmos; - -/// -/// Defines the distance function for a vector index specification in the Azure Cosmos DB service. -/// Warning: this type will be replaced by the type from the Cosmos SDK, when it is available. -/// -/// -/// for usage. -[Experimental(EFDiagnostics.CosmosVectorSearchExperimental)] -public enum DistanceFunction -{ - /// - /// Represents the Euclidean distance function. - /// - [EnumMember(Value = "euclidean")] - Euclidean, - - /// - /// Represents the cosine distance function. - /// - [EnumMember(Value = "cosine")] - Cosine, - - /// - /// Represents the dot product distance function. - /// - [EnumMember(Value = "dotproduct")] - DotProduct, -} diff --git a/src/EFCore.Cosmos/Extensions/Embedding.cs b/src/EFCore.Cosmos/Extensions/Embedding.cs deleted file mode 100644 index e46c274d887..00000000000 --- a/src/EFCore.Cosmos/Extensions/Embedding.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics.CodeAnalysis; - -// ReSharper disable once CheckNamespace -namespace Microsoft.Azure.Cosmos; - -[Experimental(EFDiagnostics.CosmosVectorSearchExperimental)] -internal class Embedding : IEquatable -{ - public string? Path { get; set; } - public VectorDataType DataType { get; set; } - public int Dimensions { get; set; } - public DistanceFunction DistanceFunction { get; set; } - - public bool Equals(Embedding? that) - => Equals(Path, that?.Path) && Equals(DataType, that?.DataType) && Equals(Dimensions, that.Dimensions); -} diff --git a/src/EFCore.Cosmos/Extensions/VectorDataType.cs b/src/EFCore.Cosmos/Extensions/VectorDataType.cs deleted file mode 100644 index cb547fd1b3a..00000000000 --- a/src/EFCore.Cosmos/Extensions/VectorDataType.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics.CodeAnalysis; -using System.Runtime.Serialization; - -// ReSharper disable once CheckNamespace -namespace Microsoft.Azure.Cosmos; - -/// -/// Defines the target data type of a vector index specification in the Azure Cosmos DB service. -/// Warning: this type will be replaced by the type from the Cosmos SDK, when it is available. -/// -[Experimental(EFDiagnostics.CosmosVectorSearchExperimental)] -public enum VectorDataType -{ - /// - /// Represents a 16-bit floating point data type. - /// - [EnumMember(Value = "float16")] - Float16, - - /// - /// Represents a 32-bit floating point data type. - /// - [EnumMember(Value = "float32")] - Float32, - - /// - /// Represents an unsigned 8-bit binary data type. - /// - [EnumMember(Value = "uint8")] - Uint8, - - /// - /// Represents a signed 8-bit binary data type. - /// - [EnumMember(Value = "int8")] - Int8, -} diff --git a/src/EFCore.Cosmos/Extensions/VectorIndexPath.cs b/src/EFCore.Cosmos/Extensions/VectorIndexPath.cs deleted file mode 100644 index 8a575c2c40f..00000000000 --- a/src/EFCore.Cosmos/Extensions/VectorIndexPath.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics.CodeAnalysis; - -// ReSharper disable once CheckNamespace -namespace Microsoft.Azure.Cosmos; - -[Experimental(EFDiagnostics.CosmosVectorSearchExperimental)] -internal sealed class VectorIndexPath -{ - public string? Path { get; set; } - public VectorIndexType Type { get; set; } -} diff --git a/src/EFCore.Cosmos/Extensions/VectorIndexType.cs b/src/EFCore.Cosmos/Extensions/VectorIndexType.cs deleted file mode 100644 index 88f71d32a5d..00000000000 --- a/src/EFCore.Cosmos/Extensions/VectorIndexType.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics.CodeAnalysis; -using System.Runtime.Serialization; - -// ReSharper disable once CheckNamespace -namespace Microsoft.Azure.Cosmos; - -/// -/// Defines the target index type of the vector index path specification in the Azure Cosmos DB service. -/// Warning: this type will be replaced by the type from the Cosmos SDK, when it is available. -/// -[Experimental(EFDiagnostics.CosmosVectorSearchExperimental)] -public enum VectorIndexType -{ - /// - /// Represents a flat vector index type. - /// - [EnumMember(Value = "flat")] - Flat, - - /// - /// Represents a Disk ANN vector index type. - /// - [EnumMember(Value = "diskANN")] - // ReSharper disable once InconsistentNaming - DiskANN, - - /// - /// Represents a quantized flat vector index type. - /// - [EnumMember(Value = "quantizedFlat")] - QuantizedFlat, -} diff --git a/src/EFCore.Cosmos/Properties/CosmosStrings.Designer.cs b/src/EFCore.Cosmos/Properties/CosmosStrings.Designer.cs index d9571fc2d05..6c63a1c718e 100644 --- a/src/EFCore.Cosmos/Properties/CosmosStrings.Designer.cs +++ b/src/EFCore.Cosmos/Properties/CosmosStrings.Designer.cs @@ -305,12 +305,6 @@ public static string NoReadItemQueryString(object? resourceId, object? partition public static string NoSubqueryPushdown => GetString("NoSubqueryPushdown"); - /// - /// Container configuration for embeddings is not yet supported by the Cosmos SDK. Instead, configure the container manually. See https://aka.ms/ef-cosmos-vectors for more information. - /// - public static string NoVectorContainerConfig - => GetString("NoVectorContainerConfig"); - /// /// The expression '{sqlExpression}' in the SQL tree does not have a type mapping assigned. /// diff --git a/src/EFCore.Cosmos/Properties/CosmosStrings.resx b/src/EFCore.Cosmos/Properties/CosmosStrings.resx index 171d85f852c..8f9a875524b 100644 --- a/src/EFCore.Cosmos/Properties/CosmosStrings.resx +++ b/src/EFCore.Cosmos/Properties/CosmosStrings.resx @@ -271,9 +271,6 @@ Azure Cosmos DB does not have an appropriate subquery for this translation. - - Container configuration for embeddings is not yet supported by the Cosmos SDK. Instead, configure the container manually. See https://aka.ms/ef-cosmos-vectors for more information. - The expression '{sqlExpression}' in the SQL tree does not have a type mapping assigned. diff --git a/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs b/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs index a5c89b6b37d..9f2793deeaa 100644 --- a/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs +++ b/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs @@ -272,17 +272,14 @@ private static async Task CreateContainerIfNotExistsOnceAsync( AnalyticalStoreTimeToLiveInSeconds = parameters.AnalyticalStoreTimeToLiveInSeconds, }; - // TODO: Enable these once they are available in the Cosmos SDK. See #33783. if (embeddings.Any()) { - throw new InvalidOperationException(CosmosStrings.NoVectorContainerConfig); - //containerProperties.VectorEmbeddingPolicy = new VectorEmbeddingPolicy(embeddings); + containerProperties.VectorEmbeddingPolicy = new VectorEmbeddingPolicy(embeddings); } if (vectorIndexes.Any()) { - throw new InvalidOperationException(CosmosStrings.NoVectorContainerConfig); - //containerProperties.IndexingPolicy = new IndexingPolicy { VectorIndexes = vectorIndexes }; + containerProperties.IndexingPolicy = new IndexingPolicy { VectorIndexes = vectorIndexes }; } var response = await wrapper.Client.GetDatabase(wrapper._databaseId).CreateContainerIfNotExistsAsync( diff --git a/test/EFCore.Cosmos.FunctionalTests/VectorSearchCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/VectorSearchCosmosTest.cs index 04da9fd280c..92d4aacb0f9 100644 --- a/test/EFCore.Cosmos.FunctionalTests/VectorSearchCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/VectorSearchCosmosTest.cs @@ -9,8 +9,7 @@ namespace Microsoft.EntityFrameworkCore; #pragma warning disable EF9103 -// These tests are skipped for now because we cannot create a compatible test container until the SDK supports it. -internal class VectorSearchCosmosTest : IClassFixture +public class VectorSearchCosmosTest : IClassFixture { public VectorSearchCosmosTest(VectorSearchFixture fixture, ITestOutputHelper testOutputHelper) {