createKnowledgeBase method
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
nameand an optionaldescription. -
Provide the Amazon Resource Name (ARN) with permissions to create a
knowledge base in the
roleArnfield. -
Provide the embedding model to use in the
embeddingModelArnfield in theknowledgeBaseConfigurationobject. -
Provide the configuration for your vector store in the
storageConfigurationobject.-
For an Amazon OpenSearch Service database, use the
opensearchServerlessConfigurationobject. For more information, see Create a vector store in Amazon OpenSearch Service. -
For an Amazon Aurora database, use the
RdsConfigurationobject. For more information, see Create a vector store in Amazon Aurora. -
For a Pinecone database, use the
pineconeConfigurationobject. For more information, see Create a vector store in Pinecone. -
For a Redis Enterprise Cloud database, use the
redisEnterpriseCloudConfigurationobject. For more information, see Create a vector store in Redis Enterprise Cloud.
-
For an Amazon OpenSearch Service database, use the
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);
}