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.server
ErrorResponse Objects
Common exception to handle failing API requests.
__init__
Creates error.
Arguments:
status
- The HTTP status code to return.reason
- Short summary of the error.message
- Detailed explanation of the error.details
- Additional details which describe the error. Must be serializable.help_url
- URL where users can get further help (e.g. docs).
ensure_loaded_agent
Wraps a request handler ensuring there is a loaded and usable agent.
Require the agent to have a loaded Core model if require_core_is_ready
is
True
.
ensure_conversation_exists
Wraps a request handler ensuring the conversation exists.
requires_auth
Wraps a request handler with token authentication.
event_verbosity_parameter
Create EventVerbosity
object using request params if present.
get_test_stories
Retrieves test stories from processor
for all conversation sessions for
conversation_id
.
Arguments:
processor
- An instance ofMessageProcessor
.conversation_id
- Conversation ID to fetch stories for.until_time
- Timestamp up to which to include events.fetch_all_sessions
- Whether to fetch stories for all conversation sessions. IfFalse
, only the last conversation session is retrieved.
Returns:
The stories for conversation_id
in test format.
update_conversation_with_events
Fetches or creates a tracker for conversation_id
and appends events
to it.
Arguments:
conversation_id
- The ID of the conversation to update the tracker for.processor
- An instance ofMessageProcessor
.domain
- The domain associated with the currentAgent
.events
- The events to append to the tracker.
Returns:
The tracker for conversation_id
with the updated events.
validate_request_body
Check if request
has a body.
validate_events_in_request_body
Validates events format in request body.
authenticate
Callback for authentication failed.
create_ssl_context
Create an SSL context if a proper certificate is passed.
Arguments:
ssl_certificate
- path to the SSL client certificatessl_keyfile
- path to the SSL key filessl_ca_file
- path to the SSL CA file for verification (optional)ssl_password
- SSL private key password (optional)
Returns:
SSL context if a valid certificate chain can be loaded, None
otherwise.
configure_cors
Configure CORS origins for the given app.
add_root_route
Add '/' route to return hello.
async_if_callback_url
Decorator to enable async request handling.
If the incoming HTTP request specified a callback_url
query parameter, the request
will return immediately with a 204 while the actual request response will
be sent to the callback_url
. If an error happens, the error payload will also
be sent to the callback_url
.
Arguments:
f
- The request handler function which should be decorated.
Returns:
The decorated function.
run_in_thread
Decorator which runs request on a separate thread.
Some requests (e.g. training or cross-validation) are computional intense requests. This means that they will block the event loop and hence the processing of other requests. This decorator can be used to process these requests on a separate thread to avoid blocking the processing of incoming requests.
Arguments:
f
- The request handler function which should be decorated.
Returns:
The decorated function.
inject_temp_dir
Decorator to inject a temporary directory before a request and clean up after.
Arguments:
f
- The request handler function which should be decorated.
Returns:
The decorated function.
create_app
Class representing a Rasa HTTP server.