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.invokeAgent(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

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

Sends a prompt for the agent to process and respond to. Use return control event type for function calling.

Note: The CLI doesn't support InvokeAgent.
  • 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 parameters returned from the action group.

  • Use return control event type for function calling.

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.

  • 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.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.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.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',
  sessionState: {
    invocationId: 'STRING_VALUE',
    promptSessionAttributes: {
      '<String>': 'STRING_VALUE',
      /* '<String>': ... */
    },
    returnControlInvocationResults: [
      {
        apiResult: {
          actionGroup: 'STRING_VALUE', /* required */
          apiPath: 'STRING_VALUE',
          httpMethod: 'STRING_VALUE',
          httpStatusCode: 'NUMBER_VALUE',
          responseBody: {
            '<String>': {
              body: 'STRING_VALUE'
            },
            /* '<String>': ... */
          },
          responseState: FAILURE | REPROMPT
        },
        functionResult: {
          actionGroup: 'STRING_VALUE', /* required */
          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.

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

      • invocationId — (String)

        The identifier of the invocation.

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

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

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

          • function — (String)

            The name of the function that was called.

          • responseBody — (map<map>)

            The response from the function call using the parameters. 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.

                  • s3Location — (map)

                    Contains the S3 location of the data source.

                    • uri — (String)

                      The S3 URI of the data source.

                  • typerequired — (String)

                    The type of the location of the data source.

                    Possible values include:
                    • "S3"
                • 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.

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

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

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

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

                  • function — (String)

                    The function in the action group to call.

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

                • invocationType — (String)

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

                  Possible values include:
                  • "ACTION_GROUP"
                  • "KNOWLEDGE_BASE"
                  • "FINISH"
                • 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 80, 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"
              • 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.

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

                      • s3Location — (map)

                        Contains the S3 location of the data source.

                        • uri — (String)

                          The S3 URI of the data source.

                      • typerequired — (String)

                        The type of the location of the data source.

                        Possible values include:
                        • "S3"
                    • 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 80, 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 80, 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.

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

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 */
          }
        },
        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 */
          }
        }
      },
      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 whose metadata attributes fulfill all the filter conditions inside this list are returned.

          • equals — (map)

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

            • 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 that contain a metadata attribute whose name matches the key and whose value is greater than the value in this object are returned.

            • 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 that contain a metadata attribute whose name matches the key and whose value is greater than or equal to the value in this object are returned.

            • 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 that contain a metadata attribute whose name matches the key and whose value is in the list specified in the value in this object are returned.

            • 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 that contain a metadata attribute whose name matches the key and whose value is less than the value in this object are returned.

            • 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 that contain a metadata attribute whose name matches the key and whose value is less than or equal to the value in this object are returned.

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

            • 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 that contain a metadata attribute whose name matches the key and whose value isn't in the list specified in the value in this object are returned.

            • 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 whose metadata attributes fulfill at least one of the filter conditions inside this list are returned.

          • startsWith — (map)

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

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

          • s3Location — (map)

            Contains the S3 location of the data source.

            • uri — (String)

              The S3 URI of the data source.

          • typerequired — (String)

            The type of the location of the data source.

            Possible values include:
            • "S3"
        • 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: {
        promptTemplate: {
          textPromptTemplate: 'STRING_VALUE'
        }
      }
    },
    knowledgeBaseConfiguration: {
      knowledgeBaseId: 'STRING_VALUE', /* required */
      modelArn: 'STRING_VALUE', /* required */
      generationConfiguration: {
        promptTemplate: {
          textPromptTemplate: '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 */
              }
            },
            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 */
              }
            }
          },
          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.

          • 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 knowwledge base query results.

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

        • 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 whose metadata attributes fulfill all the filter conditions inside this list are returned.

              • equals — (map)

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

                • 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 that contain a metadata attribute whose name matches the key and whose value is greater than the value in this object are returned.

                • 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 that contain a metadata attribute whose name matches the key and whose value is greater than or equal to the value in this object are returned.

                • 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 that contain a metadata attribute whose name matches the key and whose value is in the list specified in the value in this object are returned.

                • 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 that contain a metadata attribute whose name matches the key and whose value is less than the value in this object are returned.

                • 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 that contain a metadata attribute whose name matches the key and whose value is less than or equal to the value in this object are returned.

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

                • 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 that contain a metadata attribute whose name matches the key and whose value isn't in the list specified in the value in this object are returned.

                • 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 whose metadata attributes fulfill at least one of the filter conditions inside this list are returned.

              • startsWith — (map)

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

                • 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. Reuse the same value to continue the same session with 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:

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

            • s3Location — (map)

              Contains the S3 location of the data source.

              • uri — (String)

                The S3 URI of the data source.

            • typerequired — (String)

              The type of the location of the data source.

              Possible values include:
              • "S3"
          • metadata — (map<map>)

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

      • 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. Reuse the same value to continue the same session with the knowledge base.

Returns:

  • (AWS.Request)

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