createKnowledgeBase method

Future<CreateKnowledgeBaseResponse> createKnowledgeBase({
  1. required KnowledgeBaseConfiguration knowledgeBaseConfiguration,
  2. required String name,
  3. required String roleArn,
  4. String? clientToken,
  5. String? description,
  6. StorageConfiguration? storageConfiguration,
  7. Map<String, String>? tags,
})

Creates a knowledge base. A knowledge base contains your data sources so that Large Language Models (LLMs) can use your data. To create a knowledge base, you must first set up your data sources and configure a supported vector store. For more information, see Set up a knowledge base.

  • Provide the name and an optional description.
  • Provide the Amazon Resource Name (ARN) with permissions to create a knowledge base in the roleArn field.
  • Provide the embedding model to use in the embeddingModelArn field in the knowledgeBaseConfiguration object.
  • Provide the configuration for your vector store in the storageConfiguration object.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter knowledgeBaseConfiguration : Contains details about the embeddings model used for the knowledge base.

Parameter name : A name for the knowledge base.

Parameter roleArn : The Amazon Resource Name (ARN) of the IAM role with permissions to invoke API operations on the knowledge base.

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.

Parameter description : A description of the knowledge base.

Parameter storageConfiguration : Contains details about the configuration of the vector database used for the knowledge base.

Parameter tags : Specify the key-value pairs for the tags that you want to attach to your knowledge base in this object.

Implementation

Future<CreateKnowledgeBaseResponse> createKnowledgeBase({
  required KnowledgeBaseConfiguration knowledgeBaseConfiguration,
  required String name,
  required String roleArn,
  String? clientToken,
  String? description,
  StorageConfiguration? storageConfiguration,
  Map<String, String>? tags,
}) async {
  final $payload = <String, dynamic>{
    'knowledgeBaseConfiguration': knowledgeBaseConfiguration,
    'name': name,
    'roleArn': roleArn,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (description != null) 'description': description,
    if (storageConfiguration != null)
      'storageConfiguration': storageConfiguration,
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri: '/knowledgebases/',
    exceptionFnMap: _exceptionFns,
  );
  return CreateKnowledgeBaseResponse.fromJson(response);
}