-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path__init__.py
29 lines (25 loc) · 885 Bytes
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import ravestate as rs
import ravestate_rawio as rawio
from .verbaliser import *
from reggol import get_logger
logger = get_logger(__name__)
with rs.Module(name="verbaliser", depends=(rawio.mod,)) as mod:
prop_intent = rs.Property(
name="intent",
default_value="",
allow_push=False,
allow_pop=False,
always_signal_changed=True,
wipe_on_changed=False)
@rs.state(read=prop_intent, write=rawio.prop_out)
def react_to_intent(ctx):
"""
Looks for intents written to the verbaliser:intent property and
writes a random phrase for that intent to rawio:out
"""
intent = ctx[prop_intent.changed()]
phrase = verbaliser.get_random_phrase(intent)
if phrase:
ctx[rawio.prop_out] = phrase
else:
logger.error(f'No phrase for intent {intent} found.')