How to apply actions.py for conversational bot which extracts responses from my dataset

rasa-core
varsha

(tatenda) #1

hie, i’m new to rasa-stack and i’m creating a simple conversational pizzabot which responds to user text messages (intents e.g order_pizza, ask_pizza_cost etc)and retrieves replies from a dataset, no APIs. i have managed to train and evaluate the dataset but i dont know how to apply actions.py, like, i have no idea about those utterAction and action classes. most of the solutions involve APIs. somebody please help i need this asap.


(Varsha Kirani) #2

How does your dataset look like? Is it stored in some database?


(tatenda) #3

hie Varsha i solved that issue i used formAction. now my problem is with training the dialogue model. This is my code

from rasa_core.policies import FallbackPolicy, KerasPolicy, MemoizationPolicy from rasa_core.agent import Agent

#this will catch predictions the model isn’t very certain about #there is a threshold for the NLU predictions as well as the action predictions fallback = FallbackPolicy(fallback_action_name=“utter_action_fallback”, core_threshold=0.2, nlu_threshold=0.1)

agent = Agent(‘domain.yml’, policies=[MemoizationPolicy(), KerasPolicy(), fallback])

#loading our neatly defined training dialogues¶ training_data = agent.load_data(‘stories.md’)

agent.train(training_data)

agent.persist(‘models/dialogue’). and i get the following error

INFO:root:Generating grammar tables from /usr/lib/python3.6/lib2to3/Grammar.txt INFO:root:Generating grammar tables from /usr/lib/python3.6/lib2to3/PatternGrammar.txt INFO:apscheduler.scheduler:Scheduler started

ParserError Traceback (most recent call last) in 7 core_threshold=0.2, nlu_threshold=0.1) 8 ----> 9 agent = Agent(‘domain.yml’, policies=[MemoizationPolicy(), KerasPolicy(), fallback]) 10 11 #loading our neatly defined training dialogues¶

~/finalbot/finalbot0_env/lib/python3.6/site-packages/rasa_core/agent.py in init(self, domain, policies, interpreter, generator, tracker_store, action_endpoint, fingerprint) 191 ): 192 # Initializing variables with the passed parameters. –> 193 self.domain = self._create_domain(domain) 194 if self.domain: 195 self.domain.add_requested_slot()

~/finalbot/finalbot0_env/lib/python3.6/site-packages/rasa_core/agent.py in _create_domain(domain) 646 647 if isinstance(domain, str): –> 648 return Domain.load(domain) 649 elif isinstance(domain, Domain): 650 return domain

~/finalbot/finalbot0_env/lib/python3.6/site-packages/rasa_core/domain.py in load(cls, filename) 86 "Failed to load domain specification from ‘{}’. " 87 “File not found!”.format(os.path.abspath(filename))) —> 88 return cls.from_yaml(read_file(filename)) 89 90 @classmethod

~/finalbot/finalbot0_env/lib/python3.6/site-packages/rasa_core/domain.py in from_yaml(cls, yaml) 90 @classmethod 91 def from_yaml(cls, yaml): —> 92 cls.validate_domain_yaml(yaml) 93 data = read_yaml_string(yaml) 94 return cls.from_dict(data)

~/finalbot/finalbot0_env/lib/python3.6/site-packages/rasa_core/domain.py in validate_domain_yaml(cls, yaml) 168 schema_file = pkg_resources.resource_filename(name, 169 “schemas/domain.yml”) –> 170 source_data = utils.read_yaml_string(yaml) 171 c = Core(source_data=source_data, 172 schema_files=[schema_file])

~/finalbot/finalbot0_env/lib/python3.6/site-packages/rasa_core/utils.py in read_yaml_string(string) 325 yaml_parser.unicode_supplementary = True 326 –> 327 return yaml_parser.load(string) 328 329

~/finalbot/finalbot0_env/lib/python3.6/site-packages/ruamel/yaml/main.py in load(self, stream) 329 constructor, parser = self.get_constructor_parser(stream) 330 try: –> 331 return constructor.get_single_data() 332 finally: 333 parser.dispose()

~/finalbot/finalbot0_env/lib/python3.6/site-packages/ruamel/yaml/constructor.py in get_single_data(self) 107 # type: () -> Any 108 # Ensure that the stream contains a single document and construct it. –> 109 node = self.composer.get_single_node() 110 if node is not None: 111 return self.construct_document(node)

_ruamel_yaml.pyx in _ruamel_yaml.CParser.get_single_node()

_ruamel_yaml.pyx in _ruamel_yaml.CParser._compose_document()

_ruamel_yaml.pyx in _ruamel_yaml.CParser._compose_node()

_ruamel_yaml.pyx in _ruamel_yaml.CParser._compose_mapping_node()

_ruamel_yaml.pyx in _ruamel_yaml.CParser._parse_next_event()

ParserError: while parsing a block mapping in “”, line 2, column 1 did not find expected key in “”, line 16, column 7

what am i missing??? please help