前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Rasa X 安装之Docker Compose 模式

Rasa X 安装之Docker Compose 模式

作者头像
coding01
修改2020-08-07 10:15:42
2.5K0
修改2020-08-07 10:15:42
举报
文章被收录于专栏:Coding01

本文 2351字,需要 5.88 分钟

Rasa X 介绍

Rasa X can be used in local mode and in server mode. Rasa X in local mode is helpful for sharing your assistant before you have a server set up. Once your assistant is up and running, you will want to deploy Rasa X to a server so that it’s available 24/7 and everyone on your team can use it to review conversations and annotate new training data.

如上文所说的「Local Mode」[1]模式更多的是方便我们本地测试,如果需要提供给外界服务,我们还需要其他模式,官网提供的三种:

1.Server Quick-Install

2.Helm Chart

3.Docker Compose

因为我个人服务器用的 Docker 比较多,所以看看「Docker Compose」模式:

Docker Compose

要求服务器环境前提安装 python3, dockerdocker-compose

主要四个步骤: 1. Download 2. Install 3. Start 4. Access

Download

因为 Rasa 的镜像主要放在 Docker Hub 上,所以在国内,有时候下载速度比较慢,虽然国内也提供了很多加速方法,但个人比较推荐使用使用 Google Cloud Platform 等第三方云服务器,通过云服务器和阿里云等国内服务器交互,把镜像托管回国内服务器,得到加速的目标。

具体大家可以搜索下使用方法。

本文主要下载的镜像包括:rasa/rasa-xrasa/ducklingrasa/rasarasa/rasa-x-demo 等。

代码语言:javascript
复制
// 加速下载 rasa-x
docker pull rasa/rasa-x:0.31.0

docker tag docker.io/rasa/rasa-x:0.31.0 registry.cn-hangzhou.aliyuncs.com/rasa/rasa-x:0.31.0

docker push registry.cn-hangzhou.aliyuncs.com/rasa/rasa-x:0.31.0

// 本地下载
docker pull registry.cn-hangzhou.aliyuncs.com/rasa/rasa-x:0.31.0

docker pull rasa/duckling:0.1.6.3

docker tag docker.io/rasa/duckling:0.1.6.3 registry.cn-hangzhou.aliyuncs.com/rasa/duckling:0.1.6.3

docker push registry.cn-hangzhou.aliyuncs.com/rasa/duckling:0.1.6.3

// 本地下载
docker pull registry.cn-hangzhou.aliyuncs.com/rasa/duckling:0.1.6.3

docker pull rasa/rasa:1.10.8-full

docker tag docker.io/rasa/rasa:1.10.8-full registry.cn-hangzhou.aliyuncs.com/rasa/rasa:1.10.8-full

docker push registry.cn-hangzhou.aliyuncs.com/rasa/rasa:1.10.8-full

// 本地下载
docker pull registry.cn-hangzhou.aliyuncs.com/rasa/rasa:1.10.8-full

docker pull rasa/nginx:0.31.0

docker tag docker.io/rasa/nginx:0.31.0 registry.cn-hangzhou.aliyuncs.com/rasa/nginx:0.31.0

docker push registry.cn-hangzhou.aliyuncs.com/rasa/nginx:0.31.0

// 本地下载
docker pull registry.cn-hangzhou.aliyuncs.com/rasa/nginx:0.31.0

docker pull rasa/rasa-x-demo:0.31.0

docker tag docker.io/rasa/rasa-x-demo:0.31.0 registry.cn-hangzhou.aliyuncs.com/rasa/rasa-x-demo:0.31.0

docker push registry.cn-hangzhou.aliyuncs.com/rasa/rasa-x-demo:0.31.0

// 本地下载
docker pull registry.cn-hangzhou.aliyuncs.com/rasa/rasa-x-demo:0.31.0

具体参考:https://cr.console.aliyun.com/[2]

加速后,重新修改官网提供的配置文件:

代码语言:javascript
复制
version: "3.4"

