Skip to content

update_knowledge_base async

update_knowledge_base(
    knowledge_base_id: Id,
    name: Name,
    role_arn: KnowledgeBaseRoleArn,
    knowledge_base_configuration: KnowledgeBaseConfiguration,
    *,
    config_overrides: Optional[AsyncBedrockAgentClientConfig] = None,
    description: Optional[Description] = None,
    storage_configuration: Optional[StorageConfiguration] = None,
    metadata_configurations: Optional[MetadataConfigurations] = None,
    user_context_mode_for_retrieval: Optional[UserContextModeForRetrieval] = None,
    trusted_identity_sources: Optional[TrustedIdentitySources] = None,
) -> UpdateKnowledgeBaseResponse

Updates the configuration of a knowledge base with the fields that you specify. Because all fields will be overwritten, you must include the same values for fields that you want to keep the same.

You can change the following fields:

  • name

  • description

  • roleArn

You can't change the knowledgeBaseConfiguration or storageConfiguration fields, so you must specify the same configurations as when you created the knowledge base. You can send a GetKnowledgeBase request and copy the same configurations.

Parameters:

  • knowledge_base_id (Id) –

    The unique identifier of the knowledge base to update.

  • name (Name) –

    Specifies a new name for the knowledge base.

  • description (Optional[Description], default: None ) –

    Specifies a new description for the knowledge base.

  • role_arn (KnowledgeBaseRoleArn) –

    Specifies a different Amazon Resource Name (ARN) of the IAM role with permissions to invoke API operations on the knowledge base.

  • knowledge_base_configuration (KnowledgeBaseConfiguration) –

    Specifies the configuration for the embeddings model used for the knowledge base. You must use the same configuration as when the knowledge base was created.

  • storage_configuration (Optional[StorageConfiguration], default: None ) –

    Specifies the configuration for the vector store used for the knowledge base. You must use the same configuration as when the knowledge base was created.

  • metadata_configurations (Optional[MetadataConfigurations], default: None ) –

    Specifies up to 30 custom metadata field configurations for a managed knowledge base.

    The list that you specify replaces the existing configurations. The update removes any configuration that you leave out, and its field is no longer searchable. An empty list removes all configurations. If you don't specify a list, the existing configurations don't change.

  • user_context_mode_for_retrieval (Optional[UserContextModeForRetrieval], default: None ) –

    Specifies the end-user identity that you want the knowledge base to use to filter retrieval results by document access controls. If you don't specify a value, the knowledge base keeps its current value.

  • trusted_identity_sources (Optional[TrustedIdentitySources], default: None ) –

    Specifies up to 5 identity sources that you want the knowledge base to trust for identity-enhanced sessions. An identity source is an AWS IAM Identity Center identity store or an AWS Identity and Access Management (IAM) identity provider.

    The list that you specify replaces the existing list. To remove all identity sources, specify an empty list. If you don't specify a list, the knowledge base keeps its current identity sources.

Raises:

