1. 创建虚拟环境

  1. $ conda create -n rasa_py38 python==3.8.10
  2. $ source activate rasa_py38

💡 Rasa 只支持 Python 3.6 ~ 3.8,不支持 3.9 版本

2. 安装Poetry

安装 Poetry 还有点复杂,可以参考教程来安装。
🍎CentOS7 基础环境

3. 安装 Rasa

  1. $ git clone https://github.com/RasaHQ/rasa.git
  2. $ make install
  3. $ make install install-docs

4. 配置Nginx

我们可以通过 Nginx 反向代理来提升 Rasa API 并发稳定性,修改 /etc/nginx/nginx.conf 文件:

  1. user www-data;
  2. worker_processes auto;
  3. pid /run/nginx.pid;
  4. # include /etc/nginx/modules-enabled/*.conf;
  5. events {
  6. worker_connections 768;
  7. # multi_accept on;
  8. }
  9. http {
  10. ##
  11. # Basic Settings
  12. ##
  13. sendfile on;
  14. tcp_nopush on;
  15. tcp_nodelay on;
  16. keepalive_timeout 65;
  17. types_hash_max_size 2048;
  18. # server_tokens off;
  19. # server_names_hash_bucket_size 64;
  20. # server_name_in_redirect off;
  21. include /etc/nginx/mime.types;
  22. default_type application/octet-stream;
  23. ##
  24. # SSL Settings
  25. ##
  26. ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
  27. ssl_prefer_server_ciphers on;
  28. ##
  29. # Logging Settings
  30. ##
  31. access_log /var/log/nginx/access.log;
  32. error_log /var/log/nginx/error.log;
  33. ##
  34. # Gzip Settings
  35. ##
  36. gzip on;
  37. # gzip_vary on;
  38. # gzip_proxied any;
  39. # gzip_comp_level 6;
  40. # gzip_buffers 16 8k;
  41. # gzip_http_version 1.1;
  42. # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
  43. ##
  44. # Virtual Host Configs
  45. ##
  46. include /etc/nginx/conf.d/*.conf;
  47. include /etc/nginx/sites-enabled/*;
  48. server {
  49. listen 5001;
  50. server_name localhost;
  51. location /tieniuapi {
  52. rewrite /tieniuapi/(.*) /$1 break;
  53. proxy_pass http://localhost:5005/webhooks/xxxapi/webhook;
  54. proxy_http_version 1.1;
  55. proxy_buffering off;
  56. proxy_set_header Upgrade $http_upgrade;
  57. proxy_set_header Connection "upgrade";
  58. proxy_read_timeout 86400;
  59. }
  60. }
  61. }

5. 启动 Rasa

  1. $ rasa run -p 5005 --endpoints ./endpoints.yml \
  2. --credentials ./credentials.yml -m models/ \
  3. --enable-api --quiet