ContainerProperties: Refactors Vector Embedding and Indexing Policy Interfaces to Mark Them as Public for Preview (#4486)

* Code changes to mark internal vector interfaces as public.

* Code changes to update the public and preview modifiers.

* Code changes to update preview and ga contracts.

* Code changes to mark the policy definitions as public interface.

* Code changes to update GA contract and use #if all over.

* Code changes to fix some of the broken tests in preview.

* Code changes to update the preview contract too reflect the JSON Ignore.

* Code changes to upgrade direct version to 3.34.2
This commit is contained in:
Debdatta Kunda 2024-05-15 15:57:23 -07:00 коммит произвёл GitHub
Родитель 3ae56dbc77
Коммит a3c9d779f8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
16 изменённых файлов: 510 добавлений и 67 удалений

Просмотреть файл

@ -3,7 +3,7 @@
<ClientOfficialVersion>3.39.1</ClientOfficialVersion>
<ClientPreviewVersion>3.40.0</ClientPreviewVersion>
<ClientPreviewSuffixVersion>preview.1</ClientPreviewSuffixVersion>
<DirectVersion>3.34.0</DirectVersion>
<DirectVersion>3.34.2</DirectVersion>
<EncryptionOfficialVersion>2.0.4</EncryptionOfficialVersion>
<EncryptionPreviewVersion>2.1.0</EncryptionPreviewVersion>
<EncryptionPreviewSuffixVersion>preview4</EncryptionPreviewSuffixVersion>

Просмотреть файл

@ -122,7 +122,12 @@ namespace Microsoft.Azure.Cosmos.Fluent
/// </summary>
/// <param name="embeddings">List of vector embeddings to include in the policy definition.</param>
/// <returns>An instance of <see cref="VectorEmbeddingPolicyDefinition"/>.</returns>
internal VectorEmbeddingPolicyDefinition WithVectorEmbeddingPolicy(
#if PREVIEW
public
#else
internal
#endif
VectorEmbeddingPolicyDefinition WithVectorEmbeddingPolicy(
Collection<Embedding> embeddings)
{
return new VectorEmbeddingPolicyDefinition(

Просмотреть файл

@ -117,7 +117,12 @@ namespace Microsoft.Azure.Cosmos.Fluent
/// Defines a <see cref="VectorIndexPath"/> in the current <see cref="Container"/>'s definition.
/// </summary>
/// <returns>An instance of <see cref="VectorIndexDefinition{T}"/>.</returns>
internal VectorIndexDefinition<IndexingPolicyDefinition<T>> WithVectorIndex()
#if PREVIEW
public
#else
internal
#endif
VectorIndexDefinition<IndexingPolicyDefinition<T>> WithVectorIndex()
{
return new VectorIndexDefinition<IndexingPolicyDefinition<T>>(
this,

Просмотреть файл

@ -11,13 +11,24 @@ namespace Microsoft.Azure.Cosmos.Fluent
/// <summary>
/// <see cref="VectorEmbeddingPolicy"/> fluent definition.
/// </summary>
internal class VectorEmbeddingPolicyDefinition
#if PREVIEW
public
#else
internal
#endif
class VectorEmbeddingPolicyDefinition
{
private readonly ContainerBuilder parent;
private readonly Action<VectorEmbeddingPolicy> attachCallback;
private readonly Collection<Embedding> vectorEmbeddings;
internal VectorEmbeddingPolicyDefinition(
/// <summary>
/// Initializes a new instance of the <see cref="VectorEmbeddingPolicyDefinition"/> class.
/// </summary>
/// <param name="parent">The original instance of <see cref="ContainerBuilder"/>.</param>
/// <param name="embeddings">List of embeddings to include in the policy definition.</param>
/// <param name="attachCallback">A callback delegate to be used at a later point of time.</param>
public VectorEmbeddingPolicyDefinition(
ContainerBuilder parent,
Collection<Embedding> embeddings,
Action<VectorEmbeddingPolicy> attachCallback)

Просмотреть файл

@ -10,13 +10,23 @@ namespace Microsoft.Azure.Cosmos.Fluent
/// Vector index fluent definition.
/// </summary>
/// <seealso cref="VectorIndexPath"/>
internal class VectorIndexDefinition<T>
#if PREVIEW
public
#else
internal
#endif
class VectorIndexDefinition<T>
{
private readonly VectorIndexPath vectorIndexPath = new VectorIndexPath();
private readonly VectorIndexPath vectorIndexPath = new ();
private readonly T parent;
private readonly Action<VectorIndexPath> attachCallback;
internal VectorIndexDefinition(
/// <summary>
/// Initializes a new instance of the <see cref="VectorIndexDefinition{T}"/> class.
/// </summary>
/// <param name="parent">The original instance of <see cref="ContainerBuilder"/>.</param>
/// <param name="attachCallback">A callback delegate to be used at a later point of time.</param>
public VectorIndexDefinition(
T parent,
Action<VectorIndexPath> attachCallback)
{

Просмотреть файл

@ -306,7 +306,12 @@ namespace Microsoft.Azure.Cosmos
/// </para>
/// </remarks>
[JsonIgnore]
internal VectorEmbeddingPolicy VectorEmbeddingPolicy
#if PREVIEW
public
#else
internal
#endif
VectorEmbeddingPolicy VectorEmbeddingPolicy
{
get => this.vectorEmbeddingPolicyInternal;

Просмотреть файл

@ -9,7 +9,12 @@ namespace Microsoft.Azure.Cosmos
/// Defines the distance function for a vector index specification in the Azure Cosmos DB service.
/// </summary>
/// <seealso cref="Embedding"/> for usage.
internal enum DistanceFunction
#if PREVIEW
public
#else
internal
#endif
enum DistanceFunction
{
/// <summary>
/// Represents the euclidean distance function.

Просмотреть файл

@ -14,7 +14,12 @@ namespace Microsoft.Azure.Cosmos
/// <summary>
/// Represents the embedding settings for the vector index.
/// </summary>
internal class Embedding : IEquatable<Embedding>
#if PREVIEW
public
#else
internal
#endif
class Embedding : IEquatable<Embedding>
{
/// <summary>
/// Gets or sets a string containing the path of the vector index.

Просмотреть файл

@ -111,6 +111,12 @@ namespace Microsoft.Azure.Cosmos
[JsonProperty(PropertyName = Constants.Properties.CompositeIndexes)]
public Collection<Collection<CompositePath>> CompositeIndexes { get; internal set; } = new Collection<Collection<CompositePath>>();
/// <summary>
/// Collection of spatial index definitions to be used
/// </summary>
[JsonProperty(PropertyName = Constants.Properties.SpatialIndexes)]
public Collection<SpatialPath> SpatialIndexes { get; internal set; } = new Collection<SpatialPath>();
/// <summary>
/// Gets the vector indexes for additional indexes
/// </summary>
@ -132,23 +138,14 @@ namespace Microsoft.Azure.Cosmos
/// ]
/// ]]>
/// </example>
internal Collection<VectorIndexPath> VectorIndexes
{
get => this.VectorIndexesInternal ??= new Collection<VectorIndexPath>();
set => this.VectorIndexesInternal = value;
}
/// <summary>
/// Collection of spatial index definitions to be used
/// </summary>
[JsonProperty(PropertyName = Constants.Properties.SpatialIndexes)]
public Collection<SpatialPath> SpatialIndexes { get; internal set; } = new Collection<SpatialPath>();
/// <summary>
/// Gets or Sets an internal placeholder collection to hold the vector indexes.
/// </summary>
[JsonProperty(PropertyName = "vectorIndexes", NullValueHandling = NullValueHandling.Ignore)]
internal Collection<VectorIndexPath> VectorIndexesInternal { get; set; }
#if PREVIEW
public
#else
internal
#endif
Collection<VectorIndexPath> VectorIndexes { get; set; } = new Collection<VectorIndexPath>();
/// <summary>
/// This contains additional values for scenarios where the SDK is not aware of new fields.

Просмотреть файл

@ -8,7 +8,12 @@ namespace Microsoft.Azure.Cosmos
/// <summary>
/// Defines the target data type of a vector index specification in the Azure Cosmos DB service.
/// </summary>
internal enum VectorDataType
#if PREVIEW
public
#else
internal
#endif
enum VectorDataType
{
/// <summary>
/// Represent a float16 data type.

Просмотреть файл

@ -13,7 +13,12 @@ namespace Microsoft.Azure.Cosmos
/// Represents the vector embedding policy configuration for specifying the vector embeddings on documents in the collection in the Azure Cosmos DB service.
/// </summary>
/// <seealso cref="ContainerProperties"/>
internal sealed class VectorEmbeddingPolicy
#if PREVIEW
public
#else
internal
#endif
sealed class VectorEmbeddingPolicy
{
/// <summary>
/// Initializes a new instance of the <see cref="VectorEmbeddingPolicy"/> class.

Просмотреть файл

@ -42,7 +42,12 @@ namespace Microsoft.Azure.Cosmos
/// }
/// ]]>
/// </example>
internal sealed class VectorIndexPath
#if PREVIEW
public
#else
internal
#endif
sealed class VectorIndexPath
{
/// <summary>
/// Gets or sets the full path in a document used for vector indexing.

Просмотреть файл

@ -8,7 +8,12 @@ namespace Microsoft.Azure.Cosmos
/// <summary>
/// Defines the target index type of an vector index path specification in the Azure Cosmos DB service.
/// </summary>
internal enum VectorIndexType
#if PREVIEW
public
#else
internal
#endif
enum VectorIndexType
{
/// <summary>
/// Represents a flat vector index type.

Просмотреть файл

@ -332,6 +332,18 @@
"Attributes": [],
"MethodInfo": "Microsoft.Azure.Cosmos.ChangeFeedPolicy get_ChangeFeedPolicy();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"Microsoft.Azure.Cosmos.VectorEmbeddingPolicy get_VectorEmbeddingPolicy()": {
"Type": "Method",
"Attributes": [],
"MethodInfo": "Microsoft.Azure.Cosmos.VectorEmbeddingPolicy get_VectorEmbeddingPolicy();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"Microsoft.Azure.Cosmos.VectorEmbeddingPolicy VectorEmbeddingPolicy[Newtonsoft.Json.JsonIgnoreAttribute()]": {
"Type": "Property",
"Attributes": [
"JsonIgnoreAttribute"
],
"MethodInfo": "Microsoft.Azure.Cosmos.VectorEmbeddingPolicy VectorEmbeddingPolicy;CanRead:True;CanWrite:True;Microsoft.Azure.Cosmos.VectorEmbeddingPolicy get_VectorEmbeddingPolicy();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;Void set_VectorEmbeddingPolicy(Microsoft.Azure.Cosmos.VectorEmbeddingPolicy);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.ComputedProperty] ComputedProperties[Newtonsoft.Json.JsonIgnoreAttribute()]": {
"Type": "Property",
"Attributes": [
@ -353,6 +365,150 @@
"Type": "Method",
"Attributes": [],
"MethodInfo": "Void set_ComputedProperties(System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.ComputedProperty]);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"Void set_VectorEmbeddingPolicy(Microsoft.Azure.Cosmos.VectorEmbeddingPolicy)": {
"Type": "Method",
"Attributes": [],
"MethodInfo": "Void set_VectorEmbeddingPolicy(Microsoft.Azure.Cosmos.VectorEmbeddingPolicy);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
}
},
"NestedTypes": {}
},
"Microsoft.Azure.Cosmos.DistanceFunction;System.Enum;IsAbstract:False;IsSealed:True;IsInterface:False;IsEnum:True;IsClass:False;IsValueType:True;IsNested:False;IsGenericType:False;IsSerializable:True": {
"Subclasses": {},
"Members": {
"Int32 value__": {
"Type": "Field",
"Attributes": [],
"MethodInfo": "Int32 value__;IsInitOnly:False;IsStatic:False;"
},
"Microsoft.Azure.Cosmos.DistanceFunction Cosine[System.Runtime.Serialization.EnumMemberAttribute(Value = \"cosine\")]": {
"Type": "Field",
"Attributes": [
"EnumMemberAttribute"
],
"MethodInfo": "Microsoft.Azure.Cosmos.DistanceFunction Cosine;IsInitOnly:False;IsStatic:True;"
},
"Microsoft.Azure.Cosmos.DistanceFunction DotProduct[System.Runtime.Serialization.EnumMemberAttribute(Value = \"dotproduct\")]": {
"Type": "Field",
"Attributes": [
"EnumMemberAttribute"
],
"MethodInfo": "Microsoft.Azure.Cosmos.DistanceFunction DotProduct;IsInitOnly:False;IsStatic:True;"
},
"Microsoft.Azure.Cosmos.DistanceFunction Euclidean[System.Runtime.Serialization.EnumMemberAttribute(Value = \"euclidean\")]": {
"Type": "Field",
"Attributes": [
"EnumMemberAttribute"
],
"MethodInfo": "Microsoft.Azure.Cosmos.DistanceFunction Euclidean;IsInitOnly:False;IsStatic:True;"
}
},
"NestedTypes": {}
},
"Microsoft.Azure.Cosmos.Embedding;System.Object;IsAbstract:False;IsSealed:False;IsInterface:False;IsEnum:False;IsClass:True;IsValueType:False;IsNested:False;IsGenericType:False;IsSerializable:False": {
"Subclasses": {},
"Members": {
"Boolean Equals(Microsoft.Azure.Cosmos.Embedding)": {
"Type": "Method",
"Attributes": [],
"MethodInfo": "Boolean Equals(Microsoft.Azure.Cosmos.Embedding);IsAbstract:False;IsStatic:False;IsVirtual:True;IsGenericMethod:False;IsConstructor:False;IsFinal:True;"
},
"Microsoft.Azure.Cosmos.DistanceFunction DistanceFunction[Newtonsoft.Json.JsonPropertyAttribute(PropertyName = \"distanceFunction\")]-[Newtonsoft.Json.JsonConverterAttribute(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]": {
"Type": "Property",
"Attributes": [
"JsonConverterAttribute",
"JsonPropertyAttribute"
],
"MethodInfo": "Microsoft.Azure.Cosmos.DistanceFunction DistanceFunction;CanRead:True;CanWrite:True;Microsoft.Azure.Cosmos.DistanceFunction get_DistanceFunction();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;Void set_DistanceFunction(Microsoft.Azure.Cosmos.DistanceFunction);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"Microsoft.Azure.Cosmos.DistanceFunction get_DistanceFunction()[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": {
"Type": "Method",
"Attributes": [
"CompilerGeneratedAttribute"
],
"MethodInfo": "Microsoft.Azure.Cosmos.DistanceFunction get_DistanceFunction();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"Microsoft.Azure.Cosmos.VectorDataType DataType[Newtonsoft.Json.JsonPropertyAttribute(PropertyName = \"dataType\")]-[Newtonsoft.Json.JsonConverterAttribute(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]": {
"Type": "Property",
"Attributes": [
"JsonConverterAttribute",
"JsonPropertyAttribute"
],
"MethodInfo": "Microsoft.Azure.Cosmos.VectorDataType DataType;CanRead:True;CanWrite:True;Microsoft.Azure.Cosmos.VectorDataType get_DataType();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;Void set_DataType(Microsoft.Azure.Cosmos.VectorDataType);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"Microsoft.Azure.Cosmos.VectorDataType get_DataType()[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": {
"Type": "Method",
"Attributes": [
"CompilerGeneratedAttribute"
],
"MethodInfo": "Microsoft.Azure.Cosmos.VectorDataType get_DataType();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"System.String get_Path()[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": {
"Type": "Method",
"Attributes": [
"CompilerGeneratedAttribute"
],
"MethodInfo": "System.String get_Path();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"System.String Path[Newtonsoft.Json.JsonPropertyAttribute(PropertyName = \"path\")]": {
"Type": "Property",
"Attributes": [
"JsonPropertyAttribute"
],
"MethodInfo": "System.String Path;CanRead:True;CanWrite:True;System.String get_Path();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;Void set_Path(System.String);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"UInt64 Dimensions[Newtonsoft.Json.JsonPropertyAttribute(PropertyName = \"dimensions\")]": {
"Type": "Property",
"Attributes": [
"JsonPropertyAttribute"
],
"MethodInfo": "UInt64 Dimensions;CanRead:True;CanWrite:True;UInt64 get_Dimensions();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;Void set_Dimensions(UInt64);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"UInt64 get_Dimensions()[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": {
"Type": "Method",
"Attributes": [
"CompilerGeneratedAttribute"
],
"MethodInfo": "UInt64 get_Dimensions();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"Void .ctor()": {
"Type": "Constructor",
"Attributes": [],
"MethodInfo": "[Void .ctor(), Void .ctor()]"
},
"Void set_DataType(Microsoft.Azure.Cosmos.VectorDataType)[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": {
"Type": "Method",
"Attributes": [
"CompilerGeneratedAttribute"
],
"MethodInfo": "Void set_DataType(Microsoft.Azure.Cosmos.VectorDataType);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"Void set_Dimensions(UInt64)[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": {
"Type": "Method",
"Attributes": [
"CompilerGeneratedAttribute"
],
"MethodInfo": "Void set_Dimensions(UInt64);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"Void set_DistanceFunction(Microsoft.Azure.Cosmos.DistanceFunction)[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": {
"Type": "Method",
"Attributes": [
"CompilerGeneratedAttribute"
],
"MethodInfo": "Void set_DistanceFunction(Microsoft.Azure.Cosmos.DistanceFunction);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"Void set_Path(System.String)[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": {
"Type": "Method",
"Attributes": [
"CompilerGeneratedAttribute"
],
"MethodInfo": "Void set_Path(System.String);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"Void ValidateEmbeddingPath()": {
"Type": "Method",
"Attributes": [],
"MethodInfo": "Void ValidateEmbeddingPath();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
}
},
"NestedTypes": {}
@ -391,6 +547,11 @@
"Type": "Method",
"Attributes": [],
"MethodInfo": "Microsoft.Azure.Cosmos.Fluent.ChangeFeedPolicyDefinition WithChangeFeedPolicy(System.TimeSpan);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"Microsoft.Azure.Cosmos.Fluent.VectorEmbeddingPolicyDefinition WithVectorEmbeddingPolicy(System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.Embedding])": {
"Type": "Method",
"Attributes": [],
"MethodInfo": "Microsoft.Azure.Cosmos.Fluent.VectorEmbeddingPolicyDefinition WithVectorEmbeddingPolicy(System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.Embedding]);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
}
},
"NestedTypes": {}
@ -406,6 +567,81 @@
},
"NestedTypes": {}
},
"Microsoft.Azure.Cosmos.Fluent.IndexingPolicyDefinition`1;System.Object;IsAbstract:False;IsSealed:False;IsInterface:False;IsEnum:False;IsClass:True;IsValueType:False;IsNested:False;IsGenericType:True;IsSerializable:False": {
"Subclasses": {},
"Members": {
"Microsoft.Azure.Cosmos.Fluent.VectorIndexDefinition`1[Microsoft.Azure.Cosmos.Fluent.IndexingPolicyDefinition`1[T]] WithVectorIndex()": {
"Type": "Method",
"Attributes": [],
"MethodInfo": "Microsoft.Azure.Cosmos.Fluent.VectorIndexDefinition`1[Microsoft.Azure.Cosmos.Fluent.IndexingPolicyDefinition`1[T]] WithVectorIndex();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
}
},
"NestedTypes": {}
},
"Microsoft.Azure.Cosmos.Fluent.VectorEmbeddingPolicyDefinition;System.Object;IsAbstract:False;IsSealed:False;IsInterface:False;IsEnum:False;IsClass:True;IsValueType:False;IsNested:False;IsGenericType:False;IsSerializable:False": {
"Subclasses": {},
"Members": {
"Microsoft.Azure.Cosmos.Fluent.ContainerBuilder Attach()": {
"Type": "Method",
"Attributes": [],
"MethodInfo": "Microsoft.Azure.Cosmos.Fluent.ContainerBuilder Attach();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"Void .ctor(Microsoft.Azure.Cosmos.Fluent.ContainerBuilder, System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.Embedding], System.Action`1[Microsoft.Azure.Cosmos.VectorEmbeddingPolicy])": {
"Type": "Constructor",
"Attributes": [],
"MethodInfo": "[Void .ctor(Microsoft.Azure.Cosmos.Fluent.ContainerBuilder, System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.Embedding], System.Action`1[Microsoft.Azure.Cosmos.VectorEmbeddingPolicy]), Void .ctor(Microsoft.Azure.Cosmos.Fluent.ContainerBuilder, System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.Embedding], System.Action`1[Microsoft.Azure.Cosmos.VectorEmbeddingPolicy])]"
}
},
"NestedTypes": {}
},
"Microsoft.Azure.Cosmos.Fluent.VectorIndexDefinition`1;System.Object;IsAbstract:False;IsSealed:False;IsInterface:False;IsEnum:False;IsClass:True;IsValueType:False;IsNested:False;IsGenericType:True;IsSerializable:False": {
"Subclasses": {},
"Members": {
"Microsoft.Azure.Cosmos.Fluent.VectorIndexDefinition`1[T] Path(System.String, Microsoft.Azure.Cosmos.VectorIndexType)": {
"Type": "Method",
"Attributes": [],
"MethodInfo": "Microsoft.Azure.Cosmos.Fluent.VectorIndexDefinition`1[T] Path(System.String, Microsoft.Azure.Cosmos.VectorIndexType);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"T Attach()": {
"Type": "Method",
"Attributes": [],
"MethodInfo": "T Attach();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"Void .ctor(T, System.Action`1[Microsoft.Azure.Cosmos.VectorIndexPath])": {
"Type": "Constructor",
"Attributes": [],
"MethodInfo": "[Void .ctor(T, System.Action`1[Microsoft.Azure.Cosmos.VectorIndexPath]), Void .ctor(T, System.Action`1[Microsoft.Azure.Cosmos.VectorIndexPath])]"
}
},
"NestedTypes": {}
},
"Microsoft.Azure.Cosmos.IndexingPolicy;System.Object;IsAbstract:False;IsSealed:True;IsInterface:False;IsEnum:False;IsClass:True;IsValueType:False;IsNested:False;IsGenericType:False;IsSerializable:False": {
"Subclasses": {},
"Members": {
"System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.VectorIndexPath] get_VectorIndexes()[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": {
"Type": "Method",
"Attributes": [
"CompilerGeneratedAttribute"
],
"MethodInfo": "System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.VectorIndexPath] get_VectorIndexes();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.VectorIndexPath] VectorIndexes[Newtonsoft.Json.JsonPropertyAttribute(NullValueHandling = 1, PropertyName = \"vectorIndexes\")]": {
"Type": "Property",
"Attributes": [
"JsonPropertyAttribute"
],
"MethodInfo": "System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.VectorIndexPath] VectorIndexes;CanRead:True;CanWrite:True;System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.VectorIndexPath] get_VectorIndexes();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;Void set_VectorIndexes(System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.VectorIndexPath]);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"Void set_VectorIndexes(System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.VectorIndexPath])[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": {
"Type": "Method",
"Attributes": [
"CompilerGeneratedAttribute"
],
"MethodInfo": "Void set_VectorIndexes(System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.VectorIndexPath]);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
}
},
"NestedTypes": {}
},
"Microsoft.Azure.Cosmos.Linq.CosmosLinqExtensions;System.Object;IsAbstract:True;IsSealed:True;IsInterface:False;IsEnum:False;IsClass:True;IsValueType:False;IsNested:False;IsGenericType:False;IsSerializable:False": {
"Subclasses": {},
"Members": {
@ -418,6 +654,149 @@
}
},
"NestedTypes": {}
},
"Microsoft.Azure.Cosmos.VectorDataType;System.Enum;IsAbstract:False;IsSealed:True;IsInterface:False;IsEnum:True;IsClass:False;IsValueType:True;IsNested:False;IsGenericType:False;IsSerializable:True": {
"Subclasses": {},
"Members": {
"Int32 value__": {
"Type": "Field",
"Attributes": [],
"MethodInfo": "Int32 value__;IsInitOnly:False;IsStatic:False;"
},
"Microsoft.Azure.Cosmos.VectorDataType Float16[System.Runtime.Serialization.EnumMemberAttribute(Value = \"float16\")]": {
"Type": "Field",
"Attributes": [
"EnumMemberAttribute"
],
"MethodInfo": "Microsoft.Azure.Cosmos.VectorDataType Float16;IsInitOnly:False;IsStatic:True;"
},
"Microsoft.Azure.Cosmos.VectorDataType Float32[System.Runtime.Serialization.EnumMemberAttribute(Value = \"float32\")]": {
"Type": "Field",
"Attributes": [
"EnumMemberAttribute"
],
"MethodInfo": "Microsoft.Azure.Cosmos.VectorDataType Float32;IsInitOnly:False;IsStatic:True;"
},
"Microsoft.Azure.Cosmos.VectorDataType Int8[System.Runtime.Serialization.EnumMemberAttribute(Value = \"int8\")]": {
"Type": "Field",
"Attributes": [
"EnumMemberAttribute"
],
"MethodInfo": "Microsoft.Azure.Cosmos.VectorDataType Int8;IsInitOnly:False;IsStatic:True;"
},
"Microsoft.Azure.Cosmos.VectorDataType Uint8[System.Runtime.Serialization.EnumMemberAttribute(Value = \"uint8\")]": {
"Type": "Field",
"Attributes": [
"EnumMemberAttribute"
],
"MethodInfo": "Microsoft.Azure.Cosmos.VectorDataType Uint8;IsInitOnly:False;IsStatic:True;"
}
},
"NestedTypes": {}
},
"Microsoft.Azure.Cosmos.VectorEmbeddingPolicy;System.Object;IsAbstract:False;IsSealed:True;IsInterface:False;IsEnum:False;IsClass:True;IsValueType:False;IsNested:False;IsGenericType:False;IsSerializable:False": {
"Subclasses": {},
"Members": {
"System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.Embedding] Embeddings[Newtonsoft.Json.JsonPropertyAttribute(PropertyName = \"vectorEmbeddings\")]": {
"Type": "Field",
"Attributes": [
"JsonPropertyAttribute"
],
"MethodInfo": "System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.Embedding] Embeddings;IsInitOnly:True;IsStatic:False;"
},
"Void .ctor(System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.Embedding])": {
"Type": "Constructor",
"Attributes": [],
"MethodInfo": "[Void .ctor(System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.Embedding]), Void .ctor(System.Collections.ObjectModel.Collection`1[Microsoft.Azure.Cosmos.Embedding])]"
}
},
"NestedTypes": {}
},
"Microsoft.Azure.Cosmos.VectorIndexPath;System.Object;IsAbstract:False;IsSealed:True;IsInterface:False;IsEnum:False;IsClass:True;IsValueType:False;IsNested:False;IsGenericType:False;IsSerializable:False": {
"Subclasses": {},
"Members": {
"Microsoft.Azure.Cosmos.VectorIndexType get_Type()[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": {
"Type": "Method",
"Attributes": [
"CompilerGeneratedAttribute"
],
"MethodInfo": "Microsoft.Azure.Cosmos.VectorIndexType get_Type();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"Microsoft.Azure.Cosmos.VectorIndexType Type[Newtonsoft.Json.JsonPropertyAttribute(PropertyName = \"type\")]-[Newtonsoft.Json.JsonConverterAttribute(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]": {
"Type": "Property",
"Attributes": [
"JsonConverterAttribute",
"JsonPropertyAttribute"
],
"MethodInfo": "Microsoft.Azure.Cosmos.VectorIndexType Type;CanRead:True;CanWrite:True;Microsoft.Azure.Cosmos.VectorIndexType get_Type();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;Void set_Type(Microsoft.Azure.Cosmos.VectorIndexType);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"System.String get_Path()[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": {
"Type": "Method",
"Attributes": [
"CompilerGeneratedAttribute"
],
"MethodInfo": "System.String get_Path();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"System.String Path[Newtonsoft.Json.JsonPropertyAttribute(PropertyName = \"path\")]": {
"Type": "Property",
"Attributes": [
"JsonPropertyAttribute"
],
"MethodInfo": "System.String Path;CanRead:True;CanWrite:True;System.String get_Path();IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;Void set_Path(System.String);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"Void .ctor()": {
"Type": "Constructor",
"Attributes": [],
"MethodInfo": "[Void .ctor(), Void .ctor()]"
},
"Void set_Path(System.String)[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": {
"Type": "Method",
"Attributes": [
"CompilerGeneratedAttribute"
],
"MethodInfo": "Void set_Path(System.String);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
},
"Void set_Type(Microsoft.Azure.Cosmos.VectorIndexType)[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]": {
"Type": "Method",
"Attributes": [
"CompilerGeneratedAttribute"
],
"MethodInfo": "Void set_Type(Microsoft.Azure.Cosmos.VectorIndexType);IsAbstract:False;IsStatic:False;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
}
},
"NestedTypes": {}
},
"Microsoft.Azure.Cosmos.VectorIndexType;System.Enum;IsAbstract:False;IsSealed:True;IsInterface:False;IsEnum:True;IsClass:False;IsValueType:True;IsNested:False;IsGenericType:False;IsSerializable:True": {
"Subclasses": {},
"Members": {
"Int32 value__": {
"Type": "Field",
"Attributes": [],
"MethodInfo": "Int32 value__;IsInitOnly:False;IsStatic:False;"
},
"Microsoft.Azure.Cosmos.VectorIndexType DiskANN[System.Runtime.Serialization.EnumMemberAttribute(Value = \"diskANN\")]": {
"Type": "Field",
"Attributes": [
"EnumMemberAttribute"
],
"MethodInfo": "Microsoft.Azure.Cosmos.VectorIndexType DiskANN;IsInitOnly:False;IsStatic:True;"
},
"Microsoft.Azure.Cosmos.VectorIndexType Flat[System.Runtime.Serialization.EnumMemberAttribute(Value = \"flat\")]": {
"Type": "Field",
"Attributes": [
"EnumMemberAttribute"
],
"MethodInfo": "Microsoft.Azure.Cosmos.VectorIndexType Flat;IsInitOnly:False;IsStatic:True;"
},
"Microsoft.Azure.Cosmos.VectorIndexType QuantizedFlat[System.Runtime.Serialization.EnumMemberAttribute(Value = \"quantizedFlat\")]": {
"Type": "Field",
"Attributes": [
"EnumMemberAttribute"
],
"MethodInfo": "Microsoft.Azure.Cosmos.VectorIndexType QuantizedFlat;IsInitOnly:False;IsStatic:True;"
}
},
"NestedTypes": {}
}
},
"Members": {},

Просмотреть файл

@ -183,31 +183,31 @@ namespace Microsoft.Azure.Cosmos.Tests
[TestMethod]
public void ValidateVectorEmbeddingsAndIndexes()
{
Embedding embedding1 = new ()
Cosmos.Embedding embedding1 = new ()
{
Path = "/vector1",
DataType = VectorDataType.Int8,
DistanceFunction = DistanceFunction.DotProduct,
DataType = Cosmos.VectorDataType.Int8,
DistanceFunction = Cosmos.DistanceFunction.DotProduct,
Dimensions = 1200,
};
Embedding embedding2 = new ()
Cosmos.Embedding embedding2 = new ()
{
Path = "/vector2",
DataType = VectorDataType.Uint8,
DistanceFunction = DistanceFunction.Cosine,
DataType = Cosmos.VectorDataType.Uint8,
DistanceFunction = Cosmos.DistanceFunction.Cosine,
Dimensions = 3,
};
Embedding embedding3 = new ()
Cosmos.Embedding embedding3 = new ()
{
Path = "/vector3",
DataType = VectorDataType.Float32,
DistanceFunction = DistanceFunction.Euclidean,
DataType = Cosmos.VectorDataType.Float32,
DistanceFunction = Cosmos.DistanceFunction.Euclidean,
Dimensions = 400,
};
Collection<Embedding> embeddings = new Collection<Embedding>()
Collection<Cosmos.Embedding> embeddings = new Collection<Cosmos.Embedding>()
{
embedding1,
embedding2,
@ -216,25 +216,25 @@ namespace Microsoft.Azure.Cosmos.Tests
ContainerProperties containerSettings = new ContainerProperties(id: "TestContainer", partitionKeyPath: "/partitionKey")
{
VectorEmbeddingPolicy = new(embeddings),
VectorEmbeddingPolicy = new (embeddings),
IndexingPolicy = new Cosmos.IndexingPolicy()
{
VectorIndexes = new()
{
new VectorIndexPath()
new Cosmos.VectorIndexPath()
{
Path = "/vector1",
Type = VectorIndexType.Flat,
Type = Cosmos.VectorIndexType.Flat,
},
new VectorIndexPath()
new Cosmos.VectorIndexPath()
{
Path = "/vector2",
Type = VectorIndexType.Flat,
Type = Cosmos.VectorIndexType.Flat,
},
new VectorIndexPath()
new Cosmos.VectorIndexPath()
{
Path = "/vector3",
Type = VectorIndexType.Flat,
Type = Cosmos.VectorIndexType.Flat,
}
},
@ -245,18 +245,18 @@ namespace Microsoft.Azure.Cosmos.Tests
Assert.IsNotNull(containerSettings.VectorEmbeddingPolicy);
Assert.IsNotNull(containerSettings.IndexingPolicy.VectorIndexes);
VectorEmbeddingPolicy embeddingPolicy = containerSettings.VectorEmbeddingPolicy;
Cosmos.VectorEmbeddingPolicy embeddingPolicy = containerSettings.VectorEmbeddingPolicy;
Assert.IsNotNull(embeddingPolicy.Embeddings);
Assert.AreEqual(embeddings.Count, embeddingPolicy.Embeddings.Count());
CollectionAssert.AreEquivalent(embeddings, embeddingPolicy.Embeddings.ToList());
Collection<VectorIndexPath> vectorIndexes = containerSettings.IndexingPolicy.VectorIndexes;
Collection<Cosmos.VectorIndexPath> vectorIndexes = containerSettings.IndexingPolicy.VectorIndexes;
Assert.AreEqual("/vector1", vectorIndexes[0].Path);
Assert.AreEqual(VectorIndexType.Flat, vectorIndexes[0].Type);
Assert.AreEqual(Cosmos.VectorIndexType.Flat, vectorIndexes[0].Type);
Assert.AreEqual("/vector2", vectorIndexes[1].Path);
Assert.AreEqual(VectorIndexType.Flat, vectorIndexes[1].Type);
Assert.AreEqual(Cosmos.VectorIndexType.Flat, vectorIndexes[1].Type);
Assert.AreEqual("/vector3", vectorIndexes[2].Path);
Assert.AreEqual(VectorIndexType.Flat, vectorIndexes[2].Type);
Assert.AreEqual(Cosmos.VectorIndexType.Flat, vectorIndexes[2].Type);
}
private static string SerializeDocumentCollection(DocumentCollection collection)

Просмотреть файл

@ -400,9 +400,9 @@ namespace Microsoft.Azure.Cosmos.Tests
Assert.IsNotNull(containerProperties.VectorEmbeddingPolicy);
Assert.AreEqual(3, containerProperties.VectorEmbeddingPolicy.Embeddings.Count);
Assert.AreEqual("/vector1", containerProperties.VectorEmbeddingPolicy.Embeddings[0].Path);
Assert.AreEqual(VectorDataType.Float32, containerProperties.VectorEmbeddingPolicy.Embeddings[0].DataType);
Assert.AreEqual(Cosmos.VectorDataType.Float32, containerProperties.VectorEmbeddingPolicy.Embeddings[0].DataType);
Assert.AreEqual((ulong)1200, containerProperties.VectorEmbeddingPolicy.Embeddings[0].Dimensions);
Assert.AreEqual(DistanceFunction.Cosine, containerProperties.VectorEmbeddingPolicy.Embeddings[0].DistanceFunction);
Assert.AreEqual(Cosmos.DistanceFunction.Cosine, containerProperties.VectorEmbeddingPolicy.Embeddings[0].DistanceFunction);
Assert.AreEqual(2, containerProperties.ComputedProperties.Count);
Assert.AreEqual("lowerName", containerProperties.ComputedProperties[0].Name);
@ -749,7 +749,8 @@ namespace Microsoft.Azure.Cosmos.Tests
"ConflictResolutionPolicy",
"ChangeFeedPolicy",
"ClientEncryptionPolicy",
"PartitionKeyPaths");
"PartitionKeyPaths",
"VectorEmbeddingPolicy");
#else
SettingsContractTests.TypeAccessorGuard(typeof(ContainerProperties),
"Id",
@ -804,7 +805,7 @@ namespace Microsoft.Azure.Cosmos.Tests
[TestMethod]
public async Task ContainerSettingsIndexTest()
{
string containerJsonString = "{\"indexingPolicy\":{\"automatic\":true,\"indexingMode\":\"Consistent\",\"includedPaths\":[{\"path\":\"/*\",\"indexes\":[{\"dataType\":\"Number\",\"precision\":-1,\"kind\":\"Range\"},{\"dataType\":\"String\",\"precision\":-1,\"kind\":\"Range\"}]}],\"excludedPaths\":[{\"path\":\"/\\\"_etag\\\"/?\"}],\"compositeIndexes\":[],\"spatialIndexes\":[]},\"id\":\"MigrationTest\",\"partitionKey\":{\"paths\":[\"/id\"],\"kind\":\"Hash\"}}";
string containerJsonString = "{\"indexingPolicy\":{\"automatic\":true,\"indexingMode\":\"Consistent\",\"includedPaths\":[{\"path\":\"/*\",\"indexes\":[{\"dataType\":\"Number\",\"precision\":-1,\"kind\":\"Range\"},{\"dataType\":\"String\",\"precision\":-1,\"kind\":\"Range\"}]}],\"excludedPaths\":[{\"path\":\"/\\\"_etag\\\"/?\"}],\"compositeIndexes\":[],\"spatialIndexes\":[],\"vectorIndexes\":[]},\"id\":\"MigrationTest\",\"partitionKey\":{\"paths\":[\"/id\"],\"kind\":\"Hash\"}}";
CosmosJsonDotNetSerializer serializerCore = new CosmosJsonDotNetSerializer();
ContainerProperties containerProperties = null;
@ -1077,29 +1078,29 @@ namespace Microsoft.Azure.Cosmos.Tests
string serialization = JsonConvert.SerializeObject(containerSettings);
Assert.IsFalse(serialization.Contains("vectorEmbeddingPolicy"), "Vector Embedding Policy should not be included by default");
Embedding embedding1 = new()
Cosmos.Embedding embedding1 = new()
{
Path = "/vector1",
DataType = VectorDataType.Int8,
DistanceFunction = DistanceFunction.DotProduct,
DataType = Cosmos.VectorDataType.Int8,
DistanceFunction = Cosmos.DistanceFunction.DotProduct,
Dimensions = 1200,
};
Embedding embedding2 = new()
Cosmos.Embedding embedding2 = new()
{
Path = "/vector2",
DataType = VectorDataType.Uint8,
DistanceFunction = DistanceFunction.Cosine,
DataType = Cosmos.VectorDataType.Uint8,
DistanceFunction = Cosmos.DistanceFunction.Cosine,
Dimensions = 3,
};
Collection<Embedding> embeddings = new ()
Collection<Cosmos.Embedding> embeddings = new ()
{
embedding1,
embedding2,
};
containerSettings.VectorEmbeddingPolicy = new VectorEmbeddingPolicy(embeddings);
containerSettings.VectorEmbeddingPolicy = new Cosmos.VectorEmbeddingPolicy(embeddings);
string serializationWithValues = JsonConvert.SerializeObject(containerSettings);
Assert.IsTrue(serializationWithValues.Contains("vectorEmbeddingPolicy"), "Vector Embedding Policy should be included.");
@ -1108,8 +1109,8 @@ namespace Microsoft.Azure.Cosmos.Tests
JObject parsed = JObject.Parse(serializationWithValues);
JToken vectorEmbeddings = parsed["vectorEmbeddingPolicy"]["vectorEmbeddings"];
Assert.AreEqual(JTokenType.Array, vectorEmbeddings.Type, "Vector Embedding Policy serialized vectorEmbeddings should be an array.");
Assert.IsTrue(embedding1.Equals(vectorEmbeddings.Value<JArray>()[0].ToObject<Embedding>()));
Assert.IsTrue(embedding2.Equals(vectorEmbeddings.Value<JArray>()[1].ToObject<Embedding>()));
Assert.IsTrue(embedding1.Equals(vectorEmbeddings.Value<JArray>()[0].ToObject<Cosmos.Embedding>()));
Assert.IsTrue(embedding2.Equals(vectorEmbeddings.Value<JArray>()[1].ToObject<Cosmos.Embedding>()));
}
private static T CosmosDeserialize<T>(string payload)