-
Notifications
You must be signed in to change notification settings - Fork 526
Expand file tree
/
Copy pathEmbedding.cs
More file actions
82 lines (73 loc) · 2.9 KB
/
Embedding.cs
File metadata and controls
82 lines (73 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace Microsoft.Azure.Cosmos
{
using System;
using System.Collections.Generic;
using Microsoft.Azure.Documents;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
/// <summary>
/// Represents the embedding settings for the vector index.
/// </summary>
#if PREVIEW
public
#else
internal
#endif
class Embedding : IEquatable<Embedding>
{
/// <summary>
/// Gets or sets a string containing the path of the vector index.
/// </summary>
[JsonProperty(PropertyName = Constants.Properties.Path)]
public string Path { get; set; }
/// <summary>
/// Gets or sets the <see cref="Cosmos.VectorDataType"/> representing the corresponding vector data type.
/// </summary>
[JsonProperty(PropertyName = "dataType")]
[JsonConverter(typeof(StringEnumConverter))]
public VectorDataType DataType { get; set; }
/// <summary>
/// Gets or sets a long integer representing the dimensions of a vector.
/// </summary>
[JsonProperty(PropertyName = "dimensions")]
public ulong Dimensions { get; set; }
/// <summary>
/// Gets or sets the <see cref="Cosmos.DistanceFunction"/> which is used to calculate the respective distance between the vectors.
/// </summary>
[JsonProperty(PropertyName = "distanceFunction")]
[JsonConverter(typeof(StringEnumConverter))]
public DistanceFunction DistanceFunction { get; set; }
/// <summary>
/// This contains additional values for scenarios where the SDK is not aware of new fields.
/// This ensures that if resource is read and updated none of the fields will be lost in the process.
/// </summary>
[JsonExtensionData]
internal IDictionary<string, JToken> AdditionalProperties { get; private set; }
/// <summary>
/// Ensures that the paths specified in the vector embedding policy are valid.
/// </summary>
public void ValidateEmbeddingPath()
{
if (string.IsNullOrEmpty(this.Path))
{
throw new ArgumentException("Argument {0} can't be null or empty.", nameof(this.Path));
}
if (this.Path[0] != '/')
{
throw new ArgumentException("The argument {0} is not a valid path.", this.Path);
}
}
/// <inheritdoc/>
public bool Equals(Embedding that)
{
return this.Path.Equals(that.Path)
&& this.DataType.Equals(that.DataType)
&& this.Dimensions == that.Dimensions
&& this.Dimensions.Equals(that.Dimensions);
}
}
}