ingestKnowledgeBaseDocuments method
Ingests documents directly into the knowledge base that is connected to
the data source. The dataSourceType specified in the content
for each document must match the type of the data source that you specify
in the header. For more information, see Ingest
changes directly into a knowledge base in the Amazon Bedrock User
Guide.
May throw AccessDeniedException.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw ValidationException.
Parameter dataSourceId :
The unique identifier of the data source connected to the knowledge base
that you're adding documents to.
Parameter documents :
A list of objects, each of which contains information about the documents
to add.
Parameter knowledgeBaseId :
The unique identifier of the knowledge base to ingest the documents into.
Parameter clientToken :
A unique, case-sensitive identifier to ensure that the API request
completes no more than one time. If this token matches a previous request,
Amazon Bedrock ignores the request, but does not return an error. For more
information, see Ensuring
idempotency.
Implementation
Future<IngestKnowledgeBaseDocumentsResponse> ingestKnowledgeBaseDocuments({
required String dataSourceId,
required List<KnowledgeBaseDocument> documents,
required String knowledgeBaseId,
String? clientToken,
}) async {
final $payload = <String, dynamic>{
'documents': documents,
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
};
final response = await _protocol.send(
payload: $payload,
method: 'PUT',
requestUri:
'/knowledgebases/${Uri.encodeComponent(knowledgeBaseId)}/datasources/${Uri.encodeComponent(dataSourceId)}/documents',
exceptionFnMap: _exceptionFns,
);
return IngestKnowledgeBaseDocumentsResponse.fromJson(response);
}