AttributeError:使用RASA,“ NoneType”对象没有属性“ index”

时间:2018-11-14 13:45:03

标签: python python-3.x rasa-core

我尝试使用RASA来构建示例bot,但出现了错误消息,

Bot loaded. Type a message and press enter (use '/stop' to exit):
sad
Exception in thread Thread-2:
Traceback (most recent call last):
  File "C:\python36\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "C:\python36\lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "C:\python36\lib\site-packages\rasa_core\channels\channel.py", line 291, in on_message_wrapper
    on_new_message(message)
  File "C:\python36\lib\site-packages\rasa_core\agent.py", line 316, in handle_message
    return processor.handle_message(message)
  File "C:\python36\lib\site-packages\rasa_core\processor.py", line 86, in handle_message
    self._predict_and_execute_next_action(message, tracker)
  File "C:\python36\lib\site-packages\rasa_core\processor.py", line 305, in _predict_and_execute_next_action
    action, policy, confidence = self.predict_next_action(tracker)
  File "C:\python36\lib\site-packages\rasa_core\processor.py", line 168, in predict_next_action
    probabilities, policy = self._get_next_action_probabilities(tracker)
  File "C:\python36\lib\site-packages\rasa_core\processor.py", line 478, in _get_next_action_probabilities
    tracker, self.domain)
  File "C:\python36\lib\site-packages\rasa_core\policies\ensemble.py", line 288, in probabilities_using_best_policy
    if (result.index(max_confidence) ==
AttributeError: 'NoneType' object has no attribute 'index'

我使用:

PYTHON  3.6.0
RASA CORE   0.12.0
RASA NLU    0.13.0
TENSORFLOW  1.10.0
PROTOBUF    3.6.0

这有可能解决吗? 谢谢

2 个答案:

答案 0 :(得分:0)

您似乎尚未训练对话模型或未正确创建策略。尝试使用以下命令再次训练您的对话模块

python -m rasa_core.train -d domain.yml -s stories.md -o models/dialogue

如果您可以在以下目录中显示内容,那就很好了:

./models/dialogue

它应该看起来像下面的样子。

enter image description here

答案 1 :(得分:0)

使用rasa_core版本0.12时,您必须提供policy configuration进行培训。您可以例如Github中的模板的默认模板。 例如。将以下代码段保存到名为default_config.yml的文件中:

policies:
  - name: KerasPolicy
    epochs: 100
    max_history: 5
  - name: FallbackPolicy
    fallback_action_name: 'action_default_fallback'
  - name: MemoizationPolicy
    max_history: 5
  - name: FormPolicy

然后使用以下方法训练Rasa Core:

python -m rasa_core.train \
  -d <path to domain file> \
  -s <path to stories> \
  -c default_config.yml \
  -o models/dialogue

然后使用以下命令运行经过训练的模型:

python -m rasa_core.run -d models/dialogue