Transformer课程 业务对话机器人Rasa 3.x 命令 rasa shell 及rasa run
Transformer课程 业务对话机器人Rasa 3.x 命令 rasa shell 及rasa run
Rasa 官网
rasa shell
您可以在本地模式下使用Rasa X在UI中与您的助手交谈。查看Rasa X文档了解更多细节。
如果你更喜欢使用命令行,你可以通过运行以下命令来启动一个聊天会话:
rasa shell
默认情况下,这将加载最新的训练模型。你可以使用 --model标志来指定要加载的不同模型。
如果你用一个NLU-only模型启动shell, rasa shell会输出你输入的任何消息的意图和实体。
如果你训练了一个组合的Rasa模型,但只是想看看你的模型从文本中提取的意图和实体,你可以使用命令Rasa shell nlu。
要增加调试的日志级别,请执行:
rasa shell --debug
请注意:为了看到在外部通道中可能看到的典型问候和/或会话启动行为,需要显式地发送/session_start作为第一个消息。否则,会话启动行为将按照会话配置中的描述开始。
可以使用以下参数配置该命令:
usage: rasa shell [-h] [-v] [-vv] [--quiet]
[--conversation-id CONVERSATION_ID] [-m MODEL]
[--log-file LOG_FILE] [--use-syslog]
[--syslog-address SYSLOG_ADDRESS]
[--syslog-port SYSLOG_PORT]
[--syslog-protocol SYSLOG_PROTOCOL] [--endpoints ENDPOINTS]
[-i INTERFACE] [-p PORT] [-t AUTH_TOKEN]
[--cors [CORS [CORS ...]]] [--enable-api]
[--response-timeout RESPONSE_TIMEOUT]
[--remote-storage REMOTE_STORAGE]
[--ssl-certificate SSL_CERTIFICATE]
[--ssl-keyfile SSL_KEYFILE] [--ssl-ca-file SSL_CA_FILE]
[--ssl-password SSL_PASSWORD] [--credentials CREDENTIALS]
[--connector CONNECTOR] [--jwt-secret JWT_SECRET]
[--jwt-method JWT_METHOD]
{nlu} ... [model-as-positional-argument]
positional arguments:
{nlu}
nlu Interprets messages on the command line using your NLU
model.
model-as-positional-argument
Path to a trained Rasa model. If a directory is
specified, it will use the latest model in this
directory. (default: None)
optional arguments:
-h, --help show this help message and exit
--conversation-id CONVERSATION_ID
Set the conversation ID. (default:
54029573f170423bbc3343e96efadcb5)
-m MODEL, --model MODEL
Path to a trained Rasa model. If a directory is
specified, it will use the latest model in this
directory. (default: models)
--log-file LOG_FILE Store logs in specified file. (default: None)
--use-syslog Add syslog as a log handler (default: False)
--syslog-address SYSLOG_ADDRESS
Address of the syslog server. --use-sylog flag is
required (default: localhost)
--syslog-port SYSLOG_PORT
Port of the syslog server. --use-sylog flag is
required (default: 514)
--syslog-protocol SYSLOG_PROTOCOL
Protocol used with the syslog server. Can be UDP
(default) or TCP (default: UDP)
--endpoints ENDPOINTS
Configuration file for the model server and the
connectors as a yml file. (default: endpoints.yml)
Python Logging Options:
-v, --verbose Be verbose. Sets logging level to INFO. (default:
None)
-vv, --debug Print lots of debugging statements. Sets logging level
to DEBUG. (default: None)
--quiet Be quiet! Sets logging level to WARNING. (default:
None)
Server Settings:
-i INTERFACE, --interface INTERFACE
Network interface to run the server on. (default:
0.0.0.0)
-p PORT, --port PORT Port to run the server at. (default: 5005)
-t AUTH_TOKEN, --auth-token AUTH_TOKEN
Enable token based authentication. Requests need to
provide the token to be accepted. (default: None)
--cors [CORS [CORS ...]]
Enable CORS for the passed origin. Use * to whitelist
all origins. (default: None)
--enable-api Start the web server API in addition to the input
channel. (default: False)
--response-timeout RESPONSE_TIMEOUT
Maximum time a response can take to process (sec).
(default: 3600)
--remote-storage REMOTE_STORAGE
Set the remote location where your Rasa model is
stored, e.g. on AWS. (default: None)
--ssl-certificate SSL_CERTIFICATE
Set the SSL Certificate to create a TLS secured
server. (default: None)
--ssl-keyfile SSL_KEYFILE
Set the SSL Keyfile to create a TLS secured server.
(default: None)
--ssl-ca-file SSL_CA_FILE
If your SSL certificate needs to be verified, you can
specify the CA file using this parameter. (default:
None)
--ssl-password SSL_PASSWORD
If your ssl-keyfile is protected by a password, you
can specify it using this paramer. (default: None)
Channels:
--credentials CREDENTIALS
Authentication credentials for the connector as a yml
file. (default: None)
--connector CONNECTOR
Service to connect to. (default: None)
JWT Authentication:
--jwt-secret JWT_SECRET
Public key for asymmetric JWT methods or shared
secretfor symmetric methods. Please also make sure to
use --jwt-method to select the method of the
signature, otherwise this argument will be
ignored.Note that this key is meant for securing the
HTTP API. (default: None)
--jwt-method JWT_METHOD
Method used for the signature of the JWT
authentication payload. (default: HS256)
运行一个示例
rasa run
要启动一个运行你训练过的模型的服务器,运行:
rasa run
默认情况下,Rasa服务器使用HTTP进行通信。为了保证与SSL通信的安全性,并在HTTPS上运行服务器,需要提供有效的证书和相应的私钥文件。您可以将这些文件指定为rasa run运行命令的一部分。如果在创建过程中使用密码加密了密钥文件,还需要添加–ssl-password。
rasa run --ssl-certificate myssl.crt --ssl-keyfile myssl.key --ssl-password mypassword
默认情况下,Rasa监听每个可用的网络接口。您可以使用-i命令行选项将其限制为特定的网络接口。
rasa run -i 192.168.69.150
下面的参数可以用来配置您的Rasa服务器:
usage: rasa run [-h] [-v] [-vv] [--quiet] [-m MODEL] [--log-file LOG_FILE]
[--use-syslog] [--syslog-address SYSLOG_ADDRESS]
[--syslog-port SYSLOG_PORT]
[--syslog-protocol SYSLOG_PROTOCOL] [--endpoints ENDPOINTS]
[-i INTERFACE] [-p PORT] [-t AUTH_TOKEN]
[--cors [CORS [CORS ...]]] [--enable-api]
[--response-timeout RESPONSE_TIMEOUT]
[--remote-storage REMOTE_STORAGE]
[--ssl-certificate SSL_CERTIFICATE]
[--ssl-keyfile SSL_KEYFILE] [--ssl-ca-file SSL_CA_FILE]
[--ssl-password SSL_PASSWORD] [--credentials CREDENTIALS]
[--connector CONNECTOR] [--jwt-secret JWT_SECRET]
[--jwt-method JWT_METHOD]
{actions} ... [model-as-positional-argument]
positional arguments:
{actions}
actions Runs the action server.
model-as-positional-argument
Path to a trained Rasa model. If a directory is
specified, it will use the latest model in this
directory. (default: None)
optional arguments:
-h, --help show this help message and exit
-m MODEL, --model MODEL
Path to a trained Rasa model. If a directory is
specified, it will use the latest model in this
directory. (default: models)
--log-file LOG_FILE Store logs in specified file. (default: None)
--use-syslog Add syslog as a log handler (default: False)
--syslog-address SYSLOG_ADDRESS
Address of the syslog server. --use-sylog flag is
required (default: localhost)
--syslog-port SYSLOG_PORT
Port of the syslog server. --use-sylog flag is
required (default: 514)
--syslog-protocol SYSLOG_PROTOCOL
Protocol used with the syslog server. Can be UDP
(default) or TCP (default: UDP)
--endpoints ENDPOINTS
Configuration file for the model server and the
connectors as a yml file. (default: endpoints.yml)
Python Logging Options:
-v, --verbose Be verbose. Sets logging level to INFO. (default:
None)
-vv, --debug Print lots of debugging statements. Sets logging level
to DEBUG. (default: None)
--quiet Be quiet! Sets logging level to WARNING. (default:
None)
Server Settings:
-i INTERFACE, --interface INTERFACE
Network interface to run the server on. (default:
0.0.0.0)
-p PORT, --port PORT Port to run the server at. (default: 5005)
-t AUTH_TOKEN, --auth-token AUTH_TOKEN
Enable token based authentication. Requests need to
provide the token to be accepted. (default: None)
--cors [CORS [CORS ...]]
Enable CORS for the passed origin. Use * to whitelist
all origins. (default: None)
--enable-api Start the web server API in addition to the input
channel. (default: False)
--response-timeout RESPONSE_TIMEOUT
Maximum time a response can take to process (sec).
(default: 3600)
--remote-storage REMOTE_STORAGE
Set the remote location where your Rasa model is
stored, e.g. on AWS. (default: None)
--ssl-certificate SSL_CERTIFICATE
Set the SSL Certificate to create a TLS secured
server. (default: None)
--ssl-keyfile SSL_KEYFILE
Set the SSL Keyfile to create a TLS secured server.
(default: None)
--ssl-ca-file SSL_CA_FILE
If your SSL certificate needs to be verified, you can
specify the CA file using this parameter. (default:
None)
--ssl-password SSL_PASSWORD
If your ssl-keyfile is protected by a password, you
can specify it using this paramer. (default: None)
Channels:
--credentials CREDENTIALS
Authentication credentials for the connector as a yml
file. (default: None)
--connector CONNECTOR
Service to connect to. (default: None)
JWT Authentication:
--jwt-secret JWT_SECRET
Public key for asymmetric JWT methods or shared
secretfor symmetric methods. Please also make sure to
use --jwt-method to select the method of the
signature, otherwise this argument will be
ignored.Note that this key is meant for securing the
HTTP API. (default: None)
--jwt-method JWT_METHOD
Method used for the signature of the JWT
authentication payload. (default: HS256)
有关其他参数的更多信息,请参见模型存储。有关所有端点的详细文档,请参阅Rasa HTTP API页面。
运行一个示例:
(installingrasa) C:\Users\admin>rasa run -i 127.0.0.1 --model E:\starspace\my_rasa\models\20211227-124216-active-fort.tar.gz
Rasa官网链接: