openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
src/Custom/Embeddings/OpenAIEmbeddingCollection.cs
35lines · modecode
| 1 | using Microsoft.TypeSpec.Generator.Customizations; |
| 2 | using System; |
| 3 | using System.ClientModel.Primitives; |
| 4 | using System.Collections.Generic; |
| 5 | using System.Collections.ObjectModel; |
| 6 | |
| 7 | namespace OpenAI.Embeddings; |
| 8 | |
| 9 | /// <summary> A collection of embeddings. </summary> |
| 10 | [CodeGenType("CreateEmbeddingResponse")] |
| 11 | [CodeGenSuppress(nameof(OpenAIEmbeddingCollection), typeof(IEnumerable<OpenAIEmbedding>), typeof(string), typeof(EmbeddingTokenUsage))] |
| 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 | [CodeGenMember("Object")] |
| 16 | private string Object { get; } = "list"; |
| 17 | |
| 18 | #pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. |
| 19 | // CUSTOM: Set the inherited Items property via the base constructor. |
| 20 | internal OpenAIEmbeddingCollection(IList<OpenAIEmbedding> items, string model, string @object, EmbeddingTokenUsage usage, in JsonPatch patch) |
| 21 | : base(items ?? new ChangeTrackingList<OpenAIEmbedding>()) |
| 22 | { |
| 23 | Model = model; |
| 24 | Object = @object; |
| 25 | Usage = usage; |
| 26 | _patch = patch; |
| 27 | _patch.SetPropagators(PropagateSet, PropagateGet); |
| 28 | } |
| 29 | #pragma warning restore SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. |
| 30 | |
| 31 | // CUSTOM: Call the base constructor. |
| 32 | internal OpenAIEmbeddingCollection() : this(null, null, null, null, default) |
| 33 | { |
| 34 | } |
| 35 | } |