备注:"modelVersion"="2.0"
POST
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| question | 是 | string | 对方(债务人或其亲属等)说的话 1、max-lenght:300字 |
| userProp | 是 | object | 用户参数 |
| chatHistory | 是 | array | 历史聊天记录 1、暂时先传历史2轮记录,后期可调整; 2、需要传递客服实际回复的内容。 |
| questionRole | 是 | string | 对方角色(债务人或其亲属、朋友等) |
| answerRole | 是 | string | 客服角色(如调解专员) |
| employeeId | 否 | string | 员工编号(如”160101“,用于调用私有话术库。不传则默认线上话术库) |
| isSingleQuestion | 否 | boolean | 为true时,不会带历史聊天记录(不带上下文) 注意:默认聊天场景不用带上该参数 |
| currentNode | v2必须 | DesideNode | 当前节点状态。 ---V2版决策流程(同步) |
| modelVersion | v2必须 | string | 不传时为默认版本1.0。目前有1.0和2.0 |
| processJsonV2 | v2必须 | json | 流程图导出的json内容 |
currentNode的初始值为:
xxxxxxxxxxlet currentNode:DesideNode = { node: "96162319-6621-4153-8b77-e97310aa3817", isAI : 0, maxCount : 1, currentIndex : 1}| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| userName | 是 | string | 债务人称呼 |
| delayDays | 是 | number | 逾期天数 |
| debt | 是 | number | 债务金额 |
| proxyName | 否 | string | 委托授权方,也叫项目(不传则不过滤该参数) |
| product | 否 | string | 产品名称(不传则不过滤该参数) |
| interest | 否 | number | 利息 |
| rates | 否 | number | 利息可减免比例 |
| character | 否 | string | 债务人性格 |
| gender | 否 | string | 性别 |
| 参数名 | 必选 | 类型 | 说明 |
|---|---|---|---|
| node | 是 | String | 决策流程名称 |
| isAI | 是 | number | 当前节点是否为协商节点。 为0表示为判断节点,为1表示为协商(AI+话术回复) |
| maxCount | 是 | number | 协商节点最大对话轮数(超过maxCount时,强制进入下一节点) |
| currentIndex | 是 | number | 当前节点对话轮数 |
---流式文字
x
const postData = JSON.stringify({ "question": "喂,你好", "userProp": { "proxyName": "中国银行", "userName": "黄先生", "delayDays": 13, "debt": 123, "character": "ok", "gender": "男", }, "chatHistory": [{"question": "喂,哪位"}, {"answer": "您好,我是蚂蚁金服的调解专员,请问您是金先生吗?"}], "questionRole": "债务人", "answerRole": "调解专员", "modelVersion": "2.0", "currentNode": { "node":"start", "isAI":0, "maxCount":1, "currentIndex":1, }, processJsonV2});
const response = await fetch("/api/docs", { method: "POST", headers: { "Content-Type": "application/json" }, body: postData });
const data = response.body; if (!data) { return; }
const reader = data.getReader();const decoder = new TextDecoder();let done = false;
let is_logged = false;let isJson = false;while (!done) { const { value, done: doneReading } = await reader.read(); done = doneReading; const chunkValue = decoder.decode(value); setAanswer((prev) => prev + chunkValue); ans += chunkValue; if(ans.indexOf("{") == 0){ isJson = true; }}
if(isJson){try { const json = JSON.parse(ans); // 返回内容如下: // replyJson = { // "nextNode": nextNode, // "maxCount": maxCount, // "currentIndex": currentIndex, // "isAI": isAI, // "reply": directReply // } if(ans && json.nextNode && json.reply!=undefined && json.maxCount && json.currentIndex && json.isAI!=undefined){ ans = json.reply; currentNode.node = json.nextNode; currentNode.currentIndex = json.currentIndex; currentNode.isAI = json.isAI; currentNode.maxCount = json.maxCount; }} catch (error) {}以流式文字形式输出回复