AgentsforBedrockRuntime / Paginator / Rerank

Rerank#

class AgentsforBedrockRuntime.Paginator.Rerank#
paginator = client.get_paginator('rerank')
paginate(**kwargs)#

Creates an iterator that will paginate through responses from AgentsforBedrockRuntime.Client.rerank().

See also: AWS API Documentation

Request Syntax

response_iterator = paginator.paginate(
    queries=[
        {
            'textQuery': {
                'text': 'string'
            },
            'type': 'TEXT'
        },
    ],
    rerankingConfiguration={
        'bedrockRerankingConfiguration': {
            'modelConfiguration': {
                'additionalModelRequestFields': {
                    'string': {...}|[...]|123|123.4|'string'|True|None
                },
                'modelArn': 'string'
            },
            'numberOfResults': 123
        },
        'type': 'BEDROCK_RERANKING_MODEL'
    },
    sources=[
        {
            'inlineDocumentSource': {
                'jsonDocument': {...}|[...]|123|123.4|'string'|True|None,
                'textDocument': {
                    'text': 'string'
                },
                'type': 'TEXT'|'JSON'
            },
            'type': 'INLINE'
        },
    ],
    PaginationConfig={
        'MaxItems': 123,
        'StartingToken': 'string'
    }
)
Parameters:
  • queries (list) –

    [REQUIRED]

    An array of objects, each of which contains information about a query to submit to the reranker model.

    • (dict) –

      Contains information about a query to submit to the reranker model.

      • textQuery (dict) – [REQUIRED]

        Contains information about a text query.

        • text (string) –

          The text of the document.

      • type (string) – [REQUIRED]

        The type of the query.

  • rerankingConfiguration (dict) –

    [REQUIRED]

    Contains configurations for reranking.

    • bedrockRerankingConfiguration (dict) – [REQUIRED]

      Contains configurations for an Amazon Bedrock reranker.

      • modelConfiguration (dict) – [REQUIRED]

        Contains configurations for a reranker model.

        • additionalModelRequestFields (dict) –

          A JSON object whose keys are request fields for the model and whose values are values for those fields.

        • modelArn (string) – [REQUIRED]

          The ARN of the reranker model.

      • numberOfResults (integer) –

        The number of results to return after reranking.

    • type (string) – [REQUIRED]

      The type of reranker that the configurations apply to.

  • sources (list) –

    [REQUIRED]

    An array of objects, each of which contains information about the sources to rerank.

    • (dict) –

      Contains information about a source for reranking.

      • inlineDocumentSource (dict) – [REQUIRED]

        Contains an inline definition of a source for reranking.

        • jsonDocument (document) –

          Contains a JSON document to rerank.

        • textDocument (dict) –

          Contains information about a text document to rerank.

          • text (string) –

            The text of the document.

        • type (string) – [REQUIRED]

          The type of document to rerank.

      • type (string) – [REQUIRED]

        The type of the source.

  • PaginationConfig (dict) –

    A dictionary that provides parameters to control pagination.

    • MaxItems (integer) –

      The total number of items to return. If the total number of items available is more than the value specified in max-items then a NextToken will be provided in the output that you can use to resume pagination.

    • StartingToken (string) –

      A token to specify where to start paginating. This is the NextToken from a previous response.

Return type:

dict

Returns:

Response Syntax

{
    'results': [
        {
            'document': {
                'jsonDocument': {...}|[...]|123|123.4|'string'|True|None,
                'textDocument': {
                    'text': 'string'
                },
                'type': 'TEXT'|'JSON'
            },
            'index': 123,
            'relevanceScore': ...
        },
    ],
    'NextToken': 'string'
}

Response Structure

  • (dict) –

    • results (list) –

      An array of objects, each of which contains information about the results of reranking.

      • (dict) –

        Contains information about a document that was reranked.

        • document (dict) –

          Contains information about the document.

          • jsonDocument (document) –

            Contains a JSON document to rerank.

          • textDocument (dict) –

            Contains information about a text document to rerank.

            • text (string) –

              The text of the document.

          • type (string) –

            The type of document to rerank.

        • index (integer) –

          The ranking of the document. The lower a number, the higher the document is ranked.

        • relevanceScore (float) –

          The relevance score of the document.

    • NextToken (string) –

      A token to resume pagination.