notice
This is documentation for Rasa Documentation v2.x, which is no longer actively maintained.
For up-to-date documentation, see the latest version (3.x).
rasa.core.agent
load_from_server
Load a persisted model from a server.
create_agent
Create an agent instance based on a stored model.
Arguments:
model
- file path to the stored modelendpoints
- file path to the used endpoint configuration
load_agent
Loads agent from server, remote storage or disk.
Arguments:
model_path
- Path to the model if it's on disk.model_server
- Configuration for a potential server which serves the model.remote_storage
- URL of remote storage for model.interpreter
- NLU interpreter to parse incoming messages.generator
- Optional response generator.tracker_store
- TrackerStore for persisting the conversation history.lock_store
- LockStore to avoid that a conversation is modified by concurrent actors.action_endpoint
- Action server configuration for executing custom actions.
Returns:
The instantiated Agent
or None
.
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?']
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.
visualize
Visualize the loaded training data from the resource.
create_processor
Instantiates a processor based on the set state of the agent.