We announced the upcoming end-of-support for AWS SDK for JavaScript v2.
We recommend that you migrate to AWS SDK for JavaScript v3. For dates, additional details, and information on how to migrate, please refer to the linked announcement.

Class: AWS.BedrockAgentRuntime

Inherits:
AWS.Service show all
Identifier:
bedrockagentruntime
API Version:
2023-07-26
Defined in:
(unknown)

Overview

Constructs a service interface object. Each API operation is exposed as a function on service.

Service Description

Contains APIs related to model invocation and querying of knowledge bases.

Sending a Request Using BedrockAgentRuntime

var bedrockagentruntime = new AWS.BedrockAgentRuntime();
bedrockagentruntime.deleteAgentMemory(params, function (err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Locking the API Version

In order to ensure that the BedrockAgentRuntime object uses this specific API, you can construct the object by passing the apiVersion option to the constructor:

var bedrockagentruntime = new AWS.BedrockAgentRuntime({apiVersion: '2023-07-26'});

You can also set the API version globally in AWS.config.apiVersions using the bedrockagentruntime service identifier:

AWS.config.apiVersions = {
  bedrockagentruntime: '2023-07-26',
  // other service API versions
};

var bedrockagentruntime = new AWS.BedrockAgentRuntime();

Version:

  • 2023-07-26

Constructor Summary collapse

Property Summary collapse

Properties inherited from AWS.Service

apiVersions

Method Summary collapse

Methods inherited from AWS.Service

makeRequest, makeUnauthenticatedRequest, waitFor, setupRequestListeners, defineService

Constructor Details

new AWS.BedrockAgentRuntime(options = {}) ⇒ Object

Constructs a service object. This object has one method for each API operation.

Examples:

Constructing a BedrockAgentRuntime object

var bedrockagentruntime = new AWS.BedrockAgentRuntime({apiVersion: '2023-07-26'});

Options Hash (options):

  • params (map)

    An optional map of parameters to bind to every request sent by this service object. For more information on bound parameters, see "Working with Services" in the Getting Started Guide.

  • endpoint (String|AWS.Endpoint)

    The endpoint URI to send requests to. The default endpoint is built from the configured region. The endpoint should be a string like 'https://{service}.{region}.amazonaws.com' or an Endpoint object.

  • accessKeyId (String)

    your AWS access key ID.

  • secretAccessKey (String)

    your AWS secret access key.

  • sessionToken (AWS.Credentials)

    the optional AWS session token to sign requests with.

  • credentials (AWS.Credentials)

    the AWS credentials to sign requests with. You can either specify this object, or specify the accessKeyId and secretAccessKey options directly.

  • credentialProvider (AWS.CredentialProviderChain)

    the provider chain used to resolve credentials if no static credentials property is set.

  • region (String)

    the region to send service requests to. See AWS.BedrockAgentRuntime.region for more information.

  • maxRetries (Integer)

    the maximum amount of retries to attempt with a request. See AWS.BedrockAgentRuntime.maxRetries for more information.

  • maxRedirects (Integer)

    the maximum amount of redirects to follow with a request. See AWS.BedrockAgentRuntime.maxRedirects for more information.

  • sslEnabled (Boolean)

    whether to enable SSL for requests.

  • paramValidation (Boolean|map)

    whether input parameters should be validated against the operation description before sending the request. Defaults to true. Pass a map to enable any of the following specific validation features:

    • min [Boolean] — Validates that a value meets the min constraint. This is enabled by default when paramValidation is set to true.
    • max [Boolean] — Validates that a value meets the max constraint.
    • pattern [Boolean] — Validates that a string value matches a regular expression.
    • enum [Boolean] — Validates that a string value matches one of the allowable enum values.
  • computeChecksums (Boolean)

    whether to compute checksums for payload bodies when the service accepts it (currently supported in S3 only)

  • convertResponseTypes (Boolean)

    whether types are converted when parsing response data. Currently only supported for JSON based services. Turning this off may improve performance on large response payloads. Defaults to true.

  • correctClockSkew (Boolean)

    whether to apply a clock skew correction and retry requests that fail because of an skewed client clock. Defaults to false.

  • s3ForcePathStyle (Boolean)

    whether to force path style URLs for S3 objects.

  • s3BucketEndpoint (Boolean)

    whether the provided endpoint addresses an individual bucket (false if it addresses the root API endpoint). Note that setting this configuration option requires an endpoint to be provided explicitly to the service constructor.

  • s3DisableBodySigning (Boolean)

    whether S3 body signing should be disabled when using signature version v4. Body signing can only be disabled when using https. Defaults to true.

  • s3UsEast1RegionalEndpoint ('legacy'|'regional')

    when region is set to 'us-east-1', whether to send s3 request to global endpoints or 'us-east-1' regional endpoints. This config is only applicable to S3 client. Defaults to legacy

  • s3UseArnRegion (Boolean)

    whether to override the request region with the region inferred from requested resource's ARN. Only available for S3 buckets Defaults to true

  • retryDelayOptions (map)

    A set of options to configure the retry delay on retryable errors. Currently supported options are:

    • base [Integer] — The base number of milliseconds to use in the exponential backoff for operation retries. Defaults to 100 ms for all services except DynamoDB, where it defaults to 50ms.
    • customBackoff [function] — A custom function that accepts a retry count and error and returns the amount of time to delay in milliseconds. If the result is a non-zero negative value, no further retry attempts will be made. The base option will be ignored if this option is supplied. The function is only called for retryable errors.
  • httpOptions (map)

    A set of options to pass to the low-level HTTP request. Currently supported options are:

    • proxy [String] — the URL to proxy requests through
    • agent [http.Agent, https.Agent] — the Agent object to perform HTTP requests with. Used for connection pooling. Defaults to the global agent (http.globalAgent) for non-SSL connections. Note that for SSL connections, a special Agent object is used in order to enable peer certificate verification. This feature is only available in the Node.js environment.
    • connectTimeout [Integer] — Sets the socket to timeout after failing to establish a connection with the server after connectTimeout milliseconds. This timeout has no effect once a socket connection has been established.
    • timeout [Integer] — Sets the socket to timeout after timeout milliseconds of inactivity on the socket. Defaults to two minutes (120000).
    • xhrAsync [Boolean] — Whether the SDK will send asynchronous HTTP requests. Used in the browser environment only. Set to false to send requests synchronously. Defaults to true (async on).
    • xhrWithCredentials [Boolean] — Sets the "withCredentials" property of an XMLHttpRequest object. Used in the browser environment only. Defaults to false.
  • apiVersion (String, Date)

    a String in YYYY-MM-DD format (or a date) that represents the latest possible API version that can be used in all services (unless overridden by apiVersions). Specify 'latest' to use the latest possible version.

  • apiVersions (map<String, String|Date>)

    a map of service identifiers (the lowercase service class name) with the API version to use when instantiating a service. Specify 'latest' for each individual that can use the latest available version.

  • logger (#write, #log)

    an object that responds to .write() (like a stream) or .log() (like the console object) in order to log information about requests

  • systemClockOffset (Number)

    an offset value in milliseconds to apply to all signing times. Use this to compensate for clock skew when your system may be out of sync with the service time. Note that this configuration option can only be applied to the global AWS.config object and cannot be overridden in service-specific configuration. Defaults to 0 milliseconds.

  • signatureVersion (String)

    the signature version to sign requests with (overriding the API configuration). Possible values are: 'v2', 'v3', 'v4'.

  • signatureCache (Boolean)

    whether the signature to sign requests with (overriding the API configuration) is cached. Only applies to the signature version 'v4'. Defaults to true.

  • dynamoDbCrc32 (Boolean)

    whether to validate the CRC32 checksum of HTTP response bodies returned by DynamoDB. Default: true.

  • useAccelerateEndpoint (Boolean)

    Whether to use the S3 Transfer Acceleration endpoint with the S3 service. Default: false.

  • clientSideMonitoring (Boolean)

    whether to collect and publish this client's performance metrics of all its API requests.

  • endpointDiscoveryEnabled (Boolean|undefined)

    whether to call operations with endpoints given by service dynamically. Setting this

  • endpointCacheSize (Number)

    the size of the global cache storing endpoints from endpoint discovery operations. Once endpoint cache is created, updating this setting cannot change existing cache size. Defaults to 1000

  • hostPrefixEnabled (Boolean)

    whether to marshal request parameters to the prefix of hostname. Defaults to true.

  • stsRegionalEndpoints ('legacy'|'regional')

    whether to send sts request to global endpoints or regional endpoints. Defaults to 'legacy'.

  • useFipsEndpoint (Boolean)

    Enables FIPS compatible endpoints. Defaults to false.

  • useDualstackEndpoint (Boolean)

    Enables IPv6 dualstack endpoint. Defaults to false.

Property Details

endpointAWS.Endpoint (readwrite)

Returns an Endpoint object representing the endpoint URL for service requests.

Returns:

  • (AWS.Endpoint)

    an Endpoint object representing the endpoint URL for service requests.

Method Details

deleteAgentMemory(params = {}, callback) ⇒ AWS.Request

Deletes memory from the specified memory identifier.

Service Reference:

Examples:

Calling the deleteAgentMemory operation

var params = {
  agentAliasId: 'STRING_VALUE', /* required */
  agentId: 'STRING_VALUE', /* required */
  memoryId: 'STRING_VALUE'
};
bedrockagentruntime.deleteAgentMemory(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • agentAliasId — (String)

      The unique identifier of an alias of an agent.

    • agentId — (String)

      The unique identifier of the agent to which the alias belongs.

    • memoryId — (String)

      The unique identifier of the memory.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

getAgentMemory(params = {}, callback) ⇒ AWS.Request

Gets the sessions stored in the memory of the agent.

Service Reference:

Examples:

Calling the getAgentMemory operation

var params = {
  agentAliasId: 'STRING_VALUE', /* required */
  agentId: 'STRING_VALUE', /* required */
  memoryId: 'STRING_VALUE', /* required */
  memoryType: SESSION_SUMMARY, /* required */
  maxItems: 'NUMBER_VALUE',
  nextToken: 'STRING_VALUE'
};
bedrockagentruntime.getAgentMemory(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • agentAliasId — (String)

      The unique identifier of an alias of an agent.

    • agentId — (String)

      The unique identifier of the agent to which the alias belongs.

    • maxItems — (Integer)

      The maximum number of items to return in the response. If the total number of results is greater than this value, use the token returned in the response in the nextToken field when making another request to return the next batch of results.

    • memoryId — (String)

      The unique identifier of the memory.

    • memoryType — (String)

      The type of memory.

      Possible values include:
      • "SESSION_SUMMARY"
    • nextToken — (String)

      If the total number of results is greater than the maxItems value provided in the request, enter the token returned in the nextToken field in the response in this field to return the next batch of results.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • memoryContents — (Array<map>)

        Contains details of the sessions stored in the memory

        • sessionSummary — (map)

          Contains summary of a session.

          • memoryId — (String)

            The unique identifier of the memory where the session summary is stored.

          • sessionExpiryTime — (Date)

            The time when the memory duration for the session is set to end.

          • sessionId — (String)

            The identifier for this session.

          • sessionStartTime — (Date)

            The start time for this session.

          • summaryText — (String)

            The summarized text for this session.

      • nextToken — (String)

        If the total number of results is greater than the maxItems value provided in the request, use this token when making another request in the nextToken field to return the next batch of results.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

invokeAgent(params = {}, callback) ⇒ AWS.Request

Note: The CLI doesn't support streaming operations in Amazon Bedrock, including InvokeAgent.

Sends a prompt for the agent to process and respond to. Note the following fields for the request:

  • To continue the same conversation with an agent, use the same sessionId value in the request.

  • To activate trace enablement, turn enableTrace to true. Trace enablement helps you follow the agent's reasoning process that led it to the information it processed, the actions it took, and the final result it yielded. For more information, see Trace enablement.

  • End a conversation by setting endSession to true.

  • In the sessionState object, you can include attributes for the session or prompt or, if you configured an action group to return control, results from invocation of the action group.

The response is returned in the bytes field of the chunk object.

  • The attribution object contains citations for parts of the response.

  • If you set enableTrace to true in the request, you can trace the agent's steps and reasoning process that led it to the response.

  • If the action predicted was configured to return control, the response returns parameters for the action, elicited from the user, in the returnControl field.

  • Errors are also surfaced in the response.

Service Reference:

Examples:

Node.js EventStream Example

// In Node.js, events are streamed and can be read as they arrive.
bedrockagentruntime.invokeAgent({/** params **/}, function(err, data) {
  if (err) {
    // handle error
    return console.error(err);
  }

  var eventStream = data.completion;

  eventStream.on('data', function(event) {
    // Check the top-level field to determine which event this is.
    if (event.accessDeniedException) {
      // handle accessDeniedException event
    } else if (event.badGatewayException) {
      // handle badGatewayException event
    } else if (event.chunk) {
      // handle chunk event
    } else if (event.conflictException) {
      // handle conflictException event
    } else if (event.dependencyFailedException) {
      // handle dependencyFailedException event
    } else if (event.files) {
      // handle files event
    } else if (event.internalServerException) {
      // handle internalServerException event
    } else if (event.resourceNotFoundException) {
      // handle resourceNotFoundException event
    } else if (event.returnControl) {
      // handle returnControl event
    } else if (event.serviceQuotaExceededException) {
      // handle serviceQuotaExceededException event
    } else if (event.throttlingException) {
      // handle throttlingException event
    } else if (event.trace) {
      // handle trace event
    } else if (event.validationException) {
      // handle validationException event
    }
  });
  eventStream.on('error', function(err) { /** Handle error events **/});
  eventStream.on('end', function() { /** Finished reading all events **/});
});

Browser EventStream Example

// In browsers, events aren't processed until the response is fully buffered.
// Events will be accessible as an array.
bedrockagentruntime.invokeAgent({/** params **/}, function(err, data) {
  if (err) {
    // handle error
    return console.error(err);
  }

  var events = data.completion;

  for (var event of events) {
    // Check the top-level field to determine which event this is.
    if (event.accessDeniedException) {
      // handle accessDeniedException event
    } else if (event.badGatewayException) {
      // handle badGatewayException event
    } else if (event.chunk) {
      // handle chunk event
    } else if (event.conflictException) {
      // handle conflictException event
    } else if (event.dependencyFailedException) {
      // handle dependencyFailedException event
    } else if (event.files) {
      // handle files event
    } else if (event.internalServerException) {
      // handle internalServerException event
    } else if (event.resourceNotFoundException) {
      // handle resourceNotFoundException event
    } else if (event.returnControl) {
      // handle returnControl event
    } else if (event.serviceQuotaExceededException) {
      // handle serviceQuotaExceededException event
    } else if (event.throttlingException) {
      // handle throttlingException event
    } else if (event.trace) {
      // handle trace event
    } else if (event.validationException) {
      // handle validationException event
    }
  }
});

Async Iterator EventStream Example (Experimental)

// In Node.js v10.x, Readable streams have experimental support for async iteration.
// Instead of listening to the event stream's 'data' event, you can use a for...await loop.
async function example() {
  try {
    const result = await bedrockagentruntime.invokeAgent({/** params **/}).promise();

    const events = result.completion;

    for await (const event of events) {
      // Check the top-level field to determine which event this is.
      if (event.accessDeniedException) {
        // handle accessDeniedException event
      } else if (event.badGatewayException) {
        // handle badGatewayException event
      } else if (event.chunk) {
        // handle chunk event
      } else if (event.conflictException) {
        // handle conflictException event
      } else if (event.dependencyFailedException) {
        // handle dependencyFailedException event
      } else if (event.files) {
        // handle files event
      } else if (event.internalServerException) {
        // handle internalServerException event
      } else if (event.resourceNotFoundException) {
        // handle resourceNotFoundException event
      } else if (event.returnControl) {
        // handle returnControl event
      } else if (event.serviceQuotaExceededException) {
        // handle serviceQuotaExceededException event
      } else if (event.throttlingException) {
        // handle throttlingException event
      } else if (event.trace) {
        // handle trace event
      } else if (event.validationException) {
        // handle validationException event
      }
    }
  } catch (err) {
    // handle error
  }
}

Calling the invokeAgent operation

var params = {
  agentAliasId: 'STRING_VALUE', /* required */
  agentId: 'STRING_VALUE', /* required */
  sessionId: 'STRING_VALUE', /* required */
  enableTrace: true || false,
  endSession: true || false,
  inputText: 'STRING_VALUE',
  memoryId: 'STRING_VALUE',
  sessionState: {
    files: [
      {
        name: 'STRING_VALUE', /* required */
        source: { /* required */
          sourceType: S3 | BYTE_CONTENT, /* required */
          byteContent: {
            data: Buffer.from('...') || 'STRING_VALUE' /* Strings will be Base-64 encoded on your behalf */, /* required */
            mediaType: 'STRING_VALUE' /* required */
          },
          s3Location: {
            uri: 'STRING_VALUE' /* required */
          }
        },
        useCase: CODE_INTERPRETER | CHAT /* required */
      },
      /* more items */
    ],
    invocationId: 'STRING_VALUE',
    knowledgeBaseConfigurations: [
      {
        knowledgeBaseId: 'STRING_VALUE', /* required */
        retrievalConfiguration: { /* required */
          vectorSearchConfiguration: { /* required */
            filter: { /* RetrievalFilter */
              andAll: [
                /* recursive RetrievalFilter */,
                /* more items */
              ],
              equals: {
                key: 'STRING_VALUE', /* required */
                value: { /* required */
                }
              },
              greaterThan: {
                key: 'STRING_VALUE', /* required */
                value: { /* required */
                }
              },
              greaterThanOrEquals: {
                key: 'STRING_VALUE', /* required */
                value: { /* required */
                }
              },
              in: {
                key: 'STRING_VALUE', /* required */
                value: { /* required */
                }
              },
              lessThan: {
                key: 'STRING_VALUE', /* required */
                value: { /* required */
                }
              },
              lessThanOrEquals: {
                key: 'STRING_VALUE', /* required */
                value: { /* required */
                }
              },
              listContains: {
                key: 'STRING_VALUE', /* required */
                value: { /* required */
                }
              },
              notEquals: {
                key: 'STRING_VALUE', /* required */
                value: { /* required */
                }
              },
              notIn: {
                key: 'STRING_VALUE', /* required */
                value: { /* required */
                }
              },
              orAll: [
                /* recursive RetrievalFilter */,
                /* more items */
              ],
              startsWith: {
                key: 'STRING_VALUE', /* required */
                value: { /* required */
                }
              },
              stringContains: {
                key: 'STRING_VALUE', /* required */
                value: { /* required */
                }
              }
            },
            numberOfResults: 'NUMBER_VALUE',
            overrideSearchType: HYBRID | SEMANTIC
          }
        }
      },
      /* more items */
    ],
    promptSessionAttributes: {
      '<String>': 'STRING_VALUE',
      /* '<String>': ... */
    },
    returnControlInvocationResults: [
      {
        apiResult: {
          actionGroup: 'STRING_VALUE', /* required */
          apiPath: 'STRING_VALUE',
          confirmationState: CONFIRM | DENY,
          httpMethod: 'STRING_VALUE',
          httpStatusCode: 'NUMBER_VALUE',
          responseBody: {
            '<String>': {
              body: 'STRING_VALUE'
            },
            /* '<String>': ... */
          },
          responseState: FAILURE | REPROMPT
        },
        functionResult: {
          actionGroup: 'STRING_VALUE', /* required */
          confirmationState: CONFIRM | DENY,
          function: 'STRING_VALUE',
          responseBody: {
            '<String>': {
              body: 'STRING_VALUE'
            },
            /* '<String>': ... */
          },
          responseState: FAILURE | REPROMPT
        }
      },
      /* more items */
    ],
    sessionAttributes: {
      '<String>': 'STRING_VALUE',
      /* '<String>': ... */
    }
  }
};
bedrockagentruntime.invokeAgent(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • agentAliasId — (String)

      The alias of the agent to use.

    • agentId — (String)

      The unique identifier of the agent to use.

    • enableTrace — (Boolean)

      Specifies whether to turn on the trace or not to track the agent's reasoning process. For more information, see Trace enablement.

    • endSession — (Boolean)

      Specifies whether to end the session with the agent or not.

    • inputText — (String)

      The prompt text to send the agent.

      Note: If you include returnControlInvocationResults in the sessionState field, the inputText field will be ignored.
    • memoryId — (String)

      The unique identifier of the agent memory.

    • sessionId — (String)

      The unique identifier of the session. Use the same value across requests to continue the same conversation.

    • sessionState — (map)

      Contains parameters that specify various attributes of the session. For more information, see Control session context.

      Note: If you include returnControlInvocationResults in the sessionState field, the inputText field will be ignored.
      • files — (Array<map>)

        Contains information about the files used by code interpreter.

        • namerequired — (String)

          The name of the source file.

        • sourcerequired — (map)

          Specifies where the files are located.

          • byteContent — (map)

            The data and the text of the attached files.

            • datarequired — (Buffer, Typed Array, Blob, String)

              The raw bytes of the file to attach. The maximum size of all files that is attached is 10MB. You can attach a maximum of 5 files.

            • mediaTyperequired — (String)

              The MIME type of data contained in the file used for chat.

          • s3Location — (map)

            The s3 location of the files to attach.

            • urirequired — (String)

              The uri of the s3 object.

          • sourceTyperequired — (String)

            The source type of the files to attach.

            Possible values include:
            • "S3"
            • "BYTE_CONTENT"
        • useCaserequired — (String)

          Specifies how the source files will be used by the code interpreter.

          Possible values include:
          • "CODE_INTERPRETER"
          • "CHAT"
      • invocationId — (String)

        The identifier of the invocation of an action. This value must match the invocationId returned in the InvokeAgent response for the action whose results are provided in the returnControlInvocationResults field. For more information, see Return control to the agent developer and Control session context.

      • knowledgeBaseConfigurations — (Array<map>)

        An array of configurations, each of which applies to a knowledge base attached to the agent.

        • knowledgeBaseIdrequired — (String)

          The unique identifier for a knowledge base attached to the agent.

        • retrievalConfigurationrequired — (map)

          The configurations to apply to the knowledge base during query. For more information, see Query configurations.

          • vectorSearchConfigurationrequired — (map)

            Contains details about how the results from the vector search should be returned. For more information, see Query configurations.

            • filter — (map)

              Specifies the filters to use on the metadata in the knowledge base data sources before returning results. For more information, see Query configurations.

              • andAll — (Array<map>)

                Knowledge base data sources are returned if their metadata attributes fulfill all the filter conditions inside this list.

              • equals — (map)

                Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value matches the value in this object.

                The following example would return data sources with an animal attribute whose value is cat:

                "equals": { "key": "animal", "value": "cat" }

                • keyrequired — (String)

                  The name that the metadata attribute must match.

                • valuerequired — (map)

                  The value to whcih to compare the value of the metadata attribute.

              • greaterThan — (map)

                Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value is greater than the value in this object.

                The following example would return data sources with an year attribute whose value is greater than 1989:

                "greaterThan": { "key": "year", "value": 1989 }

                • keyrequired — (String)

                  The name that the metadata attribute must match.

                • valuerequired — (map)

                  The value to whcih to compare the value of the metadata attribute.

              • greaterThanOrEquals — (map)

                Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value is greater than or equal to the value in this object.

                The following example would return data sources with an year attribute whose value is greater than or equal to 1989:

                "greaterThanOrEquals": { "key": "year", "value": 1989 }

                • keyrequired — (String)

                  The name that the metadata attribute must match.

                • valuerequired — (map)

                  The value to whcih to compare the value of the metadata attribute.

              • in — (map)

                Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value is in the list specified in the value in this object.

                The following example would return data sources with an animal attribute that is either cat or dog:

                "in": { "key": "animal", "value": ["cat", "dog"] }

                • keyrequired — (String)

                  The name that the metadata attribute must match.

                • valuerequired — (map)

                  The value to whcih to compare the value of the metadata attribute.

              • lessThan — (map)

                Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value is less than the value in this object.

                The following example would return data sources with an year attribute whose value is less than to 1989.

                "lessThan": { "key": "year", "value": 1989 }

                • keyrequired — (String)

                  The name that the metadata attribute must match.

                • valuerequired — (map)

                  The value to whcih to compare the value of the metadata attribute.

              • lessThanOrEquals — (map)

                Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value is less than or equal to the value in this object.

                The following example would return data sources with an year attribute whose value is less than or equal to 1989.

                "lessThanOrEquals": { "key": "year", "value": 1989 }

                • keyrequired — (String)

                  The name that the metadata attribute must match.

                • valuerequired — (map)

                  The value to whcih to compare the value of the metadata attribute.

              • listContains — (map)

                Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value is a list that contains the value as one of its members.

                The following example would return data sources with an animals attribute that is a list containing a cat member (for example ["dog", "cat"]).

                "listContains": { "key": "animals", "value": "cat" }

                • keyrequired — (String)

                  The name that the metadata attribute must match.

                • valuerequired — (map)

                  The value to whcih to compare the value of the metadata attribute.

              • notEquals — (map)

                Knowledge base data sources that contain a metadata attribute whose name matches the key and whose value doesn't match the value in this object are returned.

                The following example would return data sources that don't contain an animal attribute whose value is cat.

                "notEquals": { "key": "animal", "value": "cat" }

                • keyrequired — (String)

                  The name that the metadata attribute must match.

                • valuerequired — (map)

                  The value to whcih to compare the value of the metadata attribute.

              • notIn — (map)

                Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value isn't in the list specified in the value in this object.

                The following example would return data sources whose animal attribute is neither cat nor dog.

                "notIn": { "key": "animal", "value": ["cat", "dog"] }

                • keyrequired — (String)

                  The name that the metadata attribute must match.

                • valuerequired — (map)

                  The value to whcih to compare the value of the metadata attribute.

              • orAll — (Array<map>)

                Knowledge base data sources are returned if their metadata attributes fulfill at least one of the filter conditions inside this list.

              • startsWith — (map)

                Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value starts with the value in this object. This filter is currently only supported for Amazon OpenSearch Serverless vector stores.

                The following example would return data sources with an animal attribute starts with ca (for example, cat or camel).

                "startsWith": { "key": "animal", "value": "ca" }

                • keyrequired — (String)

                  The name that the metadata attribute must match.

                • valuerequired — (map)

                  The value to whcih to compare the value of the metadata attribute.

              • stringContains — (map)

                Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value is one of the following:

                • A string that contains the value as a substring. The following example would return data sources with an animal attribute that contains the substring at (for example cat).

                  "stringContains": { "key": "animal", "value": "at" }

                • A list with a member that contains the value as a substring. The following example would return data sources with an animals attribute that is a list containing a member that contains the substring at (for example ["dog", "cat"]).

                  "stringContains": { "key": "animals", "value": "at" }

                • keyrequired — (String)

                  The name that the metadata attribute must match.

                • valuerequired — (map)

                  The value to whcih to compare the value of the metadata attribute.

            • numberOfResults — (Integer)

              The number of source chunks to retrieve.

            • overrideSearchType — (String)

              By default, Amazon Bedrock decides a search strategy for you. If you're using an Amazon OpenSearch Serverless vector store that contains a filterable text field, you can specify whether to query the knowledge base with a HYBRID search using both vector embeddings and raw text, or SEMANTIC search using only vector embeddings. For other vector store configurations, only SEMANTIC search is available. For more information, see Test a knowledge base.

              Possible values include:
              • "HYBRID"
              • "SEMANTIC"
      • promptSessionAttributes — (map<String>)

        Contains attributes that persist across a prompt and the values of those attributes. These attributes replace the $prompt_session_attributes$ placeholder variable in the orchestration prompt template. For more information, see Prompt template placeholder variables.

      • returnControlInvocationResults — (Array<map>)

        Contains information about the results from the action group invocation. For more information, see Return control to the agent developer and Control session context.

        Note: If you include this field, the inputText field will be ignored.
        • apiResult — (map)

          The result from the API response from the action group invocation.

          • actionGrouprequired — (String)

            The action group that the API operation belongs to.

          • apiPath — (String)

            The path to the API operation.

          • confirmationState — (String)

            Controls the API operations or functions to invoke based on the user confirmation.

            Possible values include:
            • "CONFIRM"
            • "DENY"
          • httpMethod — (String)

            The HTTP method for the API operation.

          • httpStatusCode — (Integer)

            http status code from API execution response (for example: 200, 400, 500).

          • responseBody — (map<map>)

            The response body from the API operation. The key of the object is the content type (currently, only TEXT is supported). The response may be returned directly or from the Lambda function.

            • body — (String)

              The body of the API response.

          • responseState — (String)

            Controls the final response state returned to end user when API/Function execution failed. When this state is FAILURE, the request would fail with dependency failure exception. When this state is REPROMPT, the API/function response will be sent to model for re-prompt

            Possible values include:
            • "FAILURE"
            • "REPROMPT"
        • functionResult — (map)

          The result from the function from the action group invocation.

          • actionGrouprequired — (String)

            The action group that the function belongs to.

          • confirmationState — (String)

            Contains the user confirmation information about the function that was called.

            Possible values include:
            • "CONFIRM"
            • "DENY"
          • function — (String)

            The name of the function that was called.

          • responseBody — (map<map>)

            The response from the function call using the parameters. The key of the object is the content type (currently, only TEXT is supported). The response may be returned directly or from the Lambda function.

            • body — (String)

              The body of the API response.

          • responseState — (String)

            Controls the final response state returned to end user when API/Function execution failed. When this state is FAILURE, the request would fail with dependency failure exception. When this state is REPROMPT, the API/function response will be sent to model for re-prompt

            Possible values include:
            • "FAILURE"
            • "REPROMPT"
      • sessionAttributes — (map<String>)

        Contains attributes that persist across a session and the values of those attributes.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • completion — (ReadableStream<Events> | Array<Events>)

        The agent's response to the user prompt.

        completion is an object-mode Readable stream in Node.js v0.10.x and higher. Attach a listener to the data event to receive events. completion is an array of events in browsers. The possible events that may be returned are listed below. Note that the top-level field in each event matches the event name.
        • accessDeniedException — (map)

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

          • message — (String)
        • badGatewayException — (map)

          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.

        • chunk — (map)

          Contains a part of an agent response and citations for it.

          • attribution — (map)

            Contains citations for a part of an agent response.

            • citations — (Array<map>)

              A list of citations and related information for a part of an agent response.

              • generatedResponsePart — (map)

                Contains the generated response and metadata

                • textResponsePart — (map)

                  Contains metadata about a textual part of the generated response that is accompanied by a citation.

                  • span — (map)

                    Contains information about where the text with a citation begins and ends in the generated output.

                    • end — (Integer)

                      Where the text with a citation ends in the generated output.

                    • start — (Integer)

                      Where the text with a citation starts in the generated output.

                  • text — (String)

                    The part of the generated text that contains a citation.

              • retrievedReferences — (Array<map>)

                Contains metadata about the sources cited for the generated response.

                • content — (map)

                  Contains the cited text from the data source.

                  • textrequired — (String)

                    The cited text from the data source.

                • location — (map)

                  Contains information about the location of the data source.

                  • confluenceLocation — (map)

                    The Confluence data source location.

                    • url — (String)

                      The Confluence host URL for the data source location.

                  • s3Location — (map)

                    The S3 data source location.

                    • uri — (String)

                      The S3 URI for the data source location.

                  • salesforceLocation — (map)

                    The Salesforce data source location.

                    • url — (String)

                      The Salesforce host URL for the data source location.

                  • sharePointLocation — (map)

                    The SharePoint data source location.

                    • url — (String)

                      The SharePoint site URL for the data source location.

                  • typerequired — (String)

                    The type of data source location.

                    Possible values include:
                    • "S3"
                    • "WEB"
                    • "CONFLUENCE"
                    • "SALESFORCE"
                    • "SHAREPOINT"
                  • webLocation — (map)

                    The web URL/URLs data source location.

                    • url — (String)

                      The web URL/URLs for the data source location.

                • metadata — (map<map>)

                  Contains metadata attributes and their values for the file in the data source. For more information, see Metadata and filtering.

          • bytes — (Buffer, Typed Array, Blob, String)

            A part of the agent response in bytes.

        • conflictException — (map)

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

          • message — (String)
        • dependencyFailedException — (map)

          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.

        • files — (map)

          Contains intermediate response for code interpreter if any files have been generated.

          • files — (Array<map>)

            Files containing intermediate response for the user.

            • bytes — (Buffer, Typed Array, Blob, String)

              The byte count of files that contains response from code interpreter.

            • name — (String)

              The name of the file containing response from code interpreter.

            • type — (String)

              The type of file that contains response from the code interpreter.

        • internalServerException — (map)

          An internal server error occurred. Retry your request.

          • message — (String)
        • resourceNotFoundException — (map)

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

          • message — (String)
        • returnControl — (map)

          Contains the parameters and information that the agent elicited from the customer to carry out an action. This information is returned to the system and can be used in your own setup for fulfilling the action.

          • invocationId — (String)

            The identifier of the action group invocation.

          • invocationInputs — (Array<map>)

            A list of objects that contain information about the parameters and inputs that need to be sent into the API operation or function, based on what the agent determines from its session with the user.

            • apiInvocationInput — (map)

              Contains information about the API operation that the agent predicts should be called.

              • actionGrouprequired — (String)

                The action group that the API operation belongs to.

              • actionInvocationType — (String)

                Contains information about the API operation to invoke.

                Possible values include:
                • "RESULT"
                • "USER_CONFIRMATION"
                • "USER_CONFIRMATION_AND_RESULT"
              • apiPath — (String)

                The path to the API operation.

              • httpMethod — (String)

                The HTTP method of the API operation.

              • parameters — (Array<map>)

                The parameters to provide for the API request, as the agent elicited from the user.

                • name — (String)

                  The name of the parameter.

                • type — (String)

                  The data type for the parameter.

                • value — (String)

                  The value of the parameter.

              • requestBody — (map)

                The request body to provide for the API request, as the agent elicited from the user.

                • content — (map<map>)

                  The content of the request body. The key of the object in this field is a media type defining the format of the request body.

                  • properties — (Array<map>)

                    A list of parameters in the request body.

                    • name — (String)

                      The name of the parameter.

                    • type — (String)

                      The type of the parameter.

                    • value — (String)

                      The value of the parameter.

            • functionInvocationInput — (map)

              Contains information about the function that the agent predicts should be called.

              • actionGrouprequired — (String)

                The action group that the function belongs to.

              • actionInvocationType — (String)

                Contains information about the function to invoke,

                Possible values include:
                • "RESULT"
                • "USER_CONFIRMATION"
                • "USER_CONFIRMATION_AND_RESULT"
              • function — (String)

                The name of the function.

              • parameters — (Array<map>)

                A list of parameters of the function.

                • name — (String)

                  The name of the parameter.

                • type — (String)

                  The data type of the parameter.

                • value — (String)

                  The value of the parameter.

        • serviceQuotaExceededException — (map)

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

          • message — (String)
        • throttlingException — (map)

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

          • message — (String)
        • trace — (map)

          Contains information about the agent and session, alongside the agent's reasoning process and results from calling actions and querying knowledge bases and metadata about the trace. You can use the trace to understand how the agent arrived at the response it provided the customer. For more information, see Trace events.

          • agentAliasId — (String)

            The unique identifier of the alias of the agent.

          • agentId — (String)

            The unique identifier of the agent.

          • agentVersion — (String)

            The version of the agent.

          • sessionId — (String)

            The unique identifier of the session with the agent.

          • trace — (map)

            Contains one part of the agent's reasoning process and results from calling API actions and querying knowledge bases. You can use the trace to understand how the agent arrived at the response it provided the customer. For more information, see Trace enablement.

            • failureTrace — (map)

              Contains information about the failure of the interaction.

              • failureReason — (String)

                The reason the interaction failed.

              • traceId — (String)

                The unique identifier of the trace.

            • guardrailTrace — (map)

              The trace details for a trace defined in the Guardrail filter.

              • action — (String)

                The trace action details used with the Guardrail.

                Possible values include:
                • "INTERVENED"
                • "NONE"
              • inputAssessments — (Array<map>)

                The details of the input assessments used in the Guardrail Trace.

                • contentPolicy — (map)

                  Content policy details of the Guardrail.

                  • filters — (Array<map>)

                    The filter details of the policy assessment used in the Guardrails filter.

                    • action — (String)

                      The action placed on the content by the Guardrail filter.

                      Possible values include:
                      • "BLOCKED"
                    • confidence — (String)

                      The confidence level regarding the content detected in the filter by the Guardrail.

                      Possible values include:
                      • "NONE"
                      • "LOW"
                      • "MEDIUM"
                      • "HIGH"
                    • type — (String)

                      The type of content detected in the filter by the Guardrail.

                      Possible values include:
                      • "INSULTS"
                      • "HATE"
                      • "SEXUAL"
                      • "VIOLENCE"
                      • "MISCONDUCT"
                      • "PROMPT_ATTACK"
                • sensitiveInformationPolicy — (map)

                  Sensitive Information policy details of Guardrail.

                  • piiEntities — (Array<map>)

                    The details of the PII entities used in the sensitive policy assessment for the Guardrail.

                    • action — (String)

                      The action of the Guardrail filter to identify and remove PII.

                      Possible values include:
                      • "BLOCKED"
                      • "ANONYMIZED"
                    • match — (String)

                      The match to settings in the Guardrail filter to identify and remove PII.

                    • type — (String)

                      The type of PII the Guardrail filter has identified and removed.

                      Possible values include:
                      • "ADDRESS"
                      • "AGE"
                      • "AWS_ACCESS_KEY"
                      • "AWS_SECRET_KEY"
                      • "CA_HEALTH_NUMBER"
                      • "CA_SOCIAL_INSURANCE_NUMBER"
                      • "CREDIT_DEBIT_CARD_CVV"
                      • "CREDIT_DEBIT_CARD_EXPIRY"
                      • "CREDIT_DEBIT_CARD_NUMBER"
                      • "DRIVER_ID"
                      • "EMAIL"
                      • "INTERNATIONAL_BANK_ACCOUNT_NUMBER"
                      • "IP_ADDRESS"
                      • "LICENSE_PLATE"
                      • "MAC_ADDRESS"
                      • "NAME"
                      • "PASSWORD"
                      • "PHONE"
                      • "PIN"
                      • "SWIFT_CODE"
                      • "UK_NATIONAL_HEALTH_SERVICE_NUMBER"
                      • "UK_NATIONAL_INSURANCE_NUMBER"
                      • "UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER"
                      • "URL"
                      • "USERNAME"
                      • "US_BANK_ACCOUNT_NUMBER"
                      • "US_BANK_ROUTING_NUMBER"
                      • "US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER"
                      • "US_PASSPORT_NUMBER"
                      • "US_SOCIAL_SECURITY_NUMBER"
                      • "VEHICLE_IDENTIFICATION_NUMBER"
                  • regexes — (Array<map>)

                    The details of the regexes used in the sensitive policy assessment for the Guardrail.

                    • action — (String)

                      The action details for the regex filter used in the Guardrail.

                      Possible values include:
                      • "BLOCKED"
                      • "ANONYMIZED"
                    • match — (String)

                      The match details for the regex filter used in the Guardrail.

                    • name — (String)

                      The name details for the regex filter used in the Guardrail.

                    • regex — (String)

                      The regex details for the regex filter used in the Guardrail.

                • topicPolicy — (map)

                  Topic policy details of the Guardrail.

                  • topics — (Array<map>)

                    The topic details of the policy assessment used in the Guardrail.

                    • action — (String)

                      The action details on a specific topic in the Guardrail.

                      Possible values include:
                      • "BLOCKED"
                    • name — (String)

                      The name details on a specific topic in the Guardrail.

                    • type — (String)

                      The type details on a specific topic in the Guardrail.

                      Possible values include:
                      • "DENY"
                • wordPolicy — (map)

                  Word policy details of the Guardrail.

                  • customWords — (Array<map>)

                    The custom word details for words defined in the Guardrail filter.

                    • action — (String)

                      The action details for the custom word filter in the Guardrail.

                      Possible values include:
                      • "BLOCKED"
                    • match — (String)

                      The match details for the custom word filter in the Guardrail.

                  • managedWordLists — (Array<map>)

                    The managed word lists for words defined in the Guardrail filter.

                    • action — (String)

                      The action details for the managed word filter in the Guardrail.

                      Possible values include:
                      • "BLOCKED"
                    • match — (String)

                      The match details for the managed word filter in the Guardrail.

                    • type — (String)

                      The type details for the managed word filter in the Guardrail.

                      Possible values include:
                      • "PROFANITY"
              • outputAssessments — (Array<map>)

                The details of the output assessments used in the Guardrail Trace.

                • contentPolicy — (map)

                  Content policy details of the Guardrail.

                  • filters — (Array<map>)

                    The filter details of the policy assessment used in the Guardrails filter.

                    • action — (String)

                      The action placed on the content by the Guardrail filter.

                      Possible values include:
                      • "BLOCKED"
                    • confidence — (String)

                      The confidence level regarding the content detected in the filter by the Guardrail.

                      Possible values include:
                      • "NONE"
                      • "LOW"
                      • "MEDIUM"
                      • "HIGH"
                    • type — (String)

                      The type of content detected in the filter by the Guardrail.

                      Possible values include:
                      • "INSULTS"
                      • "HATE"
                      • "SEXUAL"
                      • "VIOLENCE"
                      • "MISCONDUCT"
                      • "PROMPT_ATTACK"
                • sensitiveInformationPolicy — (map)

                  Sensitive Information policy details of Guardrail.

                  • piiEntities — (Array<map>)

                    The details of the PII entities used in the sensitive policy assessment for the Guardrail.

                    • action — (String)

                      The action of the Guardrail filter to identify and remove PII.

                      Possible values include:
                      • "BLOCKED"
                      • "ANONYMIZED"
                    • match — (String)

                      The match to settings in the Guardrail filter to identify and remove PII.

                    • type — (String)

                      The type of PII the Guardrail filter has identified and removed.

                      Possible values include:
                      • "ADDRESS"
                      • "AGE"
                      • "AWS_ACCESS_KEY"
                      • "AWS_SECRET_KEY"
                      • "CA_HEALTH_NUMBER"
                      • "CA_SOCIAL_INSURANCE_NUMBER"
                      • "CREDIT_DEBIT_CARD_CVV"
                      • "CREDIT_DEBIT_CARD_EXPIRY"
                      • "CREDIT_DEBIT_CARD_NUMBER"
                      • "DRIVER_ID"
                      • "EMAIL"
                      • "INTERNATIONAL_BANK_ACCOUNT_NUMBER"
                      • "IP_ADDRESS"
                      • "LICENSE_PLATE"
                      • "MAC_ADDRESS"
                      • "NAME"
                      • "PASSWORD"
                      • "PHONE"
                      • "PIN"
                      • "SWIFT_CODE"
                      • "UK_NATIONAL_HEALTH_SERVICE_NUMBER"
                      • "UK_NATIONAL_INSURANCE_NUMBER"
                      • "UK_UNIQUE_TAXPAYER_REFERENCE_NUMBER"
                      • "URL"
                      • "USERNAME"
                      • "US_BANK_ACCOUNT_NUMBER"
                      • "US_BANK_ROUTING_NUMBER"
                      • "US_INDIVIDUAL_TAX_IDENTIFICATION_NUMBER"
                      • "US_PASSPORT_NUMBER"
                      • "US_SOCIAL_SECURITY_NUMBER"
                      • "VEHICLE_IDENTIFICATION_NUMBER"
                  • regexes — (Array<map>)

                    The details of the regexes used in the sensitive policy assessment for the Guardrail.

                    • action — (String)

                      The action details for the regex filter used in the Guardrail.

                      Possible values include:
                      • "BLOCKED"
                      • "ANONYMIZED"
                    • match — (String)

                      The match details for the regex filter used in the Guardrail.

                    • name — (String)

                      The name details for the regex filter used in the Guardrail.

                    • regex — (String)

                      The regex details for the regex filter used in the Guardrail.

                • topicPolicy — (map)

                  Topic policy details of the Guardrail.

                  • topics — (Array<map>)

                    The topic details of the policy assessment used in the Guardrail.

                    • action — (String)

                      The action details on a specific topic in the Guardrail.

                      Possible values include:
                      • "BLOCKED"
                    • name — (String)

                      The name details on a specific topic in the Guardrail.

                    • type — (String)

                      The type details on a specific topic in the Guardrail.

                      Possible values include:
                      • "DENY"
                • wordPolicy — (map)

                  Word policy details of the Guardrail.

                  • customWords — (Array<map>)

                    The custom word details for words defined in the Guardrail filter.

                    • action — (String)

                      The action details for the custom word filter in the Guardrail.

                      Possible values include:
                      • "BLOCKED"
                    • match — (String)

                      The match details for the custom word filter in the Guardrail.

                  • managedWordLists — (Array<map>)

                    The managed word lists for words defined in the Guardrail filter.

                    • action — (String)

                      The action details for the managed word filter in the Guardrail.

                      Possible values include:
                      • "BLOCKED"
                    • match — (String)

                      The match details for the managed word filter in the Guardrail.

                    • type — (String)

                      The type details for the managed word filter in the Guardrail.

                      Possible values include:
                      • "PROFANITY"
              • traceId — (String)

                The details of the trace Id used in the Guardrail Trace.

            • orchestrationTrace — (map)

              Details about the orchestration step, in which the agent determines the order in which actions are executed and which knowledge bases are retrieved.

              • invocationInput — (map)

                Contains information pertaining to the action group or knowledge base that is being invoked.

                • actionGroupInvocationInput — (map)

                  Contains information about the action group to be invoked.

                  • actionGroupName — (String)

                    The name of the action group.

                  • apiPath — (String)

                    The path to the API to call, based off the action group.

                  • executionType — (String)

                    How fulfillment of the action is handled. For more information, see Handling fulfillment of the action.

                    Possible values include:
                    • "LAMBDA"
                    • "RETURN_CONTROL"
                  • function — (String)

                    The function in the action group to call.

                  • invocationId — (String)

                    The unique identifier of the invocation. Only returned if the executionType is RETURN_CONTROL.

                  • parameters — (Array<map>)

                    The parameters in the Lambda input event.

                    • name — (String)

                      The name of the parameter.

                    • type — (String)

                      The type of the parameter.

                    • value — (String)

                      The value of the parameter.

                  • requestBody — (map)

                    The parameters in the request body for the Lambda input event.

                    • content — (map<Array<map>>)

                      The content in the request body.

                      • name — (String)

                        The name of the parameter.

                      • type — (String)

                        The type of the parameter.

                      • value — (String)

                        The value of the parameter.

                  • verb — (String)

                    The API method being used, based off the action group.

                • codeInterpreterInvocationInput — (map)

                  Contains information about the code interpreter to be invoked.

                  • code — (String)

                    The code for the code interpreter to use.

                  • files — (Array<String>)

                    Files that are uploaded for code interpreter to use.

                • invocationType — (String)

                  Specifies whether the agent is invoking an action group or a knowledge base.

                  Possible values include:
                  • "ACTION_GROUP"
                  • "KNOWLEDGE_BASE"
                  • "FINISH"
                  • "ACTION_GROUP_CODE_INTERPRETER"
                • knowledgeBaseLookupInput — (map)

                  Contains details about the knowledge base to look up and the query to be made.

                  • knowledgeBaseId — (String)

                    The unique identifier of the knowledge base to look up.

                  • text — (String)

                    The query made to the knowledge base.

                • traceId — (String)

                  The unique identifier of the trace.

              • modelInvocationInput — (map)

                The input for the orchestration step.

                • The type is ORCHESTRATION.

                • The text contains the prompt.

                • The inferenceConfiguration, parserMode, and overrideLambda values are set in the PromptOverrideConfiguration object that was set when the agent was created or updated.

                • inferenceConfiguration — (map)

                  Specifications about the inference parameters that were provided alongside the prompt. These are specified in the PromptOverrideConfiguration object that was set when the agent was created or updated. For more information, see Inference parameters for foundation models.

                  • maximumLength — (Integer)

                    The maximum number of tokens allowed in the generated response.

                  • stopSequences — (Array<String>)

                    A list of stop sequences. A stop sequence is a sequence of characters that causes the model to stop generating the response.

                  • temperature — (Float)

                    The likelihood of the model selecting higher-probability options while generating a response. A lower value makes the model more likely to choose higher-probability options, while a higher value makes the model more likely to choose lower-probability options.

                  • topK — (Integer)

                    While generating a response, the model determines the probability of the following token at each point of generation. The value that you set for topK is the number of most-likely candidates from which the model chooses the next token in the sequence. For example, if you set topK to 50, the model selects the next token from among the top 50 most likely choices.

                  • topP — (Float)

                    While generating a response, the model determines the probability of the following token at each point of generation. The value that you set for Top P determines the number of most-likely candidates from which the model chooses the next token in the sequence. For example, if you set topP to 0.8, the model only selects the next token from the top 80% of the probability distribution of next tokens.

                • overrideLambda — (String)

                  The ARN of the Lambda function to use when parsing the raw foundation model output in parts of the agent sequence.

                • parserMode — (String)

                  Specifies whether to override the default parser Lambda function when parsing the raw foundation model output in the part of the agent sequence defined by the promptType.

                  Possible values include:
                  • "DEFAULT"
                  • "OVERRIDDEN"
                • promptCreationMode — (String)

                  Specifies whether the default prompt template was OVERRIDDEN. If it was, the basePromptTemplate that was set in the PromptOverrideConfiguration object when the agent was created or updated is used instead.

                  Possible values include:
                  • "DEFAULT"
                  • "OVERRIDDEN"
                • text — (String)

                  The text that prompted the agent at this step.

                • traceId — (String)

                  The unique identifier of the trace.

                • type — (String)

                  The step in the agent sequence.

                  Possible values include:
                  • "PRE_PROCESSING"
                  • "ORCHESTRATION"
                  • "KNOWLEDGE_BASE_RESPONSE_GENERATION"
                  • "POST_PROCESSING"
              • modelInvocationOutput — (map)

                Contains information pertaining to the output from the foundation model that is being invoked.

                • metadata — (map)

                  Contains information about the foundation model output.

                  • usage — (map)

                    Contains details of the foundation model usage.

                    • inputTokens — (Integer)

                      Contains information about the input tokens from the foundation model usage.

                    • outputTokens — (Integer)

                      Contains information about the output tokens from the foundation model usage.

                • rawResponse — (map)

                  Contains details of the raw response from the foundation model output.

                  • content — (String)

                    The foundation model's raw output content.

                • traceId — (String)

                  The unique identifier of the trace.

              • observation — (map)

                Details about the observation (the output of the action group Lambda or knowledge base) made by the agent.

                • actionGroupInvocationOutput — (map)

                  Contains the JSON-formatted string returned by the API invoked by the action group.

                  • text — (String)

                    The JSON-formatted string returned by the API invoked by the action group.

                • codeInterpreterInvocationOutput — (map)

                  Contains the JSON-formatted string returned by the API invoked by the code interpreter.

                  • executionError — (String)

                    Contains the error returned from code execution.

                  • executionOutput — (String)

                    Contains the successful output returned from code execution

                  • executionTimeout — (Boolean)

                    Indicates if the execution of the code timed out.

                  • files — (Array<String>)

                    Contains output files, if generated by code execution.

                • finalResponse — (map)

                  Contains details about the response to the user.

                  • text — (String)

                    The text in the response to the user.

                • knowledgeBaseLookupOutput — (map)

                  Contains details about the results from looking up the knowledge base.

                  • retrievedReferences — (Array<map>)

                    Contains metadata about the sources cited for the generated response.

                    • content — (map)

                      Contains the cited text from the data source.

                      • textrequired — (String)

                        The cited text from the data source.

                    • location — (map)

                      Contains information about the location of the data source.

                      • confluenceLocation — (map)

                        The Confluence data source location.

                        • url — (String)

                          The Confluence host URL for the data source location.

                      • s3Location — (map)

                        The S3 data source location.

                        • uri — (String)

                          The S3 URI for the data source location.

                      • salesforceLocation — (map)

                        The Salesforce data source location.

                        • url — (String)

                          The Salesforce host URL for the data source location.

                      • sharePointLocation — (map)

                        The SharePoint data source location.

                        • url — (String)

                          The SharePoint site URL for the data source location.

                      • typerequired — (String)

                        The type of data source location.

                        Possible values include:
                        • "S3"
                        • "WEB"
                        • "CONFLUENCE"
                        • "SALESFORCE"
                        • "SHAREPOINT"
                      • webLocation — (map)

                        The web URL/URLs data source location.

                        • url — (String)

                          The web URL/URLs for the data source location.

                    • metadata — (map<map>)

                      Contains metadata attributes and their values for the file in the data source. For more information, see Metadata and filtering.

                • repromptResponse — (map)

                  Contains details about the response to reprompt the input.

                  • source — (String)

                    Specifies what output is prompting the agent to reprompt the input.

                    Possible values include:
                    • "ACTION_GROUP"
                    • "KNOWLEDGE_BASE"
                    • "PARSER"
                  • text — (String)

                    The text reprompting the input.

                • traceId — (String)

                  The unique identifier of the trace.

                • type — (String)

                  Specifies what kind of information the agent returns in the observation. The following values are possible.

                  • ACTION_GROUP – The agent returns the result of an action group.

                  • KNOWLEDGE_BASE – The agent returns information from a knowledge base.

                  • FINISH – The agent returns a final response to the user with no follow-up.

                  • ASK_USER – The agent asks the user a question.

                  • REPROMPT – The agent prompts the user again for the same information.

                  Possible values include:
                  • "ACTION_GROUP"
                  • "KNOWLEDGE_BASE"
                  • "FINISH"
                  • "ASK_USER"
                  • "REPROMPT"
              • rationale — (map)

                Details about the reasoning, based on the input, that the agent uses to justify carrying out an action group or getting information from a knowledge base.

                • text — (String)

                  The reasoning or thought process of the agent, based on the input.

                • traceId — (String)

                  The unique identifier of the trace step.

            • postProcessingTrace — (map)

              Details about the post-processing step, in which the agent shapes the response..

              • modelInvocationInput — (map)

                The input for the post-processing step.

                • The type is POST_PROCESSING.

                • The text contains the prompt.

                • The inferenceConfiguration, parserMode, and overrideLambda values are set in the PromptOverrideConfiguration object that was set when the agent was created or updated.

                • inferenceConfiguration — (map)

                  Specifications about the inference parameters that were provided alongside the prompt. These are specified in the PromptOverrideConfiguration object that was set when the agent was created or updated. For more information, see Inference parameters for foundation models.

                  • maximumLength — (Integer)

                    The maximum number of tokens allowed in the generated response.

                  • stopSequences — (Array<String>)

                    A list of stop sequences. A stop sequence is a sequence of characters that causes the model to stop generating the response.

                  • temperature — (Float)

                    The likelihood of the model selecting higher-probability options while generating a response. A lower value makes the model more likely to choose higher-probability options, while a higher value makes the model more likely to choose lower-probability options.

                  • topK — (Integer)

                    While generating a response, the model determines the probability of the following token at each point of generation. The value that you set for topK is the number of most-likely candidates from which the model chooses the next token in the sequence. For example, if you set topK to 50, the model selects the next token from among the top 50 most likely choices.

                  • topP — (Float)

                    While generating a response, the model determines the probability of the following token at each point of generation. The value that you set for Top P determines the number of most-likely candidates from which the model chooses the next token in the sequence. For example, if you set topP to 0.8, the model only selects the next token from the top 80% of the probability distribution of next tokens.

                • overrideLambda — (String)

                  The ARN of the Lambda function to use when parsing the raw foundation model output in parts of the agent sequence.

                • parserMode — (String)

                  Specifies whether to override the default parser Lambda function when parsing the raw foundation model output in the part of the agent sequence defined by the promptType.

                  Possible values include:
                  • "DEFAULT"
                  • "OVERRIDDEN"
                • promptCreationMode — (String)

                  Specifies whether the default prompt template was OVERRIDDEN. If it was, the basePromptTemplate that was set in the PromptOverrideConfiguration object when the agent was created or updated is used instead.

                  Possible values include:
                  • "DEFAULT"
                  • "OVERRIDDEN"
                • text — (String)

                  The text that prompted the agent at this step.

                • traceId — (String)

                  The unique identifier of the trace.

                • type — (String)

                  The step in the agent sequence.

                  Possible values include:
                  • "PRE_PROCESSING"
                  • "ORCHESTRATION"
                  • "KNOWLEDGE_BASE_RESPONSE_GENERATION"
                  • "POST_PROCESSING"
              • modelInvocationOutput — (map)

                The foundation model output from the post-processing step.

                • parsedResponse — (map)

                  Details about the response from the Lambda parsing of the output of the post-processing step.

                  • text — (String)

                    The text returned by the parser.

                • traceId — (String)

                  The unique identifier of the trace.

            • preProcessingTrace — (map)

              Details about the pre-processing step, in which the agent contextualizes and categorizes user inputs.

              • modelInvocationInput — (map)

                The input for the pre-processing step.

                • The type is PRE_PROCESSING.

                • The text contains the prompt.

                • The inferenceConfiguration, parserMode, and overrideLambda values are set in the PromptOverrideConfiguration object that was set when the agent was created or updated.

                • inferenceConfiguration — (map)

                  Specifications about the inference parameters that were provided alongside the prompt. These are specified in the PromptOverrideConfiguration object that was set when the agent was created or updated. For more information, see Inference parameters for foundation models.

                  • maximumLength — (Integer)

                    The maximum number of tokens allowed in the generated response.

                  • stopSequences — (Array<String>)

                    A list of stop sequences. A stop sequence is a sequence of characters that causes the model to stop generating the response.

                  • temperature — (Float)

                    The likelihood of the model selecting higher-probability options while generating a response. A lower value makes the model more likely to choose higher-probability options, while a higher value makes the model more likely to choose lower-probability options.

                  • topK — (Integer)

                    While generating a response, the model determines the probability of the following token at each point of generation. The value that you set for topK is the number of most-likely candidates from which the model chooses the next token in the sequence. For example, if you set topK to 50, the model selects the next token from among the top 50 most likely choices.

                  • topP — (Float)

                    While generating a response, the model determines the probability of the following token at each point of generation. The value that you set for Top P determines the number of most-likely candidates from which the model chooses the next token in the sequence. For example, if you set topP to 0.8, the model only selects the next token from the top 80% of the probability distribution of next tokens.

                • overrideLambda — (String)

                  The ARN of the Lambda function to use when parsing the raw foundation model output in parts of the agent sequence.

                • parserMode — (String)

                  Specifies whether to override the default parser Lambda function when parsing the raw foundation model output in the part of the agent sequence defined by the promptType.

                  Possible values include:
                  • "DEFAULT"
                  • "OVERRIDDEN"
                • promptCreationMode — (String)

                  Specifies whether the default prompt template was OVERRIDDEN. If it was, the basePromptTemplate that was set in the PromptOverrideConfiguration object when the agent was created or updated is used instead.

                  Possible values include:
                  • "DEFAULT"
                  • "OVERRIDDEN"
                • text — (String)

                  The text that prompted the agent at this step.

                • traceId — (String)

                  The unique identifier of the trace.

                • type — (String)

                  The step in the agent sequence.

                  Possible values include:
                  • "PRE_PROCESSING"
                  • "ORCHESTRATION"
                  • "KNOWLEDGE_BASE_RESPONSE_GENERATION"
                  • "POST_PROCESSING"
              • modelInvocationOutput — (map)

                The foundation model output from the pre-processing step.

                • parsedResponse — (map)

                  Details about the response from the Lambda parsing of the output of the pre-processing step.

                  • isValid — (Boolean)

                    Whether the user input is valid or not. If false, the agent doesn't proceed to orchestration.

                  • rationale — (String)

                    The text returned by the parsing of the pre-processing step, explaining the steps that the agent plans to take in orchestration, if the user input is valid.

                • traceId — (String)

                  The unique identifier of the trace.

        • validationException — (map)

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

          • message — (String)
      • contentType — (String)

        The MIME type of the input data in the request. The default value is application/json.

      • memoryId — (String)

        The unique identifier of the agent memory.

      • sessionId — (String)

        The unique identifier of the session with the agent.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

invokeFlow(params = {}, callback) ⇒ AWS.Request

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.

Service Reference:

Examples:

Node.js EventStream Example

// In Node.js, events are streamed and can be read as they arrive.
bedrockagentruntime.invokeFlow({/** params **/}, function(err, data) {
  if (err) {
    // handle error
    return console.error(err);
  }

  var eventStream = data.responseStream;

  eventStream.on('data', function(event) {
    // Check the top-level field to determine which event this is.
    if (event.accessDeniedException) {
      // handle accessDeniedException event
    } else if (event.badGatewayException) {
      // handle badGatewayException event
    } else if (event.conflictException) {
      // handle conflictException event
    } else if (event.dependencyFailedException) {
      // handle dependencyFailedException event
    } else if (event.flowCompletionEvent) {
      // handle flowCompletionEvent event
    } else if (event.flowOutputEvent) {
      // handle flowOutputEvent event
    } else if (event.internalServerException) {
      // handle internalServerException event
    } else if (event.resourceNotFoundException) {
      // handle resourceNotFoundException event
    } else if (event.serviceQuotaExceededException) {
      // handle serviceQuotaExceededException event
    } else if (event.throttlingException) {
      // handle throttlingException event
    } else if (event.validationException) {
      // handle validationException event
    }
  });
  eventStream.on('error', function(err) { /** Handle error events **/});
  eventStream.on('end', function() { /** Finished reading all events **/});
});

Browser EventStream Example

// In browsers, events aren't processed until the response is fully buffered.
// Events will be accessible as an array.
bedrockagentruntime.invokeFlow({/** params **/}, function(err, data) {
  if (err) {
    // handle error
    return console.error(err);
  }

  var events = data.responseStream;

  for (var event of events) {
    // Check the top-level field to determine which event this is.
    if (event.accessDeniedException) {
      // handle accessDeniedException event
    } else if (event.badGatewayException) {
      // handle badGatewayException event
    } else if (event.conflictException) {
      // handle conflictException event
    } else if (event.dependencyFailedException) {
      // handle dependencyFailedException event
    } else if (event.flowCompletionEvent) {
      // handle flowCompletionEvent event
    } else if (event.flowOutputEvent) {
      // handle flowOutputEvent event
    } else if (event.internalServerException) {
      // handle internalServerException event
    } else if (event.resourceNotFoundException) {
      // handle resourceNotFoundException event
    } else if (event.serviceQuotaExceededException) {
      // handle serviceQuotaExceededException event
    } else if (event.throttlingException) {
      // handle throttlingException event
    } else if (event.validationException) {
      // handle validationException event
    }
  }
});

Async Iterator EventStream Example (Experimental)

// In Node.js v10.x, Readable streams have experimental support for async iteration.
// Instead of listening to the event stream's 'data' event, you can use a for...await loop.
async function example() {
  try {
    const result = await bedrockagentruntime.invokeFlow({/** params **/}).promise();

    const events = result.responseStream;

    for await (const event of events) {
      // Check the top-level field to determine which event this is.
      if (event.accessDeniedException) {
        // handle accessDeniedException event
      } else if (event.badGatewayException) {
        // handle badGatewayException event
      } else if (event.conflictException) {
        // handle conflictException event
      } else if (event.dependencyFailedException) {
        // handle dependencyFailedException event
      } else if (event.flowCompletionEvent) {
        // handle flowCompletionEvent event
      } else if (event.flowOutputEvent) {
        // handle flowOutputEvent event
      } else if (event.internalServerException) {
        // handle internalServerException event
      } else if (event.resourceNotFoundException) {
        // handle resourceNotFoundException event
      } else if (event.serviceQuotaExceededException) {
        // handle serviceQuotaExceededException event
      } else if (event.throttlingException) {
        // handle throttlingException event
      } else if (event.validationException) {
        // handle validationException event
      }
    }
  } catch (err) {
    // handle error
  }
}

Calling the invokeFlow operation

var params = {
  flowAliasIdentifier: 'STRING_VALUE', /* required */
  flowIdentifier: 'STRING_VALUE', /* required */
  inputs: [ /* required */
    {
      content: { /* required */
        document: {
        }
      },
      nodeName: 'STRING_VALUE', /* required */
      nodeOutputName: 'STRING_VALUE' /* required */
    },
    /* more items */
  ]
};
bedrockagentruntime.invokeFlow(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • flowAliasIdentifier — (String)

      The unique identifier of the flow alias.

    • flowIdentifier — (String)

      The unique identifier of the flow.

    • inputs — (Array<map>)

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

      • contentrequired — (map)

        Contains information about an input into the prompt flow.

        • document — (map)

          The input to send to the prompt flow input node.

      • nodeNamerequired — (String)

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

      • nodeOutputNamerequired — (String)

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

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • responseStream — (ReadableStream<Events> | Array<Events>)

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

        responseStream is an object-mode Readable stream in Node.js v0.10.x and higher. Attach a listener to the data event to receive events. responseStream is an array of events in browsers. The possible events that may be returned are listed below. Note that the top-level field in each event matches the event name.
        • accessDeniedException — (map)

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

          • message — (String)
        • badGatewayException — (map)

          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 — (map)

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

          • message — (String)
        • dependencyFailedException — (map)

          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 — (map)

          Contains information about why the flow completed.

          • completionReasonrequired — (String)

            The reason that the flow completed.

            Possible values include:
            • "SUCCESS"
        • flowOutputEvent — (map)

          Contains information about an output from flow invocation.

          • contentrequired — (map)

            The content in the output.

            • document — (map)

              The content in the output.

          • nodeNamerequired — (String)

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

          • nodeTyperequired — (String)

            The type of the node that the output is from.

            Possible values include:
            • "FlowInputNode"
            • "FlowOutputNode"
            • "LambdaFunctionNode"
            • "KnowledgeBaseNode"
            • "PromptNode"
            • "ConditionNode"
            • "LexNode"
        • internalServerException — (map)

          An internal server error occurred. Retry your request.

          • message — (String)
        • resourceNotFoundException — (map)

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

          • message — (String)
        • serviceQuotaExceededException — (map)

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

          • message — (String)
        • throttlingException — (map)

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

          • message — (String)
        • validationException — (map)

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

          • message — (String)

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

retrieve(params = {}, callback) ⇒ AWS.Request

Queries a knowledge base and retrieves information from it.

Service Reference:

Examples:

Calling the retrieve operation

var params = {
  knowledgeBaseId: 'STRING_VALUE', /* required */
  retrievalQuery: { /* required */
    text: 'STRING_VALUE' /* required */
  },
  nextToken: 'STRING_VALUE',
  retrievalConfiguration: {
    vectorSearchConfiguration: { /* required */
      filter: { /* RetrievalFilter */
        andAll: [
          /* recursive RetrievalFilter */,
          /* more items */
        ],
        equals: {
          key: 'STRING_VALUE', /* required */
          value: { /* required */
          }
        },
        greaterThan: {
          key: 'STRING_VALUE', /* required */
          value: { /* required */
          }
        },
        greaterThanOrEquals: {
          key: 'STRING_VALUE', /* required */
          value: { /* required */
          }
        },
        in: {
          key: 'STRING_VALUE', /* required */
          value: { /* required */
          }
        },
        lessThan: {
          key: 'STRING_VALUE', /* required */
          value: { /* required */
          }
        },
        lessThanOrEquals: {
          key: 'STRING_VALUE', /* required */
          value: { /* required */
          }
        },
        listContains: {
          key: 'STRING_VALUE', /* required */
          value: { /* required */
          }
        },
        notEquals: {
          key: 'STRING_VALUE', /* required */
          value: { /* required */
          }
        },
        notIn: {
          key: 'STRING_VALUE', /* required */
          value: { /* required */
          }
        },
        orAll: [
          /* recursive RetrievalFilter */,
          /* more items */
        ],
        startsWith: {
          key: 'STRING_VALUE', /* required */
          value: { /* required */
          }
        },
        stringContains: {
          key: 'STRING_VALUE', /* required */
          value: { /* required */
          }
        }
      },
      numberOfResults: 'NUMBER_VALUE',
      overrideSearchType: HYBRID | SEMANTIC
    }
  }
};
bedrockagentruntime.retrieve(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • knowledgeBaseId — (String)

      The unique identifier of the knowledge base to query.

    • nextToken — (String)

      If there are more results than can fit in the response, the response returns a nextToken. Use this token in the nextToken field of another request to retrieve the next batch of results.

    • retrievalConfiguration — (map)

      Contains configurations for the knowledge base query and retrieval process. For more information, see Query configurations.

      • vectorSearchConfigurationrequired — (map)

        Contains details about how the results from the vector search should be returned. For more information, see Query configurations.

        • filter — (map)

          Specifies the filters to use on the metadata in the knowledge base data sources before returning results. For more information, see Query configurations.

          • andAll — (Array<map>)

            Knowledge base data sources are returned if their metadata attributes fulfill all the filter conditions inside this list.

          • equals — (map)

            Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value matches the value in this object.

            The following example would return data sources with an animal attribute whose value is cat:

            "equals": { "key": "animal", "value": "cat" }

            • keyrequired — (String)

              The name that the metadata attribute must match.

            • valuerequired — (map)

              The value to whcih to compare the value of the metadata attribute.

          • greaterThan — (map)

            Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value is greater than the value in this object.

            The following example would return data sources with an year attribute whose value is greater than 1989:

            "greaterThan": { "key": "year", "value": 1989 }

            • keyrequired — (String)

              The name that the metadata attribute must match.

            • valuerequired — (map)

              The value to whcih to compare the value of the metadata attribute.

          • greaterThanOrEquals — (map)

            Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value is greater than or equal to the value in this object.

            The following example would return data sources with an year attribute whose value is greater than or equal to 1989:

            "greaterThanOrEquals": { "key": "year", "value": 1989 }

            • keyrequired — (String)

              The name that the metadata attribute must match.

            • valuerequired — (map)

              The value to whcih to compare the value of the metadata attribute.

          • in — (map)

            Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value is in the list specified in the value in this object.

            The following example would return data sources with an animal attribute that is either cat or dog:

            "in": { "key": "animal", "value": ["cat", "dog"] }

            • keyrequired — (String)

              The name that the metadata attribute must match.

            • valuerequired — (map)

              The value to whcih to compare the value of the metadata attribute.

          • lessThan — (map)

            Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value is less than the value in this object.

            The following example would return data sources with an year attribute whose value is less than to 1989.

            "lessThan": { "key": "year", "value": 1989 }

            • keyrequired — (String)

              The name that the metadata attribute must match.

            • valuerequired — (map)

              The value to whcih to compare the value of the metadata attribute.

          • lessThanOrEquals — (map)

            Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value is less than or equal to the value in this object.

            The following example would return data sources with an year attribute whose value is less than or equal to 1989.

            "lessThanOrEquals": { "key": "year", "value": 1989 }

            • keyrequired — (String)

              The name that the metadata attribute must match.

            • valuerequired — (map)

              The value to whcih to compare the value of the metadata attribute.

          • listContains — (map)

            Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value is a list that contains the value as one of its members.

            The following example would return data sources with an animals attribute that is a list containing a cat member (for example ["dog", "cat"]).

            "listContains": { "key": "animals", "value": "cat" }

            • keyrequired — (String)

              The name that the metadata attribute must match.

            • valuerequired — (map)

              The value to whcih to compare the value of the metadata attribute.

          • notEquals — (map)

            Knowledge base data sources that contain a metadata attribute whose name matches the key and whose value doesn't match the value in this object are returned.

            The following example would return data sources that don't contain an animal attribute whose value is cat.

            "notEquals": { "key": "animal", "value": "cat" }

            • keyrequired — (String)

              The name that the metadata attribute must match.

            • valuerequired — (map)

              The value to whcih to compare the value of the metadata attribute.

          • notIn — (map)

            Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value isn't in the list specified in the value in this object.

            The following example would return data sources whose animal attribute is neither cat nor dog.

            "notIn": { "key": "animal", "value": ["cat", "dog"] }

            • keyrequired — (String)

              The name that the metadata attribute must match.

            • valuerequired — (map)

              The value to whcih to compare the value of the metadata attribute.

          • orAll — (Array<map>)

            Knowledge base data sources are returned if their metadata attributes fulfill at least one of the filter conditions inside this list.

          • startsWith — (map)

            Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value starts with the value in this object. This filter is currently only supported for Amazon OpenSearch Serverless vector stores.

            The following example would return data sources with an animal attribute starts with ca (for example, cat or camel).

            "startsWith": { "key": "animal", "value": "ca" }

            • keyrequired — (String)

              The name that the metadata attribute must match.

            • valuerequired — (map)

              The value to whcih to compare the value of the metadata attribute.

          • stringContains — (map)

            Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value is one of the following:

            • A string that contains the value as a substring. The following example would return data sources with an animal attribute that contains the substring at (for example cat).

              "stringContains": { "key": "animal", "value": "at" }

            • A list with a member that contains the value as a substring. The following example would return data sources with an animals attribute that is a list containing a member that contains the substring at (for example ["dog", "cat"]).

              "stringContains": { "key": "animals", "value": "at" }

            • keyrequired — (String)

              The name that the metadata attribute must match.

            • valuerequired — (map)

              The value to whcih to compare the value of the metadata attribute.

        • numberOfResults — (Integer)

          The number of source chunks to retrieve.

        • overrideSearchType — (String)

          By default, Amazon Bedrock decides a search strategy for you. If you're using an Amazon OpenSearch Serverless vector store that contains a filterable text field, you can specify whether to query the knowledge base with a HYBRID search using both vector embeddings and raw text, or SEMANTIC search using only vector embeddings. For other vector store configurations, only SEMANTIC search is available. For more information, see Test a knowledge base.

          Possible values include:
          • "HYBRID"
          • "SEMANTIC"
    • retrievalQuery — (map)

      Contains the query to send the knowledge base.

      • textrequired — (String)

        The text of the query made to the knowledge base.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • nextToken — (String)

        If there are more results than can fit in the response, the response returns a nextToken. Use this token in the nextToken field of another request to retrieve the next batch of results.

      • retrievalResults — (Array<map>)

        A list of results from querying the knowledge base.

        • contentrequired — (map)

          Contains a chunk of text from a data source in the knowledge base.

          • textrequired — (String)

            The cited text from the data source.

        • location — (map)

          Contains information about the location of the data source.

          • confluenceLocation — (map)

            The Confluence data source location.

            • url — (String)

              The Confluence host URL for the data source location.

          • s3Location — (map)

            The S3 data source location.

            • uri — (String)

              The S3 URI for the data source location.

          • salesforceLocation — (map)

            The Salesforce data source location.

            • url — (String)

              The Salesforce host URL for the data source location.

          • sharePointLocation — (map)

            The SharePoint data source location.

            • url — (String)

              The SharePoint site URL for the data source location.

          • typerequired — (String)

            The type of data source location.

            Possible values include:
            • "S3"
            • "WEB"
            • "CONFLUENCE"
            • "SALESFORCE"
            • "SHAREPOINT"
          • webLocation — (map)

            The web URL/URLs data source location.

            • url — (String)

              The web URL/URLs for the data source location.

        • metadata — (map<map>)

          Contains metadata attributes and their values for the file in the data source. For more information, see Metadata and filtering.

        • score — (Float)

          The level of relevance of the result to the query.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.

retrieveAndGenerate(params = {}, callback) ⇒ AWS.Request

Queries a knowledge base and generates responses based on the retrieved results. The response only cites sources that are relevant to the query.

Service Reference:

Examples:

Calling the retrieveAndGenerate operation

var params = {
  input: { /* required */
    text: 'STRING_VALUE' /* required */
  },
  retrieveAndGenerateConfiguration: {
    type: KNOWLEDGE_BASE | EXTERNAL_SOURCES, /* required */
    externalSourcesConfiguration: {
      modelArn: 'STRING_VALUE', /* required */
      sources: [ /* required */
        {
          sourceType: S3 | BYTE_CONTENT, /* required */
          byteContent: {
            contentType: 'STRING_VALUE', /* required */
            data: Buffer.from('...') || 'STRING_VALUE' /* Strings will be Base-64 encoded on your behalf */, /* required */
            identifier: 'STRING_VALUE' /* required */
          },
          s3Location: {
            uri: 'STRING_VALUE' /* required */
          }
        },
        /* more items */
      ],
      generationConfiguration: {
        additionalModelRequestFields: {
          '<AdditionalModelRequestFieldsKey>': {
          },
          /* '<AdditionalModelRequestFieldsKey>': ... */
        },
        guardrailConfiguration: {
          guardrailId: 'STRING_VALUE', /* required */
          guardrailVersion: 'STRING_VALUE' /* required */
        },
        inferenceConfig: {
          textInferenceConfig: {
            maxTokens: 'NUMBER_VALUE',
            stopSequences: [
              'STRING_VALUE',
              /* more items */
            ],
            temperature: 'NUMBER_VALUE',
            topP: 'NUMBER_VALUE'
          }
        },
        promptTemplate: {
          textPromptTemplate: 'STRING_VALUE'
        }
      }
    },
    knowledgeBaseConfiguration: {
      knowledgeBaseId: 'STRING_VALUE', /* required */
      modelArn: 'STRING_VALUE', /* required */
      generationConfiguration: {
        additionalModelRequestFields: {
          '<AdditionalModelRequestFieldsKey>': {
          },
          /* '<AdditionalModelRequestFieldsKey>': ... */
        },
        guardrailConfiguration: {
          guardrailId: 'STRING_VALUE', /* required */
          guardrailVersion: 'STRING_VALUE' /* required */
        },
        inferenceConfig: {
          textInferenceConfig: {
            maxTokens: 'NUMBER_VALUE',
            stopSequences: [
              'STRING_VALUE',
              /* more items */
            ],
            temperature: 'NUMBER_VALUE',
            topP: 'NUMBER_VALUE'
          }
        },
        promptTemplate: {
          textPromptTemplate: 'STRING_VALUE'
        }
      },
      orchestrationConfiguration: {
        queryTransformationConfiguration: { /* required */
          type: QUERY_DECOMPOSITION /* required */
        }
      },
      retrievalConfiguration: {
        vectorSearchConfiguration: { /* required */
          filter: { /* RetrievalFilter */
            andAll: [
              /* recursive RetrievalFilter */,
              /* more items */
            ],
            equals: {
              key: 'STRING_VALUE', /* required */
              value: { /* required */
              }
            },
            greaterThan: {
              key: 'STRING_VALUE', /* required */
              value: { /* required */
              }
            },
            greaterThanOrEquals: {
              key: 'STRING_VALUE', /* required */
              value: { /* required */
              }
            },
            in: {
              key: 'STRING_VALUE', /* required */
              value: { /* required */
              }
            },
            lessThan: {
              key: 'STRING_VALUE', /* required */
              value: { /* required */
              }
            },
            lessThanOrEquals: {
              key: 'STRING_VALUE', /* required */
              value: { /* required */
              }
            },
            listContains: {
              key: 'STRING_VALUE', /* required */
              value: { /* required */
              }
            },
            notEquals: {
              key: 'STRING_VALUE', /* required */
              value: { /* required */
              }
            },
            notIn: {
              key: 'STRING_VALUE', /* required */
              value: { /* required */
              }
            },
            orAll: [
              /* recursive RetrievalFilter */,
              /* more items */
            ],
            startsWith: {
              key: 'STRING_VALUE', /* required */
              value: { /* required */
              }
            },
            stringContains: {
              key: 'STRING_VALUE', /* required */
              value: { /* required */
              }
            }
          },
          numberOfResults: 'NUMBER_VALUE',
          overrideSearchType: HYBRID | SEMANTIC
        }
      }
    }
  },
  sessionConfiguration: {
    kmsKeyArn: 'STRING_VALUE' /* required */
  },
  sessionId: 'STRING_VALUE'
};
bedrockagentruntime.retrieveAndGenerate(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • input — (map)

      Contains the query to be made to the knowledge base.

      • textrequired — (String)

        The query made to the knowledge base.

    • retrieveAndGenerateConfiguration — (map)

      Contains configurations for the knowledge base query and retrieval process. For more information, see Query configurations.

      • externalSourcesConfiguration — (map)

        The configuration used with the external source wrapper object in the retrieveAndGenerate function.

        • generationConfiguration — (map)

          The prompt used with the external source wrapper object with the retrieveAndGenerate function.

          • additionalModelRequestFields — (map<map>)

            Additional model parameters and their corresponding values not included in the textInferenceConfig structure for an external source. Takes in custom model parameters specific to the language model being used.

          • guardrailConfiguration — (map)

            The configuration details for the guardrail.

            • guardrailIdrequired — (String)

              The unique identifier for the guardrail.

            • guardrailVersionrequired — (String)

              The version of the guardrail.

          • inferenceConfig — (map)

            Configuration settings for inference when using RetrieveAndGenerate to generate responses while using an external source.

            • textInferenceConfig — (map)

              Configuration settings specific to text generation while generating responses using RetrieveAndGenerate.

              • maxTokens — (Integer)

                The maximum number of tokens to generate in the output text. Do not use the minimum of 0 or the maximum of 65536. The limit values described here are arbitary values, for actual values consult the limits defined by your specific model.

              • stopSequences — (Array<String>)

                A list of sequences of characters that, if generated, will cause the model to stop generating further tokens. Do not use a minimum length of 1 or a maximum length of 1000. The limit values described here are arbitary values, for actual values consult the limits defined by your specific model.

              • temperature — (Float)

                Controls the random-ness of text generated by the language model, influencing how much the model sticks to the most predictable next words versus exploring more surprising options. A lower temperature value (e.g. 0.2 or 0.3) makes model outputs more deterministic or predictable, while a higher temperature (e.g. 0.8 or 0.9) makes the outputs more creative or unpredictable.

              • topP — (Float)

                A probability distribution threshold which controls what the model considers for the set of possible next tokens. The model will only consider the top p% of the probability distribution when generating the next token.

          • promptTemplate — (map)

            Contain the textPromptTemplate string for the external source wrapper object.

            • textPromptTemplate — (String)

              The template for the prompt that's sent to the model for response generation. You can include prompt placeholders, which become replaced before the prompt is sent to the model to provide instructions and context to the model. In addition, you can include XML tags to delineate meaningful sections of the prompt template.

              For more information, see the following resources:

        • modelArnrequired — (String)

          The modelArn used with the external source wrapper object in the retrieveAndGenerate function.

        • sourcesrequired — (Array<map>)

          The document used with the external source wrapper object in the retrieveAndGenerate function.

          • byteContent — (map)

            The identifier, contentType, and data of the external source wrapper object.

            • contentTyperequired — (String)

              The MIME type of the document contained in the wrapper object.

            • datarequired — (Buffer, Typed Array, Blob, String)

              The byte value of the file to upload, encoded as a Base-64 string.

            • identifierrequired — (String)

              The file name of the document contained in the wrapper object.

          • s3Location — (map)

            The S3 location of the external source wrapper object.

            • urirequired — (String)

              The file location of the S3 wrapper object.

          • sourceTyperequired — (String)

            The source type of the external source wrapper object.

            Possible values include:
            • "S3"
            • "BYTE_CONTENT"
      • knowledgeBaseConfiguration — (map)

        Contains details about the resource being queried.

        • generationConfiguration — (map)

          Contains configurations for response generation based on the knowledge base query results.

          • additionalModelRequestFields — (map<map>)

            Additional model parameters and corresponding values not included in the textInferenceConfig structure for a knowledge base. This allows users to provide custom model parameters specific to the language model being used.

          • guardrailConfiguration — (map)

            The configuration details for the guardrail.

            • guardrailIdrequired — (String)

              The unique identifier for the guardrail.

            • guardrailVersionrequired — (String)

              The version of the guardrail.

          • inferenceConfig — (map)

            Configuration settings for inference when using RetrieveAndGenerate to generate responses while using a knowledge base as a source.

            • textInferenceConfig — (map)

              Configuration settings specific to text generation while generating responses using RetrieveAndGenerate.

              • maxTokens — (Integer)

                The maximum number of tokens to generate in the output text. Do not use the minimum of 0 or the maximum of 65536. The limit values described here are arbitary values, for actual values consult the limits defined by your specific model.

              • stopSequences — (Array<String>)

                A list of sequences of characters that, if generated, will cause the model to stop generating further tokens. Do not use a minimum length of 1 or a maximum length of 1000. The limit values described here are arbitary values, for actual values consult the limits defined by your specific model.

              • temperature — (Float)

                Controls the random-ness of text generated by the language model, influencing how much the model sticks to the most predictable next words versus exploring more surprising options. A lower temperature value (e.g. 0.2 or 0.3) makes model outputs more deterministic or predictable, while a higher temperature (e.g. 0.8 or 0.9) makes the outputs more creative or unpredictable.

              • topP — (Float)

                A probability distribution threshold which controls what the model considers for the set of possible next tokens. The model will only consider the top p% of the probability distribution when generating the next token.

          • promptTemplate — (map)

            Contains the template for the prompt that's sent to the model for response generation.

            • textPromptTemplate — (String)

              The template for the prompt that's sent to the model for response generation. You can include prompt placeholders, which become replaced before the prompt is sent to the model to provide instructions and context to the model. In addition, you can include XML tags to delineate meaningful sections of the prompt template.

              For more information, see the following resources:

        • knowledgeBaseIdrequired — (String)

          The unique identifier of the knowledge base that is queried and the foundation model used for generation.

        • modelArnrequired — (String)

          The ARN of the foundation model used to generate a response.

        • orchestrationConfiguration — (map)

          Settings for how the model processes the prompt prior to retrieval and generation.

          • queryTransformationConfigurationrequired — (map)

            To split up the prompt and retrieve multiple sources, set the transformation type to QUERY_DECOMPOSITION.

            • typerequired — (String)

              The type of transformation to apply to the prompt.

              Possible values include:
              • "QUERY_DECOMPOSITION"
        • retrievalConfiguration — (map)

          Contains configurations for how to retrieve and return the knowledge base query.

          • vectorSearchConfigurationrequired — (map)

            Contains details about how the results from the vector search should be returned. For more information, see Query configurations.

            • filter — (map)

              Specifies the filters to use on the metadata in the knowledge base data sources before returning results. For more information, see Query configurations.

              • andAll — (Array<map>)

                Knowledge base data sources are returned if their metadata attributes fulfill all the filter conditions inside this list.

              • equals — (map)

                Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value matches the value in this object.

                The following example would return data sources with an animal attribute whose value is cat:

                "equals": { "key": "animal", "value": "cat" }

                • keyrequired — (String)

                  The name that the metadata attribute must match.

                • valuerequired — (map)

                  The value to whcih to compare the value of the metadata attribute.

              • greaterThan — (map)

                Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value is greater than the value in this object.

                The following example would return data sources with an year attribute whose value is greater than 1989:

                "greaterThan": { "key": "year", "value": 1989 }

                • keyrequired — (String)

                  The name that the metadata attribute must match.

                • valuerequired — (map)

                  The value to whcih to compare the value of the metadata attribute.

              • greaterThanOrEquals — (map)

                Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value is greater than or equal to the value in this object.

                The following example would return data sources with an year attribute whose value is greater than or equal to 1989:

                "greaterThanOrEquals": { "key": "year", "value": 1989 }

                • keyrequired — (String)

                  The name that the metadata attribute must match.

                • valuerequired — (map)

                  The value to whcih to compare the value of the metadata attribute.

              • in — (map)

                Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value is in the list specified in the value in this object.

                The following example would return data sources with an animal attribute that is either cat or dog:

                "in": { "key": "animal", "value": ["cat", "dog"] }

                • keyrequired — (String)

                  The name that the metadata attribute must match.

                • valuerequired — (map)

                  The value to whcih to compare the value of the metadata attribute.

              • lessThan — (map)

                Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value is less than the value in this object.

                The following example would return data sources with an year attribute whose value is less than to 1989.

                "lessThan": { "key": "year", "value": 1989 }

                • keyrequired — (String)

                  The name that the metadata attribute must match.

                • valuerequired — (map)

                  The value to whcih to compare the value of the metadata attribute.

              • lessThanOrEquals — (map)

                Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value is less than or equal to the value in this object.

                The following example would return data sources with an year attribute whose value is less than or equal to 1989.

                "lessThanOrEquals": { "key": "year", "value": 1989 }

                • keyrequired — (String)

                  The name that the metadata attribute must match.

                • valuerequired — (map)

                  The value to whcih to compare the value of the metadata attribute.

              • listContains — (map)

                Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value is a list that contains the value as one of its members.

                The following example would return data sources with an animals attribute that is a list containing a cat member (for example ["dog", "cat"]).

                "listContains": { "key": "animals", "value": "cat" }

                • keyrequired — (String)

                  The name that the metadata attribute must match.

                • valuerequired — (map)

                  The value to whcih to compare the value of the metadata attribute.

              • notEquals — (map)

                Knowledge base data sources that contain a metadata attribute whose name matches the key and whose value doesn't match the value in this object are returned.

                The following example would return data sources that don't contain an animal attribute whose value is cat.

                "notEquals": { "key": "animal", "value": "cat" }

                • keyrequired — (String)

                  The name that the metadata attribute must match.

                • valuerequired — (map)

                  The value to whcih to compare the value of the metadata attribute.

              • notIn — (map)

                Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value isn't in the list specified in the value in this object.

                The following example would return data sources whose animal attribute is neither cat nor dog.

                "notIn": { "key": "animal", "value": ["cat", "dog"] }

                • keyrequired — (String)

                  The name that the metadata attribute must match.

                • valuerequired — (map)

                  The value to whcih to compare the value of the metadata attribute.

              • orAll — (Array<map>)

                Knowledge base data sources are returned if their metadata attributes fulfill at least one of the filter conditions inside this list.

              • startsWith — (map)

                Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value starts with the value in this object. This filter is currently only supported for Amazon OpenSearch Serverless vector stores.

                The following example would return data sources with an animal attribute starts with ca (for example, cat or camel).

                "startsWith": { "key": "animal", "value": "ca" }

                • keyrequired — (String)

                  The name that the metadata attribute must match.

                • valuerequired — (map)

                  The value to whcih to compare the value of the metadata attribute.

              • stringContains — (map)

                Knowledge base data sources are returned if they contain a metadata attribute whose name matches the key and whose value is one of the following:

                • A string that contains the value as a substring. The following example would return data sources with an animal attribute that contains the substring at (for example cat).

                  "stringContains": { "key": "animal", "value": "at" }

                • A list with a member that contains the value as a substring. The following example would return data sources with an animals attribute that is a list containing a member that contains the substring at (for example ["dog", "cat"]).

                  "stringContains": { "key": "animals", "value": "at" }

                • keyrequired — (String)

                  The name that the metadata attribute must match.

                • valuerequired — (map)

                  The value to whcih to compare the value of the metadata attribute.

            • numberOfResults — (Integer)

              The number of source chunks to retrieve.

            • overrideSearchType — (String)

              By default, Amazon Bedrock decides a search strategy for you. If you're using an Amazon OpenSearch Serverless vector store that contains a filterable text field, you can specify whether to query the knowledge base with a HYBRID search using both vector embeddings and raw text, or SEMANTIC search using only vector embeddings. For other vector store configurations, only SEMANTIC search is available. For more information, see Test a knowledge base.

              Possible values include:
              • "HYBRID"
              • "SEMANTIC"
      • typerequired — (String)

        The type of resource that is queried by the request.

        Possible values include:
        • "KNOWLEDGE_BASE"
        • "EXTERNAL_SOURCES"
    • sessionConfiguration — (map)

      Contains details about the session with the knowledge base.

      • kmsKeyArnrequired — (String)

        The ARN of the KMS key encrypting the session.

    • sessionId — (String)

      The unique identifier of the session. When you first make a RetrieveAndGenerate request, Amazon Bedrock automatically generates this value. You must reuse this value for all subsequent requests in the same conversational session. This value allows Amazon Bedrock to maintain context and knowledge from previous interactions. You can't explicitly set the sessionId yourself.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned. If a callback is not supplied, you must call AWS.Request.send() on the returned request object to initiate the request.

    Context (this):

    • (AWS.Response)

      the response object containing error, data properties, and the original request object.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • citations — (Array<map>)

        A list of segments of the generated response that are based on sources in the knowledge base, alongside information about the sources.

        • generatedResponsePart — (map)

          Contains the generated response and metadata

          • textResponsePart — (map)

            Contains metadata about a textual part of the generated response that is accompanied by a citation.

            • span — (map)

              Contains information about where the text with a citation begins and ends in the generated output.

              • end — (Integer)

                Where the text with a citation ends in the generated output.

              • start — (Integer)

                Where the text with a citation starts in the generated output.

            • text — (String)

              The part of the generated text that contains a citation.

        • retrievedReferences — (Array<map>)

          Contains metadata about the sources cited for the generated response.

          • content — (map)

            Contains the cited text from the data source.

            • textrequired — (String)

              The cited text from the data source.

          • location — (map)

            Contains information about the location of the data source.

            • confluenceLocation — (map)

              The Confluence data source location.

              • url — (String)

                The Confluence host URL for the data source location.

            • s3Location — (map)

              The S3 data source location.

              • uri — (String)

                The S3 URI for the data source location.

            • salesforceLocation — (map)

              The Salesforce data source location.

              • url — (String)

                The Salesforce host URL for the data source location.

            • sharePointLocation — (map)

              The SharePoint data source location.

              • url — (String)

                The SharePoint site URL for the data source location.

            • typerequired — (String)

              The type of data source location.

              Possible values include:
              • "S3"
              • "WEB"
              • "CONFLUENCE"
              • "SALESFORCE"
              • "SHAREPOINT"
            • webLocation — (map)

              The web URL/URLs data source location.

              • url — (String)

                The web URL/URLs for the data source location.

          • metadata — (map<map>)

            Contains metadata attributes and their values for the file in the data source. For more information, see Metadata and filtering.

      • guardrailAction — (String)

        Specifies if there is a guardrail intervention in the response.

        Possible values include:
        • "INTERVENED"
        • "NONE"
      • output — (map)

        Contains the response generated from querying the knowledge base.

        • textrequired — (String)

          The response generated from querying the knowledge base.

      • sessionId — (String)

        The unique identifier of the session. When you first make a RetrieveAndGenerate request, Amazon Bedrock automatically generates this value. You must reuse this value for all subsequent requests in the same conversational session. This value allows Amazon Bedrock to maintain context and knowledge from previous interactions. You can't explicitly set the sessionId yourself.

Returns:

  • (AWS.Request)

    a handle to the operation request for subsequent event callback registration.