Ejemplo n.º 1
0
def dm():
    dialogue_manager = DialogueManager(async_mode=True)
    dialogue_manager.called_async_handler = False

    @dialogue_manager.handle(domain="domain")
    async def domain(ctx, handler):
        pass

    @dialogue_manager.handle(intent="intent")
    async def intent(ctx, handler):
        pass

    @dialogue_manager.handle(domain="domain", intent="intent")
    async def domain_intent(ctx, handler):
        pass

    @dialogue_manager.handle(intent="intent", has_entity="entity_1")
    async def intent_entity_1(ctx, handler):
        pass

    @dialogue_manager.handle(intent="intent", has_entity="entity_2")
    async def intent_entity_2(ctx, handler):
        pass

    @dialogue_manager.handle(
        intent="intent", has_entities=("entity_1", "entity_2", "entity_3")
    )
    async def intent_entities(ctx, handler):
        pass

    @dialogue_manager.handle(targeted_only=True)
    async def targeted_only(ctx, handler):
        pass

    # Defined to test default use
    @dialogue_manager.handle()
    async def dummy_ruleless(ctx, handler):
        pass

    @dialogue_manager.handle(default=True)
    async def default(ctx, handler):
        pass

    @dialogue_manager.handle(intent="async")
    async def async_handler(_, responder):
        await asyncio.sleep(0.050)
        dialogue_manager.called_async_handler = True
        responder.reply("this is the async handler")

    return dialogue_manager
Ejemplo n.º 2
0
def dm():
    dialogue_manager = DialogueManager(async_mode=True)
    dialogue_manager.called_async_handler = False

    @dialogue_manager.handle(domain='domain')
    async def domain(ctx, handler):
        pass

    @dialogue_manager.handle(intent='intent')
    async def intent(ctx, handler):
        pass

    @dialogue_manager.handle(domain='domain', intent='intent')
    async def domain_intent(ctx, handler):
        pass

    @dialogue_manager.handle(intent='intent', has_entity='entity_1')
    async def intent_entity_1(ctx, handler):
        pass

    @dialogue_manager.handle(intent='intent', has_entity='entity_2')
    async def intent_entity_2(ctx, handler):
        pass

    @dialogue_manager.handle(intent='intent',
                             has_entities=('entity_1', 'entity_2', 'entity_3'))
    async def intent_entities(ctx, handler):
        pass

    @dialogue_manager.handle(targeted_only=True)
    async def targeted_only(ctx, handler):
        pass

    # Defined to test default use
    @dialogue_manager.handle()
    async def dummy_ruleless(ctx, handler):
        pass

    @dialogue_manager.handle(default=True)
    async def default(ctx, handler):
        pass

    @dialogue_manager.handle(intent='async')
    async def async_handler(_, responder):
        await asyncio.sleep(0.050)
        dialogue_manager.called_async_handler = True
        responder.reply('this is the async handler')

    return dialogue_manager
Ejemplo n.º 3
0
def dm():
    dm = DialogueManager()
    dm.add_dialogue_rule("domain", lambda x, y: None, domain="domain")
    dm.add_dialogue_rule("intent", lambda x, y: None, intent="intent")
    dm.add_dialogue_rule("domain_intent",
                         lambda x, y: None,
                         domain="domain",
                         intent="intent")
    dm.add_dialogue_rule("intent_entity_1",
                         lambda x, y: None,
                         intent="intent",
                         has_entity="entity_1")
    dm.add_dialogue_rule("intent_entity_2",
                         lambda x, y: None,
                         intent="intent",
                         has_entity="entity_2")
    dm.add_dialogue_rule(
        "intent_entities",
        lambda x, y: None,
        intent="intent",
        has_entities=("entity_1", "entity_2", "entity_3"),
    )

    dm.add_dialogue_rule("targeted_only",
                         lambda x, y: None,
                         targeted_only=True)
    dm.add_dialogue_rule("dummy_ruleless",
                         lambda x, y: None)  # Defined to test default use
    dm.add_dialogue_rule("default", lambda x, y: None, default=True)

    return dm
Ejemplo n.º 4
0
def dm():
    dm = DialogueManager()
    dm.add_dialogue_rule('domain', lambda x, y: None, domain='domain')
    dm.add_dialogue_rule('intent', lambda x, y: None, intent='intent')
    dm.add_dialogue_rule('domain_intent',
                         lambda x, y: None,
                         domain='domain',
                         intent='intent')
    dm.add_dialogue_rule('intent_entity_1',
                         lambda x, y: None,
                         intent='intent',
                         has_entity='entity_1')
    dm.add_dialogue_rule('intent_entity_2',
                         lambda x, y: None,
                         intent='intent',
                         has_entity='entity_2')
    dm.add_dialogue_rule('intent_entities',
                         lambda x, y: None,
                         intent='intent',
                         has_entities=('entity_1', 'entity_2', 'entity_3'))

    dm.add_dialogue_rule('targeted_only',
                         lambda x, y: None,
                         targeted_only=True)
    dm.add_dialogue_rule('dummy_ruleless',
                         lambda x, y: None)  # Defined to test default use
    dm.add_dialogue_rule('default', lambda x, y: None, default=True)

    return dm