openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
src/Custom/Embeddings/OpenAIEmbeddingCollection.cs
58lines · modecode
| 1 | using System; |
| 2 | using System.Collections.Generic; |
| 3 | using System.Collections.ObjectModel; |
| 4 | |
| 5 | namespace OpenAI.Embeddings; |
| 6 | |
| 7 | [CodeGenType("CreateEmbeddingResponse")] |
| 8 | [CodeGenSuppress("Data")] |
| 9 | [CodeGenSuppress(nameof(OpenAIEmbeddingCollection))] |
| 10 | [CodeGenSuppress(nameof(OpenAIEmbeddingCollection), typeof(string), typeof(EmbeddingTokenUsage))] |
| 11 | [CodeGenSuppress(nameof(OpenAIEmbeddingCollection), typeof(string), typeof(EmbeddingTokenUsage), typeof(InternalCreateEmbeddingResponseObject), typeof(IDictionary<string, BinaryData>))] |
| 12 | public partial class OpenAIEmbeddingCollection : ReadOnlyCollection<OpenAIEmbedding> |
| 13 | { |
| 14 | // CUSTOM: Made private. This property does not add value in the context of a strongly-typed class. |
| 15 | /// <summary> The object type, which is always "list". </summary> |
| 16 | [CodeGenMember("Object")] |
| 17 | private InternalCreateEmbeddingResponseObject Object { get; } = InternalCreateEmbeddingResponseObject.List; |
| 18 | |
| 19 | // CUSTOM: Set the inherited Items property via the base constructor in favor of the suppressed Data property. |
| 20 | /// <summary> Initializes a new instance of <see cref="OpenAIEmbeddingCollection"/>. </summary> |
| 21 | /// <param name="data"> The list of embeddings generated by the model. </param> |
| 22 | /// <param name="model"> The name of the model used to generate the embedding. </param> |
| 23 | /// <param name="usage"> The usage information for the request. </param> |
| 24 | /// <exception cref="ArgumentNullException"> <paramref name="data"/>, <paramref name="model"/> or <paramref name="usage"/> is null. </exception> |
| 25 | internal OpenAIEmbeddingCollection(IEnumerable<OpenAIEmbedding> data, string model, EmbeddingTokenUsage usage) |
| 26 | : base([.. data]) |
| 27 | { |
| 28 | Argument.AssertNotNull(data, nameof(data)); |
| 29 | Argument.AssertNotNull(model, nameof(model)); |
| 30 | Argument.AssertNotNull(usage, nameof(usage)); |
| 31 | |
| 32 | Model = model; |
| 33 | Usage = usage; |
| 34 | } |
| 35 | |
| 36 | // CUSTOM: Set the inherited Items property via the base constructor in favor of the suppressed Data property. |
| 37 | /// <summary> Initializes a new instance of <see cref="OpenAIEmbeddingCollection"/>. </summary> |
| 38 | /// <param name="data"> The list of embeddings generated by the model. </param> |
| 39 | /// <param name="model"> The name of the model used to generate the embedding. </param> |
| 40 | /// <param name="object"> The object type, which is always "list". </param> |
| 41 | /// <param name="usage"> The usage information for the request. </param> |
| 42 | /// <param name="serializedAdditionalRawData"> Keeps track of any properties unknown to the library. </param> |
| 43 | internal OpenAIEmbeddingCollection(IReadOnlyList<OpenAIEmbedding> data, string model, InternalCreateEmbeddingResponseObject @object, EmbeddingTokenUsage usage, IDictionary<string, BinaryData> serializedAdditionalRawData) |
| 44 | : base([.. data]) |
| 45 | { |
| 46 | Model = model; |
| 47 | Object = @object; |
| 48 | Usage = usage; |
| 49 | _additionalBinaryDataProperties = serializedAdditionalRawData; |
| 50 | } |
| 51 | |
| 52 | // CUSTOM: Set the inherited Items property via the base constructor in favor of the suppressed Data property. |
| 53 | /// <summary> Initializes a new instance of <see cref="OpenAIEmbeddingCollection"/> for deserialization. </summary> |
| 54 | internal OpenAIEmbeddingCollection() |
| 55 | : base([]) |
| 56 | { |
| 57 | } |
| 58 | } |