无法验证域yaml文件

时间:2019-04-03 09:10:32

标签: python chatbot rasa-nlu rasa-core

在使用Rasa-NLU和Rasa-Core构建聊天机器人时,我面临“无法验证Domain.yaml文件:无效域”的问题。

还已经使用在线yaml代码语法进行了检查,并且似乎是有效的yml文件。仍然面临问题

无法继续进行,请提供帮助。联机检查时,域文件似乎正常

域名yml:

slots:
  Hardware:
   type: text
  Software:
   type: text  
  Network:
   type: text


intents:
 -greet
 -goodbye
 -Accept
 -Reject
 -Software_Issue
 -Network_Issue
 -Hardware_Issue


entities:
 - Hardware
 - Software
 - Network

templates:
  utter_greet:
    - 'Hello! I am your IT Helpdesk bot to help you with Software, Hardware and Network Issues. May I know how can I help you?'
    - 'Hi! I am your IT Helpdesk bot to help you with Software, Hardware and Network Issues. May I know how can I help you'
  utter_goodbye:
    - 'Bye bye , Have a nice day Ahead'
  utter_Software_issue_and_seek_permission_for_raising_ticket:
    - 'I understand you have a software issue,Shall I raise ticket on behalf of you for the same?'
  utter_Hardware_issue_and_seek_permission_for_raising_ticket:
    - 'I understand you have a hardware issue,Shall I raise ticket on behalf of you for the same?'
  utter_Network_issue_and_seek_permission_for_raising_ticket:
    - 'I understand you have a network issue,Shall I raise ticket on behalf of you for the same?'         


actions:
  -utter_greet
  -utter_goodbye
  -utter_Software_issue_and_seek_permission_for_raising_ticket
  -utter_Hardware_issue_and_seek_permission_for_raising_ticket
  -utter_Network_issue_and_seek_permission_for_raising_ticket
  -action_ITchatbot

训练文件:

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import logging

from rasa_core.agent import Agent
from rasa_core.policies.keras_policy import KerasPolicy
from rasa_core.policies.memoization import MemoizationPolicy
from rasa_core.interpreter import RasaNLUInterpreter
from rasa_core.train import interactive
from rasa_core.utils import EndpointConfig

logger = logging.getLogger(__name__)


def run_ITHelpdesk_online(interpreter,
                      domain_file="IT_Helpdesk_domain.yml",
                      training_data_file='data/Stories.md'):
action_endpoint = EndpointConfig(url="http://localhost:5055/webhook")                                                                                        
agent = Agent(domain_file,
              policies=[MemoizationPolicy(max_history=2), KerasPolicy(max_history=3, epochs=3, batch_size=50)],
              interpreter=interpreter,
              action_endpoint=action_endpoint)

data = agent.load_data(training_data_file)                                      
agent.train(data)
interactive.run_interactive_learning(agent, training_data_file)
return agent


if __name__ == '__main__':
  logging.basicConfig(level="INFO")
  nlu_interpreter = RasaNLUInterpreter('./models/nlu/default/ITchatbot')
  run_ITHelpdesk_online(nlu_interpreter)

错误:

INFO:rasa_nlu.components:Added 'nlp_spacy' to component cache. Key 'nlp_spacy-en'.
ERROR:pykwalify.core:validation.invalid
ERROR:pykwalify.core: --- All found errors ---
ERROR:pykwalify.core:["Value 'b'-greet -goodbye -Accept -Reject -Software_Issue -Network_Issue -Hardware_Issue'' is not a list. Value path: '/intents'"]
Traceback (most recent call last):
File "C:\Users\h\AppData\Local\Programs\Python\Python35\lib\site- packages\rasa_core\domain.py", line 174, in validate_domain_yaml
 c.validate(raise_exception=True)
File "C:\Users\h\AppData\Local\Programs\Python\Python35\lib\site-packages\pykwalify\core.py", line 167, in validate
 error_msg=u'.\n - '.join(self.validation_errors)))
  pykwalify.errors.SchemaError: <SchemaError: error code 2: Schema validation failed:
- Value 'b'-greet -goodbye -Accept -Reject -Software_Issue -Network_Issue 
 -Hardware_Issue'' is not a list. Value path: '/intents'.: Path: '/'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
 File "train_interactive.py", line 36, in <module>
run_ITHelpdesk_online(nlu_interpreter)
 File "train_interactive.py", line 25, in run_ITHelpdesk_online
action_endpoint=action_endpoint)
File "C:\Users\h\AppData\Local\Programs\Python\Python35\lib\site- 
 packages\rasa_core\agent.py", line 193, in __init__
self.domain = self._create_domain(domain)
 File 
     "C:\Users\h\AppData\Local\Programs\Python\Python35\lib\site- 
   packages\rasa_core\agent.py", line 648, in _create_domain
return Domain.load(domain)
 File 
     "C:\Users\h\AppData\Local\Programs\Python\Python35\lib\site- 
   packages\rasa_core\domain.py", line 88, in load
return cls.from_yaml(read_file(filename))
 File 
     "C:\Users\h\AppData\Local\Programs\Python\Python35\lib\site- 
   packages\rasa_core\domain.py", line 92, in from_yaml
cls.validate_domain_yaml(yaml)
 File 
    "C:\Users\h\AppData\Local\Programs\Python\Python35\lib\site- 
  packages\rasa_core\domain.py", line 176, in validate_domain_yaml
    raise InvalidDomain("Failed to validate your domain yaml. "
    rasa_core.domain.InvalidDomain: Failed to validate your domain yaml. Make 
  sure the file is correct, to do sotake a look at the errors logged during 
  validation previous to this exception.

1 个答案:

答案 0 :(得分:0)

域文件必须正确格式化。 您在短划线和意图和动作之间也缺少空格。

-greet       -> - greet
-utter_greet -> - utter_greet