BedrockInvokeModelProps

class aws_cdk.aws_stepfunctions_tasks.BedrockInvokeModelProps(*, comment=None, query_language=None, state_name=None, credentials=None, heartbeat=None, heartbeat_timeout=None, integration_pattern=None, task_timeout=None, timeout=None, assign=None, input_path=None, output_path=None, outputs=None, result_path=None, result_selector=None, model, accept=None, body=None, content_type=None, guardrail=None, input=None, output=None, trace_enabled=None)

Bases: TaskStateBaseProps

Properties for invoking a Bedrock Model.

Parameters:
  • comment (Optional[str]) – A comment describing this state. Default: No comment

  • query_language (Optional[QueryLanguage]) – The name of the query language used by the state. If the state does not contain a queryLanguage field, then it will use the query language specified in the top-level queryLanguage field. Default: - JSONPath

  • state_name (Optional[str]) – Optional name for this state. Default: - The construct ID will be used as state name

  • credentials (Union[Credentials, Dict[str, Any], None]) – Credentials for an IAM Role that the State Machine assumes for executing the task. This enables cross-account resource invocations. Default: - None (Task is executed using the State Machine’s execution role)

  • heartbeat (Optional[Duration]) – (deprecated) Timeout for the heartbeat. Default: - None

  • heartbeat_timeout (Optional[Timeout]) – Timeout for the heartbeat. [disable-awslint:duration-prop-type] is needed because all props interface in aws-stepfunctions-tasks extend this interface Default: - None

  • integration_pattern (Optional[IntegrationPattern]) – AWS Step Functions integrates with services directly in the Amazon States Language. You can control these AWS services using service integration patterns. Depending on the AWS Service, the Service Integration Pattern availability will vary. Default: - IntegrationPattern.REQUEST_RESPONSE for most tasks. IntegrationPattern.RUN_JOB for the following exceptions: BatchSubmitJob, EmrAddStep, EmrCreateCluster, EmrTerminationCluster, and EmrContainersStartJobRun.

  • task_timeout (Optional[Timeout]) – Timeout for the task. [disable-awslint:duration-prop-type] is needed because all props interface in aws-stepfunctions-tasks extend this interface Default: - None

  • timeout (Optional[Duration]) – (deprecated) Timeout for the task. Default: - None

  • assign (Optional[Mapping[str, Any]]) – Workflow variables to store in this step. Using workflow variables, you can store data in a step and retrieve that data in future steps. Default: - Not assign variables

  • input_path (Optional[str]) – JSONPath expression to select part of the state to be the input to this state. May also be the special value JsonPath.DISCARD, which will cause the effective input to be the empty object {}. Default: $

  • output_path (Optional[str]) – JSONPath expression to select part of the state to be the output to this state. May also be the special value JsonPath.DISCARD, which will cause the effective output to be the empty object {}. Default: $

  • outputs (Any) – Used to specify and transform output from the state. When specified, the value overrides the state output default. The output field accepts any JSON value (object, array, string, number, boolean, null). Any string value, including those inside objects or arrays, will be evaluated as JSONata if surrounded by {% %} characters. Output also accepts a JSONata expression directly. Default: - $states.result or $states.errorOutput

  • result_path (Optional[str]) – JSONPath expression to indicate where to inject the state’s output. May also be the special value JsonPath.DISCARD, which will cause the state’s input to become its output. Default: $

  • result_selector (Optional[Mapping[str, Any]]) – The JSON that will replace the state’s raw result and become the effective result before ResultPath is applied. You can use ResultSelector to create a payload with values that are static or selected from the state’s raw result. Default: - None

  • model (IModel) – The Bedrock model that the task will invoke.

  • accept (Optional[str]) – The desired MIME type of the inference body in the response. Default: ‘application/json’

  • body (Optional[TaskInput]) – The input data for the Bedrock model invocation. The inference parameters contained in the body depend on the Bedrock model being used. The body must be in the format specified in the contentType field. For example, if the content type is application/json, the body must be JSON formatted. The body must be up to 256 KB in size. For input data that exceeds 256 KB, use input instead to retrieve the input data from S3. You must specify either the body or the input field, but not both. Default: - Input data is retrieved from the location specified in the input field

  • content_type (Optional[str]) – (deprecated) The MIME type of the input data in the request. Default: ‘application/json’

  • guardrail (Optional[Guardrail]) – The guardrail is applied to the invocation. Default: - No guardrail is applied to the invocation.

  • input (Union[BedrockInvokeModelInputProps, Dict[str, Any], None]) – The source location to retrieve the input data from. Default: - Input data is retrieved from the body field

  • output (Union[BedrockInvokeModelOutputProps, Dict[str, Any], None]) – The destination location where the API response is written. If you specify this field, the API response body is replaced with a reference to the output location. Default: - The API response body is returned in the result.

  • trace_enabled (Optional[bool]) – Specifies whether to enable or disable the Bedrock trace. Default: - Trace is not enabled for the invocation.

ExampleMetadata:

infused

Example:

import aws_cdk.aws_bedrock as bedrock


model = bedrock.FoundationModel.from_foundation_model_id(self, "Model", bedrock.FoundationModelIdentifier.AMAZON_TITAN_TEXT_G1_EXPRESS_V1)

