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(
    enableTrace=True|False,
    flowAliasIdentifier='string',
    flowIdentifier='string',
    inputs=[
        {
            'content': {
                'document': {...}|[...]|123|123.4|'string'|True|None
            },
            'nodeName': 'string',
            'nodeOutputName': 'string'
        },
    ]
)
Parameters:
  • enableTrace (boolean) – Specifies whether to return the trace for the flow or not. Traces track inputs and outputs for nodes in the flow. For more information, see Track each step in your prompt flow by viewing its trace in Amazon Bedrock.

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

      • 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'
        },
        'flowTraceEvent': {
            'trace': {
                'conditionNodeResultTrace': {
                    'nodeName': 'string',
                    'satisfiedConditions': [
                        {
                            'conditionName': 'string'
                        },
                    ],
                    'timestamp': datetime(2015, 1, 1)
                },
                'nodeInputTrace': {
                    'fields': [
                        {
                            'content': {
                                'document': {...}|[...]|123|123.4|'string'|True|None
                            },
                            'nodeInputName': 'string'
                        },
                    ],
                    'nodeName': 'string',
                    'timestamp': datetime(2015, 1, 1)
                },
                'nodeOutputTrace': {
                    'fields': [
                        {
                            'content': {
                                'document': {...}|[...]|123|123.4|'string'|True|None
                            },
                            'nodeOutputName': 'string'
                        },
                    ],
                    'nodeName': 'string',
                    'timestamp': datetime(2015, 1, 1)
                }
            }
        },
        '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.

      • flowTraceEvent (dict) –

        Contains information about a trace, which tracks an input or output for a node in the flow.

        • trace (dict) –

          The trace object containing information about an input or output for a node in the flow.

          Note

          This is a Tagged Union structure. Only one of the following top level keys will be set: conditionNodeResultTrace, nodeInputTrace, nodeOutputTrace. 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'}
          
          • conditionNodeResultTrace (dict) –

            Contains information about an output from a condition node.

            • nodeName (string) –

              The name of the condition node.

            • satisfiedConditions (list) –

              An array of objects containing information about the conditions that were satisfied.

            • timestamp (datetime) –

              The date and time that the trace was returned.

          • nodeInputTrace (dict) –

            Contains information about the input into a node.

            • fields (list) –

              An array of objects containing information about each field in the input.

              • (dict) –

                Contains information about a field in the input into a node. For more information, see Track each step in your prompt flow by viewing its trace in Amazon Bedrock.

                • content (dict) –

                  The content of the node input.

                  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 of the node input.

                • nodeInputName (string) –

                  The name of the node input.

            • nodeName (string) –

              The name of the node that received the input.

            • timestamp (datetime) –

              The date and time that the trace was returned.

          • nodeOutputTrace (dict) –

            Contains information about the output from a node.

            • fields (list) –

              An array of objects containing information about each field in the output.

              • (dict) –

                Contains information about a field in the output from a node. For more information, see Track each step in your prompt flow by viewing its trace in Amazon Bedrock.

                • content (dict) –

                  The content of the node 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 of the node output.

                • nodeOutputName (string) –

                  The name of the node output.

            • nodeName (string) –

              The name of the node that yielded the output.

            • timestamp (datetime) –

              The date and time that the trace was returned.

      • 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