在國外,有知名的開源專案 Rasa 實作 Task Chatbot,對各種業務場景通過自然語言互動,在對話中識別意圖、收集資料,提高業務流程自動化,
那么,中文有沒有優秀的聊天機器人開源框架呢?
這就是答案
Chatopera Language Understanding Service,Chatopera 語意理解服務
https://github.com/chatopera/clause
Clause Quick Start Guide / Clause 快速開始
Chatopera Language Understanding Service,Chatopera 語意理解服務

前提
- 已部署 Clause 服務,參考部署檔案
下載鏡像
下載示例代碼
git clone https://github.com/chatopera/clause-quick-start.git
cd clause-quick-start
安裝依賴
安裝 Clause Python Package
cd clause-quick-start
pip install -r requirements.txt
執行示例程式
cd clause-quick-start # demo目錄
CL_HOST=127.0.0.1 # 設定 Clause 服務的 IP 地址
CL_PORT=8056 # 設定 Clause 服務的埠
python bot.py # 執行demo腳本
該腳本執行的示例代碼bot.py內有注釋介紹如何完成:
| 步驟 | 說明 |
|---|---|
| 1 | 清除該機器人之前的資料 |
| 2 | 創建自定義詞典 |
| 3 | 添加自定義詞條 |
| 4 | 創建意圖 |
| 5 | 添加意圖槽位 |
| 6 | 添加意圖說法 |
| 7 | 訓練機器人 |
| 8 | 創建會話 |
| 9 | 和機器人對話 |
示例程式是一個點餐程式,輸出內容如下:
[connect] clause host 127.0.0.1, port 8056
[clean_up_bot] remove intent take_out
[clean_up_bot] remove customdict food
[create] dict name food
[create] intent name take_out
[create] intent slot time
[create] intent slot loc
[create] intent slot food
[create] intent utter 我想訂一份{food}
[create] intent utter 我想點外賣
[create] intent utter 我想點一份外賣,{time}用餐
[create] intent utter 我想點一份{food},送到{loc}
[train] start to train bot ...
[train] in progress ...
[chat] human: 我想點外賣,來一份漢堡包
[chat] bot: 您想什么時候送到?
[chat] human: 今天下午5點
[chat] bot: 您希望該訂單送到哪里?
[chat] human: 送到大望路5號20樓
[chat] bot: 好的
[session] 訂單資訊: 收集資訊已完畢 True
intent: take_out
entities:
food: 漢堡包
time: 今天下午5點
loc: 大望路5號
詳細了解程式,參考檔案,
輸入檔案
需要強調的是,該示例程式使用了 profile.json 檔案作為機器人的輸入資料,該檔案描述了機器人的詞典、說法和槽位等資訊,
profile.json 內容如下:
{
"chatbotID": "bot007",
"dicts": [
{
"name": "food",
"dictwords": [
{
"word": "漢堡",
"synonyms": "漢堡包;漢堡;漢堡包"
}
]
}
],
"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": "您需要什么食物?"
}
],
"utters": [
{
"utterance": "我想訂一份{food}"
}
]
}
]
}
開發者可以很方便的通過修改這個檔案復用bot.py腳本訓練和請求機器人對話服務,
停止服務并清空資料
恢復該示例專案到初始狀態,
cd clause-quick-start
docker-compose down
docker-compose rm
sudo rm -rf ./var/mysql/data/*
sudo rm -rf ./var/activemq/data/*
sudo rm -rf ./var/redis/data/*
sudo rm -rf ./var/local/workarea/*
Clause 服務端技術堆疊
以下僅列出部分 Clause 使用的框架/開源軟體,
Apache Thrift, C++, Docker, LevelDB, ActiveMQ, Jieba, Xapian, LAC/PaddlePaddle, Google Protobuf, etc.
選擇標準:開源并且商業友好、高性能、適合集群大規模生產環境使用、適用 Cloud Native開發部署、微服務模式、多語言 SDK、可部署于廉價的硬體資源、可維護性強、成熟,

了解更多
https://github.com/chatopera/clause/wiki
- 概述
- 系統設計與實作
- 服務部署
- 示例程式
- 開發環境搭建
- 系統集成
- API 檔案
- FAQ
開源許可協議
Apache License Version 2.0
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/171568.html
標籤:其他
下一篇:帶你一起學習實用計算機英語!(IT行業、四六級黨記起來)《軟體工程專業英語》第二單元的重點詞匯+名詞縮寫+重難句+軟體需求規格說明
