openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
joseharriaga/MessageResponseItem

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/Custom/Embeddings/OpenAIEmbeddingCollection.cs

65lines · modecode

1using System;
2using System.ClientModel;
3using System.ClientModel.Primitives;
4using System.Collections.Generic;
5using System.Collections.ObjectModel;
6using System.Text.Json;
7
8namespace OpenAI.Embeddings;
9
10[CodeGenType("CreateEmbeddingResponse")]
11[CodeGenSuppress("Data")]
12[CodeGenSuppress(nameof(OpenAIEmbeddingCollection))]
13[CodeGenSuppress(nameof(OpenAIEmbeddingCollection), typeof(string), typeof(EmbeddingTokenUsage))]
14#pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
15[CodeGenSuppress(nameof(OpenAIEmbeddingCollection), typeof(string), typeof(string), typeof(EmbeddingTokenUsage), typeof(JsonPatch))]
16#pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
17public partial class OpenAIEmbeddingCollection : ReadOnlyCollection<OpenAIEmbedding>
18{
19 // CUSTOM: Made private. This property does not add value in the context of a strongly-typed class.
20 /// <summary> The object type, which is always "list". </summary>
21 [CodeGenMember("Object")]
22 private string Object { get; } = "list";
23
24 // CUSTOM: Set the inherited Items property via the base constructor in favor of the suppressed Data property.
25 /// <summary> Initializes a new instance of <see cref="OpenAIEmbeddingCollection"/>. </summary>
26 /// <param name="data"> The list of embeddings generated by the model. </param>
27 /// <param name="model"> The name of the model used to generate the embedding. </param>
28 /// <param name="usage"> The usage information for the request. </param>
29 /// <exception cref="ArgumentNullException"> <paramref name="data"/>, <paramref name="model"/> or <paramref name="usage"/> is null. </exception>
30 internal OpenAIEmbeddingCollection(IEnumerable<OpenAIEmbedding> data, string model, EmbeddingTokenUsage usage)
31 : base([.. data])
32 {
33 Argument.AssertNotNull(data, nameof(data));
34 Argument.AssertNotNull(model, nameof(model));
35 Argument.AssertNotNull(usage, nameof(usage));
36
37 Model = model;
38 Usage = usage;
39 }
40
41 // CUSTOM: Set the inherited Items property via the base constructor in favor of the suppressed Data property.
42 /// <summary> Initializes a new instance of <see cref="OpenAIEmbeddingCollection"/>. </summary>
43 /// <param name="data"> The list of embeddings generated by the model. </param>
44 /// <param name="model"> The name of the model used to generate the embedding. </param>
45 /// <param name="object"> The object type, which is always "list". </param>
46 /// <param name="usage"> The usage information for the request. </param>
47 /// <param name="patch"> Keeps track of any properties unknown to the library. </param>
48#pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
49 internal OpenAIEmbeddingCollection(IReadOnlyList<OpenAIEmbedding> data, string model, string @object, EmbeddingTokenUsage usage, in JsonPatch patch)
50 : base([.. data])
51 {
52 Model = model;
53 Object = @object;
54 Usage = usage;
55 _patch = patch;
56 }
57#pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates.
58
59 // CUSTOM: Set the inherited Items property via the base constructor in favor of the suppressed Data property.
60 /// <summary> Initializes a new instance of <see cref="OpenAIEmbeddingCollection"/> for deserialization. </summary>
61 internal OpenAIEmbeddingCollection()
62 : base([])
63 {
64 }
65}