openai/openai-dotnet

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
OpenAI_2.0.0-beta.1

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/Generated/Internal/ClientPipelineExtensions.cs

41lines · modepreview

// <auto-generated/>

#nullable disable

using System.ClientModel;
using System.ClientModel.Primitives;
using System.Threading.Tasks;

namespace OpenAI
{
    internal static partial class ClientPipelineExtensions
    {
        public static async ValueTask<ClientResult<bool>> ProcessHeadAsBoolMessageAsync(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options)
        {
            PipelineResponse response = await pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false);
            switch (response.Status)
            {
                case >= 200 and < 300:
                    return ClientResult.FromValue(true, response);
                case >= 400 and < 500:
                    return ClientResult.FromValue(false, response);
                default:
                    return new ErrorResult<bool>(response, new ClientResultException(response));
            }
        }

        public static ClientResult<bool> ProcessHeadAsBoolMessage(this ClientPipeline pipeline, PipelineMessage message, RequestOptions options)
        {
            PipelineResponse response = pipeline.ProcessMessage(message, options);
            switch (response.Status)
            {
                case >= 200 and < 300:
                    return ClientResult.FromValue(true, response);
                case >= 400 and < 500:
                    return ClientResult.FromValue(false, response);
                default:
                    return new ErrorResult<bool>(response, new ClientResultException(response));
            }
        }
    }
}