View a markdown version of this page

Start grounding by associating an ontology - AWS Context

Start grounding by associating an ontology

To start grounding, associate a published custom ontology with the Agent Context. You associate an ontology with a task. The task runs in the background and imports each ontology that you choose, in order. Each import is a curation change. Under the default curation policy, AWS Context applies the import at once. If a curation policy holds it for review, AWS Context applies it after you approve it. After the import is applied, grounding starts.

You can associate an ontology on the AWS Context console or with the API. If the association fails or no grounding proposals appear, see Troubleshoot structured data grounding.

Associate an ontology on the console

To associate an ontology on the AWS Context console, follow these steps:

  1. In the navigation pane, choose Agent context, and then choose your Agent Context.

  2. Choose Actions, and then choose Customize context. Customize context is also on the Next steps panel and on the Curation tab.

  3. On the Associate ontologies card, choose Associate ontologies.

  4. In the table, select one or more ontologies. The table lists only your published custom ontologies. It doesn’t list drafts or built-in ontologies. It still lists an ontology that is already associated with the Agent Context.

  5. Choose Associate ontologies.

The console shows the message "Customization task <task-id> created." and opens the Curation tab. The task appears in the Customization tasks table with the task type Ontology association. The table shows the task’s run status and the number of changes that it created.

If a curation policy holds an import for review, its proposal appears on the Curation tab with the other proposals that wait for review. To approve it, follow the steps in Review grounding proposals on the console.

After the import is applied, grounding starts. After grounding runs, its proposals appear on the Curation tab. To review them, see Review and edit grounding proposals.

Associate an ontology with the API

To associate an ontology with the API, call StartTask with your Agent Context (agentContextId) and the ontologies to import (inputConfiguration.importOntology.ontologies). Name each ontology by its ID or ARN (ontologyId). A version (ontologyVersion) is optional. Also send the access control for what the task adds (accessControlConfig). A description (description) and a client token (clientToken) are optional.

The task runs in the background. The response has the task’s ID (id), its ARN (arn), its type (type), which is IMPORT_ONTOLOGY, and its status (status), which is PENDING for a new task.

The following example shows the inputs for StartTask. It isn’t a complete request.

StartTask agentContextId: <agent-context-id> inputConfiguration: importOntology: ontologies: - ontologyId: <ontology-id> accessControlConfig: accessControlList: - access: ALLOW principalId: "*" GetTask agentContextId: <agent-context-id> taskId: <task-id>

Replace the following values:

  • <agent-context-id> – the ID or ARN of your Agent Context.

  • <ontology-id> – the ID or ARN of a published custom ontology, from ListOntologies or GetOntology. To import more than one ontology, add one entry for each.

  • <task-id> – the task’s id from the StartTask response.

To check the task, call GetTask until its status is final. The task has one of the following statuses.

Status What it means

PENDING

The task is waiting to run.

IN_PROGRESS

The task is importing the ontologies.

COMPLETED

The task imported every ontology.

FAILED

The task stopped, or at least one ontology wasn’t imported. statusReasonCode and statusMessage say why. For the codes, see FAILED: the association task doesn’t import an ontology.

CANCELLING

Someone canceled the task with CancelTask, and the task is stopping.

CANCELLED

The task stopped after it was canceled.

COMPLETED, FAILED, and CANCELLED are final. A task can partly succeed. If it imports some ontologies but not others, its status is FAILED, and statusMessage says how many ontologies it imported. When the task is final, outputs lists the change sets that it created, and statistics counts them. statistics.numberOfChangeSetsAutoApproved counts the imports that the curation policy applied without review.

If a curation policy holds an import for review, approve its curation proposal:

  1. Call ListCurationProposals with status set to PENDING_REVIEW. Find the proposal whose changeSetId matches a changeSetId in the task’s outputs. The proposal has generatedBy set to IMPORT_ONTOLOGY_TASK.

  2. Call AcceptCurationProposal with the proposal’s curationProposalId and revisionId.

The following example shows the inputs for ListCurationProposals and AcceptCurationProposal. It isn’t a complete request.

ListCurationProposals agentContextId: <agent-context-id> status: PENDING_REVIEW AcceptCurationProposal agentContextId: <agent-context-id> curationProposalId: <proposal-id> revisionId: <revision-id>

Replace the following values:

  • <agent-context-id> – the ID or ARN of your Agent Context.

  • <proposal-id> – the proposal’s curationProposalId from ListCurationProposals.

  • <revision-id> – the proposal’s revisionId from ListCurationProposals.

For the AcceptCurationProposal request fields, see AcceptCurationProposal and RejectCurationProposal request fields.

The proposal’s status changes to APPROVED. After grounding runs, new proposals with generatedBy set to ONTOLOGY_GROUNDING appear in the curation queue with status PENDING_REVIEW. For a large catalog, the proposals arrive in batches, so the first proposals can appear before grounding has checked every table. For more information, see How structured data grounding works.

For the StartTask request fields, see the next section, StartTask request fields for associating an ontology. If StartTask fails or the task ends FAILED, see FAILED: the association task doesn’t import an ontology. If approving a held import fails, see ValidationException: approving a held import fails.

StartTask request fields for associating an ontology

The following table describes each field in the StartTask request for associating an ontology.

Field Description and rules

agentContextId

Required. The Agent Context to import the ontologies into, by its ID or ARN.

inputConfiguration

Required. What the task imports. Set exactly one member. To associate ontologies, set importOntology. The member that you set determines the task’s type, IMPORT_ONTOLOGY.

ontologies

Required. In inputConfiguration.importOntology. The ontologies to import, 1 to 10. AWS Context imports them in the order that you list them. Each ontology can appear only once.

ontologyId

Required. In each entry of ontologies. The ID or ARN of the ontology to import. The ontology must belong to the account that owns the Agent Context.

ontologyVersion

Optional. In each entry of ontologies. The ontology’s version, in the form MAJOR.MINOR.PATCH. A custom ontology has one version, 1.0.0. If you leave it out, AWS Context imports that version.

accessControlConfig

Optional, but send it. Who can see what the task adds to the Agent Context. Only one entry is supported in accessControlList: access set to ALLOW and principalId set to *. This entry lets every reader of the Agent Context see what the task adds. Any other entry, a DENY entry, or more than one entry fails with a ValidationException, and the task doesn’t start. If you leave out accessControlConfig, AWS Context uses that one entry. Send it anyway, because a later release will refuse a request without it.

description

Optional. A description of the task, up to 1,024 characters. It can’t contain control characters.

clientToken

Optional. Makes the request safe to retry. 1 to 64 printable ASCII characters, with no spaces. The token is scoped to your account and the Agent Context. If you reuse a token in the same Agent Context with different parameters, the call fails with a ValidationException. AWS SDKs generate a token if you don’t set one.

You can associate each ontology with an Agent Context only once. If the ontology is already loaded in the Agent Context, the task records that import as failed with ONTOLOGY_ALREADY_IMPORTED. To make grounding check every table again, associate a different published ontology, for example an edited copy that you upload as a new ontology. For more information, see Bring your own ontology and FAILED: the association task doesn’t import an ontology.