openai/openai-dotnet

Public

mirrored from https://github.com/openai/openai-dotnetAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
user/travisw/mcptoolfilter-serialization-draft

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/Custom/Embeddings/OpenAIEmbeddingCollection.cs

35lines · modecode

1using Microsoft.TypeSpec.Generator.Customizations;
2using System;
3using System.ClientModel.Primitives;
4using System.Collections.Generic;
5using System.Collections.ObjectModel;
6
7namespace OpenAI.Embeddings;
8
9/// <summary> A collection of embeddings. </summary>
10[CodeGenType("CreateEmbeddingResponse")]
11[CodeGenSuppress(nameof(OpenAIEmbeddingCollection), typeof(IEnumerable<OpenAIEmbedding>), typeof(string), typeof(EmbeddingTokenUsage))]
12public 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}