// <auto-generated/>

#nullable disable

using System;
using System.ClientModel;
using System.ClientModel.Primitives;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
using OpenAI;

namespace OpenAI.Chat
{
    public partial class ChatClient
    {
        private readonly Uri _endpoint;

        protected ChatClient()
        {
        }

        public ClientPipeline Pipeline { get; }

        [Experimental("OPENAI001")]
        public virtual CollectionResult GetChatCompletions(string after, int? limit, string order, IDictionary<string, string> metadata, string model, RequestOptions options)
        {
            return new ChatClientGetChatCompletionsCollectionResult(
                this,
                after,
                limit,
                order,
                metadata,
                model,
                options);
        }

        [Experimental("OPENAI001")]
        public virtual AsyncCollectionResult GetChatCompletionsAsync(string after, int? limit, string order, IDictionary<string, string> metadata, string model, RequestOptions options)
        {
            return new ChatClientGetChatCompletionsAsyncCollectionResult(
                this,
                after,
                limit,
                order,
                metadata,
                model,
                options);
        }

        [Experimental("OPENAI001")]
        public virtual CollectionResult<ChatCompletion> GetChatCompletions(ChatCompletionCollectionOptions options = default, CancellationToken cancellationToken = default)
        {
            return new ChatClientGetChatCompletionsCollectionResultOfT(
                this,
                options?.AfterId,
                options?.PageSizeLimit,
                options?.Order?.ToString(),
                options?.Metadata,
                options?.Model,
                cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
        }

        [Experimental("OPENAI001")]
        public virtual AsyncCollectionResult<ChatCompletion> GetChatCompletionsAsync(ChatCompletionCollectionOptions options = default, CancellationToken cancellationToken = default)
        {
            return new ChatClientGetChatCompletionsAsyncCollectionResultOfT(
                this,
                options?.AfterId,
                options?.PageSizeLimit,
                options?.Order?.ToString(),
                options?.Metadata,
                options?.Model,
                cancellationToken.CanBeCanceled ? new RequestOptions { CancellationToken = cancellationToken } : null);
        }

        public virtual ClientResult CompleteChat(BinaryContent content, RequestOptions options = null)
        {
            Argument.AssertNotNull(content, nameof(content));

            using PipelineMessage message = CreateCompleteChatRequest(content, options);
            return ClientResult.FromResponse(Pipeline.ProcessMessage(message, options));
        }

        public virtual async Task<ClientResult> CompleteChatAsync(BinaryContent content, RequestOptions options = null)
        {
            Argument.AssertNotNull(content, nameof(content));

            using PipelineMessage message = CreateCompleteChatRequest(content, options);
            return ClientResult.FromResponse(await Pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false));
        }
    }
}