x-database-credentials: &database-credentials
  DB_HOST: "db"
  DB_PORT: "5432"
  DB_USER: "${DB_USER:-admin}"
  DB_PASSWORD: "${DB_PASSWORD}"
  DB_LOGIN_DB: "${DB_LOGIN_DB:-rasa}"x-rabbitmq-credentials: &rabbitmq-credentials
  RABBITMQ_HOST: "rabbit"
  RABBITMQ_USERNAME: "user"
  RABBITMQ_PASSWORD: ${RABBITMQ_PASSWORD}x-redis-credentials: &redis-credentials
  REDIS_HOST: "redis"
  REDIS_PORT: "6379"
  REDIS_PASSWORD: ${REDIS_PASSWORD}
  REDIS_DB: "1"x-duckling-credentials: &duckling-credentials
  RASA_DUCKLING_HTTP_URL: "http://duckling:8000"x-rasax-credentials: &rasax-credentials
  RASA_X_HOST: "http://rasa-x:5002"
  RASA_X_USERNAME: ${RASA_X_USERNAME:-admin}
  RASA_X_PASSWORD: ${RASA_X_PASSWORD:-}
  RASA_X_TOKEN: ${RASA_X_TOKEN}
  JWT_SECRET: ${JWT_SECRET}
  RASA_USER_APP: "http://app:5055"
  RASA_PRODUCTION_HOST: "http://rasa-production:5005"
  RASA_WORKER_HOST: "http://rasa-worker:5005"
  RASA_TOKEN: ${RASA_TOKEN}x-rasa-credentials: &rasa-credentials
  <<: *rabbitmq-credentials
  <<: *rasax-credentials
  <<: *database-credentials
  <<: *redis-credentials
  <<: *duckling-credentials
  RASA_TOKEN: ${RASA_TOKEN}
  RASA_MODEL_PULL_INTERVAL: 10
  RABBITMQ_QUEUE: "rasa_production_events"x-rasa-services: &default-rasa-service
  restart: always
  image: "registry.cn-hangzhou.aliyuncs.com/rasa/rasa:${RASA_VERSION}-full"
  expose:
    - "5005"  command: >
    x
    --no-prompt
    --production
    --config-endpoint http://rasa-x:5002/api/config?token=${RASA_X_TOKEN}
    --port 5005
    --jwt-method HS256
    --jwt-secret ${JWT_SECRET}
    --auth-token '${RASA_TOKEN}'
    --cors "*"
  depends_on:
    - rasa-x    - rabbit    - redisservices:
  rasa-x:
    restart: always
    image: "registry.cn-hangzhou.aliyuncs.com/rasa/rasa-x:${RASA_X_VERSION}"
    expose:
      - "5002"    volumes:
      - ./models:/app/models      - ./environments.yml:/app/environments.yml      - ./credentials.yml:/app/credentials.yml      - ./endpoints.yml:/app/endpoints.yml      - ./logs:/logs      - ./auth:/app/auth    environment:
      <<: *database-credentials
      <<: *rasa-credentials
      SELF_PORT: "5002"
      DB_DATABASE: "${DB_DATABASE:-rasa}"
      RASA_MODEL_DIR: "/app/models"
      PASSWORD_SALT: ${PASSWORD_SALT}
      RABBITMQ_QUEUE: "rasa_production_events"
      RASA_X_USER_ANALYTICS: "0"
      SANIC_RESPONSE_TIMEOUT: "3600"
    depends_on:
      - db
  rasa-production:
    <<: *default-rasa-service
    environment:
      <<: *rasa-credentials
      RASA_ENVIRONMENT: "production"
      DB_DATABASE: "tracker"
      RASA_MODEL_SERVER: "http://rasa-x:5002/api/projects/default/models/tags/production"

  rasa-worker:
    <<: *default-rasa-service
    environment:
      <<: *rasa-credentials
      RASA_ENVIRONMENT: "worker"
      DB_DATABASE: "worker_tracker"
      RASA_MODEL_SERVER: "http://rasa-x:5002/api/projects/default/models/tags/production"

  app:
    restart: always
    image: "registry.cn-hangzhou.aliyuncs.com/rasa/rasa-x-demo:${RASA_X_DEMO_VERSION}"
    expose:
      - "5055"    depends_on:
      - rasa-production
  db:
    restart: always
    image: "daocloud.io/library/postgres:11.7"
    expose:
      - "5432"    environment:
      POSTGRES_USER: "${DB_USER:-admin}"
      POSTGRES_PASSWORD: "${DB_PASSWORD}"
      POSTGRES_DB: "${DB_DATABASE:-rasa}"
    volumes:
      - ./db:/bitnami/postgresql
  rabbit:
    restart: always
    image: "daocloud.io/library/rabbitmq:3.8.3"
    environment:
      RABBITMQ_HOST: "rabbit"
      RABBITMQ_USERNAME: "user"
      RABBITMQ_PASSWORD: ${RABBITMQ_PASSWORD}
      RABBITMQ_DISK_FREE_LIMIT: "{mem_relative, 0.1}"
    expose:
      - "5672"
  duckling:
    restart: always
    image: "registry.cn-hangzhou.aliyuncs.com/rasa/duckling:0.1.6.3"
    expose:
      - "8000"    command: ["duckling-example-exe", "--no-access-log", "--no-error-log"]

  nginx:
    restart: always
    image: "registry.cn-hangzhou.aliyuncs.com/rasa/nginx:${RASA_X_VERSION}"
    ports:
      - "80:8080"      - "443:8443"    volumes:
      - ./certs:/opt/bitnami/certs      - ./terms:/opt/bitnami/nginx/conf/bitnami/terms    depends_on:
      - rasa-x      - rasa-production      - app
  redis:
    restart: always
    image: "daocloud.io/library/redis:5.0.8"
    environment:
      REDIS_PASSWORD: ${REDIS_PASSWORD}
    expose:
      - "6379"

start

编写完 docker-compose.yml 后就可以创建容器了:

代码语言:javascript
复制
docker-compose up -d

access

执行命令:

代码语言:javascript
复制
python rasa_x_commands.py create --update admin me <PASSWORD>

好了,利用新密码就可以进入 Rasa X 网页。

总结

其中配置项主要参考官网说的来,这里就不再赘述了。有了 docker 环境下的 Rasa X,接下来就可以进入我们的交互环节,结合一些使用场景 (如:微信公众号、Slack 等),制作我们的 AI 互动助手 (如,给 Slack 发送指令,回复微信公众号粉丝问题等)。

参考

[1] 「Local Mode」 https://mp.weixin.qq.com/s/HpPxrG2Sr67Sz_nEJHH2PA

[2] https://cr.console.aliyun.com/ https://cr.console.aliyun.com/

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2020-08-01,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 coding01 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
容器镜像服务
容器镜像服务(Tencent Container Registry,TCR)为您提供安全独享、高性能的容器镜像托管分发服务。您可同时在全球多个地域创建独享实例,以实现容器镜像的就近拉取,降低拉取时间,节约带宽成本。TCR 提供细颗粒度的权限管理及访问控制,保障您的数据安全。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档