AgentsforBedrockRuntime / Client / optimize_prompt
optimize_prompt#
- AgentsforBedrockRuntime.Client.optimize_prompt(**kwargs)#
Optimizes a prompt for the task that you specify. For more information, see Optimize a prompt in the Amazon Bedrock User Guide.
See also: AWS API Documentation
Request Syntax
response = client.optimize_prompt( input={ 'textPrompt': { 'text': 'string' } }, targetModelId='string' )
- Parameters:
input (dict) –
[REQUIRED]
Contains the prompt to optimize.
Note
This is a Tagged Union structure. Only one of the following top level keys can be set:
textPrompt
.textPrompt (dict) –
Contains information about the text prompt to optimize.
text (string) – [REQUIRED]
The text in the text prompt to optimize.
targetModelId (string) –
[REQUIRED]
The unique identifier of the model that you want to optimize the prompt for.
- Return type:
dict
- Returns:
The response of this operation contains an
EventStream
member. When iterated theEventStream
will yield events based on the structure below, where only one of the top level keys will be present for any given event.Response Syntax
{ 'optimizedPrompt': EventStream({ 'accessDeniedException': { 'message': 'string' }, 'analyzePromptEvent': { 'message': 'string' }, 'badGatewayException': { 'message': 'string', 'resourceName': 'string' }, 'dependencyFailedException': { 'message': 'string', 'resourceName': 'string' }, 'internalServerException': { 'message': 'string' }, 'optimizedPromptEvent': { 'optimizedPrompt': { 'textPrompt': { 'text': 'string' } } }, 'throttlingException': { 'message': 'string' }, 'validationException': { 'message': 'string' } }) }
Response Structure
(dict) –
optimizedPrompt (
EventStream
) –The prompt after being optimized for the task.
accessDeniedException (dict) –
The request is denied because of missing access permissions. Check your permissions and retry your request.
message (string) –
analyzePromptEvent (dict) –
An event in which the prompt was analyzed in preparation for optimization.
message (string) –
A message describing the analysis of the prompt.
badGatewayException (dict) –
There was an issue with a dependency due to a server issue. Retry your request.
message (string) –
resourceName (string) –
The name of the dependency that caused the issue, such as Amazon Bedrock, Lambda, or STS.
dependencyFailedException (dict) –
There was an issue with a dependency. Check the resource configurations and retry the request.
message (string) –
resourceName (string) –
The name of the dependency that caused the issue, such as Amazon Bedrock, Lambda, or STS.
internalServerException (dict) –
An internal server error occurred. Retry your request.
message (string) –
optimizedPromptEvent (dict) –
An event in which the prompt was optimized.
optimizedPrompt (dict) –
Contains information about the optimized prompt.
Note
This is a Tagged Union structure. Only one of the following top level keys will be set:
textPrompt
. If a client receives an unknown member it will setSDK_UNKNOWN_MEMBER
as the top level key, which maps to the name or tag of the unknown member. The structure ofSDK_UNKNOWN_MEMBER
is as follows:'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}
textPrompt (dict) –
Contains information about the text in the prompt that was optimized.
text (string) –
The text in the text prompt to optimize.
throttlingException (dict) –
Your request was throttled because of service-wide limitations. Resubmit your request later or in a different region. You can also purchase Provisioned Throughput to increase the rate or number of tokens you can process.
message (string) –
validationException (dict) –
Input validation failed. Check your request parameters and retry the request.
message (string) –
Exceptions
AgentsforBedrockRuntime.Client.exceptions.ValidationException
AgentsforBedrockRuntime.Client.exceptions.InternalServerException
AgentsforBedrockRuntime.Client.exceptions.DependencyFailedException
AgentsforBedrockRuntime.Client.exceptions.BadGatewayException
AgentsforBedrockRuntime.Client.exceptions.ThrottlingException
AgentsforBedrockRuntime.Client.exceptions.AccessDeniedException