task = tasks.BedrockInvokeModel(self, "Prompt Model",
    model=model,
    body=sfn.TaskInput.from_object({
        "input_text": "Generate a list of five first names.",
        "text_generation_config": {
            "max_token_count": 100,
            "temperature": 1
        }
    }),
    result_selector={
        "names": sfn.JsonPath.string_at("$.Body.results[0].outputText")
    }
)

Attributes

accept

The desired MIME type of the inference body in the response.

Default:

‘application/json’

See:

https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html

assign

Workflow variables to store in this step.

Using workflow variables, you can store data in a step and retrieve that data in future steps.

Default:
  • Not assign variables

See:

https://docs.aws.amazon.com/ja_jp/step-functions/latest/dg/workflow-variables.html

body

The input data for the Bedrock model invocation.

The inference parameters contained in the body depend on the Bedrock model being used.

The body must be in the format specified in the contentType field. For example, if the content type is application/json, the body must be JSON formatted.

The body must be up to 256 KB in size. For input data that exceeds 256 KB, use input instead to retrieve the input data from S3.

You must specify either the body or the input field, but not both.

Default:
  • Input data is retrieved from the location specified in the input field

See:

https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html

comment

A comment describing this state.

Default:

No comment

content_type

(deprecated) The MIME type of the input data in the request.

Default:

‘application/json’

Deprecated:

This property does not require configuration because the only acceptable value is ‘application/json’.

See:

https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_InvokeModel.html

Stability:

deprecated

credentials

Credentials for an IAM Role that the State Machine assumes for executing the task.

This enables cross-account resource invocations.

Default:
  • None (Task is executed using the State Machine’s execution role)

See:

https://docs.aws.amazon.com/step-functions/latest/dg/concepts-access-cross-acct-resources.html

guardrail

The guardrail is applied to the invocation.

Default:
  • No guardrail is applied to the invocation.

heartbeat

(deprecated) Timeout for the heartbeat.

Default:
  • None

Deprecated:

use heartbeatTimeout

Stability:

deprecated

heartbeat_timeout

Timeout for the heartbeat.

[disable-awslint:duration-prop-type] is needed because all props interface in aws-stepfunctions-tasks extend this interface

Default:
  • None

input

The source location to retrieve the input data from.

Default:
  • Input data is retrieved from the body field

input_path

JSONPath expression to select part of the state to be the input to this state.

May also be the special value JsonPath.DISCARD, which will cause the effective input to be the empty object {}.

Default:

$

integration_pattern

AWS Step Functions integrates with services directly in the Amazon States Language.

You can control these AWS services using service integration patterns.

Depending on the AWS Service, the Service Integration Pattern availability will vary.

Default:

  • IntegrationPattern.REQUEST_RESPONSE for most tasks.

IntegrationPattern.RUN_JOB for the following exceptions: BatchSubmitJob, EmrAddStep, EmrCreateCluster, EmrTerminationCluster, and EmrContainersStartJobRun.

See:

https://docs.aws.amazon.com/step-functions/latest/dg/connect-supported-services.html

model

The Bedrock model that the task will invoke.

See:

https://docs.aws.amazon.com/bedrock/latest/userguide/api-methods-run.html

output

The destination location where the API response is written.

If you specify this field, the API response body is replaced with a reference to the output location.

Default:
  • The API response body is returned in the result.

output_path

JSONPath expression to select part of the state to be the output to this state.

May also be the special value JsonPath.DISCARD, which will cause the effective output to be the empty object {}.

Default:

$

outputs

Used to specify and transform output from the state.

When specified, the value overrides the state output default. The output field accepts any JSON value (object, array, string, number, boolean, null). Any string value, including those inside objects or arrays, will be evaluated as JSONata if surrounded by {% %} characters. Output also accepts a JSONata expression directly.

Default:
  • $states.result or $states.errorOutput

See:

https://docs.aws.amazon.com/step-functions/latest/dg/concepts-input-output-filtering.html

query_language

The name of the query language used by the state.

If the state does not contain a queryLanguage field, then it will use the query language specified in the top-level queryLanguage field.

Default:
  • JSONPath

result_path

JSONPath expression to indicate where to inject the state’s output.

May also be the special value JsonPath.DISCARD, which will cause the state’s input to become its output.

Default:

$

result_selector

The JSON that will replace the state’s raw result and become the effective result before ResultPath is applied.

You can use ResultSelector to create a payload with values that are static or selected from the state’s raw result.

Default:
  • None

See:

https://docs.aws.amazon.com/step-functions/latest/dg/input-output-inputpath-params.html#input-output-resultselector

state_name

Optional name for this state.

Default:
  • The construct ID will be used as state name

task_timeout

Timeout for the task.

[disable-awslint:duration-prop-type] is needed because all props interface in aws-stepfunctions-tasks extend this interface

Default:
  • None

timeout

(deprecated) Timeout for the task.

Default:
  • None

Deprecated:

use taskTimeout

Stability:

deprecated

trace_enabled

Specifies whether to enable or disable the Bedrock trace.

Default:
  • Trace is not enabled for the invocation.