retrieve method

Future<RetrieveResponse> retrieve({
  1. required String knowledgeBaseId,
  2. required KnowledgeBaseQuery retrievalQuery,
  3. GuardrailConfiguration? guardrailConfiguration,
  4. String? nextToken,
  5. KnowledgeBaseRetrievalConfiguration? retrievalConfiguration,
})

Queries a knowledge base and retrieves information from it.

May throw AccessDeniedException. May throw BadGatewayException. May throw ConflictException. May throw DependencyFailedException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter knowledgeBaseId : The unique identifier of the knowledge base to query.

Parameter retrievalQuery : Contains the query to send the knowledge base.

Parameter guardrailConfiguration : Guardrail settings.

Parameter nextToken : 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.

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

Implementation

Future<RetrieveResponse> retrieve({
  required String knowledgeBaseId,
  required KnowledgeBaseQuery retrievalQuery,
  GuardrailConfiguration? guardrailConfiguration,
  String? nextToken,
  KnowledgeBaseRetrievalConfiguration? retrievalConfiguration,
}) async {
  final $payload = <String, dynamic>{
    'retrievalQuery': retrievalQuery,
    if (guardrailConfiguration != null)
      'guardrailConfiguration': guardrailConfiguration,
    if (nextToken != null) 'nextToken': nextToken,
    if (retrievalConfiguration != null)
      'retrievalConfiguration': retrievalConfiguration,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/knowledgebases/${Uri.encodeComponent(knowledgeBaseId)}/retrieve',
    exceptionFnMap: _exceptionFns,
  );
  return RetrieveResponse.fromJson(response);
}