AspireOpenAIExtensions Methods
ClassMethods2 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>)extensionAspire 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
builderIHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to.namestringThe 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> optionalAn optional method that can be used for customizing the OpenAISettings . It's invoked after the settings are read from the configuration.configureOptions Action<OpenAIClientOptions> optionalAn 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>)extensionAspire 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
builderIHostApplicationBuilder The Hosting.IHostApplicationBuilder to read config from and add services to.connectionName stringA name used to retrieve the connection string from the ConnectionStrings configuration section.configureSettings Action<OpenAISettings> optionalAn optional method that can be used for customizing the OpenAISettings . It's invoked after the settings are read from the configuration.configureOptions Action<OpenAIClientOptions> optionalAn 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.