Agents for Amazon Bedrock Runtime

2024/11/20 - Agents for Amazon Bedrock Runtime - 1 new api methods

Changes  Releasing new Prompt Optimization to enhance your prompts for improved performance

OptimizePrompt (new) Link ΒΆ

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

client.optimize_prompt(
    input={
        'textPrompt': {
            'text': 'string'
        }
    },
    targetModelId='string'
)
type input:

dict

param input:

[REQUIRED]

Contains the prompt to optimize.

  • textPrompt (dict) --

    Contains information about the text prompt to optimize.

    • text (string) -- [REQUIRED]

      The text in the text prompt to optimize.

type targetModelId:

string

param targetModelId:

[REQUIRED]

The unique identifier of the model that you want to optimize the prompt for.

rtype:

dict

returns:

The response of this operation contains an :class:`.EventStream` member. When iterated the :class:`.EventStream` 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 (:class:`.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.

          • 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) --