AspireOpenAIExtensions Methods
Class Methods 2 members
Provides extension methods for registering
OpenAIClient as a singleton in the services provided by the Hosting.IHostApplicationBuilder. AddKeyedOpenAIClient(IHostApplicationBuilder, string, Action<OpenAISettings>, Action<OpenAIClientOptions>) Section titled AddKeyedOpenAIClient(IHostApplicationBuilder, string, Action<OpenAISettings>, Action<OpenAIClientOptions>) extension AspireOpenAIClientBuilder Registers
OpenAIClient as a singleton for given name in the services provided by the builder. public static class AspireOpenAIExtensions{ public static AspireOpenAIClientBuilder AddKeyedOpenAIClient( this IHostApplicationBuilder builder, string name, Action<OpenAISettings>? configureSettings = null, Action<OpenAIClientOptions>? configureOptions = null) { // ... }}Parameters
builder IHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to. name string The name of the component, which is used as the ServiceDescriptor.ServiceKey of the service and also to retrieve the connection string from the ConnectionStrings configuration section. configureSettings Action<OpenAISettings> optional An optional method that can be used for customizing the OpenAISettings. It's invoked after the settings are read from the configuration. configureOptions Action<OpenAIClientOptions> optional An optional method that can be used for customizing the OpenAIClientOptions. Returns
AspireOpenAIClientBuilder An AspireOpenAIClientBuilder that can be used to register additional services. Remarks
Reads the configuration from "Aspire.OpenAI:{name}" section.
AddOpenAIClient(IHostApplicationBuilder, string, Action<OpenAISettings>, Action<OpenAIClientOptions>) Section titled AddOpenAIClient(IHostApplicationBuilder, string, Action<OpenAISettings>, Action<OpenAIClientOptions>) extension AspireOpenAIClientBuilder Registers
OpenAIClient as a singleton in the services provided by the builder. public static class AspireOpenAIExtensions{ public static AspireOpenAIClientBuilder AddOpenAIClient( this IHostApplicationBuilder builder, string connectionName, Action<OpenAISettings>? configureSettings = null, Action<OpenAIClientOptions>? configureOptions = null) { // ... }}Parameters
builder IHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to. connectionName string A name used to retrieve the connection string from the ConnectionStrings configuration section. configureSettings Action<OpenAISettings> optional An optional method that can be used for customizing the OpenAISettings. It's invoked after the settings are read from the configuration. configureOptions Action<OpenAIClientOptions> optional An optional method that can be used for customizing the OpenAIClientOptions. Returns
AspireOpenAIClientBuilder An AspireOpenAIClientBuilder that can be used to register additional services. Remarks
Reads the configuration from "Aspire.OpenAI" section.