src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/PutHuggingFaceRequest.g.cs (200 lines of code) (raw):

// Licensed to Elasticsearch B.V under one or more agreements. // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information. // // ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ // ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ // ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ // ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ // ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ // ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ // ------------------------------------------------ // // This file is automatically generated. // Please do not edit these files manually. // // ------------------------------------------------ #nullable restore using System; using System.Linq; using Elastic.Clients.Elasticsearch.Serialization; namespace Elastic.Clients.Elasticsearch.Inference; public sealed partial class PutHuggingFaceRequestParameters : Elastic.Transport.RequestParameters { } internal sealed partial class PutHuggingFaceRequestConverter : System.Text.Json.Serialization.JsonConverter<Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequest> { private static readonly System.Text.Json.JsonEncodedText PropChunkingSettings = System.Text.Json.JsonEncodedText.Encode("chunking_settings"); private static readonly System.Text.Json.JsonEncodedText PropService = System.Text.Json.JsonEncodedText.Encode("service"); private static readonly System.Text.Json.JsonEncodedText PropServiceSettings = System.Text.Json.JsonEncodedText.Encode("service_settings"); public override Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); LocalJsonValue<Elastic.Clients.Elasticsearch.Inference.InferenceChunkingSettings?> propChunkingSettings = default; LocalJsonValue<Elastic.Clients.Elasticsearch.Inference.HuggingFaceServiceSettings> propServiceSettings = default; while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { if (propChunkingSettings.TryReadProperty(ref reader, options, PropChunkingSettings, null)) { continue; } if (reader.ValueTextEquals(PropService)) { reader.Skip(); continue; } if (propServiceSettings.TryReadProperty(ref reader, options, PropServiceSettings, null)) { continue; } if (options.UnmappedMemberHandling is System.Text.Json.Serialization.JsonUnmappedMemberHandling.Skip) { reader.Skip(); continue; } throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); return new Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequest(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance) { ChunkingSettings = propChunkingSettings.Value, ServiceSettings = propServiceSettings.Value }; } public override void Write(System.Text.Json.Utf8JsonWriter writer, Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequest value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); writer.WriteProperty(options, PropChunkingSettings, value.ChunkingSettings, null, null); writer.WriteProperty(options, PropService, value.Service, null, null); writer.WriteProperty(options, PropServiceSettings, value.ServiceSettings, null, null); writer.WriteEndObject(); } } /// <summary> /// <para> /// Create a Hugging Face inference endpoint. /// </para> /// <para> /// Create an inference endpoint to perform an inference task with the <c>hugging_face</c> service. /// </para> /// <para> /// You must first create an inference endpoint on the Hugging Face endpoint page to get an endpoint URL. /// Select the model you want to use on the new endpoint creation page (for example <c>intfloat/e5-small-v2</c>), then select the sentence embeddings task under the advanced configuration section. /// Create the endpoint and copy the URL after the endpoint initialization has been finished. /// </para> /// <para> /// The following models are recommended for the Hugging Face service: /// </para> /// <list type="bullet"> /// <item> /// <para> /// <c>all-MiniLM-L6-v2</c> /// </para> /// </item> /// <item> /// <para> /// <c>all-MiniLM-L12-v2</c> /// </para> /// </item> /// <item> /// <para> /// <c>all-mpnet-base-v2</c> /// </para> /// </item> /// <item> /// <para> /// <c>e5-base-v2</c> /// </para> /// </item> /// <item> /// <para> /// <c>e5-small-v2</c> /// </para> /// </item> /// <item> /// <para> /// <c>multilingual-e5-base</c> /// </para> /// </item> /// <item> /// <para> /// <c>multilingual-e5-small</c> /// </para> /// </item> /// </list> /// </summary> [System.Text.Json.Serialization.JsonConverter(typeof(Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequestConverter))] public sealed partial class PutHuggingFaceRequest : Elastic.Clients.Elasticsearch.Requests.PlainRequest<Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequestParameters> { [System.Obsolete("The request contains additional required properties that must be initialized. Please use an alternative constructor to ensure all required values are properly set.")] [System.Diagnostics.CodeAnalysis.SetsRequiredMembers] public PutHuggingFaceRequest(Elastic.Clients.Elasticsearch.Inference.HuggingFaceTaskType taskType, Elastic.Clients.Elasticsearch.Id huggingfaceInferenceId) : base(r => r.Required("task_type", taskType).Required("huggingface_inference_id", huggingfaceInferenceId)) { } [System.Diagnostics.CodeAnalysis.SetsRequiredMembers] public PutHuggingFaceRequest(Elastic.Clients.Elasticsearch.Inference.HuggingFaceTaskType taskType, Elastic.Clients.Elasticsearch.Id huggingfaceInferenceId, Elastic.Clients.Elasticsearch.Inference.HuggingFaceServiceSettings serviceSettings) : base(r => r.Required("task_type", taskType).Required("huggingface_inference_id", huggingfaceInferenceId)) { ServiceSettings = serviceSettings; } #if NET7_0_OR_GREATER public PutHuggingFaceRequest() { } #endif [System.Diagnostics.CodeAnalysis.SetsRequiredMembers] internal PutHuggingFaceRequest(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel sentinel) { _ = sentinel; } internal override Elastic.Clients.Elasticsearch.Requests.ApiUrls ApiUrls => Elastic.Clients.Elasticsearch.Requests.ApiUrlLookup.InferencePutHuggingFace; protected override Elastic.Transport.HttpMethod StaticHttpMethod => Elastic.Transport.HttpMethod.PUT; internal override bool SupportsBody => true; internal override string OperationName => "inference.put_hugging_face"; /// <summary> /// <para> /// The unique identifier of the inference endpoint. /// </para> /// </summary> public #if NET7_0_OR_GREATER required #endif Elastic.Clients.Elasticsearch.Id HuggingfaceInferenceId { get => P<Elastic.Clients.Elasticsearch.Id>("huggingface_inference_id"); set => PR("huggingface_inference_id", value); } /// <summary> /// <para> /// The type of the inference task that the model will perform. /// </para> /// </summary> public #if NET7_0_OR_GREATER required #endif Elastic.Clients.Elasticsearch.Inference.HuggingFaceTaskType TaskType { get => P<Elastic.Clients.Elasticsearch.Inference.HuggingFaceTaskType>("task_type"); set => PR("task_type", value); } /// <summary> /// <para> /// The chunking configuration object. /// </para> /// </summary> public Elastic.Clients.Elasticsearch.Inference.InferenceChunkingSettings? ChunkingSettings { get; set; } /// <summary> /// <para> /// The type of service supported for the specified task type. In this case, <c>hugging_face</c>. /// </para> /// </summary> public string Service => "hugging_face"; /// <summary> /// <para> /// Settings used to install the inference model. These settings are specific to the <c>hugging_face</c> service. /// </para> /// </summary> public #if NET7_0_OR_GREATER required #endif Elastic.Clients.Elasticsearch.Inference.HuggingFaceServiceSettings ServiceSettings { get; set; } } /// <summary> /// <para> /// Create a Hugging Face inference endpoint. /// </para> /// <para> /// Create an inference endpoint to perform an inference task with the <c>hugging_face</c> service. /// </para> /// <para> /// You must first create an inference endpoint on the Hugging Face endpoint page to get an endpoint URL. /// Select the model you want to use on the new endpoint creation page (for example <c>intfloat/e5-small-v2</c>), then select the sentence embeddings task under the advanced configuration section. /// Create the endpoint and copy the URL after the endpoint initialization has been finished. /// </para> /// <para> /// The following models are recommended for the Hugging Face service: /// </para> /// <list type="bullet"> /// <item> /// <para> /// <c>all-MiniLM-L6-v2</c> /// </para> /// </item> /// <item> /// <para> /// <c>all-MiniLM-L12-v2</c> /// </para> /// </item> /// <item> /// <para> /// <c>all-mpnet-base-v2</c> /// </para> /// </item> /// <item> /// <para> /// <c>e5-base-v2</c> /// </para> /// </item> /// <item> /// <para> /// <c>e5-small-v2</c> /// </para> /// </item> /// <item> /// <para> /// <c>multilingual-e5-base</c> /// </para> /// </item> /// <item> /// <para> /// <c>multilingual-e5-small</c> /// </para> /// </item> /// </list> /// </summary> public readonly partial struct PutHuggingFaceRequestDescriptor { internal Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequest Instance { get; init; } [System.Diagnostics.CodeAnalysis.SetsRequiredMembers] public PutHuggingFaceRequestDescriptor(Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequest instance) { Instance = instance; } public PutHuggingFaceRequestDescriptor(Elastic.Clients.Elasticsearch.Inference.HuggingFaceTaskType taskType, Elastic.Clients.Elasticsearch.Id huggingfaceInferenceId) { #pragma warning disable CS0618 Instance = new Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequest(taskType, huggingfaceInferenceId); #pragma warning restore CS0618 } [System.Obsolete("The use of the parameterless constructor is not permitted for this type.")] public PutHuggingFaceRequestDescriptor() { throw new System.InvalidOperationException("The use of the parameterless constructor is not permitted for this type."); } public static explicit operator Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequestDescriptor(Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequest instance) => new Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequestDescriptor(instance); public static implicit operator Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequest(Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequestDescriptor descriptor) => descriptor.Instance; /// <summary> /// <para> /// The unique identifier of the inference endpoint. /// </para> /// </summary> public Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequestDescriptor HuggingfaceInferenceId(Elastic.Clients.Elasticsearch.Id value) { Instance.HuggingfaceInferenceId = value; return this; } /// <summary> /// <para> /// The type of the inference task that the model will perform. /// </para> /// </summary> public Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequestDescriptor TaskType(Elastic.Clients.Elasticsearch.Inference.HuggingFaceTaskType value) { Instance.TaskType = value; return this; } /// <summary> /// <para> /// The chunking configuration object. /// </para> /// </summary> public Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequestDescriptor ChunkingSettings(Elastic.Clients.Elasticsearch.Inference.InferenceChunkingSettings? value) { Instance.ChunkingSettings = value; return this; } /// <summary> /// <para> /// The chunking configuration object. /// </para> /// </summary> public Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequestDescriptor ChunkingSettings() { Instance.ChunkingSettings = Elastic.Clients.Elasticsearch.Inference.InferenceChunkingSettingsDescriptor.Build(null); return this; } /// <summary> /// <para> /// The chunking configuration object. /// </para> /// </summary> public Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequestDescriptor ChunkingSettings(System.Action<Elastic.Clients.Elasticsearch.Inference.InferenceChunkingSettingsDescriptor>? action) { Instance.ChunkingSettings = Elastic.Clients.Elasticsearch.Inference.InferenceChunkingSettingsDescriptor.Build(action); return this; } /// <summary> /// <para> /// Settings used to install the inference model. These settings are specific to the <c>hugging_face</c> service. /// </para> /// </summary> public Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequestDescriptor ServiceSettings(Elastic.Clients.Elasticsearch.Inference.HuggingFaceServiceSettings value) { Instance.ServiceSettings = value; return this; } /// <summary> /// <para> /// Settings used to install the inference model. These settings are specific to the <c>hugging_face</c> service. /// </para> /// </summary> public Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequestDescriptor ServiceSettings(System.Action<Elastic.Clients.Elasticsearch.Inference.HuggingFaceServiceSettingsDescriptor> action) { Instance.ServiceSettings = Elastic.Clients.Elasticsearch.Inference.HuggingFaceServiceSettingsDescriptor.Build(action); return this; } [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] internal static Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequest Build(System.Action<Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequestDescriptor> action) { var builder = new Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequestDescriptor(new Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequest(Elastic.Clients.Elasticsearch.Serialization.JsonConstructorSentinel.Instance)); action.Invoke(builder); return builder.Instance; } public Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequestDescriptor ErrorTrace(bool? value) { Instance.ErrorTrace = value; return this; } public Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequestDescriptor FilterPath(params string[]? value) { Instance.FilterPath = value; return this; } public Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequestDescriptor Human(bool? value) { Instance.Human = value; return this; } public Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequestDescriptor Pretty(bool? value) { Instance.Pretty = value; return this; } public Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequestDescriptor SourceQueryString(string? value) { Instance.SourceQueryString = value; return this; } public Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequestDescriptor RequestConfiguration(Elastic.Transport.IRequestConfiguration? value) { Instance.RequestConfiguration = value; return this; } public Elastic.Clients.Elasticsearch.Inference.PutHuggingFaceRequestDescriptor RequestConfiguration(System.Func<Elastic.Transport.RequestConfigurationDescriptor, Elastic.Transport.IRequestConfiguration>? configurationSelector) { Instance.RequestConfiguration = configurationSelector.Invoke(Instance.RequestConfiguration is null ? new Elastic.Transport.RequestConfigurationDescriptor() : new Elastic.Transport.RequestConfigurationDescriptor(Instance.RequestConfiguration)) ?? Instance.RequestConfiguration; return this; } }