using Microsoft.TypeSpec.Generator.Customizations; using System; using System.ClientModel; using System.ClientModel.Primitives; using System.Diagnostics.CodeAnalysis; namespace OpenAI.Conversations; // CUSTOM: // - Renamed. // - Suppressed constructor that takes endpoint parameter; endpoint is now a property in the options class. /// The service client for OpenAI conversation operations. [CodeGenType("Conversations")] [CodeGenSuppress("ConversationClient", typeof(ClientPipeline), typeof(Uri))] public partial class ConversationClient { // CUSTOM: Added as a convenience. /// Initializes a new instance of . /// The API key to authenticate with the service. /// is null. public ConversationClient(string apiKey) : this(new ApiKeyCredential(apiKey), new OpenAIClientOptions()) { } // CUSTOM: // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . /// The to authenticate with the service. /// is null. public ConversationClient(ApiKeyCredential credential) : this(credential, new OpenAIClientOptions()) { } // CUSTOM: // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. /// Initializes a new instance of . /// The to authenticate with the service. /// The options to configure the client. /// is null. public ConversationClient(ApiKeyCredential credential, OpenAIClientOptions options) : this(OpenAIClient.CreateApiKeyAuthenticationPolicy(credential), options) { } // CUSTOM: Added as a convenience. /// Initializes a new instance of . /// The authentication policy used to authenticate with the service. /// is null. public ConversationClient(AuthenticationPolicy authenticationPolicy) : this(authenticationPolicy, new OpenAIClientOptions()) { } // CUSTOM: Added as a convenience. /// Initializes a new instance of . /// The authentication policy used to authenticate with the service. /// The options to configure the client. /// is null. public ConversationClient(AuthenticationPolicy authenticationPolicy, OpenAIClientOptions options) { Argument.AssertNotNull(authenticationPolicy, nameof(authenticationPolicy)); options ??= new OpenAIClientOptions(); Pipeline = OpenAIClient.CreatePipeline(authenticationPolicy, options); _endpoint = OpenAIClient.GetEndpoint(options); } // CUSTOM: // - Used a custom pipeline. // - Demoted the endpoint parameter to be a property in the options class. // - Made protected. /// Initializes a new instance of . /// The HTTP pipeline to send and receive REST requests and responses. /// The options to configure the client. /// is null. protected internal ConversationClient(ClientPipeline pipeline, OpenAIClientOptions options) { Argument.AssertNotNull(pipeline, nameof(pipeline)); options ??= new OpenAIClientOptions(); Pipeline = pipeline; _endpoint = OpenAIClient.GetEndpoint(options); } [Experimental("SCME0002")] public ConversationClient(ConversationClientSettings settings) : this(AuthenticationPolicy.Create(settings), settings?.Options) { } /// /// Gets the endpoint URI for the service. /// [Experimental("OPENAI001")] public Uri Endpoint => _endpoint; }