Esempio n. 1
0
def create_machine(model):
    return HierarchicalMachine(model=model, **KWARGS)
Esempio n. 2
0
from typing import List, Optional

from transitions.extensions import (HierarchicalGraphMachine,
                                    HierarchicalMachine)
from transitions.extensions.nesting import NestedState

from ..models.chat import BaseMessage

NestedState.separator = '.'

PROMPT_STATEMACHINE = HierarchicalMachine(
    initial='ask',
    states=['yes', 'no'],
    transitions=[
        dict(trigger='prompt.result',
             source='ask',
             dest='yes',
             conditions=['is_yes']),
        dict(trigger='prompt.result', source='ask', dest='no'),
    ],
)

INITIAL = 'hi'

FINALS = ['bye', 'booked']

STATES = [
    INITIAL,
    dict(name='dialog', on_enter='inc_dialog_count'),
    dict(name='suggest', children=PROMPT_STATEMACHINE),
    'booked',