快速接入AI老师
本文档是一篇从0开始进行AI老师接口接入的教程,包含环境准备、接口介绍和实践案例
环境准备
注册阿里云账号
提供阿里云主账号ID
获取主账号ID
通过主账号登录时,右上角“账号ID”即为阿里云主账号ID

通过RAM子账号登录时,右上角“主账号ID”为阿里云主账号ID

提供主账号ID
将阿里云主账号ID提供给AI口语老师产品经理@海鹤,进行初始化配置
创建RAM子账号
由于阿里云主账号具有完全的账号权限,且无法进行权限控制。若AccessKey保管或者使用不当,被他人恶意利用,将会对账号资源造成巨大威胁,推荐使用RAM子账号或者STS临时授权进行服务访问。
搜索栏搜索“访问控制”,进入RAM访问控制的控制台页面。点击“身份管理”->“用户”->“创建用户”

创建RAM用户,勾选“使用永久 AccessKey 访问”

立即复制并妥善保管AK SK(请及时保存 AccessKey 信息,页面关闭后将无法再次获取信息)

给RAM子账号授权
点击“权限管理”->“权限策略”->“创建权限策略”

点击“脚本编辑”->复制如下内容并创建权限策略
{
"Version": "1",
"Statement": [
{
"Effect": "Allow",
"Action": "aicontent:*",
"Resource": "acs:aicontent::*:*"
}
]
}
将创建好的权限策略授予新建的RAM用户


至此完成所有环境准备工作,可以使用RAM子账号的AccessKey、AccessSecret进行AI老师接口调用。
接口文档
接口概览
API | API概述 | |
同步练接口 | 本接口根据课本原文和主题等信息生成启动同步练所需数据 | |
本接口根据对话任务和历史对话记录进行同步练对话 | ||
本接口对同步练老师的对话内容提供翻译能力 | ||
本接口用于提示学生如何回复同步练老师的对话内容 | ||
扩展练接口 | 本接口根据课本原文和主题等信息生成启动拓展练所需数据 | |
本接口根据对话任务和历史对话记录进行拓展练对话 | ||
本接口对拓展练老师的对话内容提供翻译能力 | ||
本接口用于提示学生如何回复拓展练老师的对话内容 | ||
本接口用于润色拓展练中学生的对话内容 | ||
通用接口 | 本接口用于检测同步练和拓展练中学生对话内容是否存在语法错误 |
零代码接口调试
通过接口调试页面可快速熟悉接口出入参
进入接口文档业务, 点击右上角的"去调用"

按接口要求填入参数并发起调用即可

