AgentsforBedrockRuntime / Client / retrieve

retrieve#

AgentsforBedrockRuntime.Client.retrieve(**kwargs)#

Retrieve from knowledge base.

See also: AWS API Documentation

Request Syntax

response = client.retrieve(
    knowledgeBaseId='string',
    retrievalQuery={
        'text': 'string'
    },
    retrievalConfiguration={
        'vectorSearchConfiguration': {
            'numberOfResults': 123
        }
    },
    nextToken='string'
)
Parameters:
  • knowledgeBaseId (string) –

    [REQUIRED]

    Identifier of the KnowledgeBase

  • retrievalQuery (dict) –

    [REQUIRED]

    Knowledge base input query.

    • text (string) – [REQUIRED]

      Knowledge base input query in text

  • retrievalConfiguration (dict) –

    Search parameters for retrieving from knowledge base.

    • vectorSearchConfiguration (dict) – [REQUIRED]

      Knowledge base vector search configuration

      • numberOfResults (integer) – [REQUIRED]

        Top-K results to retrieve from knowledge base.

  • nextToken (string) – Opaque continuation token of previous paginated response.

Return type:

dict

Returns:

Response Syntax

{
    'retrievalResults': [
        {
            'content': {
                'text': 'string'
            },
            'location': {
                'type': 'S3',
                's3Location': {
                    'uri': 'string'
                }
            },
            'score': 123.0
        },
    ],
    'nextToken': 'string'
}

Response Structure

  • (dict) –

    • retrievalResults (list) –

      List of knowledge base retrieval results

      • (dict) –

        Result item returned from a knowledge base retrieval.

        • content (dict) –

          Content of a retrieval result.

          • text (string) –

            Content of a retrieval result in text

        • location (dict) –

          The source location of a retrieval result.

          • type (string) –

            The location type of a retrieval result.

          • s3Location (dict) –

            The S3 location of a retrieval result.

            • uri (string) –

              URI of S3 location

        • score (float) –

          The relevance score of a result.

    • nextToken (string) –

      Opaque continuation token of previous paginated response.

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