Agent
These docs are for version 1.x of Rasa Open Source.
User Guide
- Installation
- Tutorial: Rasa Basics
- Tutorial: Building Assistants
- Command Line Interface
- Architecture
- Messaging and Voice Channels
- Testing Your Assistant
- Setting up CI/CD
- Validate Data
- Configuring the HTTP API
- Deploying Your Rasa Assistant
- Cloud Storage
NLU
- About
- Using NLU Only
- Training Data Format
- Language Support
- Choosing a Pipeline
- Components
- Entity Extraction
Core
- About
- Stories
- Domains
- Responses
- Actions
- Reminders and External Events
- Policies
- Slots
- Forms
- Retrieval Actions
- Interactive Learning
- Fallback Actions
- Knowledge Base Actions
Conversation Design
API Reference
- Action Server
- HTTP API
- Jupyter Notebooks
- Agent
- Custom NLU Components
- Rasa SDK
- Events
- Tracker
- Tracker Stores
- Event Brokers
- Lock Stores
- Training Data Importers
- Featurization of Conversations
- TensorFlow Configuration
- Migration Guide
- Rasa Open Source Change Log
Migrate from (beta)
Reference
Versions
viewing: 1.10.23
Warning: This document is for an old version of Rasa. The latest version is 1.10.26.
Agent ¶
classrasa.core.agent.``Agent( domain=None, policies=None, interpreter=None, generator=None, tracker_store=None, lock_store=None, action_endpoint=None, fingerprint=None, model_directory=None, model_server=None, remote_storage=None, path_to_model_archive=None) ¶
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.
create_processor( preprocessor=None) ¶
Instantiates a processor based on the set state of the agent.
Return type
MessageProcessor
asyncexecute_action( sender_id, action, output_channel, policy, confidence) ¶
Handle a single message.
Return type
handle_channels( channels, http_port=5005, route='/webhooks/', cors=None) ¶
Start a webserver attaching the input channels and handling msgs.
Return type
Sanic
asynchandle_message( message, message_preprocessor=None, **kwargs) ¶
Handle a single message.
Return type
Optional[List[Dict[str, Any]]
asynchandle_text( text_message, message_preprocessor=None, output_channel=None, _sender_id='default') ¶
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/restaurantbot/models/current")
>>> await agent.handle_text("hello")
[u'how can I help you?']
Return type
Optional[List[Dict[str, Any]]
is_core_ready() ¶
Check if all necessary components and policies are ready to use the agent.
Return type
bool
is_ready() ¶
Check if all necessary components are instantiated to use agent.
Policies might not be available, if this is an NLU only agent.
Return type
bool
classmethodload( model_path, interpreter=None, generator=None, tracker_store=None, lock_store=None, action_endpoint=None, model_server=None, remote_storage=None, path_to_model_archive=None) ¶
Load a persisted model from the passed path.
Return type
asyncload_data( training_resource, remove_duplicates=True, unique_last_num_states=None, augmentation_factor=50, tracker_limit=None, use_story_concatenation=True, debug_plots=False, exclusion_percentage=None) ¶
Load training data from a resource.
Return type
List DialogueStateTracker
asynclog_message( message, message_preprocessor=None, **kwargs) ¶
Append a message to a dialogue - does not predict actions.
Return type
asyncparse_message_using_nlu_interpreter( message_data, tracker=None) ¶
Handles message text and intent payload input messages.
The return value of this function is parsed_data.
Parameters
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”}], }
Return type
Dict[str, Any]
persist( model_path) ¶
Persists this agent into a directory for later loading and usage.
Return type
None
asyncpredict_next( sender_id, **kwargs) ¶
Handle a single message.
Return type
Optional[Dict[str, Any]
toggle_memoization( activate) ¶
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.
Return type
None
train( training_trackers, **kwargs) ¶
Train the policies / policy ensemble using dialogue data from file.
Parameters
training_trackers – trackers to train on
kwargs – additional arguments passed to the underlying ML trainer (e.g. keras parameters)
Return type
None
asynctrigger_intent( intent_name, entities, output_channel, tracker) ¶
Trigger a user intent, e.g. triggered by an external event.
Return type
None