Layered Configurations

This section of the documentation covers general information about layered configurations in Semantria API.

A layered configuration is a special, extended configuration that exists at the account level. It allows you to define a configuration that inherits configuration items (query topics, user entities, sentiment phrases, concept topics, and blacklist items) from other configurations and industry packs.

The main differences between discrete and layered configurations:

  1. A layer has parents which can be other configs or industry packs
  2. A layer cannot have its own config items; the items are resolved in real-time from the parents

Apart from these differences, a configuration layer acts like a discrete config (the endpoints are the same, it has its own settings/tags, thresholds, etc).

_An example of how to visualize a layered configuration__An example of how to visualize a layered configuration_

An example of how to visualize a layered configuration

The advantage of using a layered configuration becomes apparent when you would like to take a prebuilt industry pack and extend it. Previously this would be accomplished by cloning an industry pack to a new configuration, which you can then modify. The downside to this is that the configuration that was cloned from the industry pack will no longer receive updates applied to the pack.

Layering an industry pack together with a configuration, enables you to make modifications to the new layered configuration and also continue to receive industry pack updates.

You can create a configuration layer using the endpoint: Create Configuration

Setting the layer attribute to true will cause this request to create a configuration layer. It is also necessary to include parents that it inherits from in the parents attribute. This can be seen in the example code below.

import requests

url = "https://api5.semantria.com/configs/"

payload = {
    "parents": ["CONFIGURATION_ID"],
    "settings": ["ANAPHORA_RESOLUTION"],
    "alphanumeric_threshold": 0,
    "concept_topics_threshold": 0,
    "deep_models_threshold": 0,
    "entities_threshold": 0,
    "is_autoresponse_enabled": True,
    "language_id": "en",
    "layer": True,
    "name": "layer2",
    "pos_types": "Noun,Verb,Adjective",
    "summary_size": 0,
}
headers = {
    "accept": "application/json",
    "content-type": "application/json",
    "Authorization": "AUTHORIZATION_ID"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)

Another helpful request for working with layered configuration is:

Get ids for configurations that use this config as a parent

This will provide the ids of any children of a parent configuration.