diff --git a/README.md b/README.md index 82375b4..25b2681 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,9 @@ **edit at 2019.06.24** 将之前的[rasa-nlu-gao](https://github.com/GaoQ1/rasa_nlu_gq)进行了修改,以支持新版本的rasa,而且不再在源码里进行修改。首先需要`pip install rasa-nlu-gao>=0.3.1`,具体用法如下。 -## Command +## Running by command ### install packages - - python >= 3.5 + - python >= 3.6 ``` pip install -r requirements.txt ``` @@ -29,7 +29,7 @@ pip install -r requirements.txt ``` make train ``` -训练nlu和core模型,新版本中会将模型自动打包成zip文件 +训练nlu和core模型,新版本中会将模型自动打包成zip文件。 ### run model ``` @@ -88,5 +88,10 @@ make run-x ## some problems Q: 为什么我会报`couldn't find component...`这个错? - A: rasa使用了importlib动态加载自定义component和policy。这个错误的原因是你没有将component和policy的目录append到PYTHONPATH里面。你需要`export PYTHONPATH=/path/to/your/component` + + Q: 为什么训练会报10000time超时错误? + A: 这个问题是因为你没有启用bert-as-service服务。启动教程参考[rasa对话系统踩坑记(八)](https://www.jianshu.com/p/6a93209c48a4),启动之后在config.yml将对用的bert-as-service服务ip改下,本例子默认是127.0.0.1,但是你要在本机启动bert服务 + + Q: 如何能够快速尝试例子呢? + A: 介于各个开发环境不同,报各种错误,所以上传了docker文件。但前提还是你要安装docker,并在运行前确保bert-as-service启用,当然你不用bert的话可以忽略。然后你只需要`sh dev/deploy_dev.sh`,就可以愉快的通过postman或者curl测试这个demo了。记得`docker logs -f chatbot_dev`查看有没有训练完,有没有报错。linux和mac下没有问题。windows下可能需要微调下。 diff --git a/configs/endpoints.yml b/configs/endpoints.yml index 56d98ea..8bb853d 100644 --- a/configs/endpoints.yml +++ b/configs/endpoints.yml @@ -1,2 +1,7 @@ action_endpoint: url: http://localhost:5055/webhook + +tracker_store: + store_type: mongod + url: mongodb://mongo:27017 + db: chatbot \ No newline at end of file diff --git a/dev/Dockerfile.dev b/dev/Dockerfile.dev new file mode 100755 index 0000000..b3c5a9d --- /dev/null +++ b/dev/Dockerfile.dev @@ -0,0 +1,42 @@ +FROM python:3.6-slim + +SHELL ["/bin/bash", "-c"] + +# Default to UTF-8 file.encoding +ENV LANG C.UTF-8 + +RUN apt-get update -qq && \ + apt-get install -y --no-install-recommends \ + apt-utils \ + vim \ + procps \ + build-essential \ + wget \ + unzip \ + openssh-client \ + graphviz-dev \ + pkg-config \ + git-core \ + openssl \ + libssl-dev \ + libffi6 \ + libffi-dev \ + libpng-dev \ + curl \ + python3-tk \ + tk-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \ + mkdir /app + +WORKDIR /app + +ENV PYTHONPATH "${PYTHONPATH}:/app" + +COPY requirements.txt ./ + +RUN pip install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple/ && \ + pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ + +ENTRYPOINT ["/bin/sh"] +CMD ["/app/dev/run.sh"] diff --git a/dev/deploy_dev.sh b/dev/deploy_dev.sh new file mode 100755 index 0000000..91bb23a --- /dev/null +++ b/dev/deploy_dev.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +if [ ! "$(docker ps -a | grep mongo)" ] + then echo "start mongo db docker"; + mkdir ~/data; + docker pull mongo; + docker run --name mongo -p 27017:27017 -v ~/data:/data/db -itd mongo; +fi + +CHATBOT_VERSION=0.0.1 + +docker build -f dev/Dockerfile.dev . -t chatbot_dev:$CHATBOT_VERSION +docker run --name chatbot_dev -p 5005:5005 -p 5002:5002 --link mongo -v "$PWD":/app -itd chatbot_dev:$CHATBOT_VERSION diff --git a/dev/run.sh b/dev/run.sh new file mode 100644 index 0000000..bfbabd1 --- /dev/null +++ b/dev/run.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +make train +make run diff --git a/requirements.txt b/requirements.txt index c811398..05e2725 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -keras +keras==2.2.4 rasa-nlu-gao>=0.3.0 -rasa-sdk +rasa-sdk~=1.1.0