接口调用示例
SDK使用教程
获取最新版本SDK,本文档以Java语言、Apache Maven为例:
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aicontent20240611</artifactId>
<version>1.3.1</version>
</dependency>用1.3节中保存的RAM子账号AK、SK填充至"YOUR_ALIYUN_AK"、"YOUR_ALIYUN_SK"位置。
注意:同步练对话任务生成、拓展练对话任务生成接口耗时较长,可以通过setReadTimeout( )、setConnectTimeout( )设置超时时间
public class OpenApiUtils {
/**
* <b>description</b> :
* <p>使用AK&SK初始化账号Client</p>
* @return Client
*
* @throws Exception
*/
public static com.aliyun.aicontent20240611.Client createClient() throws Exception {
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
.setAccessKeyId("YOUR_ALIYUN_AK")
.setAccessKeySecret("YOUR_ALIYUN_SK");
config.endpoint = "aicontent.aliyuncs.com";
return new com.aliyun.aicontent20240611.Client(config);
}
public static void main(String[] args_) throws Exception {
java.util.List<String> args = java.util.Arrays.asList(args_);
com.aliyun.aicontent20240611.Client client = OpenApiUtils.createClient();
com.aliyun.aicontent20240611.models.AITeacherExpansionPracticeTaskGenerateRequest AITeacherExpansionPracticeTaskGenerateRequest = new com.aliyun.aicontent20240611.models.AITeacherExpansionPracticeTaskGenerateRequest()
.setUserId("1234")
.setGrade("13")
.setTextContent("Dog walker Dog walking, as a profession, originated in the US. Some may think that it's a perfect job, because dog walkers won't be imprisoned in an office. But it's actually manual labour. At their busiest, dog walkers may have more than ten dogs to take care of in a day. Hotel test sleeper A hotel test sleeper, as the name suggests, has to write expert reviews about the facilities, locations, prices, dining and other services of hotels, in order to provide evaluations and guides for travelers. Hotel test sleepers don't need to punch in for work and they get about ten thousand yuan as income every month. What a comfortable job! Food taster In ancient times, a food taster was a person who tasted foods (or drinks) to be served to someone else, to confirm that it was safe to eat. But now, those working as food tasters just get to taste various new foods and drinks aimed at specific regions across the world. They then give their opinions on these products to the companies and suggest improvements.")
.setTopic("talk about your dream job");
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions()
.setReadTimeout(180000)
.setConnectTimeout(180000);
java.util.Map<String, String> headers = new java.util.HashMap<>();
try {
// 复制代码运行请自行打印 API 的返回值
AITeacherExpansionPracticeTaskGenerateResponse aiTeacherExpansionPracticeTaskGenerateResponse = client.aITeacherExpansionPracticeTaskGenerateWithOptions(AITeacherExpansionPracticeTaskGenerateRequest, headers, runtime);
System.out.println(JSON.toJSONString(aiTeacherExpansionPracticeTaskGenerateResponse));
} catch (TeaException error) {
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
// 错误 message
System.out.println(error.getMessage());
// 诊断地址
System.out.println(error.getData().get("Recommend"));
com.aliyun.teautil.Common.assertAsString(error.message);
} catch (Exception _error) {
TeaException error = new TeaException(_error.getMessage(), _error);
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
// 错误 message
System.out.println(error.getMessage());
com.aliyun.teautil.Common.assertAsString(error.message);
}
}
}SDK调用示例
同步练对话任务生成
请求参数
{
"user_id": "886ebaxxxxxxxxxxxxxxxxxa87a525",
"grade": "13",
"topic": "talk about your dream job",
"textContent": "Dog walker Dog walking, as a profession, originated in the US. Some may think that it's a perfect job, because dog walkers won't be imprisoned in an office. But it's actually manual labour. At their busiest, dog walkers may have more than ten dogs to take care of in a day. Hotel test sleeper A hotel test sleeper, as the name suggests, has to write expert reviews about the facilities, locations, prices, dining and other services of hotels, in order to provide evaluations and guides for travelers. Hotel test sleepers don't need to punch in for work and they get about ten thousand yuan as income every month. What a comfortable job! Food taster In ancient times, a food taster was a person who tasted foods (or drinks) to be served to someone else, to confirm that it was safe to eat. But now, those working as food tasters just get to taste various new foods and drinks aimed at specific regions across the world. They then give their opinions on these products to the companies and suggest improvements."
}响应参数
{
"success": true,
"errCode": null,
"errMessage": null,
"requestId": "72xxxx16-xxxx-xxxx-xxxx-25Cxxxx7DB76",
"httpStatusCode": 200,
"data": {
"taskType": "textbook_question_answering",
"taskContent": [
{
"assistant": "Where did dog walking start as a job?",
"user": "Dog walking started as a job in the US."
},
{
"assistant": "Why do some people think dog walking is a perfect job?",
"user": "Some think it's perfect because dog walkers won't be in an office."
},
{
"assistant": "What is a dog walker's job like?",
"user": "It's manual labour, and they may take care of more than ten dogs in a day."
},
{
"assistant": "What does a hotel test sleeper do?",
"user": "A hotel test sleeper writes reviews about hotels."
},
{
"assistant": "What are the benefits for a hotel test sleeper?",
"user": "Hotel test sleepers don't need to punch in and get about ten thousand yuan every month."
},
{
"assistant": "What did a food taster do in ancient times?",
"user": "A food taster tasted foods or drinks to confirm they were safe."
},
{
"assistant": "What do food tasters do now?",
"user": "Food tasters taste new foods and drinks, give opinions, and suggest improvements."
}
}
}拓展练对话任务生成
请求参数
{
"body": {
"userId": "1234",
"grade": "13",
"topic": "talk about your dream job",
"textContent": "Dog walker Dog walking, as a profession, originated in the US. Some may think that it's a perfect job, because dog walkers won't be imprisoned in an office. But it's actually manual labour. At their busiest, dog walkers may have more than ten dogs to take care of in a day. Hotel test sleeper A hotel test sleeper, as the name suggests, has to write expert reviews about the facilities, locations, prices, dining and other services of hotels, in order to provide evaluations and guides for travelers. Hotel test sleepers don't need to punch in for work and they get about ten thousand yuan as income every month. What a comfortable job! Food taster In ancient times, a food taster was a person who tasted foods (or drinks) to be served to someone else, to confirm that it was safe to eat. But now, those working as food tasters just get to taste various new foods and drinks aimed at specific regions across the world. They then give their opinions on these products to the companies and suggest improvements."
}
}响应参数
{
"success": true,
"errCode": null,
"errMessage": null,
"requestId": "3DF1BA91-2F41-0CAA-8ED3-6016870FCB57",
"httpStatusCode": 200,
"data": {
"taskType": "textbook_dialogue",
"taskContent": [
{
"assistant": "Ask Jamie if they've ever thought about what their dream job would be.",
"user": "Tell Alex that you have considered different options and found a few interesting."
},
{
"assistant": "Ask Jamie if they value having the flexibility to work outside of a traditional office.",
"user": "Explain to Alex that the freedom to work in various settings, like a dog walker, is very appealing."
},
{
"assistant": "Ask Jamie if they think income is an important factor in choosing a dream job.",
"user": "Share with Alex that while income is important, finding a balance between salary and personal satisfaction, like a hotel test sleeper, is key."
},
{
"assistant": "Ask Jamie if they enjoy tasting new foods and if that could influence their choice of a dream job.",
"user": "Tell Alex that being a food taster sounds intriguing because it combines a passion for food with providing valuable feedback to companies."
},
{
"assistant": "Ask Jamie if they consider the impact of their job on others when choosing a dream career.",
"user": "Discuss with Alex that helping others, such as guiding travelers with expert hotel reviews, adds a layer of fulfillment beyond personal gain."
}
],
"backgroundDescription": "At a career counseling session, we are going to discuss our dream jobs and what makes them appealing, considering aspects like freedom, income, and personal satisfaction.",
"roleSet": {
"assistant": "Alex",
"user": "Jamie"
},
"startSentence": "Hey Jamie, have you ever thought about your dream job?"
}
}场景案例
同步练和拓展练最重要的区别在于,用户是否需要参考标准答案进行回复。
同步练主要面向有标准答案的对话任务,虽然该模式允许用户和标准答案有一定的区别或偏差,AI会相对严格地要求用户使用标准答案回复问题。例如,在绘本场景中,用户需要回答“绘本上有什么内容”。因为绘本上,天空中有一只白色的大鸟,所以用户必须参考标准答案回答。可以回答“天上有一只大鸟”,或“天上有一只白色的鸟”都算对。但是如果回答“天上有一架飞机”,则会被判断为错误。
拓展练习对话主要针对较为开放的交流场景。例如基于某一个话题进行问答讨论。在练习过程中,虽然AI提出的问题没有预设答案,但用户仍需在相关话题内进行回答。若用户回答偏离主题,AI会尝试引导其回归话题。
拓展练整体流程
本小节以一个拓展练案例,来演示如何使用上述接口进行AI口语对话训练。
时序图
关键步骤解析
时序图中步骤1:进行对话任务生成
接口入参
{
"body": {
"userId": "1234",
"grade": "13",
"topic": "talk about your dream job",
"textContent": "Dog walker Dog walking, as a profession, originated in the US. Some may think that it's a perfect job, because dog walkers won't be imprisoned in an office. But it's actually manual labour. At their busiest, dog walkers may have more than ten dogs to take care of in a day. Hotel test sleeper A hotel test sleeper, as the name suggests, has to write expert reviews about the facilities, locations, prices, dining and other services of hotels, in order to provide evaluations and guides for travelers. Hotel test sleepers don't need to punch in for work and they get about ten thousand yuan as income every month. What a comfortable job! Food taster In ancient times, a food taster was a person who tasted foods (or drinks) to be served to someone else, to confirm that it was safe to eat. But now, those working as food tasters just get to taste various new foods and drinks aimed at specific regions across the world. They then give their opinions on these products to the companies and suggest improvements."
}
}响应参数
{
"success": true,
"errCode": null,
"errMessage": null,
"requestId": "3DF1BA91-2F41-0CAA-8ED3-6016870FCB57",
"httpStatusCode": 200,
"data": {
"taskType": "textbook_dialogue",
"taskContent": [
{
"assistant": "Ask Jamie if they've ever thought about what their dream job would be.",
"user": "Tell Alex that you have considered different options and found a few interesting."
},
{
"assistant": "Ask Jamie if they value having the flexibility to work outside of a traditional office.",
"user": "Explain to Alex that the freedom to work in various settings, like a dog walker, is very appealing."
},
{
"assistant": "Ask Jamie if they think income is an important factor in choosing a dream job.",
"user": "Share with Alex that while income is important, finding a balance between salary and personal satisfaction, like a hotel test sleeper, is key."
},
{
"assistant": "Ask Jamie if they enjoy tasting new foods and if that could influence their choice of a dream job.",
"user": "Tell Alex that being a food taster sounds intriguing because it combines a passion for food with providing valuable feedback to companies."
},
{
"assistant": "Ask Jamie if they consider the impact of their job on others when choosing a dream career.",
"user": "Discuss with Alex that helping others, such as guiding travelers with expert hotel reviews, adds a layer of fulfillment beyond personal gain."
}
],
"backgroundDescription": "At a career counseling session, we are going to discuss our dream jobs and what makes them appealing, considering aspects like freedom, income, and personal satisfaction.",
"roleSet": {
"assistant": "Alex",
"user": "Jamie"
},
"startSentence": "Hey Jamie, have you ever thought about your dream job?"
}
}时序图中步骤5:执行拓展练
接口入参
初次启动拓展练,不存在历史对话记录,所以入参中records为空
执行拓展练接口的入参dialogueTasks,即为对话任务生成接口中的响应参数taskContent
执行拓展练接口的入参roleInfo,即为对话任务生成接口中的响应参数roleSet
{
"dialogueTasks": [
{
"assistant": "Ask Jamie if they've ever thought about what their dream job would be.",
"user": "Tell Alex that you have considered different options and found a few interesting.",
"order": 1
},
{
"assistant": "Ask Jamie if they value having the flexibility to work outside of a traditional office.",
"user": "Explain to Alex that the freedom to work in various settings, like a dog walker, is very appealing.",
"order": 2
},
{
"assistant": "Ask Jamie if they think income is an important factor in choosing a dream job.",
"user": "Share with Alex that while income is important, finding a balance between salary and personal satisfaction, like a hotel test sleeper, is key.",
"order": 3
},
{
"assistant": "Ask Jamie if they enjoy tasting new foods and if that could influence their choice of a dream job.",
"user": "Tell Alex that being a food taster sounds intriguing because it combines a passion for food with providing valuable feedback to companies.",
"order": 4
},
{
"assistant": "Ask Jamie if they consider the impact of their job on others when choosing a dream career.",
"user": "Discuss with Alex that helping others, such as guiding travelers with expert hotel reviews, adds a layer of fulfillment beyond personal gain.",
"order": 5
}
],
"background": "At a career counseling session, we are going to discuss our dream jobs and what makes them appealing, considering aspects like freedom, income, and personal satisfaction.",
"roleInfo": {
"assistant": "Alex",
"user": "Jamie"
},
"topic": "talk about your dream job",
"startSentence": "Hey Jamie, have you ever thought about your dream job?",
"userId": "12345"
}响应参数
AI老师的第一轮对话内容以启动拓展练时设定的起始句子startSentence为开场
isFinish为false代表整个拓展练对话任务未完成
isOffTopicControl为false表示该轮对话内容未跑题,isOffTopicControl如果跑题2次以上,会强制开启下一轮对话
{
"success": true,
"errCode": null,
"errMessage": null,
"requestId": "A1BA13CD-7052-00A1-8999-FEDEF2ED168C",
"httpStatusCode": 200,
"data": {
"englishResult": "Hey Jamie, have you ever thought about your dream job?",
"chineseResult": "嘿,杰米,你有没有想过你梦想中的工作?",
"isFinish": false,
"isOffTopicControl": false,
"isOnTopic": true,
"questionIndex": 1
}
}时序图中步骤9:执行拓展练翻译
接口入参
拓展练翻译接口会对对话记录records中最后一条对话内容(支持翻译老师或学生的对话内容)进行翻译
{
"dialogueTasks": [
{
"assistant": "Ask Jamie if they've ever thought about what their dream job would be.",
"user": "Tell Alex that you have considered different options and found a few interesting.",
"order": 1
},
{
"assistant": "Ask Jamie if they value having the flexibility to work outside of a traditional office.",
"user": "Explain to Alex that the freedom to work in various settings, like a dog walker, is very appealing.",
"order": 2
},
{
"assistant": "Ask Jamie if they think income is an important factor in choosing a dream job.",
"user": "Share with Alex that while income is important, finding a balance between salary and personal satisfaction, like a hotel test sleeper, is key.",
"order": 3
},
{
"assistant": "Ask Jamie if they enjoy tasting new foods and if that could influence their choice of a dream job.",
"user": "Tell Alex that being a food taster sounds intriguing because it combines a passion for food with providing valuable feedback to companies.",
"order": 4
},
{
"assistant": "Ask Jamie if they consider the impact of their job on others when choosing a dream career.",
"user": "Discuss with Alex that helping others, such as guiding travelers with expert hotel reviews, adds a layer of fulfillment beyond personal gain.",
"order": 5
}
],
"background": "At a career counseling session, we are going to discuss our dream jobs and what makes them appealing, considering aspects like freedom, income, and personal satisfaction.",
"roleInfo": {
"assistant": "Alex",
"user": "Jamie"
},
"topic": "talk about your dream job",
"startSentence": "Hey Jamie, have you ever thought about your dream job?",
"userId": "12345",
"records": [
{
"content": "Hey Jamie, have you ever thought about your dream job?",
"role": "assistant",
"order": 1
}
]
}响应参数
{
"success": true,
"errCode": null,
"errMessage": null,
"requestId": "B5F9D838-CDF1-0502-ACC1-E50BC8B223F2",
"httpStatusCode": 200,
"data": {
"result": "嘿,杰米,你有没有想过你的理想工作是什么?"
}
}时序图中步骤13:拓展练小助手提示
接口入参
拓展练小助手提示接口会提示学生如何回复对话记录records中最后一条AI老师对话内容
{
"dialogueTasks": [
{
"assistant": "Ask Jamie if they've ever thought about what their dream job would be.",
"user": "Tell Alex that you have considered different options and found a few interesting.",
"order": 1
},
{
"assistant": "Ask Jamie if they value having the flexibility to work outside of a traditional office.",
"user": "Explain to Alex that the freedom to work in various settings, like a dog walker, is very appealing.",
"order": 2
},
{
"assistant": "Ask Jamie if they think income is an important factor in choosing a dream job.",
"user": "Share with Alex that while income is important, finding a balance between salary and personal satisfaction, like a hotel test sleeper, is key.",
"order": 3
},
{
"assistant": "Ask Jamie if they enjoy tasting new foods and if that could influence their choice of a dream job.",
"user": "Tell Alex that being a food taster sounds intriguing because it combines a passion for food with providing valuable feedback to companies.",
"order": 4
},
{
"assistant": "Ask Jamie if they consider the impact of their job on others when choosing a dream career.",
"user": "Discuss with Alex that helping others, such as guiding travelers with expert hotel reviews, adds a layer of fulfillment beyond personal gain.",
"order": 5
}
],
"background": "At a career counseling session, we are going to discuss our dream jobs and what makes them appealing, considering aspects like freedom, income, and personal satisfaction.",
"roleInfo": {
"assistant": "Alex",
"user": "Jamie"
},
"topic": "talk about your dream job",
"startSentence": "Hey Jamie, have you ever thought about your dream job?",
"userId": "12345",
"records": [
{
"content": "Hey Jamie, have you ever thought about your dream job?",
"role": "assistant",
"order": 1
}
]
}响应参数
{
"success": true,
"errCode": null,
"errMessage": null,
"requestId": "0E6C9300-B4F9-068E-A88A-AB859FCC42E4",
"httpStatusCode": 200,
"data": {
"englishResult": "Yeah, I have. I've looked at a few different options and found some pretty cool stuff.",
"chineseResult": "是的,我有。我有了几个不同的候选,还发现了一些很酷的东西。"
}
}时序图中步骤17:执行拓展练
接口入参
学生回复(Yeah, I have. I've looked at a few different options)填充到records的第二条记录中
学生回复是新输入内容,尚未经过AI老师的判断,所以参数isOnTopic和isOffTopicControl都是空
{
"dialogueTasks": [
{
"assistant": "Ask Jamie if they've ever thought about what their dream job would be.",
"user": "Tell Alex that you have considered different options and found a few interesting.",
"order": 1
},
{
"assistant": "Ask Jamie if they value having the flexibility to work outside of a traditional office.",
"user": "Explain to Alex that the freedom to work in various settings, like a dog walker, is very appealing.",
"order": 2
},
{
"assistant": "Ask Jamie if they think income is an important factor in choosing a dream job.",
"user": "Share with Alex that while income is important, finding a balance between salary and personal satisfaction, like a hotel test sleeper, is key.",
"order": 3
},
{
"assistant": "Ask Jamie if they enjoy tasting new foods and if that could influence their choice of a dream job.",
"user": "Tell Alex that being a food taster sounds intriguing because it combines a passion for food with providing valuable feedback to companies.",
"order": 4
},
{
"assistant": "Ask Jamie if they consider the impact of their job on others when choosing a dream career.",
"user": "Discuss with Alex that helping others, such as guiding travelers with expert hotel reviews, adds a layer of fulfillment beyond personal gain.",
"order": 5
}
],
"background": "At a career counseling session, we are going to discuss our dream jobs and what makes them appealing, considering aspects like freedom, income, and personal satisfaction.",
"roleInfo": {
"assistant": "Alex",
"user": "Jamie"
},
"topic": "talk about your dream job",
"startSentence": "Hey Jamie, have you ever thought about your dream job?",
"userId": "12345",
"records": [
{
"content": "Hey Jamie, have you ever thought about your dream job?",
"role": "assistant",
"order": 1
},
{
"content": "Yeah, I have. I've looked at a few different options",
"role": "user",
"order": 2
}
]
}响应参数
响应结果中参数isOnTopic和isOffTopicControl是对学生回复(Yeah, I have. I've looked at a few different options)的跑题判断结果,再下一轮拓展练接口中需要填充到records中学生对话内容的入参中
englishResult是AI老师的第二轮对话内容,即步骤19的内容
questionIndex为2表明该轮对话已进入dialogueTasks的第二轮对话内容
{
"success": true,
"errCode": null,
"errMessage": null,
"requestId": "AFF47D20-DE5A-0CA0-82B0-72AFC6EB28F5",
"httpStatusCode": 200,
"data": {
"englishResult": "That's great, Jamie! It sounds like you've given it some thought. Do you like the idea of working outside of a traditional office, like from home or different places?",
"chineseResult": "太棒了,杰米!听起来你已经考虑过了。你喜欢在传统办公室之外工作的想法,比如在家或不同的地方?",
"isFinish": false,
"isOffTopicControl": false,
"isOnTopic": true,
"questionIndex": 2
}
}时序图中步骤21:执行语法检测
将学生回复输入给AI老师之后,如果学生想对自己的回复检测是否有语法问题,可以使用语法检测功能
正确语法示例
接口入参
{
"content": "Yeah, I have. I've looked at a few different options.",
"userId": "12345"
}响应参数
{
"success": true,
"errCode": null,
"errMessage": null,
"requestId": "23503E55-63CC-0D87-BAA8-4CC27A8A998E",
"httpStatusCode": 200,
"data": {
"correctionStatus": "No_Error",
"errorReason": null,
"correction": "Yeah, I have. I've looked at a few different options.",
"analysis": "语法正确。"
}
}错误语法示例
接口入参
{
"content": "Yes, i has.",
"userId": "12345"
}响应参数
{
"success": true,
"errCode": null,
"errMessage": null,
"requestId": "A00D682C-3281-09BB-83EF-A752EA9AAAE5",
"httpStatusCode": 200,
"data": {
"correctionStatus": "Has_Error",
"errorReason": null,
"correction": "Yes, I have.",
"analysis": "主语 \"I\" 是第一人称单数,因此动词 \"has\" 应该变为 \"have\"。"
}
}时序图中步骤25:执行拓展练润色
接口入参
{
"dialogueTasks": [
{
"assistant": "Ask Jamie if they've ever thought about what their dream job would be.",
"user": "Tell Alex that you have considered different options and found a few interesting.",
"order": 1
},
{
"assistant": "Ask Jamie if they value having the flexibility to work outside of a traditional office.",
"user": "Explain to Alex that the freedom to work in various settings, like a dog walker, is very appealing.",
"order": 2
},
{
"assistant": "Ask Jamie if they think income is an important factor in choosing a dream job.",
"user": "Share with Alex that while income is important, finding a balance between salary and personal satisfaction, like a hotel test sleeper, is key.",
"order": 3
},
{
"assistant": "Ask Jamie if they enjoy tasting new foods and if that could influence their choice of a dream job.",
"user": "Tell Alex that being a food taster sounds intriguing because it combines a passion for food with providing valuable feedback to companies.",
"order": 4
},
{
"assistant": "Ask Jamie if they consider the impact of their job on others when choosing a dream career.",
"user": "Discuss with Alex that helping others, such as guiding travelers with expert hotel reviews, adds a layer of fulfillment beyond personal gain.",
"order": 5
}
],
"background": "At a career counseling session, we are going to discuss our dream jobs and what makes them appealing, considering aspects like freedom, income, and personal satisfaction.",
"roleInfo": {
"assistant": "Alex",
"user": "Jamie"
},
"topic": "talk about your dream job",
"startSentence": "Hey Jamie, have you ever thought about your dream job?",
"userId": "12345",
"records": [
{
"content": "Hey Jamie, have you ever thought about your dream job?",
"role": "assistant",
"order": 1
},
{
"content": "Yeah, I have. I've looked at a few different options",
"role": "user",
"order": 2
}
]
}响应参数
润色后使用considered代替looked at更合适
{
"success": true,
"errCode": null,
"errMessage": null,
"requestId": "5DA2B7B6-E816-0D8C-9DE1-B272E19C722F",
"httpStatusCode": 200,
"data": {
"result": "Yeah, I have. I've considered a few different options."
}
}时序图中步骤29:执行拓展练
接口入参
学生进行第二轮回复,注意records中第一轮学生回复的isOnTopic和isOffTopicControl需要进行填充
{
"dialogueTasks": [
{
"assistant": "Ask Jamie if they've ever thought about what their dream job would be.",
"user": "Tell Alex that you have considered different options and found a few interesting.",
"order": 1
},
{
"assistant": "Ask Jamie if they value having the flexibility to work outside of a traditional office.",
"user": "Explain to Alex that the freedom to work in various settings, like a dog walker, is very appealing.",
"order": 2
},
{
"assistant": "Ask Jamie if they think income is an important factor in choosing a dream job.",
"user": "Share with Alex that while income is important, finding a balance between salary and personal satisfaction, like a hotel test sleeper, is key.",
"order": 3
},
{
"assistant": "Ask Jamie if they enjoy tasting new foods and if that could influence their choice of a dream job.",
"user": "Tell Alex that being a food taster sounds intriguing because it combines a passion for food with providing valuable feedback to companies.",
"order": 4
},
{
"assistant": "Ask Jamie if they consider the impact of their job on others when choosing a dream career.",
"user": "Discuss with Alex that helping others, such as guiding travelers with expert hotel reviews, adds a layer of fulfillment beyond personal gain.",
"order": 5
}
],
"background": "At a career counseling session, we are going to discuss our dream jobs and what makes them appealing, considering aspects like freedom, income, and personal satisfaction.",
"roleInfo": {
"assistant": "Alex",
"user": "Jamie"
},
"topic": "talk about your dream job",
"startSentence": "Hey Jamie, have you ever thought about your dream job?",
"userId": "12345",
"records": [
{
"content": "Hey Jamie, have you ever thought about your dream job?",
"role": "assistant",
"order": 1
},
{
"content": "Yeah, I have. I've looked at a few different options",
"role": "user",
"order": 2,
"isOffTopicControl": false,
"isOnTopic": true
},
{
"content": "That's great, Jamie! It sounds like you've given it some thought. Do you like the idea of working outside of a traditional office, like from home or different places?",
"role": "assistant",
"order": 3
},
{
"content": "Yes, it is very freeing to work in different environments, for example, I can walk the dog",
"role": "user",
"order": 4
}
]
}响应参数
{
"success": true,
"errCode": null,
"errMessage": null,
"requestId": "2F1B58C3-2170-01CB-9290-B17514B1A047",
"httpStatusCode": 200,
"data": {
"englishResult": "That sounds really nice, Jamie! Being able to walk your dog while working sounds like a great perk. Do you think income is an important factor in choosing a dream job?",
"chineseResult": "听起来真不错,杰米!能够在工作时遛狗听起来是一个很好的福利。你认为收入是选择理想工作的重要因素吗?",
"isFinish": false,
"isOffTopicControl": false,
"isOnTopic": true,
"questionIndex": 3
}
}同步练整体流程
本小节以一个同步练案例,来演示如何使用上述接口进行AI口语对话训练。
时序图
关键步骤解析
时序图中步骤1:进行对话任务生成
请求参数
{
"user_id": "886ebaxxxxxxxxxxxxxxxxxa87a525",
"grade": "13",
"topic": "talk about your dream job",
"textContent": "Dog walker Dog walking, as a profession, originated in the US. Some may think that it's a perfect job, because dog walkers won't be imprisoned in an office. But it's actually manual labour. At their busiest, dog walkers may have more than ten dogs to take care of in a day. Hotel test sleeper A hotel test sleeper, as the name suggests, has to write expert reviews about the facilities, locations, prices, dining and other services of hotels, in order to provide evaluations and guides for travelers. Hotel test sleepers don't need to punch in for work and they get about ten thousand yuan as income every month. What a comfortable job! Food taster In ancient times, a food taster was a person who tasted foods (or drinks) to be served to someone else, to confirm that it was safe to eat. But now, those working as food tasters just get to taste various new foods and drinks aimed at specific regions across the world. They then give their opinions on these products to the companies and suggest improvements."
}响应参数
{
"success": true,
"errCode": null,
"errMessage": null,
"requestId": "72xxxx16-xxxx-xxxx-xxxx-25Cxxxx7DB76",
"httpStatusCode": 200,
"data": {
"taskType": "textbook_question_answering",
"taskContent": [
{
"assistant": "Where did dog walking start as a job?",
"user": "Dog walking started as a job in the US."
},
{
"assistant": "Why do some people think dog walking is a perfect job?",
"user": "Some think it's perfect because dog walkers won't be in an office."
},
{
"assistant": "What is a dog walker's job like?",
"user": "It's manual labour, and they may take care of more than ten dogs in a day."
},
{
"assistant": "What does a hotel test sleeper do?",
"user": "A hotel test sleeper writes reviews about hotels."
},
{
"assistant": "What are the benefits for a hotel test sleeper?",
"user": "Hotel test sleepers don't need to punch in and get about ten thousand yuan every month."
},
{
"assistant": "What did a food taster do in ancient times?",
"user": "A food taster tasted foods or drinks to confirm they were safe."
},
{
"assistant": "What do food tasters do now?",
"user": "Food tasters taste new foods and drinks, give opinions, and suggest improvements."
}
]
}
}时序图中步骤5:执行同步练
接口入参
初次启动同步练,不存在历史对话记录,所以入参中records为空
执行同步练接口的入参dialogueTasks,即为对话任务生成接口中的响应参数taskContent
{
"dialogueTasks": [
{
"assistant": "Where did dog walking start as a job?",
"user": "Dog walking started as a job in the US.",
"order": 1
},
{
"assistant": "Why do some people think dog walking is a perfect job?",
"user": "Some think it's perfect because dog walkers won't be in an office.",
"order": 2
},
{
"assistant": "What is a dog walker's job like?",
"user": "It's manual labour, and they may take care of more than ten dogs in a day.",
"order": 3
},
{
"assistant": "What does a hotel test sleeper do?",
"user": "A hotel test sleeper writes reviews about hotels.",
"order": 4
},
{
"assistant": "What are the benefits for a hotel test sleeper?",
"user": "Hotel test sleepers don't need to punch in and get about ten thousand yuan every month.",
"order": 5
},
{
"assistant": "What did a food taster do in ancient times?",
"user": "A food taster tasted foods or drinks to confirm they were safe.",
"order": 6
},
{
"assistant": "What do food tasters do now?",
"user": "Food tasters taste new foods and drinks, give opinions, and suggest improvements.",
"order": 7
}
],
"userId": "12345"
}响应参数
isFinish为false代表整个拓展练对话任务未完成
isOnTopic为true表示该轮对话内容扣题
{
"success": true,
"errCode": null,
"errMessage": null,
"requestId": "6495130B-68B4-088E-88B1-76861974C2BE",
"httpStatusCode": 200,
"data": {
"englishResult": "Good day! Where did dog walking start as a job?",
"isFinish": false,
"isOnTopic": true,
"questionIndex": 1
}
}时序图中步骤9:执行同步练翻译
接口入参
{
"body": {
"dialogueTasks": [
{
"assistant": "Where did dog walking start as a job?",
"user": "Dog walking started as a job in the US.",
"order": 1
},
{
"assistant": "Why do some people think dog walking is a perfect job?",
"user": "Some think it's perfect because dog walkers won't be in an office.",
"order": 2
},
{
"assistant": "What is a dog walker's job like?",
"user": "It's manual labour, and they may take care of more than ten dogs in a day.",
"order": 3
},
{
"assistant": "What does a hotel test sleeper do?",
"user": "A hotel test sleeper writes reviews about hotels.",
"order": 4
},
{
"assistant": "What are the benefits for a hotel test sleeper?",
"user": "Hotel test sleepers don't need to punch in and get about ten thousand yuan every month.",
"order": 5
},
{
"assistant": "What did a food taster do in ancient times?",
"user": "A food taster tasted foods or drinks to confirm they were safe.",
"order": 6
},
{
"assistant": "What do food tasters do now?",
"user": "Food tasters taste new foods and drinks, give opinions, and suggest improvements.",
"order": 7
}
],
"userId": "12345",
"records": [
{
"content": "Good day! Where did dog walking start as a job?",
"role": "assistant",
"order": 1
}
]
}
}响应参数
{
"success": true,
"errCode": null,
"errMessage": null,
"requestId": "DF2FCFCD-FB4A-0C6C-B478-319291770DCF",
"httpStatusCode": 200,
"data": {
"result": "美好的一天!遛狗作为一项工作是从哪里开始的呢?"
}
}时序图中步骤13:获取同步练小助手提示
接口入参
{
"body": {
"dialogueTasks": [
{
"assistant": "Where did dog walking start as a job?",
"user": "Dog walking started as a job in the US.",
"order": 1
},
{
"assistant": "Why do some people think dog walking is a perfect job?",
"user": "Some think it's perfect because dog walkers won't be in an office.",
"order": 2
},
{
"assistant": "What is a dog walker's job like?",
"user": "It's manual labour, and they may take care of more than ten dogs in a day.",
"order": 3
},
{
"assistant": "What does a hotel test sleeper do?",
"user": "A hotel test sleeper writes reviews about hotels.",
"order": 4
},
{
"assistant": "What are the benefits for a hotel test sleeper?",
"user": "Hotel test sleepers don't need to punch in and get about ten thousand yuan every month.",
"order": 5
},
{
"assistant": "What did a food taster do in ancient times?",
"user": "A food taster tasted foods or drinks to confirm they were safe.",
"order": 6
},
{
"assistant": "What do food tasters do now?",
"user": "Food tasters taste new foods and drinks, give opinions, and suggest improvements.",
"order": 7
}
],
"userId": "12345",
"records": [
{
"content": "Good day! Where did dog walking start as a job?",
"role": "assistant",
"order": 1
}
]
}
}响应参数
{
"success": true,
"errCode": null,
"errMessage": null,
"requestId": "DCADE251-3EDC-00E7-A4E9-08D38A24C2F2",
"httpStatusCode": 200,
"data": {
"englishResult": "Dog walking started as a job in the US.",
"chineseResult": "在美国,遛狗最初是一份工作。"
}
}时序图中步骤17:执行同步练
接口入参
学生回复(Dog walking as a job originated in the United States)填充到records的第二条记录中
{
"dialogueTasks": [
{
"assistant": "Where did dog walking start as a job?",
"user": "Dog walking started as a job in the US.",
"order": 1
},
{
"assistant": "Why do some people think dog walking is a perfect job?",
"user": "Some think it's perfect because dog walkers won't be in an office.",
"order": 2
},
{
"assistant": "What is a dog walker's job like?",
"user": "It's manual labour, and they may take care of more than ten dogs in a day.",
"order": 3
},
{
"assistant": "What does a hotel test sleeper do?",
"user": "A hotel test sleeper writes reviews about hotels.",
"order": 4
},
{
"assistant": "What are the benefits for a hotel test sleeper?",
"user": "Hotel test sleepers don't need to punch in and get about ten thousand yuan every month.",
"order": 5
},
{
"assistant": "What did a food taster do in ancient times?",
"user": "A food taster tasted foods or drinks to confirm they were safe.",
"order": 6
},
{
"assistant": "What do food tasters do now?",
"user": "Food tasters taste new foods and drinks, give opinions, and suggest improvements.",
"order": 7
}
],
"userId": "12345",
"records": [
{
"content": "Good day! Where did dog walking start as a job?",
"role": "assistant",
"order": 1,
"isOnTopic": true
},
{
"content": "Dog walking as a job originated in the United States",
"role": "user",
"order": 2
}
]
}响应参数
AI老师首先肯定了第一轮学生回复,接着将话题引入第二轮对话内容
{
"success": true,
"errCode": null,
"errMessage": null,
"requestId": "EF611D05-F2DD-0D91-919A-2FC4896EFF42",
"httpStatusCode": 200,
"data": {
"englishResult": "Great. It is correct. The answer is \"Dog walking started as a job in the US.\". Now, Why do some people think dog walking is a perfect job?",
"isFinish": false,
"isOnTopic": true,
"questionIndex": 2
}
}时序图中步骤21:执行语法检测
将学生回复输入给AI老师之后,如果学生想对自己的回复检测是否有语法问题,可以使用语法检测功能
正确语法示例
接口入参
{
"content": "Dog walking started as a job in the US.",
"userId": "12345"
}响应参数
{
"success": true,
"errCode": null,
"errMessage": null,
"requestId": "0D580B0A-1032-00E2-A454-8FE720553ABA",
"httpStatusCode": 200,
"data": {
"correctionStatus": "No_Error",
"errorReason": null,
"correction": "Dog walking started as a job in the US.",
"analysis": "语法正确。"
}
}错误语法示例
接口入参
{
"content": "Dog walking started as an job in the US.",
"userId": "12345"
}响应参数
{
"success": true,
"errCode": null,
"errMessage": null,
"requestId": "54DB369F-F0DA-0CE1-8C6E-FCAB5CC1D401",
"httpStatusCode": 200,
"data": {
"correctionStatus": "Has_Error",
"errorReason": null,
"correction": "Dog walking started as a job in the US.",
"analysis": "不定冠词使用错误:在 \"an\" 和 \"job\" 之间,因为 \"job\" 是以辅音开头的单词,所以应该使用 \"a\" 而不是 \"an\"。"
}
}时序图中步骤25:执行同步练
接口入参
{
"body": {
"dialogueTasks": [
{
"assistant": "Where did dog walking start as a job?",
"user": "Dog walking started as a job in the US.",
"order": 1
},
{
"assistant": "Why do some people think dog walking is a perfect job?",
"user": "Some think it's perfect because dog walkers won't be in an office.",
"order": 2
},
{
"assistant": "What is a dog walker's job like?",
"user": "It's manual labour, and they may take care of more than ten dogs in a day.",
"order": 3
},
{
"assistant": "What does a hotel test sleeper do?",
"user": "A hotel test sleeper writes reviews about hotels.",
"order": 4
},
{
"assistant": "What are the benefits for a hotel test sleeper?",
"user": "Hotel test sleepers don't need to punch in and get about ten thousand yuan every month.",
"order": 5
},
{
"assistant": "What did a food taster do in ancient times?",
"user": "A food taster tasted foods or drinks to confirm they were safe.",
"order": 6
},
{
"assistant": "What do food tasters do now?",
"user": "Food tasters taste new foods and drinks, give opinions, and suggest improvements.",
"order": 7
}
],
"userId": "12345",
"records": [
{
"content": "Good day! Where did dog walking start as a job?",
"role": "assistant",
"order": 1,
"isOnTopic": true
},
{
"content": "Dog walking as a job originated in the United States",
"role": "user",
"order": 2,
"isOnTopic": true
},
{
"content": "Good work. You're right. The answer is \\\"Dog walking started as a job in the US.\\\". Why do some people think dog walking is a perfect job?",
"role": "assistant",
"isOnTopic": true,
"order": 3
},
{
"content": "Because dog walking is a very free job",
"role": "user",
"order": 4
}
]
}
}响应参数
{
"success": true,
"errCode": null,
"errMessage": null,
"requestId": "EA4F6FC5-1DE8-09CC-B6BE-F58F99F5CF1A",
"httpStatusCode": 200,
"data": {
"englishResult": "Good work. It is correct. The answer is \"Some think it's perfect because dog walkers won't be in an office.\". What is a dog walker's job like?",
"isFinish": false,
"isOnTopic": true,
"questionIndex": 3
}
}