Class AIServiceCollection
- java.lang.Object
-
- com.microsoft.semantickernel.services.AIServiceCollection
-
public class AIServiceCollection extends Object
A collection that can hold AI services
-
-
Constructor Summary
Constructors Constructor Description AIServiceCollection()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AIServiceProviderbuild()Builds an AIServiceProvider from the registered services and default names.<T extends AIService>
voidsetService(String name, Supplier<T> factory, boolean setAsDefault, Class<T> serviceType)Registers a transient service factory with an optional name and default flag.<T extends AIService>
voidsetService(String name, T service, boolean setAsDefault, Class<T> serviceType)Registers a singleton service instance with an optional name and default flag.<T extends AIService>
voidsetService(Supplier<T> factory, Class<T> serviceType)Registers a transient service factory with the default name.<T extends AIService>
voidsetService(T service, Class<T> serviceType)Registers a singleton service instance with the default name.
-
-
-
Method Detail
-
setService
public <T extends AIService> void setService(T service, Class<T> serviceType)
Registers a singleton service instance with the default name.- Parameters:
service- The service instance.serviceType- The type of the service.
-
setService
public <T extends AIService> void setService(String name, T service, boolean setAsDefault, Class<T> serviceType)
Registers a singleton service instance with an optional name and default flag.- Parameters:
name- The name of the service, or null for the default service.service- The service instance.setAsDefault- Whether the service should be the default for its type.serviceType- The type of the service.
-
setService
public <T extends AIService> void setService(Supplier<T> factory, Class<T> serviceType)
Registers a transient service factory with the default name.- Parameters:
factory- The factory function to create the service instance.serviceType- The type of the service.
-
setService
public <T extends AIService> void setService(@Nullable String name, Supplier<T> factory, boolean setAsDefault, Class<T> serviceType)
Registers a transient service factory with an optional name and default flag.- Parameters:
name- The name of the service, or null for the default service.factory- The factory function to create the service instance.setAsDefault- Whether the service should be the default for its type.serviceType- The type of the service.
-
build
public AIServiceProvider build()
Builds an AIServiceProvider from the registered services and default names.- Returns:
- The AIServiceProvider.
-
-