Source code in docs_src/capo_bedrock_agent/_services/async_bedrock_agent.py
async def update_knowledge_base(
    self,
    knowledge_base_id: "capo_bedrock_agent.types.id.Id",
    name: "capo_bedrock_agent.types.name.Name",
    role_arn: "capo_bedrock_agent.types.knowledge_base_role_arn.KnowledgeBaseRoleArn",
    knowledge_base_configuration: "capo_bedrock_agent.types.knowledge_base_configuration.KnowledgeBaseConfiguration",
    *,
    config_overrides: Optional[AsyncBedrockAgentClientConfig] = None,
    description: Optional[
        "capo_bedrock_agent.types.description.Description"
    ] = None,
    storage_configuration: Optional[
        "capo_bedrock_agent.types.storage_configuration.StorageConfiguration"
    ] = None,
    metadata_configurations: Optional[
        "capo_bedrock_agent.types.metadata_configurations.MetadataConfigurations"
    ] = None,
    user_context_mode_for_retrieval: Optional[
        "capo_bedrock_agent.types.user_context_mode_for_retrieval.UserContextModeForRetrieval"
    ] = None,
    trusted_identity_sources: Optional[
        "capo_bedrock_agent.types.trusted_identity_sources.TrustedIdentitySources"
    ] = None,
) -> "capo_bedrock_agent.types.update_knowledge_base_response.UpdateKnowledgeBaseResponse":
    """<p>Updates the configuration of a knowledge base with the fields that you specify. Because all fields will be overwritten, you must include the same values for fields that you want to keep the same.</p> <p>You can change the following fields:</p> <ul> <li> <p> <code>name</code> </p> </li> <li> <p> <code>description</code> </p> </li> <li> <p> <code>roleArn</code> </p> </li> </ul> <p>You can't change the <code>knowledgeBaseConfiguration</code> or <code>storageConfiguration</code> fields, so you must specify the same configurations as when you created the knowledge base. You can send a <a href="https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_GetKnowledgeBase.html">GetKnowledgeBase</a> request and copy the same configurations.</p>

    Args:
        knowledge_base_id: <p>The unique identifier of the knowledge base to update.</p>
        name: <p>Specifies a new name for the knowledge base.</p>
        description: <p>Specifies a new description for the knowledge base.</p>
        role_arn: <p>Specifies a different Amazon Resource Name (ARN) of the IAM role with permissions to invoke API operations on the knowledge base.</p>
        knowledge_base_configuration: <p>Specifies the configuration for the embeddings model used for the knowledge base. You must use the same configuration as when the knowledge base was created.</p>
        storage_configuration: <p>Specifies the configuration for the vector store used for the knowledge base. You must use the same configuration as when the knowledge base was created.</p>
        metadata_configurations: <p>Specifies up to 30 custom metadata field configurations for a managed knowledge base.</p> <p>The list that you specify replaces the existing configurations. The update removes any configuration that you leave out, and its field is no longer searchable. An empty list removes all configurations. If you don't specify a list, the existing configurations don't change.</p>
        user_context_mode_for_retrieval: <p>Specifies the end-user identity that you want the knowledge base to use to filter retrieval results by document access controls. If you don't specify a value, the knowledge base keeps its current value.</p>
        trusted_identity_sources: <p>Specifies up to 5 identity sources that you want the knowledge base to trust for identity-enhanced sessions. An identity source is an AWS IAM Identity Center identity store or an AWS Identity and Access Management (IAM) identity provider.</p> <p>The list that you specify replaces the existing list. To remove all identity sources, specify an empty list. If you don't specify a list, the knowledge base keeps its current identity sources.</p>

    Raises:
        capo_bedrock_agent.errors.access_denied_exception.AccessDeniedException: <p>The request is denied because of missing access permissions.</p>
        capo_bedrock_agent.errors.conflict_exception.ConflictException: <p>There was a conflict performing an operation.</p>
        capo_bedrock_agent.errors.internal_server_exception.InternalServerException: <p>An internal server error occurred. Retry your request.</p>
        capo_bedrock_agent.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.</p>
        capo_bedrock_agent.errors.throttling_exception.ThrottlingException: <p>The number of requests exceeds the limit. Resubmit your request later.</p>
        capo_bedrock_agent.errors.validation_exception.ValidationException: <p>Input validation failed. Check your request parameters and retry the request.</p>
        capo_bedrock_agent.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_bedrock_agent.types.update_knowledge_base_request.UpdateKnowledgeBaseRequest]",
    ) -> AsyncOperationResponse[
        "capo_bedrock_agent.types.update_knowledge_base_response.UpdateKnowledgeBaseResponse"
    ]:
        import capo_bedrock_agent._operations.amazon_bedrock_agent_build_time_lambda.update_knowledge_base

        (
            output,
            http_response,
        ) = await capo_bedrock_agent._operations.amazon_bedrock_agent_build_time_lambda.update_knowledge_base.async_update_knowledge_base(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_bedrock_agent.types.update_knowledge_base_request.UpdateKnowledgeBaseRequest",
    ) -> dict[str, Any]:
        import capo_bedrock_agent.types.update_knowledge_base_request

        return (
            capo_bedrock_agent.types.update_knowledge_base_request.redact_sensitive(
                input_
            )
        )

    def _redact_output(
        output: "capo_bedrock_agent.types.update_knowledge_base_response.UpdateKnowledgeBaseResponse",
    ) -> dict[str, Any]:
        import capo_bedrock_agent.types.update_knowledge_base_response

        return capo_bedrock_agent.types.update_knowledge_base_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "UpdateKnowledgeBase",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_bedrock_agent.types.update_knowledge_base_request.UpdateKnowledgeBaseRequest = {
        "knowledge_base_id": knowledge_base_id,
        "name": name,
        "role_arn": role_arn,
        "knowledge_base_configuration": knowledge_base_configuration,
    }
    if description is not None:
        input_["description"] = description
    if storage_configuration is not None:
        input_["storage_configuration"] = storage_configuration
    if metadata_configurations is not None:
        input_["metadata_configurations"] = metadata_configurations
    if user_context_mode_for_retrieval is not None:
        input_["user_context_mode_for_retrieval"] = user_context_mode_for_retrieval
    if trusted_identity_sources is not None:
        input_["trusted_identity_sources"] = trusted_identity_sources

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output