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,
) -> 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.

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,
) -> "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>

    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

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