notice
This is documentation for Rasa Open Source Documentation v2.0.x, which is no longer actively maintained.
For up-to-date documentation, see the latest version (2.3.x).
rasa.core.agent
load_from_server
Load a persisted model from a server.
Agent Objects
The Agent class provides a convenient interface for the most important Rasa functionality.
This includes training, handling messages, loading a dialogue model, getting the next action, and handling a channel.
load
Load a persisted model from the passed path.
is_core_ready
Check if all necessary components and policies are ready to use the agent.
is_ready
Check if all necessary components are instantiated to use agent.
Policies might not be available, if this is an NLU only agent.
parse_message_using_nlu_interpreter
Handles message text and intent payload input messages.
The return value of this function is parsed_data.
Arguments:
message_data
Text - Contain the received message in text or\ intent payload format.tracker
DialogueStateTracker - Contains the tracker to be\ used by the interpreter.
Returns:
The parsed message.
Example:
{\
"text"
- '/greet{"name":"Rasa"}',\"intent"
- {"name": "greet", "confidence": 1.0},\"intent_ranking"
- [{"name": "greet", "confidence": 1.0}],\"entities"
- [{"entity": "name", "start": 6,\"end"
- 21, "value": "Rasa"}],\ }
handle_message
Handle a single message.
predict_next
Handle a single message.
log_message
Append a message to a dialogue - does not predict actions.
execute_action
Handle a single message.
trigger_intent
Trigger a user intent, e.g. triggered by an external event.
handle_text
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.
:Example:
>>> from rasa.core.agent import Agent >>> from rasa.core.interpreter import RasaNLUInterpreter >>> agent = Agent.load("examples/moodbot/models") >>> await agent.handle_text("hello") [u'how can I help you?']
toggle_memoization
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. TEDPolicy
). Useful to test
prediction
capabilities of an ensemble when ignoring memorized turns from the
training data.
load_data
Load training data from a resource.
train
Train the policies / policy ensemble using dialogue data from file.
Arguments:
training_trackers
- trackers to train on**kwargs
- additional arguments passed to the underlying ML trainer (e.g. keras parameters)
persist
Persists this agent into a directory for later loading and usage.
create_processor
Instantiates a processor based on the set state of the agent.