参考https://github.com/chatopera/clause-py-demo
前提:安装完毕 Docker、Docker Compose 和 Python3.x
git clone https://github.com/chatopera/clause-py-demo.git
cd clause-py-demo
docker-compose pull
我使用了sudo
创新python环境,并使用
(env) xuehp@haomeiya002:~/git/clause-py-demo$
sudo pip3 install thrift
sudo pip3 install absl-py
sudo pip3 install clause
sudo pip3 install -r requirements.txt
export DOCKER_HOST=8056
sudo docker-compose up
等待,这样服务就运行起来了。
注意:
bot.py 是一个示例程序
加载文件profile.json,这个文件定义了一个机器人,例如:点餐机器人
处理同义词,识别意图。这些在文件profile.json中已经定义。文件见后文
和服务端交互,继续完成以下操作:训练机器人、开始对话。如下图
运行bot.py失败,ConnectionResetError: [Errno 104] Connection reset by peer
profile.json文件,很重要。定义了一个机器人,意图、交互方式(说法)、槽位、槽值的抽取方式
{
"chatbotID": "bot007",
"dicts": [
{
"name": "food",
"type": "vocab",
"dictwords": [
{
"word": "汉堡",
"synonyms": "汉堡包;漢堡;漢堡包"
},
{
"word": "蕃茄酱"
}
]
},
{
"name": "phoneNumber",
"type": "regex",
"patterns": ["1[0-9]{9}"]
}
],
"intents": [
{
"name": "take_out",
"description": "下外卖订单",
"slots": [
{
"name": "time",
"dictname": "@TIME",
"requires": true,
"question": "您想什么时候送到?"
},
{
"name": "loc",
"dictname": "@LOC",
"requires": true,
"question": "您希望该订单送到哪里?"
},
{
"name": "food",
"dictname": "food",
"requires": true,
"question": "您需要什么食物?"
},
{
"name": "phone",
"dictname": "phoneNumber",
"requires": true,
"question": "您的手机号是什么?"
}
],
"utters": [
{
"utterance": "我想订一份{food}"
},
{
"utterance": "我想点外卖"
},
{
"utterance": "我想点一份外卖,{time}用餐"
},
{
"utterance": "我想点一份{food},送到{loc}"
}
]
}
]
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章