AgentsforBedrockRuntime / Client / invoke_flow

invoke_flow#

AgentsforBedrockRuntime.Client.invoke_flow(**kwargs)#

Invokes an alias of a flow to run the inputs that you specify and return the output of each node as a stream. If there’s an error, the error is returned. For more information, see Test a flow in Amazon Bedrock in the Amazon Bedrock User Guide.

Note

The CLI doesn’t support streaming operations in Amazon Bedrock, including InvokeFlow.

See also: AWS API Documentation

Request Syntax

response = client.invoke_flow(
    flowAliasIdentifier='string',
    flowIdentifier='string',
    inputs=[
        {
            'content': {
                'document': {...}|[...]|123|123.4|'string'|True|None
            },
            'nodeName': 'string',
            'nodeOutputName': 'string'
        },
    ]
)
Parameters:
  • flowAliasIdentifier (string) –

    [REQUIRED]

    The unique identifier of the flow alias.

  • flowIdentifier (string) –

    [REQUIRED]

    The unique identifier of the flow.

  • inputs (list) –

    [REQUIRED]

    A list of objects, each containing information about an input into the flow.

    • (dict) –

      Contains information about an input into the prompt flow and where to send it.

      This data type is used in the following API operations:

      • content (dict) – [REQUIRED]

        Contains information about an input into the prompt flow.

        Note

        This is a Tagged Union structure. Only one of the following top level keys can be set: document.

        • document (document) –

          The input to send to the prompt flow input node.

      • nodeName (string) – [REQUIRED]

        The name of the flow input node that begins the prompt flow.

      • nodeOutputName (string) – [REQUIRED]

        The name of the output from the flow input node that begins the prompt flow.

Return type:

dict

Returns:

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

{
    'responseStream': EventStream({
        'accessDeniedException': {
            'message': 'string'
        },
        'badGatewayException': {
            'message': 'string',
            'resourceName': 'string'
        },
        'conflictException': {
            'message': 'string'
        },
        'dependencyFailedException': {
            'message': 'string',
            'resourceName': 'string'
        },
        'flowCompletionEvent': {
            'completionReason': 'SUCCESS'
        },
        'flowOutputEvent': {
            'content': {
                'document': {...}|[...]|123|123.4|'string'|True|None
            },
            'nodeName': 'string',
            'nodeType': 'FlowInputNode'|'FlowOutputNode'|'LambdaFunctionNode'|'KnowledgeBaseNode'|'PromptNode'|'ConditionNode'|'LexNode'
        },
        'internalServerException': {
            'message': 'string'
        },
        'resourceNotFoundException': {
            'message': 'string'
        },
        'serviceQuotaExceededException': {
            'message': 'string'
        },
        'throttlingException': {
            'message': 'string'
        },
        'validationException': {
            'message': 'string'
        }
    })
}

Response Structure

  • (dict) –

    • responseStream (EventStream) –

      The output of the flow, returned as a stream. If there’s an error, the error is returned.

      • accessDeniedException (dict) –

        The request is denied because of missing access permissions. Check your permissions and retry your request.

        • message (string) –

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

      • conflictException (dict) –

        There was a conflict performing an operation. Resolve the conflict and retry your request.

        • message (string) –

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

      • flowCompletionEvent (dict) –

        Contains information about why the flow completed.

        • completionReason (string) –

          The reason that the flow completed.

      • flowOutputEvent (dict) –

        Contains information about an output from flow invocation.

        • content (dict) –

          The content in the output.

          Note

          This is a Tagged Union structure. Only one of the following top level keys will be set: document. If a client receives an unknown member it will set SDK_UNKNOWN_MEMBER as the top level key, which maps to the name or tag of the unknown member. The structure of SDK_UNKNOWN_MEMBER is as follows:

          'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}
          
          • document (document) –

            The content in the output.

        • nodeName (string) –

          The name of the flow output node that the output is from.

        • nodeType (string) –

          The type of the node that the output is from.

      • internalServerException (dict) –

        An internal server error occurred. Retry your request.

        • message (string) –

      • resourceNotFoundException (dict) –

        The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.

        • message (string) –

      • serviceQuotaExceededException (dict) –

        The number of requests exceeds the service quota. Resubmit your request later.

        • message (string) –

      • throttlingException (dict) –

        The number of requests exceeds the limit. Resubmit your request later.

        • message (string) –

      • validationException (dict) –

        Input validation failed. Check your request parameters and retry the request.

        • message (string) –

Exceptions

  • AgentsforBedrockRuntime.Client.exceptions.ConflictException

  • AgentsforBedrockRuntime.Client.exceptions.ResourceNotFoundException

  • AgentsforBedrockRuntime.Client.exceptions.ValidationException

  • AgentsforBedrockRuntime.Client.exceptions.InternalServerException

  • AgentsforBedrockRuntime.Client.exceptions.DependencyFailedException

  • AgentsforBedrockRuntime.Client.exceptions.BadGatewayException

  • AgentsforBedrockRuntime.Client.exceptions.ThrottlingException

  • AgentsforBedrockRuntime.Client.exceptions.AccessDeniedException

  • AgentsforBedrockRuntime.Client.exceptions.ServiceQuotaExceededException