Class OpenAIClientProvider
- java.lang.Object
-
- com.microsoft.semantickernel.connectors.ai.openai.util.OpenAIClientProvider
-
public class OpenAIClientProvider extends Object
Builds an OpenAI client instance, seeSettingsMapdocumentation for details on how the settings are loaded.If clientType is not set via OPENAI_CLIENT_TYPE setting, then this will attempt to first instantiate an OpenAI client, and if that fails, then it will attempt to instantiate an Azure OpenAI client.
-
-
Field Summary
Fields Modifier and Type Field Description static StringOPENAI_CLIENT_TYPE
-
Constructor Summary
Constructors Constructor Description OpenAIClientProvider(Map<String,String> configuredSettings, ClientType clientType)Create a new OpenAI client provider
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static com.azure.ai.openai.OpenAIAsyncClientget(List<File> propertyFileLocations)Get a client, overrides the default locations that are searched for settingsstatic com.azure.ai.openai.OpenAIAsyncClientget(List<File> propertyFileLocations, ClientType clientType)Get a client, overrides the default locations that are searched for settingscom.azure.ai.openai.OpenAIAsyncClientgetAsyncClient()Builds an OpenAI client instance, the settings for the client are loaded from the following sources in the order of precedence (lower number in this list overrides a higher number): 1.static com.azure.ai.openai.OpenAIAsyncClientgetClient()Builds an OpenAI client instance, seeSettingsMapdocumentation for details on how the settings are loaded.static com.azure.ai.openai.OpenAIAsyncClientgetWithAdditional(List<File> propertyFileLocations)Get a client, looks for settings in the default locations as defined by this class, PLUS the additional locations providedstatic com.azure.ai.openai.OpenAIAsyncClientgetWithAdditional(List<File> propertyFileLocations, ClientType clientType)Get a client, looks for settings in the default locations as defined by this class, PLUS the additional locations provided
-
-
-
Field Detail
-
OPENAI_CLIENT_TYPE
public static final String OPENAI_CLIENT_TYPE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OpenAIClientProvider
public OpenAIClientProvider(Map<String,String> configuredSettings, @Nullable ClientType clientType)
Create a new OpenAI client provider- Parameters:
configuredSettings- settings to use to configure the clientclientType- client type
-
-
Method Detail
-
get
public static com.azure.ai.openai.OpenAIAsyncClient get(List<File> propertyFileLocations, @Nullable ClientType clientType) throws ConfigurationException
Get a client, overrides the default locations that are searched for settings- Parameters:
propertyFileLocations- locations to look for settings inclientType- client type- Returns:
- A client instance
- Throws:
ConfigurationException- if the settings are not found
-
get
public static com.azure.ai.openai.OpenAIAsyncClient get(List<File> propertyFileLocations) throws ConfigurationException
Get a client, overrides the default locations that are searched for settings- Parameters:
propertyFileLocations- locations to look for settings in- Returns:
- A client instance
- Throws:
ConfigurationException- if the settings are not found
-
getWithAdditional
public static com.azure.ai.openai.OpenAIAsyncClient getWithAdditional(List<File> propertyFileLocations, @Nullable ClientType clientType) throws ConfigurationException
Get a client, looks for settings in the default locations as defined by this class, PLUS the additional locations provided- Parameters:
propertyFileLocations- additional locations to look for settingsclientType- client type- Returns:
- A client instance
- Throws:
ConfigurationException
-
getWithAdditional
public static com.azure.ai.openai.OpenAIAsyncClient getWithAdditional(List<File> propertyFileLocations) throws ConfigurationException
Get a client, looks for settings in the default locations as defined by this class, PLUS the additional locations provided- Parameters:
propertyFileLocations- additional locations to look for settings- Returns:
- A client instance
- Throws:
ConfigurationException
-
getClient
public static com.azure.ai.openai.OpenAIAsyncClient getClient() throws ConfigurationExceptionBuilds an OpenAI client instance, seeSettingsMapdocumentation for details on how the settings are loaded.- Returns:
- A client instance
- Throws:
ConfigurationException- If the settings are not found
-
getAsyncClient
public com.azure.ai.openai.OpenAIAsyncClient getAsyncClient() throws ConfigurationExceptionBuilds an OpenAI client instance, the settings for the client are loaded from the following sources in the order of precedence (lower number in this list overrides a higher number):- 1. Environment variables.
- 2. System properties.
- 3. Properties file set via CONF_PROPERTIES environment variable.
- 4. Properties file: ./conf.properties (Not used if CONF_PROPERTIES was set).
- 5. Properties file: ~/.sk/conf.properties (Not used if CONF_PROPERTIES was set).
If clientType is not set via OPENAI_CLIENT_TYPE setting, then this will attempt to first instantiate an OpenAI client, and if that fails, then it will attempt to instantiate an Azure OpenAI client.
- Returns:
- A client instance
- Throws:
ConfigurationException- If the settings are not found
-
-