notice
This is unreleased documentation for Rasa Documentation Main/Unreleased version.
For the latest released documentation, see the latest version (3.x).
rasa.core.agent
load_from_server
Load a persisted model from a server.
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.endpoints
- Endpoint configuration.loop
- Optional async loop to pass to broker creation.
Returns:
The instantiated Agent
or None
.
agent_must_be_ready
Any Agent method decorated with this will raise if the agent is not ready.
Agent Objects
The Agent class provides an interface for the most important Rasa functionality.
This includes training, handling messages, loading a dialogue model, getting the next action, and handling a channel.
__init__
Initializes an Agent
.
load
Constructs a new agent and loads the processer and model.
load_model
Loads the agent's model and processor given a new model path.
model_id
Returns the model_id from processor's model_metadata.
model_name
Returns the model name from processor's model_path.
is_ready
Check if all necessary components are instantiated to use agent.
parse_message
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.
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_for_sender_id
Predict the next action for a sender id.
predict_next_with_tracker
Predicts the next action.
log_message
Append a message to a dialogue - does not predict actions.
execute_action
Executes an action.
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 >>> agent = Agent.load("examples/moodbot/models") >>> await agent.handle_text("hello") [u'how can I help you?']
load_model_from_remote_storage
Loads an Agent from remote storage.