企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
### 3.2.13 国学大会 #### (1)功能说明 国学大会目前主要包括两本典籍内容,分别是弟子规、三字经。该技能主要是通过学与练相结合的方式,强化对学习内容的认知和记忆,逐步达到学会、掌握的目的。 #### (2)接口说明 **请求方法** * POST **请求地址** * http://api.ruyi.ai/v1/message **请求参数说明** |参数名 |参数类型 | 是否必须 |参数说明 | :-----| :---| :---:|:----- |q |String| 是| 自然语言表达,例如“国学大会”等 |app_key| String|是 |应用开发者秘钥,注册开发者后台账号,建立虚拟助理后获得 |user_id |String| 是 |用户唯一标识,便于支持个性化语义解析。建议开发者使用 UUID 字符,且不同用户必须用不同的 user_id,防止意图串。 #### (3)返回说明 **返回参数说明** |名称 |类型| 说明 |:---|:---|:--- |code |Integer | 返回代码 |msg | String |返回代码描述 |parameters|JSON Object |解析到的实体以及服务说明 |action|String|服务的接口名称 |name| String|匹配的意图名称 |result | JSON Object| 接口返回内容 |outputs| Array| 服务输出结果,微信端使用 type 类型为 wechat 开头的内容;硬件端收到所有内容,依据需求解析使用 **返回代码说明** |返回代码 |错误类型|说明 |:---|:---|:--- |0/200 |成功 |请求成功 |400 |无效请求 |某些必需参数缺失或参数值错误,详见msg字段 |401 |未授权 |授权失败,app_key缺失或错误 |403 |请求被禁止|有效请求,但服务拒绝响应,请联系contact@ruyi.ai |408 |请求超时 |请求响应超时,一般响应时间设置为2000ms以内 |429 |短时间内大量访问 |短时间内请求数过多 |500 |内部错误 |服务处理异常 |503 |服务不可用|服务异常或正在维护 #### (4)请求示例 **请求范例** 打开国学大会 游戏规则 弟子规 从头开始 弟子规圣人训首孝悌次谨信(正确跟读) 巩固练习 第一项(回答错误) 退出 **请求示例正确** http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=从头开始 (那个头开始) 返回结果 ```json {"code": 0, "msg": "ok", "result"{ "_text": "从头开始", "msg_id": "d1eb1bbd-c317-4242-b70e-31dfa36751ad", "intents": [ { "parameters": { "startFromBegining": "false", "chapterNumber": "1" }, "action": "开始接口", "name": "【适配js】开始游戏(弟子规内容总叙)", "result": { "finish": false, "content": { "words": [ "弟子规", "圣人训", "首孝悌", "次谨信" ], "explain": "弟子规,是圣人的教诲。首先要孝敬父母、友爱兄弟姊妹,其次要谨言慎行、讲求信用。", "picUrl": "http://on9d0c18z.bkt.clouddn.com/第一章1.jpg", "audioUrl": "http://ruyi-xiaodu.bj.bcebos.com/dizigui/弟子规1.wav" } "text": "{\"type\":\"baidu.display.directive\",\"payload\":{\"type\":\"Display.RenderTemplate\",\"template\":{\"type\":\"BodyTemplate5\",\"token\":\"com.haizhi.baidu.dizigui.diyizhangzongxu\",\"backgroundImage\":{\"url\":\"http://on9d0c18z.bkt.clouddn.com/第一章1.jpg\",\"widthPixels\":1280,\"heightPixels\":720},\"images\":[{\"url\":\"http://on9d0c18z.bkt.clouddn.com/第一章1.jpg\",\"widthPixels\":450,\"heightPixels\":600}],\"title\":\"\"},\"hint\":{\"type\":\"Hint\",\"hints\":[{\"type\":\"PlainText\",\"text\":\"\"},{\"type\":\"PlainText\",\"text\":\"\"}]},\"text\":\"<speak> <audio src=\\\"http://ruyi-xiaodu.bj.bcebos.com/dizigui/弟子规1.wav\\\"></audio> </speak>\"}}", "type": "dialog" }, "outputs": [ { "type": "wechat.text", "property": { "text": "{\"type\":\"baidu.display.directive\",\"payload\":{\"type\":\"Display.RenderTemplate\",\"template\":{\"type\":\"BodyTemplate5\",\"token\":\"com.haizhi.baidu.dizigui.diyizhangzongxu\",\"backgroundImage\":{\"url\":\"http://on9d0c18z.bkt.clouddn.com/第一章1.jpg\",\"widthPixels\":1280,\"heightPixels\":720},\"images\":[{\"url\":\"http://on9d0c18z.bkt.clouddn.com/第一章1.jpg\",\"widthPixels\":450,\"heightPixels\":600}],\"title\":\"\"},\"hint\":{\"type\":\"Hint\",\"hints\":[{\"type\":\"PlainText\",\"text\":\"\"},{\"type\":\"PlainText\",\"text\":\"\"}]},\"text\":\"<speak> <audio src=\\\"http://ruyi-xiaodu.bj.bcebos.com/dizigui/弟子规1.wav\\\"></audio> </speak>\"}}" } }, { "type": "dialog", "property": { "text": "请跟我读http://ruyi-xiaodu.bj.bcebos.com/dizigui/弟子规1.wav", "emotion": "calm" } }, "score": "1.0", "scoreColor": "c4", "is_match": 1, "skill_id": "4107891e-63da-47f5-86e9-3f8db56d9c96", "id": "111a056e-0eeb-4f2a-ba06-4cd5075005b9" } ], "meta_process_milliseconds": 281 } ``` **请求示例正确** http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=弟子规圣人训首孝悌次谨信 (正确跟读) 返回结果 ```json {"code": 0, "msg": "ok", "result"{ "_text": "弟子规圣人训首孝悌次谨信", "msg_id": "7535af4e-f266-4234-afa0-3b47503dd07d", "intents": [ { "parameters": { "any": "弟子规圣人训首孝悌次谨信" }, "action": "下一句接口", "name": "【适配js】跟读弟子规(弟子规内容)", "result": { "sectionEnd": false, "finish": false, "content": { "words": [ "泛爱众", "而亲仁", "有余力", "则学文" ], "explain": "博爱大众,亲近有仁德的人。 有多余的时间和精力,学习有益的学问。", "picUrl": "http://on9d0c18z.bkt.clouddn.com/第一章2.jpg", "audioUrl": "http://ruyi-xiaodu.bj.bcebos.com/dizigui/弟子规2.wav" } "text": "请跟我读http://ruyi-xiaodu.bj.bcebos.com/dizigui/弟子规2.wav", "type": "dialog" }, "outputs": [ { "type": "dialog", "property": { "text": "请跟我读http://ruyi-xiaodu.bj.bcebos.com/dizigui/弟子规2.wav", "emotion": "calm" } }, "score": "1.0", "scoreColor": "c4", "is_match": 1, "skill_id": "4107891e-63da-47f5-86e9-3f8db56d9c96", "id": "f520db85-e4d1-4f56-9c55-d45bf76bac34" } ], "meta_process_milliseconds": 146 } ``` **请求示例正确** http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=第一项 (巩固练习错误回答) 返回结果 ```json {"code": 0, "msg": "ok", "result"{ "_text": "第一项", "msg_id": "b23e9415-9438-4168-9437-1eb6f54bcd27", "intents": [ { "parameters": { "choiceAnswer": "选项一" }, "action": "回答接口", "name": "【适配js】回答题目(弟子规题目)", "result": { "correctAnswer": "选项二", "isCorrect": false, "lastQuestion": false, "questionAndAnswer": { "question": "短句“圣人训”中“训”的意思是?", "choices": [ "选项1:训练", "选项2:教导、教诲", "选项3:解释" ], "answer": "选项二" }, "questionType": "XUANZETI" "type": "undefined" }, "outputs": [ { "type": "dialog", "property": { "text": "很遗憾,回答错误。正确答案是选项二。请听下一题:短句“圣人训”中“训”的意思是?选项1:训练。选项2:教导、教诲。选项3:解释", "emotion": "calm" } }, "score": "1.0", "scoreColor": "c4", "is_match": 1, "skill_id": "4107891e-63da-47f5-86e9-3f8db56d9c96", "id": "58e2d728-0deb-4499-b0f0-b36afa45c8a0" } ], "meta_process_milliseconds": 311 } ``` **请求示例退出** http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=退出 (退出游戏) 返回结果 ```json {"code": 0, "msg": "ok", "result"{ "_text": "退出", "msg_id": "01f2bf62-ac76-491b-9974-c1754ec709a8", "intents": [ { "parameters": { "退出": "结束" }, "action": "退出接口", "name": "【适配js】退出", "result": { "title": "第一章:总叙", "sentence": [ "泛爱众", "而亲仁", "有余力", "则学文" ] } }, "text": "好的,已为您退出。您已学习到第一章:总叙。泛爱众,而亲仁,有余力,则学文", "type": "dialog" }, "outputs": [ { "type": "dialog", "property": { "text": "好的,已为您退出。您已学习到第一章:总叙。泛爱众,而亲仁,有余力,则学文", "emotion": "positive" } }, "score": "1.0", "scoreColor": "c4", "is_match": 1, "skill_id": "4107891e-63da-47f5-86e9-3f8db56d9c96", "id": "6ce19dd5-cee9-4b77-8583-df22f4782bc7" } ], "meta_process_milliseconds": 153 } ``` **详细参数说明** |名称|类型|说明| |:---|:---|:--- |service | String |服务名称 |startFromBegining|bool|是否重新开始 |chapterNumber | int | 选择章数 |choiceAnswer | String |选择题回答(优先匹配选择题回答,如果选择题回答为空,则匹配文字题回答) |textAnswer|String|文字题回答 |sectionEnd | String |4句小节结束 |finish|String|书籍内容结束 |content | String |学习内容(词句、解释、图片、音频) |correctAnswer|String|正确答案 |isCorrect| String |是否正确 |lastQuestion|String|是否最后一个问题 |question | String |问题 |answer|String|答案 |questionType | String |问题类型 |choices | String |选项 **指令清单** |指令名称|范例| |:---|:--- |唤醒 | 打开国学大会 |游戏规则 | 了解游戏规则 |继续上次内容还是从头开始 | 从头开始 |巩固练习 | 巩固练习 |退出 | 退出