@laiye-ai/sdk-core
v1.1.3
Published
WuLai OpenAPI SDK
Downloads
20
Readme
@laiye-ai/sdk-core
安装
npm 安装
npm install @laiye-ai/sdk-core -S
yarn 安装
yarn add @laiye-ai/sdk-core -S
使用环境
Node.js >= 8.x
如何使用
"use strict";
const WuLaiClient = require("@laiye-ai/sdk-core");
// 初始化 client,pubkey 和 secret 必传
const client = new WuLaiClient({
pubkey: "your pubkey",
secret: "your secret"
});
client
.getBotResponse({
msg_body: {
text: {
content: "谢谢"
}
},
user_id: "created user_id",
extra: "extra info"
})
.then(res => {
console.log(res);
});
SDK初始化配置
new WulaiClient([, options])
new WulaiClient({
pubkey: "string", // 机器人 pubkey,required
secret: "string", // 机器人 secret,required
endpoint: "string", // base url,optional
apiVersion: "v2", // 版本,optional
debug: "boolean", // 是否开启调试模式,开启后 sdk 将对所有请求进行日志输出,默认为 stdout 输出模式
options: { // optional
timeout: 6000, // 超时时间,单位ms,默认 6000ms,optional
agent: "<Http Agent>", // http or https 连接池,optional
compression: "boolean", // 服务端返回数据是否压缩,optional
maxRetry: "number", // 网络请求异常,重试次数,默认 3 次,设置 1 为取消,optional
headers: "object" // 请求头,optional
}
});
常见场景及调用示例
一、基础对话
二、个性化对话
三、异步基础对话
四、异步定制对话
SDK 相关说明文档
SDK-CommonRequest
SDK-日志配置
SDK-设置请求超时时间
SDK-已实现API
SDK-待实现API
License
This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.