Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Custom/Assistants/AssistantClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ public AssistantClient(AuthenticationPolicy authenticationPolicy, OpenAIClientOp
_threadSubClient = new(Pipeline, options);
}

[Experimental("SCME0002")]
public AssistantClient(AssistantClientSettings settings)
: this(AuthenticationPolicy.Create(settings),
settings.Options)
{
}

/// <summary>
/// Gets the endpoint URI for the service.
/// </summary>
Expand Down
20 changes: 20 additions & 0 deletions src/Custom/Assistants/AssistantClientSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Microsoft.Extensions.Configuration;
using System.ClientModel.Primitives;
using System.Diagnostics.CodeAnalysis;

namespace OpenAI.Assistants;

[Experimental("SCME0002")]
public sealed class AssistantClientSettings : ClientSettings
{
public OpenAIClientOptions Options { get; set; }

protected override void BindCore(IConfigurationSection section)
{
var optionsSection = section.GetSection("Options");
if (optionsSection.Exists())
{
Options ??= new OpenAIClientOptions(optionsSection);
}
}
}
8 changes: 8 additions & 0 deletions src/Custom/Audio/AudioClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ protected internal AudioClient(ClientPipeline pipeline, string model, OpenAIClie
_endpoint = OpenAIClient.GetEndpoint(options);
}

[Experimental("SCME0002")]
public AudioClient(AudioClientSettings settings)
: this(settings.Model,
AuthenticationPolicy.Create(settings),
settings.Options)
{
}

/// <summary>
/// Gets the name of the model used in requests sent to the service.
/// </summary>
Expand Down
24 changes: 24 additions & 0 deletions src/Custom/Audio/AudioClientSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.Extensions.Configuration;
using System.ClientModel.Primitives;
using System.Diagnostics.CodeAnalysis;

namespace OpenAI.Audio;

[Experimental("SCME0002")]
public sealed class AudioClientSettings : ClientSettings
{
public string Model { get; set; }

public OpenAIClientOptions Options { get; set; }

protected override void BindCore(IConfigurationSection section)
{
Model = section["Model"];

var optionsSection = section.GetSection("Options");
if (optionsSection.Exists())
{
Options ??= new OpenAIClientOptions(optionsSection);
}
}
}
7 changes: 7 additions & 0 deletions src/Custom/Batch/BatchClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ protected internal BatchClient(ClientPipeline pipeline, OpenAIClientOptions opti
_endpoint = OpenAIClient.GetEndpoint(options);
}

[Experimental("SCME0002")]
public BatchClient(BatchClientSettings settings)
: this(AuthenticationPolicy.Create(settings),
settings.Options)
{
}

/// <summary>
/// Gets the endpoint URI for the service.
/// </summary>
Expand Down
20 changes: 20 additions & 0 deletions src/Custom/Batch/BatchClientSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Microsoft.Extensions.Configuration;
using System.ClientModel.Primitives;
using System.Diagnostics.CodeAnalysis;

namespace OpenAI.Batch;

[Experimental("SCME0002")]
public sealed class BatchClientSettings : ClientSettings
{
public OpenAIClientOptions Options { get; set; }

protected override void BindCore(IConfigurationSection section)
{
var optionsSection = section.GetSection("Options");
if (optionsSection.Exists())
{
Options ??= new OpenAIClientOptions(optionsSection);
}
}
}
8 changes: 8 additions & 0 deletions src/Custom/Chat/ChatClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ protected internal ChatClient(ClientPipeline pipeline, string model, OpenAIClien
_telemetry = new OpenTelemetrySource(model, _endpoint);
}

[Experimental("SCME0002")]
public ChatClient(ChatClientSettings settings)
: this(settings.Model,
AuthenticationPolicy.Create(settings),
settings.Options)
{
}

/// <summary>
/// Gets the name of the model used in requests sent to the service.
/// </summary>
Expand Down
24 changes: 24 additions & 0 deletions src/Custom/Chat/ChatClientSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.Extensions.Configuration;
using System.ClientModel.Primitives;
using System.Diagnostics.CodeAnalysis;

namespace OpenAI.Chat;

[Experimental("SCME0002")]
public sealed class ChatClientSettings : ClientSettings
{
public string Model { get; set; }

public OpenAIClientOptions Options { get; set; }

protected override void BindCore(IConfigurationSection section)
{
Model = section["Model"];

var optionsSection = section.GetSection("Options");
if (optionsSection.Exists())
{
Options ??= new OpenAIClientOptions(optionsSection);
}
}
}
7 changes: 7 additions & 0 deletions src/Custom/Containers/ContainerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ protected internal ContainerClient(ClientPipeline pipeline, OpenAIClientOptions
_endpoint = OpenAIClient.GetEndpoint(options);
}

[Experimental("SCME0002")]
public ContainerClient(ContainerClientSettings settings)
: this(AuthenticationPolicy.Create(settings),
settings.Options)
{
}

/// <summary>
/// Gets the endpoint URI for the service.
/// </summary>
Expand Down
20 changes: 20 additions & 0 deletions src/Custom/Containers/ContainerClientSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Microsoft.Extensions.Configuration;
using System.ClientModel.Primitives;
using System.Diagnostics.CodeAnalysis;

namespace OpenAI.Containers;

[Experimental("SCME0002")]
public sealed class ContainerClientSettings : ClientSettings
{
public OpenAIClientOptions Options { get; set; }

protected override void BindCore(IConfigurationSection section)
{
var optionsSection = section.GetSection("Options");
if (optionsSection.Exists())
{
Options ??= new OpenAIClientOptions(optionsSection);
}
}
}
7 changes: 7 additions & 0 deletions src/Custom/Conversations/ConversationClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ protected internal ConversationClient(ClientPipeline pipeline, OpenAIClientOptio
_endpoint = OpenAIClient.GetEndpoint(options);
}

[Experimental("SCME0002")]
public ConversationClient(ConversationClientSettings settings)
: this(AuthenticationPolicy.Create(settings),
settings.Options)
{
}

/// <summary>
/// Gets the endpoint URI for the service.
/// </summary>
Expand Down
20 changes: 20 additions & 0 deletions src/Custom/Conversations/ConversationClientSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Microsoft.Extensions.Configuration;
using System.ClientModel.Primitives;
using System.Diagnostics.CodeAnalysis;

namespace OpenAI.Conversations;

[Experimental("SCME0002")]
public sealed class ConversationClientSettings : ClientSettings
{
public OpenAIClientOptions Options { get; set; }

protected override void BindCore(IConfigurationSection section)
{
var optionsSection = section.GetSection("Options");
if (optionsSection.Exists())
{
Options ??= new OpenAIClientOptions(optionsSection);
}
}
}
Loading
Loading