Class GenerativeAiInferenceAsyncClient
- java.lang.Object
-
- com.oracle.bmc.http.internal.BaseAsyncClient
-
- com.oracle.bmc.generativeaiinference.GenerativeAiInferenceAsyncClient
-
- All Implemented Interfaces:
GenerativeAiInferenceAsync
,AutoCloseable
@Generated(value="OracleSDKGenerator", comments="API Version: 20231130") public class GenerativeAiInferenceAsyncClient extends BaseAsyncClient implements GenerativeAiInferenceAsync
Async client implementation for GenerativeAiInference service.
There are two ways to use async client: 1. Use AsyncHandler: using AsyncHandler, if the response to the call is anInputStream
, like getObject Api in object storage service, developers need to process the stream in AsyncHandler, and not anywhere else, because the stream will be closed right after the AsyncHandler is invoked.
2. Use Java Future: using Java Future, developers need to close the stream after they are done with the Java Future.
Accessing the result should be done in a mutually exclusive manner, either through the Future or the AsyncHandler, but not both. If the Future is used, the caller should pass in null as the AsyncHandler. If the AsyncHandler is used, it is still safe to use the Future to determine whether or not the request was completed via Future.isDone/isCancelled.
Please refer to https://github.com/oracle/oci-java-sdk/blob/master/bmc-examples/src/main/java/ResteasyClientWithObjectStorageExample.java
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GenerativeAiInferenceAsyncClient.Builder
Builder class for this client.
-
Field Summary
Fields Modifier and Type Field Description String
clientCommonLibraryVersion
Compatible SDK version, provided by the codegen.Optional<String>
minimumClientCommonLibraryVersionFromClient
Minimum compatible SDK version, maybe provided by the codegen.static Service
SERVICE
Service instance for GenerativeAiInference.
-
Constructor Summary
Constructors Constructor Description GenerativeAiInferenceAsyncClient(AbstractAuthenticationDetailsProvider authenticationDetailsProvider, ClientConfiguration configuration, ClientConfigurator clientConfigurator, RequestSignerFactory defaultRequestSignerFactory)
Deprecated.Use thebuilder
instead.GenerativeAiInferenceAsyncClient(AbstractAuthenticationDetailsProvider authenticationDetailsProvider, ClientConfiguration configuration, ClientConfigurator clientConfigurator, RequestSignerFactory defaultRequestSignerFactory, List<ClientConfigurator> additionalClientConfigurators)
Deprecated.Use thebuilder
instead.GenerativeAiInferenceAsyncClient(AbstractAuthenticationDetailsProvider authenticationDetailsProvider, ClientConfiguration configuration, ClientConfigurator clientConfigurator, RequestSignerFactory defaultRequestSignerFactory, List<ClientConfigurator> additionalClientConfigurators, String endpoint)
Deprecated.Use thebuilder
instead.GenerativeAiInferenceAsyncClient(AbstractAuthenticationDetailsProvider authenticationDetailsProvider, ClientConfiguration configuration, ClientConfigurator clientConfigurator, RequestSignerFactory defaultRequestSignerFactory, Map<SigningStrategy,RequestSignerFactory> signingStrategyRequestSignerFactories, List<ClientConfigurator> additionalClientConfigurators, String endpoint)
Deprecated.Use thebuilder
instead.GenerativeAiInferenceAsyncClient(BasicAuthenticationDetailsProvider authenticationDetailsProvider)
Deprecated.Use thebuilder
instead.GenerativeAiInferenceAsyncClient(BasicAuthenticationDetailsProvider authenticationDetailsProvider, ClientConfiguration configuration)
Deprecated.Use thebuilder
instead.GenerativeAiInferenceAsyncClient(BasicAuthenticationDetailsProvider authenticationDetailsProvider, ClientConfiguration configuration, ClientConfigurator clientConfigurator)
Deprecated.Use thebuilder
instead.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static GenerativeAiInferenceAsyncClient.Builder
builder()
Create a builder for this client.Future<ChatResponse>
chat(ChatRequest request, AsyncHandler<ChatRequest,ChatResponse> handler)
Creates a response for the given conversation.protected <REQ extends BmcRequest<?>,RESP extends BmcResponse,RESP_BUILDER extends BmcResponse.Builder<RESP>>
ClientCall<REQ,RESP,RESP_BUILDER>clientCall(REQ request, Supplier<RESP_BUILDER> responseBuilder)
void
close()
Future<EmbedTextResponse>
embedText(EmbedTextRequest request, AsyncHandler<EmbedTextRequest,EmbedTextResponse> handler)
Produces embeddings for the inputs.Future<GenerateTextResponse>
generateText(GenerateTextRequest request, AsyncHandler<GenerateTextRequest,GenerateTextResponse> handler)
Generates a text response based on the user prompt.String
getClientCommonLibraryVersion()
protected ClientConfigurator
getDefaultConfigurator()
String
getEndpoint()
Optional<String>
getMinimumClientCommonLibraryVersionFromClient()
void
populateServiceParametersInEndpoint(String endpoint, Map<String,Object> requiredParametersMap)
Populate the parameters in the endpoint with its corresponding value and update the base endpoint.void
refreshClient()
Rebuild the backingHttpClient
.Future<RerankTextResponse>
rerankText(RerankTextRequest request, AsyncHandler<RerankTextRequest,RerankTextResponse> handler)
Reranks the text responses based on the input documents and a prompt.void
setEndpoint(String endpoint)
void
setRegion(Region region)
Sets the region to call (ex, Region.US_PHOENIX_1).void
setRegion(String regionId)
Sets the region to call (ex, ‘us-phoenix-1’).Future<SummarizeTextResponse>
summarizeText(SummarizeTextRequest request, AsyncHandler<SummarizeTextRequest,SummarizeTextResponse> handler)
Summarizes the input text.void
updateBaseEndpoint(String endpoint)
This method should be used for parameterized endpoint templates only.void
useRealmSpecificEndpointTemplate(boolean useOfRealmSpecificEndpointTemplateEnabled)
This method should be used to enable or disable the use of realm-specific endpoint template.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.AutoCloseable
close
-
Methods inherited from interface com.oracle.bmc.generativeaiinference.GenerativeAiInferenceAsync
getEndpoint, refreshClient, setEndpoint, useRealmSpecificEndpointTemplate
-
-
-
-
Constructor Detail
-
GenerativeAiInferenceAsyncClient
@Deprecated public GenerativeAiInferenceAsyncClient(BasicAuthenticationDetailsProvider authenticationDetailsProvider)
Deprecated.Use thebuilder
instead.Create a new client instance.- Parameters:
authenticationDetailsProvider
- The authentication details (seeGenerativeAiInferenceAsyncClient.Builder.build(com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider)
)
-
GenerativeAiInferenceAsyncClient
@Deprecated public GenerativeAiInferenceAsyncClient(BasicAuthenticationDetailsProvider authenticationDetailsProvider, ClientConfiguration configuration)
Deprecated.Use thebuilder
instead.Create a new client instance.- Parameters:
authenticationDetailsProvider
- The authentication details (seeGenerativeAiInferenceAsyncClient.Builder.build(com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider)
)configuration
-ClientBuilderBase.configuration
-
GenerativeAiInferenceAsyncClient
@Deprecated public GenerativeAiInferenceAsyncClient(BasicAuthenticationDetailsProvider authenticationDetailsProvider, ClientConfiguration configuration, ClientConfigurator clientConfigurator)
Deprecated.Use thebuilder
instead.Create a new client instance.- Parameters:
authenticationDetailsProvider
- The authentication details (seeGenerativeAiInferenceAsyncClient.Builder.build(com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider)
)configuration
-ClientBuilderBase.configuration
clientConfigurator
-ClientBuilderBase.clientConfigurator(com.oracle.bmc.http.ClientConfigurator)
-
GenerativeAiInferenceAsyncClient
@Deprecated public GenerativeAiInferenceAsyncClient(AbstractAuthenticationDetailsProvider authenticationDetailsProvider, ClientConfiguration configuration, ClientConfigurator clientConfigurator, RequestSignerFactory defaultRequestSignerFactory)
Deprecated.Use thebuilder
instead.Create a new client instance.- Parameters:
authenticationDetailsProvider
- The authentication details (seeGenerativeAiInferenceAsyncClient.Builder.build(com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider)
)configuration
-ClientBuilderBase.configuration
clientConfigurator
-ClientBuilderBase.clientConfigurator(com.oracle.bmc.http.ClientConfigurator)
defaultRequestSignerFactory
-ClientBuilderBase.requestSignerFactory
-
GenerativeAiInferenceAsyncClient
@Deprecated public GenerativeAiInferenceAsyncClient(AbstractAuthenticationDetailsProvider authenticationDetailsProvider, ClientConfiguration configuration, ClientConfigurator clientConfigurator, RequestSignerFactory defaultRequestSignerFactory, List<ClientConfigurator> additionalClientConfigurators)
Deprecated.Use thebuilder
instead.Create a new client instance.- Parameters:
authenticationDetailsProvider
- The authentication details (seeGenerativeAiInferenceAsyncClient.Builder.build(com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider)
)configuration
-ClientBuilderBase.configuration
clientConfigurator
-ClientBuilderBase.clientConfigurator(com.oracle.bmc.http.ClientConfigurator)
defaultRequestSignerFactory
-ClientBuilderBase.requestSignerFactory
additionalClientConfigurators
-ClientBuilderBase.additionalClientConfigurators
-
GenerativeAiInferenceAsyncClient
@Deprecated public GenerativeAiInferenceAsyncClient(AbstractAuthenticationDetailsProvider authenticationDetailsProvider, ClientConfiguration configuration, ClientConfigurator clientConfigurator, RequestSignerFactory defaultRequestSignerFactory, List<ClientConfigurator> additionalClientConfigurators, String endpoint)
Deprecated.Use thebuilder
instead.Create a new client instance.- Parameters:
authenticationDetailsProvider
- The authentication details (seeGenerativeAiInferenceAsyncClient.Builder.build(com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider)
)configuration
-ClientBuilderBase.configuration
clientConfigurator
-ClientBuilderBase.clientConfigurator(com.oracle.bmc.http.ClientConfigurator)
defaultRequestSignerFactory
-ClientBuilderBase.requestSignerFactory
additionalClientConfigurators
-ClientBuilderBase.additionalClientConfigurators
endpoint
-ClientBuilderBase.endpoint(java.lang.String)
-
GenerativeAiInferenceAsyncClient
@Deprecated public GenerativeAiInferenceAsyncClient(AbstractAuthenticationDetailsProvider authenticationDetailsProvider, ClientConfiguration configuration, ClientConfigurator clientConfigurator, RequestSignerFactory defaultRequestSignerFactory, Map<SigningStrategy,RequestSignerFactory> signingStrategyRequestSignerFactories, List<ClientConfigurator> additionalClientConfigurators, String endpoint)
Deprecated.Use thebuilder
instead.Create a new client instance.- Parameters:
authenticationDetailsProvider
- The authentication details (seeGenerativeAiInferenceAsyncClient.Builder.build(com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider)
)configuration
-ClientBuilderBase.configuration
clientConfigurator
-ClientBuilderBase.clientConfigurator(com.oracle.bmc.http.ClientConfigurator)
defaultRequestSignerFactory
-ClientBuilderBase.requestSignerFactory
additionalClientConfigurators
-ClientBuilderBase.additionalClientConfigurators
endpoint
-ClientBuilderBase.endpoint(java.lang.String)
signingStrategyRequestSignerFactories
-ClientBuilderBase.signingStrategyRequestSignerFactories
-
-
Method Detail
-
builder
public static GenerativeAiInferenceAsyncClient.Builder builder()
Create a builder for this client.- Returns:
- builder
-
setRegion
public void setRegion(Region region)
Description copied from interface:GenerativeAiInferenceAsync
Sets the region to call (ex, Region.US_PHOENIX_1).Note, this will call
setEndpoint
after resolving the endpoint. If the service is not available in this region, however, an IllegalArgumentException will be raised.- Specified by:
setRegion
in interfaceGenerativeAiInferenceAsync
- Parameters:
region
- The region of the service.
-
setRegion
public void setRegion(String regionId)
Description copied from interface:GenerativeAiInferenceAsync
Sets the region to call (ex, ‘us-phoenix-1’).Note, this will first try to map the region ID to a known Region and call
setRegion
.If no known Region could be determined, it will create an endpoint based on the default endpoint format (
Region.formatDefaultRegionEndpoint(Service, String)
and then callsetEndpoint
.- Specified by:
setRegion
in interfaceGenerativeAiInferenceAsync
- Parameters:
regionId
- The public region ID.
-
chat
public Future<ChatResponse> chat(ChatRequest request, AsyncHandler<ChatRequest,ChatResponse> handler)
Description copied from interface:GenerativeAiInferenceAsync
Creates a response for the given conversation.- Specified by:
chat
in interfaceGenerativeAiInferenceAsync
- Parameters:
request
- The request object containing the details to sendhandler
- The request handler to invoke upon completion, may be null.- Returns:
- A Future that can be used to get the response if no AsyncHandler was provided. Note, if you provide an AsyncHandler and use the Future, some types of responses (like java.io.InputStream) may not be able to be read in both places as the underlying stream may only be consumed once.
-
embedText
public Future<EmbedTextResponse> embedText(EmbedTextRequest request, AsyncHandler<EmbedTextRequest,EmbedTextResponse> handler)
Description copied from interface:GenerativeAiInferenceAsync
Produces embeddings for the inputs.An embedding is numeric representation of a piece of text. This text can be a phrase, a sentence, or one or more paragraphs. The Generative AI embedding model transforms each phrase, sentence, or paragraph that you input, into an array with 1024 numbers. You can use these embeddings for finding similarity in your input text such as finding phrases that are similar in context or category. Embeddings are mostly used for semantic searches where the search function focuses on the meaning of the text that it's searching through rather than finding results based on keywords.
- Specified by:
embedText
in interfaceGenerativeAiInferenceAsync
- Parameters:
request
- The request object containing the details to sendhandler
- The request handler to invoke upon completion, may be null.- Returns:
- A Future that can be used to get the response if no AsyncHandler was provided. Note, if you provide an AsyncHandler and use the Future, some types of responses (like java.io.InputStream) may not be able to be read in both places as the underlying stream may only be consumed once.
-
generateText
public Future<GenerateTextResponse> generateText(GenerateTextRequest request, AsyncHandler<GenerateTextRequest,GenerateTextResponse> handler)
Description copied from interface:GenerativeAiInferenceAsync
Generates a text response based on the user prompt.- Specified by:
generateText
in interfaceGenerativeAiInferenceAsync
- Parameters:
request
- The request object containing the details to sendhandler
- The request handler to invoke upon completion, may be null.- Returns:
- A Future that can be used to get the response if no AsyncHandler was provided. Note, if you provide an AsyncHandler and use the Future, some types of responses (like java.io.InputStream) may not be able to be read in both places as the underlying stream may only be consumed once.
-
rerankText
public Future<RerankTextResponse> rerankText(RerankTextRequest request, AsyncHandler<RerankTextRequest,RerankTextResponse> handler)
Description copied from interface:GenerativeAiInferenceAsync
Reranks the text responses based on the input documents and a prompt.Rerank assigns an index and a relevance score to each document, indicating which document is most related to the prompt.
- Specified by:
rerankText
in interfaceGenerativeAiInferenceAsync
- Parameters:
request
- The request object containing the details to sendhandler
- The request handler to invoke upon completion, may be null.- Returns:
- A Future that can be used to get the response if no AsyncHandler was provided. Note, if you provide an AsyncHandler and use the Future, some types of responses (like java.io.InputStream) may not be able to be read in both places as the underlying stream may only be consumed once.
-
summarizeText
public Future<SummarizeTextResponse> summarizeText(SummarizeTextRequest request, AsyncHandler<SummarizeTextRequest,SummarizeTextResponse> handler)
Description copied from interface:GenerativeAiInferenceAsync
Summarizes the input text.- Specified by:
summarizeText
in interfaceGenerativeAiInferenceAsync
- Parameters:
request
- The request object containing the details to sendhandler
- The request handler to invoke upon completion, may be null.- Returns:
- A Future that can be used to get the response if no AsyncHandler was provided. Note, if you provide an AsyncHandler and use the Future, some types of responses (like java.io.InputStream) may not be able to be read in both places as the underlying stream may only be consumed once.
-
getDefaultConfigurator
protected ClientConfigurator getDefaultConfigurator()
-
useRealmSpecificEndpointTemplate
public void useRealmSpecificEndpointTemplate(boolean useOfRealmSpecificEndpointTemplateEnabled)
This method should be used to enable or disable the use of realm-specific endpoint template.The default value is null. To enable the use of endpoint template defined for the realm in use, set the flag to true To disable the use of endpoint template defined for the realm in use, set the flag to false
- Parameters:
useOfRealmSpecificEndpointTemplateEnabled
- This flag can be set to true or false to enable or disable the use of realm-specific endpoint template respectively
-
populateServiceParametersInEndpoint
public final void populateServiceParametersInEndpoint(String endpoint, Map<String,Object> requiredParametersMap)
Populate the parameters in the endpoint with its corresponding value and update the base endpoint.The value will be populated iff the parameter in endpoint is a required request path parameter or a required request query parameter. If not, the parameter in the endpoint will be ignored and left blank.
- Parameters:
endpoint
- The endpoint template in userequiredParametersMap
- Map of parameter name as key and value set in request path or query parameter as value
-
updateBaseEndpoint
public final void updateBaseEndpoint(String endpoint)
This method should be used for parameterized endpoint templates only.This does not include {region} and {secondLevelDomain} parameters.
- Parameters:
endpoint
- The updated endpoint to use
-
setEndpoint
public final void setEndpoint(String endpoint)
-
getEndpoint
public final String getEndpoint()
-
refreshClient
public final void refreshClient()
Rebuild the backingHttpClient
.This will call
ClientConfigurator
s again, and can be used to e.g. refresh the SSL certificate.
-
close
public final void close()
- Specified by:
close
in interfaceAutoCloseable
-
getClientCommonLibraryVersion
public String getClientCommonLibraryVersion()
-
getMinimumClientCommonLibraryVersionFromClient
public Optional<String> getMinimumClientCommonLibraryVersionFromClient()
-
clientCall
protected <REQ extends BmcRequest<?>,RESP extends BmcResponse,RESP_BUILDER extends BmcResponse.Builder<RESP>> ClientCall<REQ,RESP,RESP_BUILDER> clientCall(REQ request, Supplier<RESP_BUILDER> responseBuilder)
-
-