Пример #1
0
async def _write_domain_to_file(
    domain_path: Text,
    evts: List[Dict[Text, Any]],
    endpoint: EndpointConfig
) -> None:
    """Write an updated domain file to the file path."""

    domain = await retrieve_domain(endpoint)
    old_domain = Domain.from_dict(domain)

    messages = _collect_messages(evts)
    actions = _collect_actions(evts)

    # TODO for now there is no way to distinguish between action and form
    intent_properties = Domain.collect_intent_properties(
        _intents_from_messages(messages))

    collected_actions = list({e["name"]
                              for e in actions
                              if e["name"] not in default_action_names()})

    new_domain = Domain(
        intent_properties=intent_properties,
        entities=_entities_from_messages(messages),
        slots=[],
        templates={},
        action_names=collected_actions,
        form_names=[])

    old_domain.merge(new_domain).persist_clean(domain_path)
Пример #2
0
def test_collect_intent_properties(intents, intent_properties):
    assert Domain.collect_intent_properties(intents) == intent_properties
Пример #3
0
def test_collect_intent_properties(intents, entities, intent_properties):
    Domain._add_default_intents(intent_properties, entities)

    assert Domain.collect_intent_properties(intents, entities) == intent_properties