Skip to content

create_knowledge_base

create_knowledge_base(
    name: Name,
    knowledge_base_type: KnowledgeBaseType,
    *,
    config_overrides: Optional[QConnectClientConfig] = None,
    client_token: Optional[NonEmptyString] = None,
    source_configuration: Optional[SourceConfiguration] = None,
    rendering_configuration: Optional[RenderingConfiguration] = None,
    vector_ingestion_configuration: Optional[VectorIngestionConfiguration] = None,
    server_side_encryption_configuration: Optional[
        ServerSideEncryptionConfiguration
    ] = None,
    description: Optional[Description] = None,
    tags: Optional[Tags] = None,
) -> CreateKnowledgeBaseResponse

Creates a knowledge base.

When using this API, you cannot reuse Amazon AppIntegrations DataIntegrations with external knowledge bases such as Salesforce and ServiceNow. If you do, you'll get an InvalidRequestException error.

For example, you're programmatically managing your external knowledge base, and you want to add or remove one of the fields that is being ingested from Salesforce. Do the following:

  1. Call DeleteKnowledgeBase.

  2. Call DeleteDataIntegration.

  3. Call CreateDataIntegration to recreate the DataIntegration or a create different one.

  4. Call CreateKnowledgeBase.

Parameters:

  • client_token (Optional[NonEmptyString], default: None ) –

    A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the Amazon Web Services SDK populates this field. For more information about idempotency, see Making retries safe with idempotent APIs.

  • name (Name) –

    The name of the knowledge base.

  • knowledge_base_type (KnowledgeBaseType) –

    The type of knowledge base. Only CUSTOM knowledge bases allow you to upload your own content. EXTERNAL knowledge bases support integrations with third-party systems whose content is synchronized automatically.

  • source_configuration (Optional[SourceConfiguration], default: None ) –

    The source of the knowledge base content. Only set this argument for EXTERNAL or Managed knowledge bases.

  • rendering_configuration (Optional[RenderingConfiguration], default: None ) –

    Information about how to render the content.

  • vector_ingestion_configuration (Optional[VectorIngestionConfiguration], default: None ) –

    Contains details about how to ingest the documents in a data source.

  • server_side_encryption_configuration (Optional[ServerSideEncryptionConfiguration], default: None ) –

    The configuration information for the customer managed key used for encryption.

    This KMS key must have a policy that allows kms:CreateGrant, kms:DescribeKey, kms:Decrypt, and kms:GenerateDataKey* permissions to the IAM identity using the key to invoke Amazon Q in Connect.

    For more information about setting up a customer managed key for Amazon Q in Connect, see Enable Amazon Q in Connect for your instance.

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

    The description.

  • tags (Optional[Tags], default: None ) –

    The tags used to organize, track, or control access for this resource.

Raises:

  • AccessDeniedException –

    You do not have sufficient access to perform this action.

  • ConflictException –

    The request could not be processed because of conflict in the current state of the resource. For example, if you're using a Create API (such as CreateAssistant) that accepts name, a conflicting resource (usually with the same name) is being created or mutated.

  • ServiceQuotaExceededException –

    You've exceeded your service quota. To perform the requested action, remove some of the relevant resources, or use service quotas to request a service quota increase.

  • UnauthorizedException –

    You do not have permission to perform this action.

  • ValidationException –

    The input fails to satisfy the constraints specified by a service.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_qconnect/_services/q_connect.py
