emora-chat / emora_stdm

State Transition Dialogue Manager
24 stars 9 forks source link

ngrams is None type #17

Closed talynfan closed 1 year ago

talynfan commented 1 year ago

Writing a macro, ngrams.text() fails because ngrams is considered "NoneType".

class Repeat(Macro):
    def run(self, ngrams, vars, args):
        user_text = ngrams.text()
        # user_text = vars.get('__user_utterance__')
        return user_text

The error:

S: Hi say something
U: Everything is awesome when you're part of a team
ERROR: Macro REPEAT raised exception AttributeError("'NoneType' object has no attribute 'text'")
Traceback (most recent call last):
  File "C:\Users\tmail\Documents\Emora_sandbox\cs329-workspace\meow_test_macro.py", line 66, in <module>
    df.run(debugging=False)
  File "C:\Users\tmail\.conda\envs\emora_venv\lib\site-packages\emora_stdm\state_transition_dialogue_manager\dialogue_flow.py", line 160, in run
    system_response = self.system_turn(debugging=debugging)
  File "C:\Users\tmail\.conda\envs\emora_venv\lib\site-packages\emora_stdm\state_transition_dialogue_manager\dialogue_flow.py", line 180, in system_turn
    response, next_state = self.system_transition(self.state(), debugging=debugging)
  File "C:\Users\tmail\.conda\envs\emora_venv\lib\site-packages\emora_stdm\state_transition_dialogue_manager\dialogue_flow.py", line 533, in system_transition
    raise AssertionError('dialogue flow system transition found no valid options from state {}'.format(state))
AssertionError: dialogue flow system transition found no valid options from state 1
Traceback (most recent call last):
  File "C:\Users\tmail\.conda\envs\emora_venv\lib\site-packages\emora_stdm\state_transition_dialogue_manager\natex_nlg.py", line 233, in macro
    tree.children[0] = macro(self._ngrams, self._vars, macro_args)
  File "C:\Users\tmail\.conda\envs\emora_venv\lib\site-packages\emora_stdm\state_transition_dialogue_manager\macro.py", line 32, in __call__
    return self.run(*args, **kwargs)
  File "C:\Users\tmail\Documents\Emora_sandbox\cs329-workspace\meow_test_macro.py", line 16, in run
    user_text = ngrams.text()
AttributeError: 'NoneType' object has no attribute 'text'

Process finished with exit code 1
talynfan commented 1 year ago

Fixed in emora-stdm==2.0.5

ngrams.text() and ngrams.raw_text() can only be called on a NLU transition.