Agent(domain, policies=None, featurizer=None, interpreter=None, tracker_store=None)¶
Public interface for common things to do.
This includes e.g. train an assistant, or handle messages with an assistant.
continue_message_handling(sender_id, executed_action, events)¶
Handle messages coming from the channel.
handle_message(text_message, message_preprocessor=None, output_channel=None, sender=None)¶
Handle a single message.
If a message preprocessor is passed, the message will be passed to that function first and the return value is then used as the input for the dialogue engine.
The return value of this function depends on the output_channel. If the output channel is not set, set to None, or set to CollectingOutputChannel this function will return the messages the bot wants to respond.
>>> from rasa_core.agent import Agent >>> agent = Agent.load("examples/babi/models/policy/current", ... interpreter="examples/babi/models/nlu/current_py2") >>> agent.handle_message("hello") [u'how can I help you?']
load(path, interpreter=None, tracker_store=None)¶
Persists this agent into a directory for later loading and usage.
Toggles the memoization on and off.
If a memoization policy is present in the ensemble, this will toggle the prediction of that policy. When set to false the Memoization policies present in the policy ensemble will not make any predictions. Hence, the prediction result from the ensemble always needs to come from a different policy (e.g. KerasPolicy). Useful to test prediction capabilities of an ensemble when ignoring memorized turns from the training data.
Train the policies / policy ensemble using dialogue data from file
train_online(filename=None, input_channel=None, **kwargs)¶
Runs an online training session on the set policies / ensemble.
The policies will be pretrained using the data from filename. After that the model will get trained on dialogues from the input channel. During the dialogue the annotations and state of the agent can be changed to correct wrong behaviour.