g-ai-robot3 0.1.79 → 0.1.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -166
- package/dist/components/digitalHuman.vue.d.ts +9 -0
- package/dist/g-ai-robot3.es.js +2059 -2063
- package/dist/g-ai-robot3.umd.js +70 -70
- package/dist/index.css +1 -1
- package/dist/index.vue.d.ts +0 -9
- package/dist/type.d.ts +1 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# g-ai-robot3
|
|
1
|
+
# g-ai-robot3数字人组件文档
|
|
2
2
|
|
|
3
3
|
## 简介
|
|
4
4
|
```
|
|
@@ -13,174 +13,106 @@ npm install g-ai-robot3 --save
|
|
|
13
13
|
### 使用
|
|
14
14
|
``` javascript
|
|
15
15
|
import gAiRobot from "g-ai-robot";
|
|
16
|
-
import "g-ai-robot3/dist/g-ai-robot3.css"
|
|
16
|
+
import "g-ai-robot3/dist/g-ai-robot3.css";
|
|
17
17
|
|
|
18
|
-
<g-ai-robot
|
|
19
|
-
:
|
|
20
|
-
placement="top-end"
|
|
18
|
+
<g-ai-robot :cozeInfo="{bot_id:'7429224296222097443'}" :apiPrefix="'/api21215'"
|
|
19
|
+
:canvasWidth="180" :canvasHeight="180" :videoStyle="{width:'180px',visibility:'hidden'}" :digitalStyle="{width:'180px',height:'180px'}"
|
|
21
20
|
>
|
|
22
21
|
</g-ai-robot>
|
|
23
|
-
//添加到引用组件的代码中(不在组件中引入)
|
|
24
|
-
const video = ref(null);
|
|
25
|
-
const canvas = ref(null);
|
|
26
|
-
const ctx = ref(null);
|
|
27
|
-
const canvas_tmp = ref(null);
|
|
28
|
-
const ctx_tmp = ref(null);
|
|
29
|
-
|
|
30
|
-
const init = () => {
|
|
31
|
-
ctx.value = canvas.value.getContext('2d');
|
|
32
|
-
|
|
33
|
-
// 创建的canvas宽高最好与显示图片的canvas、video宽高一致
|
|
34
|
-
canvas_tmp.value = document.createElement('canvas');
|
|
35
|
-
canvas_tmp.value.setAttribute('width', 300);
|
|
36
|
-
canvas_tmp.value.setAttribute('height', 300);
|
|
37
|
-
ctx_tmp.value = canvas_tmp.value.getContext('2d');
|
|
38
|
-
|
|
39
|
-
video.value.addEventListener('play', computeFrame);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const numToPoint = (num, width) => {
|
|
43
|
-
let col = num % width;
|
|
44
|
-
let row = Math.floor(num / width);
|
|
45
|
-
row = col === 0 ? row : row + 1;
|
|
46
|
-
col = col === 0 ? width : col;
|
|
47
|
-
return [row, col];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const pointToNum = (point, width) => {
|
|
51
|
-
let [row, col] = point;
|
|
52
|
-
return (row - 1) * width + col
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const getAroundPoint = (point, width, height, area) => {
|
|
56
|
-
let [row, col] = point;
|
|
57
|
-
let allAround = [];
|
|
58
|
-
if (row > height || col > width || row < 0 || col < 0) return allAround;
|
|
59
|
-
for (let i = 0; i < area; i++) {
|
|
60
|
-
let pRow = row - 1 + i;
|
|
61
|
-
for (let j = 0; j < area; j++) {
|
|
62
|
-
let pCol = col - 1 + j;
|
|
63
|
-
if (i === area % 2 && j === area % 2) continue;
|
|
64
|
-
allAround.push([pRow, pCol]);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return allAround.filter(([iRow, iCol]) => {
|
|
68
|
-
return (iRow > 0 && iCol > 0) && (iRow <= height && iCol <= width);
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const computeFrame = () => {
|
|
73
|
-
if (video.value) {
|
|
74
|
-
if (video.value.paused || video.value.ended) return;
|
|
75
|
-
}
|
|
76
|
-
// 如果视频比例和canvas比例不正确可能会出现显示形变, 调整除的值进行比例调整
|
|
77
|
-
ctx_tmp.value.drawImage(video.value, 0, 0, video.value.clientWidth / 1, video.value.clientHeight / 1);
|
|
78
|
-
|
|
79
|
-
// 获取到绘制的canvas的所有像素rgba值组成的数组
|
|
80
|
-
let frame = ctx_tmp.value.getImageData(0, 0, video.value.clientWidth, video.value.clientHeight);
|
|
81
22
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
23
|
+
## 必填参数 (Required Parameters)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
| 参数 | 说明 | 类型 | 示例值 | 注意事项 |
|
|
27
|
+
|--------------------|-----------------------|--------------|-----------------------------------------|--------------------------------------------------------------------------|
|
|
28
|
+
| `cozeInfo` | 智能体配置 | object | `{bot_id:'7429224296222097443'}` | 必须替换为实际的bot_id |
|
|
29
|
+
| `apiPrefix` | API基础路径 | string | `'/api21215'` | 可在项目中配置代理,默认值`'/api21215'`
|
|
30
|
+
| `canvasWidth` | 画布宽度 | number | `180` | 必须与`videoStyle`和`digitalStyle`的宽度保持一致 |
|
|
31
|
+
| `canvasHeight` | 画布高度 | number | `180` | 必须与`videoStyle`和`digitalStyle`的高度保持一致 |
|
|
32
|
+
| `videoStyle` | 视频样式 | CSSProperties | `{width:'180px',visibility:'hidden'}` | width必须与`canvasWidth`保持一致 |
|
|
33
|
+
| `digitalStyle` | 数字人样式 | CSSProperties | `{width:'180px',height:'180px'}` | width/height必须与`canvasWidth`/`canvasHeight`保持一致
|
|
34
|
+
|
|
35
|
+
### 配置示例
|
|
36
|
+
| :canvasWidth="180" :canvasHeight="180" :videoStyle="{width:'180px',visibility:'hidden'}" :digitalStyle="{width:'180px',height:'180px'}" |
|
|
37
|
+
|
|
38
|
+
## 基础配置参数
|
|
39
|
+
|
|
40
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
41
|
+
|---------------------|---------------------------------------|------------|-----------------------------------------|
|
|
42
|
+
| `isDebug` | 是否开启调试模式(打印语音输出) | boolean | `false` |
|
|
43
|
+
| `dialogBoxTheme` | 对话框主题 | string | `"light"` |
|
|
44
|
+
| `showMsgBubble` | 是否显示消息气泡 | boolean | `true` |
|
|
45
|
+
| `isExhibitionPro` | 是否为数字展厅项目 | boolean | `false` |
|
|
46
|
+
| `isShowDialogIcon` | 是否显示对话框图标 | boolean | `false` |
|
|
47
|
+
| `stream` | 是否启用流式传输 | string | `"True"` |
|
|
48
|
+
| `title` | 对话框标题 | string | `"GR水利大模型"` |
|
|
49
|
+
| `greet` | 欢迎语 | string | `"您好,我是GR水利大模型智能小助手..."` |
|
|
50
|
+
| `welcomeMessage` | 欢迎消息 | string | `"您好,我是GR水利大模型智能小助手..."` |
|
|
51
|
+
| `waitTxt` | 等待提示文本 | string | `"贵仁科技AI正在生成回答"` |
|
|
52
|
+
| `systemName` | 系统标识 | string | `"g-ai-robot3"` |
|
|
53
|
+
| `placementBottom` | 对话框底部距离 | number | `100` |
|
|
54
|
+
| `placementLeft` | 对话框左侧距离 | number | `450` |
|
|
55
|
+
| `useAudio` | 是否启用音频功能 | boolean | `true` |
|
|
56
|
+
| `space` | 监听间隔(ms) 已废弃 | number | `3000` |
|
|
57
|
+
| `mode` | 交互模式,默认video,其他已废弃 | string | `"video"` |
|
|
58
|
+
|
|
59
|
+
### API 配置
|
|
60
|
+
|
|
61
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
62
|
+
|---------------------------|--------------------------------|------------|-----------------------------------------|
|
|
63
|
+
| `apiPrefix` | API基础路径,自定义跨域 | string | `'/api21215'` |
|
|
64
|
+
| `createConversationUrl` | 创建会话接口 | string | `${apiPrefix}/chatGlm/createConversation` |
|
|
65
|
+
| `wakeupAudio` | 音频打标接口 | string | `${apiPrefix}/asr/saveWakeUpAudio` |
|
|
66
|
+
| `interrupt` | 中断请求接口 | string | `${apiPrefix}/chatGlm/cancelChat` |
|
|
67
|
+
| `qaServer` | 问答服务接口 | string | `${apiPrefix}/chatGlm/searchTextNew` |
|
|
68
|
+
| `audioWs` | 语音WebSocket服务 | string | `wss://model.keepsoft.net:39002/funasrWs` |
|
|
69
|
+
| `voiceprintWs` | 声纹识别WebSocket服务 | string | `wss://model.keepsoft.net:39002/speakerWs` |
|
|
70
|
+
| `instructWs` | 指令WebSocket服务(已废弃) | string | `wss://model.keepsoft.net:39002/commandWs` |
|
|
71
|
+
|
|
72
|
+
### 数字人配置
|
|
73
|
+
|
|
74
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
75
|
+
|------------------------|--------------------------|--------------|----------------------------|
|
|
76
|
+
| `videoStyle` | 视频样式 | CSSProperties | `{ width: "180px", visibility: "hidden" }` |
|
|
77
|
+
| `digitalStyle` | 数字人样式 | CSSProperties | `{ width: "180px", height: "180px" }` |
|
|
78
|
+
| `bubbleStyle` | 气泡样式 | CSSProperties | `{ width: "30%", height: "30%" }` |
|
|
79
|
+
| `canvasWidth` | 画布宽度 | number | `300` |
|
|
80
|
+
| `canvasHeight` | 画布高度 | number | `300` |
|
|
81
|
+
| `canvasCartoonWidth` | 卡通形象宽度 | number | `200` |
|
|
82
|
+
| `canvasCartoonHeight` | 卡通形象高度 | number | `320` |
|
|
83
|
+
| `offer` | 数字人形象接口 | string | `${apiPrefix}/metahuman/offer` |
|
|
84
|
+
| `humanaudio` | 数字人音频接口 | string | `${apiPrefix}/metahuman/humanaudio` |
|
|
85
|
+
| `stop_audio` | 停止音频接口 | string | `${apiPrefix}/metahuman/stop_audio` |
|
|
86
|
+
| `textDriven` | 文本驱动接口 | string | `${apiPrefix}/intelligentVoice/tts` |
|
|
87
|
+
|
|
88
|
+
### 消息气泡配置
|
|
89
|
+
|
|
90
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
91
|
+
|--------------------|--------------------------|---------|---------|
|
|
92
|
+
| `showMsgNumber` | 显示消息数量 | number | `5` |
|
|
93
|
+
| `bubbleTheme` | 气泡主题 | string | `"dark"`|
|
|
94
|
+
| `useCustomDialog` | 是否使用自定义对话框 | boolean | `false` |
|
|
95
|
+
| `BubbleWidth` | 气泡宽度 | number | `220` |
|
|
96
|
+
| `BubbleBottom` | 气泡底部距离 | number | `85` |
|
|
97
|
+
|
|
98
|
+
## 事件处理
|
|
99
|
+
|
|
100
|
+
### 关键词触发事件,工作流处理
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
eventFun: [
|
|
104
|
+
{
|
|
105
|
+
keywords: ["打开灌区"], // 触发关键词
|
|
106
|
+
trigger: "after", // 触发时机: before/after/together
|
|
107
|
+
fun: (a: any) => { // 回调函数
|
|
108
|
+
console.log("打开灌区");
|
|
95
109
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
let opNum = 0;
|
|
103
|
-
let rSum = 0;
|
|
104
|
-
let gSum = 0;
|
|
105
|
-
let bSum = 0;
|
|
106
|
-
arroundPoint.forEach((position) => {
|
|
107
|
-
const index = pointToNum(position, width);
|
|
108
|
-
rSum = rSum + tempData[(index - 1) * 4];
|
|
109
|
-
gSum = gSum + tempData[(index - 1) * 4 + 1];
|
|
110
|
-
bSum = bSum + tempData[(index - 1) * 4 + 2];
|
|
111
|
-
if (tempData[(index - 1) * 4 + 3] !== 255) opNum++;
|
|
112
|
-
})
|
|
113
|
-
let alpha = (255 / arroundPoint.length) * (arroundPoint.length - opNum);
|
|
114
|
-
if (alpha !== 255) {
|
|
115
|
-
// debugger
|
|
116
|
-
frame.data[i * 4] = parseInt(rSum / arroundPoint.length);
|
|
117
|
-
frame.data[i * 4 + 1] = parseInt(gSum / arroundPoint.length);
|
|
118
|
-
frame.data[i * 4 + 2] = parseInt(bSum / arroundPoint.length);
|
|
119
|
-
frame.data[i * 4 + 3] = parseInt(alpha);
|
|
120
|
-
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
keywords: ["打开技术舱"],
|
|
113
|
+
trigger: "after",
|
|
114
|
+
fun: (a: any) => {
|
|
115
|
+
console.log("打开技术舱");
|
|
121
116
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
ctx.value.putImageData(frame, 0, 0);
|
|
125
|
-
setTimeout(computeFrame, 0);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
onMounted(() => {
|
|
129
|
-
init();
|
|
130
|
-
})
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
# props
|
|
135
|
-
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|
|
136
|
-
|---------- |-------------------|------------|---------|---------|
|
|
137
|
-
| isDebug | 开启debug打印 | Boolean | - | - |
|
|
138
|
-
| title | 问答标题 | String | - | - |
|
|
139
|
-
| greet | 问答问候语 | String | - | - |
|
|
140
|
-
| waitTxt | 问答等候语 | String | - | - |
|
|
141
|
-
| systemName | 系统编码 | String | - | - |
|
|
142
|
-
| robotCss | 机器人在视口中的位置 | object | - | left: "10px", bottom: "10px" |
|
|
143
|
-
| placement | 问答弹窗位置 |String | left/right/top/bottom/top-start/top-end/bottom-start/bottom-end | top-end |
|
|
144
|
-
| useAudio | 语音功能 |Boolean | true/false | true |
|
|
145
|
-
| space | 监听时间间隔 |Number | - | 3000 |
|
|
146
|
-
| mode | 交互模式 |String | text/audio | text |
|
|
147
|
-
| openInstruct | 是否开启指令控制 |Boolean | true/false | true |
|
|
148
|
-
| qaServer | 问答服务地址 |String | - | - |
|
|
149
|
-
| audioServer | 语音服务地址 |String | - | - |
|
|
150
|
-
| cozeInfo | 扣字大模型参数 |Object | - | - |
|
|
151
|
-
| wsServer | 语音监听地址 |String | - | - |
|
|
152
|
-
| instructWs | 指令监听地址 |String | - | - |
|
|
153
|
-
| eventFun | 触发事件 |Array | - | - |
|
|
154
|
-
| searchTextCallback | 扣子大模型事件流回调函数 |Function | - | - |
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
# cozeInfo
|
|
159
|
-
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|
|
160
|
-
|---------- |-------------------|------------|---------|---------|
|
|
161
|
-
| iss | | String | - | - |
|
|
162
|
-
| kid | | String | - | - |
|
|
163
|
-
| private_key | | String | - | - |
|
|
164
|
-
| bot_id | | String | - | - |
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
# eventFun
|
|
168
|
-
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|
|
169
|
-
|---------- |-------------------|------------|---------|---------|
|
|
170
|
-
| keywords | 触发关键字 | Array | - | - |
|
|
171
|
-
| trigger | 回调触发时机 | String | after/together | - |
|
|
172
|
-
| fun | 触发的回调函数 | Function | - | - |
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
# 方法
|
|
176
|
-
| 参数 | 说明 | 参数 |
|
|
177
|
-
|---------- |------------------ |--------------|
|
|
178
|
-
| searchText | 问答接口 |接收一个参数:{searchText} 问题的字符串 |
|
|
179
|
-
| startMonitorAudio | 开启语音监听 | - |
|
|
180
|
-
| uploadWavFile | 语音转文字接口 |接收一个参数(formData类型):{modelName,audio} modelName:语音模型(tiny/base/small/medium/large), audio:语音文件流 |
|
|
181
|
-
|
|
182
|
-
# Slot
|
|
183
|
-
| 参数 | 说明 |
|
|
184
|
-
|---------- |--------------|
|
|
185
|
-
| reference | 触发问答弹窗显示的HTML元素 |
|
|
186
|
-
|
|
117
|
+
}
|
|
118
|
+
]
|
|
@@ -14,6 +14,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
14
14
|
width: string;
|
|
15
15
|
height: string;
|
|
16
16
|
};
|
|
17
|
+
bubbleStyle: () => {
|
|
18
|
+
width: string;
|
|
19
|
+
height: string;
|
|
20
|
+
};
|
|
17
21
|
canvasWidth: number;
|
|
18
22
|
canvasHeight: number;
|
|
19
23
|
canvasCartoonWidth: number;
|
|
@@ -44,6 +48,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
44
48
|
width: string;
|
|
45
49
|
height: string;
|
|
46
50
|
};
|
|
51
|
+
bubbleStyle: () => {
|
|
52
|
+
width: string;
|
|
53
|
+
height: string;
|
|
54
|
+
};
|
|
47
55
|
canvasWidth: number;
|
|
48
56
|
canvasHeight: number;
|
|
49
57
|
canvasCartoonWidth: number;
|
|
@@ -60,6 +68,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
60
68
|
isExhibitionPro: boolean;
|
|
61
69
|
videoStyle: import("vue").CSSProperties;
|
|
62
70
|
digitalStyle: import("vue").CSSProperties;
|
|
71
|
+
bubbleStyle: import("vue").CSSProperties;
|
|
63
72
|
offer: string;
|
|
64
73
|
human: string;
|
|
65
74
|
humanaudio: string;
|