Interface BedrockAgentRuntimeAsyncClient
- All Superinterfaces:
AutoCloseable
,AwsClient
,SdkAutoCloseable
,SdkClient
builder()
method.The asynchronous client performs non-blocking I/O when configured with any
SdkAsyncHttpClient
supported in the SDK. However, full non-blocking is not guaranteed as the async client may
perform blocking calls in some cases such as credentials retrieval and endpoint discovery as part of the async API
call.
Contains APIs related to model invocation and querying of knowledge bases.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Value for looking up the service's metadata from theServiceMetadataProvider
.static final String
-
Method Summary
Modifier and TypeMethodDescriptionbuilder()
Create a builder that can be used to configure and create aBedrockAgentRuntimeAsyncClient
.create()
Create aBedrockAgentRuntimeAsyncClient
with the region loaded from theDefaultAwsRegionProviderChain
and credentials loaded from theDefaultCredentialsProvider
.default CompletableFuture
<Void> invokeAgent
(Consumer<InvokeAgentRequest.Builder> invokeAgentRequest, InvokeAgentResponseHandler asyncResponseHandler) default CompletableFuture
<Void> invokeAgent
(InvokeAgentRequest invokeAgentRequest, InvokeAgentResponseHandler asyncResponseHandler) default CompletableFuture
<RetrieveResponse> retrieve
(Consumer<RetrieveRequest.Builder> retrieveRequest) Queries a knowledge base and retrieves information from it.default CompletableFuture
<RetrieveResponse> retrieve
(RetrieveRequest retrieveRequest) Queries a knowledge base and retrieves information from it.retrieveAndGenerate
(Consumer<RetrieveAndGenerateRequest.Builder> retrieveAndGenerateRequest) Queries a knowledge base and generates responses based on the retrieved results.retrieveAndGenerate
(RetrieveAndGenerateRequest retrieveAndGenerateRequest) Queries a knowledge base and generates responses based on the retrieved results.default RetrievePublisher
retrievePaginator
(Consumer<RetrieveRequest.Builder> retrieveRequest) This is a variant ofretrieve(software.amazon.awssdk.services.bedrockagentruntime.model.RetrieveRequest)
operation.default RetrievePublisher
retrievePaginator
(RetrieveRequest retrieveRequest) This is a variant ofretrieve(software.amazon.awssdk.services.bedrockagentruntime.model.RetrieveRequest)
operation.The SDK service client configuration exposes client settings to the user, e.g., ClientOverrideConfigurationMethods inherited from interface software.amazon.awssdk.utils.SdkAutoCloseable
close
Methods inherited from interface software.amazon.awssdk.core.SdkClient
serviceName
-
Field Details
-
SERVICE_NAME
- See Also:
-
SERVICE_METADATA_ID
Value for looking up the service's metadata from theServiceMetadataProvider
.- See Also:
-
-
Method Details
-
invokeAgent
default CompletableFuture<Void> invokeAgent(InvokeAgentRequest invokeAgentRequest, InvokeAgentResponseHandler asyncResponseHandler) The CLI doesn't support
InvokeAgent
.Sends a prompt for the agent to process and respond to. Note the following fields for the request:
-
To continue the same conversation with an agent, use the same
sessionId
value in the request. -
To activate trace enablement, turn
enableTrace
totrue
. Trace enablement helps you follow the agent's reasoning process that led it to the information it processed, the actions it took, and the final result it yielded. For more information, see Trace enablement. -
End a conversation by setting
endSession
totrue
. -
In the
sessionState
object, you can include attributes for the session or prompt or, if you configured an action group to return control, results from invocation of the action group.
The response is returned in the
bytes
field of thechunk
object.-
The
attribution
object contains citations for parts of the response. -
If you set
enableTrace
totrue
in the request, you can trace the agent's steps and reasoning process that led it to the response. -
If the action predicted was configured to return control, the response returns parameters for the action, elicited from the user, in the
returnControl
field. -
Errors are also surfaced in the response.
- Parameters:
invokeAgentRequest
-- Returns:
- A Java Future containing the result of the InvokeAgent operation returned by the service.
The CompletableFuture returned by this method can be completed exceptionally with the following exceptions. The exception returned is wrapped with CompletionException, so you need to invokeThrowable.getCause()
to retrieve the underlying exception.- ConflictException There was a conflict performing an operation. Resolve the conflict and retry your request.
- ResourceNotFoundException The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.
- ValidationException Input validation failed. Check your request parameters and retry the request.
- InternalServerException An internal server error occurred. Retry your request.
- DependencyFailedException There was an issue with a dependency. Check the resource configurations and retry the request.
- BadGatewayException There was an issue with a dependency due to a server issue. Retry your request.
- ThrottlingException The number of requests exceeds the limit. Resubmit your request later.
- AccessDeniedException The request is denied because of missing access permissions. Check your permissions and retry your request.
- ServiceQuotaExceededException The number of requests exceeds the service quota. Resubmit your request later.
- SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for catch all scenarios.
- SdkClientException If any client side error occurs such as an IO related failure, failure to get credentials, etc.
- BedrockAgentRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
- See Also:
-
-
invokeAgent
default CompletableFuture<Void> invokeAgent(Consumer<InvokeAgentRequest.Builder> invokeAgentRequest, InvokeAgentResponseHandler asyncResponseHandler) The CLI doesn't support
InvokeAgent
.Sends a prompt for the agent to process and respond to. Note the following fields for the request:
-
To continue the same conversation with an agent, use the same
sessionId
value in the request. -
To activate trace enablement, turn
enableTrace
totrue
. Trace enablement helps you follow the agent's reasoning process that led it to the information it processed, the actions it took, and the final result it yielded. For more information, see Trace enablement. -
End a conversation by setting
endSession
totrue
. -
In the
sessionState
object, you can include attributes for the session or prompt or, if you configured an action group to return control, results from invocation of the action group.
The response is returned in the
bytes
field of thechunk
object.-
The
attribution
object contains citations for parts of the response. -
If you set
enableTrace
totrue
in the request, you can trace the agent's steps and reasoning process that led it to the response. -
If the action predicted was configured to return control, the response returns parameters for the action, elicited from the user, in the
returnControl
field. -
Errors are also surfaced in the response.
This is a convenience which creates an instance of the
InvokeAgentRequest.Builder
avoiding the need to create one manually viaInvokeAgentRequest.builder()
- Parameters:
invokeAgentRequest
- AConsumer
that will call methods onInvokeAgentRequest.Builder
to create a request.- Returns:
- A Java Future containing the result of the InvokeAgent operation returned by the service.
The CompletableFuture returned by this method can be completed exceptionally with the following exceptions. The exception returned is wrapped with CompletionException, so you need to invokeThrowable.getCause()
to retrieve the underlying exception.- ConflictException There was a conflict performing an operation. Resolve the conflict and retry your request.
- ResourceNotFoundException The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.
- ValidationException Input validation failed. Check your request parameters and retry the request.
- InternalServerException An internal server error occurred. Retry your request.
- DependencyFailedException There was an issue with a dependency. Check the resource configurations and retry the request.
- BadGatewayException There was an issue with a dependency due to a server issue. Retry your request.
- ThrottlingException The number of requests exceeds the limit. Resubmit your request later.
- AccessDeniedException The request is denied because of missing access permissions. Check your permissions and retry your request.
- ServiceQuotaExceededException The number of requests exceeds the service quota. Resubmit your request later.
- SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for catch all scenarios.
- SdkClientException If any client side error occurs such as an IO related failure, failure to get credentials, etc.
- BedrockAgentRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
- See Also:
-
-
retrieve
Queries a knowledge base and retrieves information from it.
- Parameters:
retrieveRequest
-- Returns:
- A Java Future containing the result of the Retrieve operation returned by the service.
The CompletableFuture returned by this method can be completed exceptionally with the following exceptions. The exception returned is wrapped with CompletionException, so you need to invokeThrowable.getCause()
to retrieve the underlying exception.- ConflictException There was a conflict performing an operation. Resolve the conflict and retry your request.
- ResourceNotFoundException The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.
- ValidationException Input validation failed. Check your request parameters and retry the request.
- InternalServerException An internal server error occurred. Retry your request.
- DependencyFailedException There was an issue with a dependency. Check the resource configurations and retry the request.
- BadGatewayException There was an issue with a dependency due to a server issue. Retry your request.
- ThrottlingException The number of requests exceeds the limit. Resubmit your request later.
- AccessDeniedException The request is denied because of missing access permissions. Check your permissions and retry your request.
- ServiceQuotaExceededException The number of requests exceeds the service quota. Resubmit your request later.
- SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for catch all scenarios.
- SdkClientException If any client side error occurs such as an IO related failure, failure to get credentials, etc.
- BedrockAgentRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
- See Also:
-
retrieve
default CompletableFuture<RetrieveResponse> retrieve(Consumer<RetrieveRequest.Builder> retrieveRequest) Queries a knowledge base and retrieves information from it.
This is a convenience which creates an instance of the
RetrieveRequest.Builder
avoiding the need to create one manually viaRetrieveRequest.builder()
- Parameters:
retrieveRequest
- AConsumer
that will call methods onRetrieveRequest.Builder
to create a request.- Returns:
- A Java Future containing the result of the Retrieve operation returned by the service.
The CompletableFuture returned by this method can be completed exceptionally with the following exceptions. The exception returned is wrapped with CompletionException, so you need to invokeThrowable.getCause()
to retrieve the underlying exception.- ConflictException There was a conflict performing an operation. Resolve the conflict and retry your request.
- ResourceNotFoundException The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.
- ValidationException Input validation failed. Check your request parameters and retry the request.
- InternalServerException An internal server error occurred. Retry your request.
- DependencyFailedException There was an issue with a dependency. Check the resource configurations and retry the request.
- BadGatewayException There was an issue with a dependency due to a server issue. Retry your request.
- ThrottlingException The number of requests exceeds the limit. Resubmit your request later.
- AccessDeniedException The request is denied because of missing access permissions. Check your permissions and retry your request.
- ServiceQuotaExceededException The number of requests exceeds the service quota. Resubmit your request later.
- SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for catch all scenarios.
- SdkClientException If any client side error occurs such as an IO related failure, failure to get credentials, etc.
- BedrockAgentRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
- See Also:
-
retrieveAndGenerate
default CompletableFuture<RetrieveAndGenerateResponse> retrieveAndGenerate(RetrieveAndGenerateRequest retrieveAndGenerateRequest) Queries a knowledge base and generates responses based on the retrieved results. The response only cites sources that are relevant to the query.
- Parameters:
retrieveAndGenerateRequest
-- Returns:
- A Java Future containing the result of the RetrieveAndGenerate operation returned by the service.
The CompletableFuture returned by this method can be completed exceptionally with the following exceptions. The exception returned is wrapped with CompletionException, so you need to invokeThrowable.getCause()
to retrieve the underlying exception.- ConflictException There was a conflict performing an operation. Resolve the conflict and retry your request.
- ResourceNotFoundException The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.
- ValidationException Input validation failed. Check your request parameters and retry the request.
- InternalServerException An internal server error occurred. Retry your request.
- DependencyFailedException There was an issue with a dependency. Check the resource configurations and retry the request.
- BadGatewayException There was an issue with a dependency due to a server issue. Retry your request.
- ThrottlingException The number of requests exceeds the limit. Resubmit your request later.
- AccessDeniedException The request is denied because of missing access permissions. Check your permissions and retry your request.
- ServiceQuotaExceededException The number of requests exceeds the service quota. Resubmit your request later.
- SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for catch all scenarios.
- SdkClientException If any client side error occurs such as an IO related failure, failure to get credentials, etc.
- BedrockAgentRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
- See Also:
-
retrieveAndGenerate
default CompletableFuture<RetrieveAndGenerateResponse> retrieveAndGenerate(Consumer<RetrieveAndGenerateRequest.Builder> retrieveAndGenerateRequest) Queries a knowledge base and generates responses based on the retrieved results. The response only cites sources that are relevant to the query.
This is a convenience which creates an instance of the
RetrieveAndGenerateRequest.Builder
avoiding the need to create one manually viaRetrieveAndGenerateRequest.builder()
- Parameters:
retrieveAndGenerateRequest
- AConsumer
that will call methods onRetrieveAndGenerateRequest.Builder
to create a request.- Returns:
- A Java Future containing the result of the RetrieveAndGenerate operation returned by the service.
The CompletableFuture returned by this method can be completed exceptionally with the following exceptions. The exception returned is wrapped with CompletionException, so you need to invokeThrowable.getCause()
to retrieve the underlying exception.- ConflictException There was a conflict performing an operation. Resolve the conflict and retry your request.
- ResourceNotFoundException The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.
- ValidationException Input validation failed. Check your request parameters and retry the request.
- InternalServerException An internal server error occurred. Retry your request.
- DependencyFailedException There was an issue with a dependency. Check the resource configurations and retry the request.
- BadGatewayException There was an issue with a dependency due to a server issue. Retry your request.
- ThrottlingException The number of requests exceeds the limit. Resubmit your request later.
- AccessDeniedException The request is denied because of missing access permissions. Check your permissions and retry your request.
- ServiceQuotaExceededException The number of requests exceeds the service quota. Resubmit your request later.
- SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for catch all scenarios.
- SdkClientException If any client side error occurs such as an IO related failure, failure to get credentials, etc.
- BedrockAgentRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
- See Also:
-
retrievePaginator
This is a variant of
retrieve(software.amazon.awssdk.services.bedrockagentruntime.model.RetrieveRequest)
operation. The return type is a custom publisher that can be subscribed to request a stream of response pages. SDK will internally handle making service calls for you.When the operation is called, an instance of this class is returned. At this point, no service calls are made yet and so there is no guarantee that the request is valid. If there are errors in your request, you will see the failures only after you start streaming the data. The subscribe method should be called as a request to start streaming data. For more info, see
Publisher.subscribe(org.reactivestreams.Subscriber)
. Each call to the subscribe method will result in a newSubscription
i.e., a new contract to stream data from the starting request.The following are few ways to use the response class:
1) Using the subscribe helper methodsoftware.amazon.awssdk.services.bedrockagentruntime.paginators.RetrievePublisher publisher = client.retrievePaginator(request); CompletableFuture<Void> future = publisher.subscribe(res -> { // Do something with the response }); future.get();
software.amazon.awssdk.services.bedrockagentruntime.paginators.RetrievePublisher publisher = client.retrievePaginator(request); publisher.subscribe(new Subscriber<software.amazon.awssdk.services.bedrockagentruntime.model.RetrieveResponse>() { public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... }; public void onNext(software.amazon.awssdk.services.bedrockagentruntime.model.RetrieveResponse response) { //... }; });
Please notice that the configuration of null won't limit the number of results you get with the paginator. It only limits the number of results in each page.
Note: If you prefer to have control on service calls, use the
retrieve(software.amazon.awssdk.services.bedrockagentruntime.model.RetrieveRequest)
operation.- Parameters:
retrieveRequest
-- Returns:
- A custom publisher that can be subscribed to request a stream of response pages.
The CompletableFuture returned by this method can be completed exceptionally with the following exceptions. The exception returned is wrapped with CompletionException, so you need to invokeThrowable.getCause()
to retrieve the underlying exception.- ConflictException There was a conflict performing an operation. Resolve the conflict and retry your request.
- ResourceNotFoundException The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.
- ValidationException Input validation failed. Check your request parameters and retry the request.
- InternalServerException An internal server error occurred. Retry your request.
- DependencyFailedException There was an issue with a dependency. Check the resource configurations and retry the request.
- BadGatewayException There was an issue with a dependency due to a server issue. Retry your request.
- ThrottlingException The number of requests exceeds the limit. Resubmit your request later.
- AccessDeniedException The request is denied because of missing access permissions. Check your permissions and retry your request.
- ServiceQuotaExceededException The number of requests exceeds the service quota. Resubmit your request later.
- SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for catch all scenarios.
- SdkClientException If any client side error occurs such as an IO related failure, failure to get credentials, etc.
- BedrockAgentRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
- See Also:
-
retrievePaginator
This is a variant of
retrieve(software.amazon.awssdk.services.bedrockagentruntime.model.RetrieveRequest)
operation. The return type is a custom publisher that can be subscribed to request a stream of response pages. SDK will internally handle making service calls for you.When the operation is called, an instance of this class is returned. At this point, no service calls are made yet and so there is no guarantee that the request is valid. If there are errors in your request, you will see the failures only after you start streaming the data. The subscribe method should be called as a request to start streaming data. For more info, see
Publisher.subscribe(org.reactivestreams.Subscriber)
. Each call to the subscribe method will result in a newSubscription
i.e., a new contract to stream data from the starting request.The following are few ways to use the response class:
1) Using the subscribe helper methodsoftware.amazon.awssdk.services.bedrockagentruntime.paginators.RetrievePublisher publisher = client.retrievePaginator(request); CompletableFuture<Void> future = publisher.subscribe(res -> { // Do something with the response }); future.get();
software.amazon.awssdk.services.bedrockagentruntime.paginators.RetrievePublisher publisher = client.retrievePaginator(request); publisher.subscribe(new Subscriber<software.amazon.awssdk.services.bedrockagentruntime.model.RetrieveResponse>() { public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... }; public void onNext(software.amazon.awssdk.services.bedrockagentruntime.model.RetrieveResponse response) { //... }; });
Please notice that the configuration of null won't limit the number of results you get with the paginator. It only limits the number of results in each page.
Note: If you prefer to have control on service calls, use the
retrieve(software.amazon.awssdk.services.bedrockagentruntime.model.RetrieveRequest)
operation.
This is a convenience which creates an instance of the
RetrieveRequest.Builder
avoiding the need to create one manually viaRetrieveRequest.builder()
- Parameters:
retrieveRequest
- AConsumer
that will call methods onRetrieveRequest.Builder
to create a request.- Returns:
- A custom publisher that can be subscribed to request a stream of response pages.
The CompletableFuture returned by this method can be completed exceptionally with the following exceptions. The exception returned is wrapped with CompletionException, so you need to invokeThrowable.getCause()
to retrieve the underlying exception.- ConflictException There was a conflict performing an operation. Resolve the conflict and retry your request.
- ResourceNotFoundException The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.
- ValidationException Input validation failed. Check your request parameters and retry the request.
- InternalServerException An internal server error occurred. Retry your request.
- DependencyFailedException There was an issue with a dependency. Check the resource configurations and retry the request.
- BadGatewayException There was an issue with a dependency due to a server issue. Retry your request.
- ThrottlingException The number of requests exceeds the limit. Resubmit your request later.
- AccessDeniedException The request is denied because of missing access permissions. Check your permissions and retry your request.
- ServiceQuotaExceededException The number of requests exceeds the service quota. Resubmit your request later.
- SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for catch all scenarios.
- SdkClientException If any client side error occurs such as an IO related failure, failure to get credentials, etc.
- BedrockAgentRuntimeException Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type.
- See Also:
-
serviceClientConfiguration
Description copied from interface:SdkClient
The SDK service client configuration exposes client settings to the user, e.g., ClientOverrideConfiguration- Specified by:
serviceClientConfiguration
in interfaceAwsClient
- Specified by:
serviceClientConfiguration
in interfaceSdkClient
- Returns:
- SdkServiceClientConfiguration
-
create
Create aBedrockAgentRuntimeAsyncClient
with the region loaded from theDefaultAwsRegionProviderChain
and credentials loaded from theDefaultCredentialsProvider
. -
builder
Create a builder that can be used to configure and create aBedrockAgentRuntimeAsyncClient
.
-