Skip to content

start_ontology_induction async

start_ontology_induction(
    ontology_name: OntologyName,
    input_config: OntologyInductionInputConfig,
    *,
    config_overrides: Optional[AsyncContextClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    ontology_description: Optional[UserDefinedString] = None,
    seed_ontology_id: Optional[OntologyIdentifier] = None,
    prompt: Optional[OntologyInductionPrompt] = None,
    tags: Optional[TagMap] = None,
    ontology_tags: Optional[TagMap] = None,
) -> StartOntologyInductionResponse

Starts an ontology induction, which induces a draft ontology from the documents that you provide. The induction runs asynchronously. To get its status, call GetOntologyInduction. When the induction's status is DRAFT, AWS Context has created the ontology as a DRAFT: GetOntologyInduction returns the ontology's ID, and GetOntology returns the draft. To publish the draft, use the AWS Context console. Because AWS Context creates the ontology on your behalf, you need context:CreateOntology permission in addition to context:StartOntologyInduction. If you specify tags, you also need context:TagResource permission.

Parameters:

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

    A unique, case-sensitive identifier that you provide to make the request idempotent. A retry of the same request with the same token returns the induction that the first request created, and the same token used with a different request returns a ValidationException. If that induction, or the ontology it created, was deleted since, a retry with the token fails with ConflictException.

  • ontology_name (OntologyName) –

    The new ontology's display name.

  • ontology_description (Optional[UserDefinedString], default: None ) –

    Optional. The new ontology's description. An empty string is the same as none.

  • input_config (OntologyInductionInputConfig) –

    The input to induce the ontology from. Set exactly one member.

  • seed_ontology_id (Optional[OntologyIdentifier], default: None ) –

    Optional. An existing ontology to start from, by ID or ARN. If you omit it, AWS Context induces the ontology from the documents alone. The seed must be an ontology that you own, it must be PUBLISHED, and its current version must be derived from a Turtle source document. You also need context:GetOntology permission on the seed. If the seed doesn't exist, the request fails with ResourceNotFoundException. If it can't be used, the request fails with ValidationException. If the seed's source document is deleted while the induction runs, is larger than 400,000 bytes, or doesn't parse, the induction fails with SEED_INVALID.

  • prompt (Optional[OntologyInductionPrompt], default: None ) –

    Optional. Instructions for the induction.

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

    Tags to add to the induction when you create it: up to 200 in the request, of which at most 50 can be user tags. Keys can't start with aws:. To add tags, you also need context:TagResource permission on the new induction. If you specify more than 50 user tags, the request fails with ServiceQuotaExceededException, as on TagResource. If an AWS Organizations tag policy refuses a tag, the request fails with ValidationException. These tags go on the induction only. ontologyTags go on the ontology.

  • ontology_tags (Optional[TagMap], default: None ) –

    Tags to add to the ontology the induction creates at DRAFT, with the same limits and rules as tags. They are checked here, and supplying them also requires context:TagResource on the new ontology. These tags go on the ontology only. tags go on the induction.

Raises:

  • AccessDeniedException –

    You don't have sufficient access to perform this operation. Verify that you have permission to perform the operation on the resource.

  • InternalServerException –

    The request failed because of an internal error. Retry the request.

  • ThrottlingException –

    The request was denied because it exceeded a request rate quota. Wait, then retry the request.

  • ValidationException –

    The input fails to satisfy the constraints of the operation. Correct the input before you retry the request.

  • ConflictException –

    The request conflicts with the current state of the resource. Check the resource's current state before you retry the request.

  • ResourceNotFoundException –

    The specified resource was not found. Check that the ID is correct and that the resource exists in your account and Region.

  • ServiceQuotaExceededException –

    The request would exceed a service quota. Check the quota that quotaCode names, reduce your usage, and then retry the request.

  • UnknownServiceError –

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

Examples:

Start an ontology induction The following example starts an ontology induction from one Markdown document; the induction runs asynchronously and creates a DRAFT ontology when it finishes.

>>> await client.start_ontology_induction(client_token='8b0e6d4c-2a1f-4c3e-9d7b-5a6f7e8d9c0b', ontology_name='library-catalog', ontology_description='Books, authors, members, and loans for a lending library.', input_config={'documents': [{'name': 'catalog-overview.md', 'contentType': 'MARKDOWN', 'content': 'IyBMaWJyYXJ5IGNhdGFsb2cKCkVhY2ggYm9vayBoYXMgYW4gSVNCTiwgYSB0aXRsZSwgYW5kIG9uZSBvciBtb3JlIGF1dGhvcnMuIE1lbWJlcnMgYm9ycm93IGNvcGllcyBvZiBib29rcyB0aHJvdWdoIGxvYW5zIHRoYXQgaGF2ZSBhIGR1ZSBkYXRlLgo='}]}, prompt='Model books, authors, library members, and loans. Give every type a stable identifier.')
Source code in docs_src/capo_context/_services/async_context.py
async def start_ontology_induction(
    self,
    ontology_name: "capo_context.types.ontology_name.OntologyName",
    input_config: "capo_context.types.ontology_induction_input_config.OntologyInductionInputConfig",
    *,
    config_overrides: Optional[AsyncContextClientConfig] = None,
    client_token: Optional["capo_context.types.client_token.ClientToken"] = None,
    ontology_description: Optional[
        "capo_context.types.user_defined_string.UserDefinedString"
    ] = None,
    seed_ontology_id: Optional[
        "capo_context.types.ontology_identifier.OntologyIdentifier"
    ] = None,
    prompt: Optional[
        "capo_context.types.ontology_induction_prompt.OntologyInductionPrompt"
    ] = None,
    tags: Optional["capo_context.types.tag_map.TagMap"] = None,
    ontology_tags: Optional["capo_context.types.tag_map.TagMap"] = None,
) -> "capo_context.types.start_ontology_induction_response.StartOntologyInductionResponse":
    """<p>Starts an ontology induction, which induces a draft ontology from the documents that you provide. The induction runs asynchronously. To get its status, call GetOntologyInduction. When the induction's status is <code>DRAFT</code>, AWS Context has created the ontology as a <code>DRAFT</code>: GetOntologyInduction returns the ontology's ID, and GetOntology returns the draft. To publish the draft, use the AWS Context console. Because AWS Context creates the ontology on your behalf, you need <code>context:CreateOntology</code> permission in addition to <code>context:StartOntologyInduction</code>. If you specify tags, you also need <code>context:TagResource</code> permission.</p>

    Args:
        client_token: <p>A unique, case-sensitive identifier that you provide to make the request idempotent. A retry of the same request with the same token returns the induction that the first request created, and the same token used with a different request returns a <code>ValidationException</code>. If that induction, or the ontology it created, was deleted since, a retry with the token fails with <code>ConflictException</code>.</p>
        ontology_name: <p>The new ontology's display name.</p>
        ontology_description: <p>Optional. The new ontology's description. An empty string is the same as none.</p>
        input_config: <p>The input to induce the ontology from. Set exactly one member.</p>
        seed_ontology_id: <p>Optional. An existing ontology to start from, by ID or ARN. If you omit it, AWS Context induces the ontology from the documents alone. The seed must be an ontology that you own, it must be <code>PUBLISHED</code>, and its current version must be derived from a Turtle source document. You also need <code>context:GetOntology</code> permission on the seed. If the seed doesn't exist, the request fails with <code>ResourceNotFoundException</code>. If it can't be used, the request fails with <code>ValidationException</code>. If the seed's source document is deleted while the induction runs, is larger than 400,000 bytes, or doesn't parse, the induction fails with <code>SEED_INVALID</code>.</p>
        prompt: <p>Optional. Instructions for the induction.</p>
        tags: <p>Tags to add to the induction when you create it: up to 200 in the request, of which at most 50 can be user tags. Keys can't start with <code>aws:</code>. To add tags, you also need <code>context:TagResource</code> permission on the new induction. If you specify more than 50 user tags, the request fails with <code>ServiceQuotaExceededException</code>, as on TagResource. If an AWS Organizations tag policy refuses a tag, the request fails with <code>ValidationException</code>. These tags go on the induction only. <code>ontologyTags</code> go on the ontology.</p>
        ontology_tags: <p>Tags to add to the ontology the induction creates at DRAFT, with the same limits and rules as <code>tags</code>. They are checked here, and supplying them also requires <code>context:TagResource</code> on the new ontology. These tags go on the ontology only. <code>tags</code> go on the induction.</p>

    Raises:
        capo_context.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access to perform this operation. Verify that you have permission to perform the operation on the resource.</p>
        capo_context.errors.internal_server_exception.InternalServerException: <p>The request failed because of an internal error. Retry the request.</p>
        capo_context.errors.throttling_exception.ThrottlingException: <p>The request was denied because it exceeded a request rate quota. Wait, then retry the request.</p>
        capo_context.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints of the operation. Correct the input before you retry the request.</p>
        capo_context.errors.conflict_exception.ConflictException: <p>The request conflicts with the current state of the resource. Check the resource's current state before you retry the request.</p>
        capo_context.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource was not found. Check that the ID is correct and that the resource exists in your account and Region.</p>
        capo_context.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request would exceed a service quota. Check the quota that <code>quotaCode</code> names, reduce your usage, and then retry the request.</p>
        capo_context.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Start an ontology induction
        The following example starts an ontology induction from one Markdown document; the induction runs asynchronously and creates a DRAFT ontology when it finishes.

        >>> await client.start_ontology_induction(client_token='8b0e6d4c-2a1f-4c3e-9d7b-5a6f7e8d9c0b', ontology_name='library-catalog', ontology_description='Books, authors, members, and loans for a lending library.', input_config={'documents': [{'name': 'catalog-overview.md', 'contentType': 'MARKDOWN', 'content': 'IyBMaWJyYXJ5IGNhdGFsb2cKCkVhY2ggYm9vayBoYXMgYW4gSVNCTiwgYSB0aXRsZSwgYW5kIG9uZSBvciBtb3JlIGF1dGhvcnMuIE1lbWJlcnMgYm9ycm93IGNvcGllcyBvZiBib29rcyB0aHJvdWdoIGxvYW5zIHRoYXQgaGF2ZSBhIGR1ZSBkYXRlLgo='}]}, prompt='Model books, authors, library members, and loans. Give every type a stable identifier.')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_context.types.start_ontology_induction_request.StartOntologyInductionRequest]",
    ) -> AsyncOperationResponse[
        "capo_context.types.start_ontology_induction_response.StartOntologyInductionResponse"
    ]:
        import capo_context._operations.context.start_ontology_induction

        (
            output,
            http_response,
        ) = await capo_context._operations.context.start_ontology_induction.async_start_ontology_induction(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_context.types.start_ontology_induction_request.StartOntologyInductionRequest",
    ) -> dict[str, Any]:
        import capo_context.types.start_ontology_induction_request

        return capo_context.types.start_ontology_induction_request.redact_sensitive(
            input_
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("StartOntologyInduction", redact_input=_redact_input),
    )
    input_: capo_context.types.start_ontology_induction_request.StartOntologyInductionRequest = {
        "ontology_name": ontology_name,
        "input_config": input_config,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if ontology_description is not None:
        input_["ontology_description"] = ontology_description
    if seed_ontology_id is not None:
        input_["seed_ontology_id"] = seed_ontology_id
    if prompt is not None:
        input_["prompt"] = prompt
    if tags is not None:
        input_["tags"] = tags
    if ontology_tags is not None:
        input_["ontology_tags"] = ontology_tags

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