💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
### 3.2.4 鹦鹉学舌 #### (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": "b0618a1b-dd9a-413f-9108-86808bc4a128", "intents": [{ "parameters": { "kid_ciyu1": "什么", "service": "yingwu" }, "action": "0", "name": "正确的词语", "result": { "text": "什么。这个词我知道,继续玩就继续说,不想玩就跟我说【不玩了】", "type": "dialog" }, "outputs": [{ "type": "wechat.text", "property": { "text": "什么。继续继续" } }, { "type": "dialog", "property": { "text": "什么。", "emotion": "calm" } }], "score": "1.0", "scoreColor": "c4", "is_match": 1, "id": "031ffbe4-3580-4146-adef-8a6dc1c8734b" }], "meta_process_milliseconds": 27 } } ``` **请求示例失败** (输入错误的词语) * 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": "2b259b43-38af-4d56-b554-94a387c94565", "intents": [{ "parameters": { "service": "yingwu" }, "action": "0", "name": "错误的词语", "result": { "text": "这个词我没学过呀,换一个吧", "type": "dialog" }, "outputs": [{ "type": "wechat.text", "property": { "text": "你刚说的我不知道呢,继续玩就继续说,不想玩就跟我说【不玩了】" } }, { "type": "dialog", "property": { "text": "这个词我没学过呀,换一个吧", "emotion": "calm" } }], "score": "1.0", "scoreColor": "c4", "is_match": 1, "id": "4e21dce1-99d9-4b8e-bf0e-a45b773913d2" }], "meta_process_milliseconds": 30 } } ``` **请求示例退出** (结束游戏,返回统计分数) * 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": "5f424322-17b0-44cd-92bb-644b77c24056", "intents": [{ "parameters": { "service": "yingwu" }, "action": "0", "name": "不玩了", "result": { "text": "好的!跟你玩游戏很有意思啊,下次还想玩记得对我说【鹦鹉鹦鹉】哦", "type": "dialog" }, "outputs": [{ "type": "wechat.text", "property": { "text": "好的!跟你玩游戏很有意思啊,下次还想玩记得对我说【鹦鹉鹦鹉】哦" } }, { "type": "dialog", "property": { "text": "好的!跟你玩游戏很有意思啊,下次还想玩记得对我说【鹦鹉鹦鹉】哦", "emotion": "positive" } }], "score": "1.0", "scoreColor": "c4", "is_match": 1, "id": "fd653951-3aef-4503-9571-d9fd78af2bbc" }], "meta_process_milliseconds": 29 } } ``` **详细参数说明** |名称|类型|说明| |:---|:---|:--- |service | String |服务名称 |kid_ciyu1|String |识别的正确词语