def create_knowledge_base(
    self,
    name: "capo_qconnect.types.name.Name",
    knowledge_base_type: "capo_qconnect.types.knowledge_base_type.KnowledgeBaseType",
    *,
    config_overrides: Optional[QConnectClientConfig] = None,
    client_token: Optional[
        "capo_qconnect.types.non_empty_string.NonEmptyString"
    ] = None,
    source_configuration: Optional[
        "capo_qconnect.types.source_configuration.SourceConfiguration"
    ] = None,
    rendering_configuration: Optional[
        "capo_qconnect.types.rendering_configuration.RenderingConfiguration"
    ] = None,
    vector_ingestion_configuration: Optional[
        "capo_qconnect.types.vector_ingestion_configuration.VectorIngestionConfiguration"
    ] = None,
    server_side_encryption_configuration: Optional[
        "capo_qconnect.types.server_side_encryption_configuration.ServerSideEncryptionConfiguration"
    ] = None,
    description: Optional["capo_qconnect.types.description.Description"] = None,
    tags: Optional["capo_qconnect.types.tags.Tags"] = None,
) -> (
    "capo_qconnect.types.create_knowledge_base_response.CreateKnowledgeBaseResponse"
):
    """<p>Creates a knowledge base.</p> <note> <p>When using this API, you cannot reuse <a href="https://docs.aws.amazon.com/appintegrations/latest/APIReference/Welcome.html">Amazon AppIntegrations</a> DataIntegrations with external knowledge bases such as Salesforce and ServiceNow. If you do, you'll get an <code>InvalidRequestException</code> error. </p> <p>For example, you're programmatically managing your external knowledge base, and you want to add or remove one of the fields that is being ingested from Salesforce. Do the following:</p> <ol> <li> <p>Call <a href="https://docs.aws.amazon.com/amazon-q-connect/latest/APIReference/API_DeleteKnowledgeBase.html">DeleteKnowledgeBase</a>.</p> </li> <li> <p>Call <a href="https://docs.aws.amazon.com/appintegrations/latest/APIReference/API_DeleteDataIntegration.html">DeleteDataIntegration</a>.</p> </li> <li> <p>Call <a href="https://docs.aws.amazon.com/appintegrations/latest/APIReference/API_CreateDataIntegration.html">CreateDataIntegration</a> to recreate the DataIntegration or a create different one.</p> </li> <li> <p>Call CreateKnowledgeBase.</p> </li> </ol> </note>

    Args:
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the Amazon Web Services SDK populates this field. For more information about idempotency, see <a href="http://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/">Making retries safe with idempotent APIs</a>.</p>
        name: <p>The name of the knowledge base.</p>
        knowledge_base_type: <p>The type of knowledge base. Only CUSTOM knowledge bases allow you to upload your own content. EXTERNAL knowledge bases support integrations with third-party systems whose content is synchronized automatically. </p>
        source_configuration: <p>The source of the knowledge base content. Only set this argument for EXTERNAL or Managed knowledge bases.</p>
        rendering_configuration: <p>Information about how to render the content.</p>
        vector_ingestion_configuration: <p>Contains details about how to ingest the documents in a data source.</p>
        server_side_encryption_configuration: <p>The configuration information for the customer managed key used for encryption. </p> <p>This KMS key must have a policy that allows <code>kms:CreateGrant</code>, <code>kms:DescribeKey</code>, <code>kms:Decrypt</code>, and <code>kms:GenerateDataKey*</code> permissions to the IAM identity using the key to invoke Amazon Q in Connect.</p> <p>For more information about setting up a customer managed key for Amazon Q in Connect, see <a href="https://docs.aws.amazon.com/connect/latest/adminguide/enable-q.html">Enable Amazon Q in Connect for your instance</a>.</p>
        description: <p>The description.</p>
        tags: <p>The tags used to organize, track, or control access for this resource.</p>

    Raises:
        capo_qconnect.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_qconnect.errors.conflict_exception.ConflictException: <p>The request could not be processed because of conflict in the current state of the resource. For example, if you're using a <code>Create</code> API (such as <code>CreateAssistant</code>) that accepts name, a conflicting resource (usually with the same name) is being created or mutated.</p>
        capo_qconnect.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>You've exceeded your service quota. To perform the requested action, remove some of the relevant resources, or use service quotas to request a service quota increase.</p>
        capo_qconnect.errors.unauthorized_exception.UnauthorizedException: <p>You do not have permission to perform this action.</p>
        capo_qconnect.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by a service.</p>
        capo_qconnect.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_qconnect.types.create_knowledge_base_request.CreateKnowledgeBaseRequest]",
    ) -> OperationResponse[
        "capo_qconnect.types.create_knowledge_base_response.CreateKnowledgeBaseResponse"
    ]:
        import capo_qconnect._operations.wisdom_service.create_knowledge_base

        output, http_response = (
            capo_qconnect._operations.wisdom_service.create_knowledge_base.create_knowledge_base(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_qconnect.types.create_knowledge_base_request.CreateKnowledgeBaseRequest",
    ) -> dict[str, Any]:
        import capo_qconnect.types.create_knowledge_base_request

        return capo_qconnect.types.create_knowledge_base_request.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_qconnect.types.create_knowledge_base_response.CreateKnowledgeBaseResponse",
    ) -> dict[str, Any]:
        import capo_qconnect.types.create_knowledge_base_response

        return capo_qconnect.types.create_knowledge_base_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateKnowledgeBase",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_qconnect.types.create_knowledge_base_request.CreateKnowledgeBaseRequest = {
        "name": name,
        "knowledge_base_type": knowledge_base_type,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if source_configuration is not None:
        input_["source_configuration"] = source_configuration
    if rendering_configuration is not None:
        input_["rendering_configuration"] = rendering_configuration
    if vector_ingestion_configuration is not None:
        input_["vector_ingestion_configuration"] = vector_ingestion_configuration
    if server_side_encryption_configuration is not None:
        input_["server_side_encryption_configuration"] = (
            server_side_encryption_configuration
        )
    if description is not None:
        input_["description"] = description
    if tags is not None:
        input_["tags"] = tags

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output