Class ServiceCollectionExtension
- Namespace
- GenerativeAI.Web
- Assembly
- GenerativeAI.Web.dll
Extension methods for configuring GenerativeAI services in dependency injection.
public static class ServiceCollectionExtension
- Inheritance
-
ServiceCollectionExtension
- Inherited Members
Methods
AddGenerativeAI(IServiceCollection)
Adds the Google Generative AI features to the IServiceCollection.
public static IServiceCollection AddGenerativeAI(this IServiceCollection services)
Parameters
servicesIServiceCollectionThe IServiceCollection to add the services to.
Returns
- IServiceCollection
The updated IServiceCollection for chaining additional calls.
AddGenerativeAI(IServiceCollection, GenerativeAIOptions)
Adds the Google Generative AI features to the IServiceCollection using the specified options.
public static IServiceCollection AddGenerativeAI(this IServiceCollection services, GenerativeAIOptions options)
Parameters
servicesIServiceCollectionThe IServiceCollection to add the services to.
optionsGenerativeAIOptionsThe configuration options for the Google Generative AI services.
Returns
- IServiceCollection
The updated IServiceCollection for chaining additional calls.
AddGenerativeAI(IServiceCollection, IConfiguration)
Adds Google Generative AI features to the IServiceCollection.
public static IServiceCollection AddGenerativeAI(this IServiceCollection services, IConfiguration namedConfigurationSection)
Parameters
servicesIServiceCollectionThe IServiceCollection to add services to.
namedConfigurationSectionIConfigurationThe IConfiguration section with service options.
Returns
- IServiceCollection
The IServiceCollection so that additional calls can be chained.
AddGenerativeAI(IServiceCollection, Action<GenerativeAIOptions>)
Adds the Google Generative AI features to the IServiceCollection with optional configuration.
public static IServiceCollection AddGenerativeAI(this IServiceCollection services, Action<GenerativeAIOptions> setupAction)
Parameters
servicesIServiceCollectionThe IServiceCollection to add the services to.
setupActionAction<GenerativeAIOptions>An optional action to configure the GenerativeAIOptions.
Returns
- IServiceCollection
The updated IServiceCollection for chaining additional calls.
AddGenerativeAI(IServiceCollection, string)
Adds the Google Generative AI features to the IServiceCollection.
public static IServiceCollection AddGenerativeAI(this IServiceCollection services, string configSectionPath)
Parameters
servicesIServiceCollectionThe IServiceCollection to add the services to.
configSectionPathstringThe configuration section path containing Generative AI options.
Returns
- IServiceCollection
The updated IServiceCollection for chaining additional calls.
ConfigureGenerativeAI(IServiceCollection, Action<GenerativeAIOptions>)
Configures GenerativeAI options for the service collection.
public static void ConfigureGenerativeAI(this IServiceCollection services, Action<GenerativeAIOptions> setupAction)
Parameters
servicesIServiceCollectionThe service collection to configure.
setupActionAction<GenerativeAIOptions>The action to configure GenerativeAI options.
WithAdc(IServiceCollection)
Configures the Google ADC (Application Default Credentials) authentication for Generative AI services.
public static void WithAdc(this IServiceCollection services)
Parameters
servicesIServiceCollectionThe IServiceCollection to configure the authentication for.
WithOAuth(IServiceCollection, string)
Configures the IServiceCollection to use Google OAuth authentication for Generative AI services.
public static void WithOAuth(this IServiceCollection services, string clientSecretFilePath)
Parameters
servicesIServiceCollectionThe IServiceCollection to configure.
clientSecretFilePathstringThe file path to the client secret JSON file used for Google OAuth authentication.
WithServiceAccount(IServiceCollection, string)
Configures Google Service Account authentication for Generative AI features in the IServiceCollection.
public static void WithServiceAccount(this IServiceCollection services, string jsonFilePath)
Parameters
servicesIServiceCollectionThe IServiceCollection to add the authentication configuration to.
jsonFilePathstringThe file path to the JSON credential file for Google Service Account authentication.
WithServiceAccount(IServiceCollection, string, string, string)
Configures Google Service Account authentication for the Generative AI services.
public static void WithServiceAccount(this IServiceCollection services, string serviceAccountEmail, string certificateFilePath, string passPhrase)
Parameters
servicesIServiceCollectionThe IServiceCollection to configure the authentication for.
serviceAccountEmailstringThe email address associated with the Google Service Account.
certificateFilePathstringThe file path to the service account's certificate.
passPhrasestringThe passphrase for the certificate file.