g-ai-robot3 1.1.1 → 1.1.3
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/LICENSE +20 -20
- package/README.md +111 -116
- package/dist/g-ai-robot3.es.js +5196 -5172
- package/dist/index.css +1 -1
- package/dist/index.d.ts +15 -3
- package/dist/index.vue.d.ts +6 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/vite-plugin.mjs +21 -21
- package/package.json +69 -69
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 yuchen
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 yuchen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -77,95 +77,90 @@ export default defineConfig({
|
|
|
77
77
|
});
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
-
## 默认内部配置
|
|
81
|
-
|
|
82
|
-
以下默认值会随 npm 包一起发布,且都可以通过 props 覆盖:
|
|
83
|
-
|
|
84
|
-
| 项目 | 默认值 |
|
|
85
|
-
| --- | --- |
|
|
86
|
-
| `apiPrefix` | `"/api21216"` |
|
|
87
|
-
| `cozeInfo.bot_id` | `"7473691358872584226"` |
|
|
88
|
-
| `createConversationUrl` | `${apiPrefix}/chatGlm/createConversation` |
|
|
89
|
-
| `qaServer` | `${apiPrefix}/chatGlm/searchTextNew` |
|
|
90
|
-
| `interrupt` | `${apiPrefix}/chatGlm/cancelChat` |
|
|
91
|
-
| `wakeupAudio` | `${apiPrefix}/asr/saveWakeUpAudio` |
|
|
92
|
-
| `offer` | `${apiPrefix}/metahuman/offer` |
|
|
93
|
-
| `humanaudio` | `${apiPrefix}/metahuman/humanaudio` |
|
|
94
|
-
| `stop_audio` | `${apiPrefix}/metahuman/stop_audio` |
|
|
95
|
-
| `textDriven` | `${apiPrefix}/intelligentVoice/tts` |
|
|
96
|
-
| `audioWs` | `wss://model.keepsoft.net:39002/funasrWs` |
|
|
97
|
-
| `voiceprintWs` | `wss://model.keepsoft.net:39002/speakerWs` |
|
|
98
|
-
| `instructWs` | `wss://model.keepsoft.net:39002/commandWs` |
|
|
99
|
-
|
|
100
80
|
## 常用 Props
|
|
101
81
|
|
|
102
|
-
###
|
|
103
|
-
|
|
104
|
-
| 参数 | 类型
|
|
105
|
-
|
|
|
106
|
-
| `cozeInfo` | `{ bot_id:
|
|
107
|
-
| `apiPrefix` | `string` | `"/api21216"`
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
|
112
|
-
|
|
|
113
|
-
| `
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
|
118
|
-
|
|
|
119
|
-
| `
|
|
120
|
-
| `
|
|
121
|
-
| `
|
|
122
|
-
| `
|
|
123
|
-
| `
|
|
124
|
-
| `
|
|
125
|
-
| `
|
|
126
|
-
| `
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
|
131
|
-
|
|
|
132
|
-
| `
|
|
133
|
-
| `
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
|
138
|
-
|
|
|
139
|
-
| `
|
|
140
|
-
| `
|
|
141
|
-
| `
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
|
146
|
-
|
|
|
147
|
-
| `
|
|
148
|
-
| `
|
|
149
|
-
| `
|
|
150
|
-
| `
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
|
155
|
-
|
|
|
156
|
-
| `
|
|
157
|
-
| `
|
|
82
|
+
### 必填参数(Required)
|
|
83
|
+
|
|
84
|
+
| 参数 | 说明 | 类型 | 默认值 | 注意事项 |
|
|
85
|
+
| ----------- | ------------ | -------- | ------------------- | ---------------------------------------------------------------------- |
|
|
86
|
+
| `cozeInfo` | 智能体配置 | `object` | `{ bot_id: "..." }` | `bot_id` 必须替换为实际的智能体 id |
|
|
87
|
+
| `apiPrefix` | API 基础路径 | `string` | `"/api21216"` | 必须配置为你的代理前缀(如 `/api21216`),可通过本地代理或环境变量覆盖 |
|
|
88
|
+
|
|
89
|
+
### 基础配置
|
|
90
|
+
|
|
91
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
92
|
+
| --------------------- | ------------------------------------------ | --------------------- | -------------------------------------- |
|
|
93
|
+
| `isDebug` | 是否开启调试模式(打印语音输出) | `boolean` | `false` |
|
|
94
|
+
| `dialogBoxTheme` | 对话框主题 | `string` | `"light"` |
|
|
95
|
+
| `suspensionStyle` | 对话框高度 | `CSSProperties` | `{ maxHeight: "33vh" }` |
|
|
96
|
+
| `showMsgBubble` | 是否显示消息气泡 | `boolean` | `true` |
|
|
97
|
+
| `isExhibitionPro` | 是否为数字展厅项目 | `boolean` | `false` |
|
|
98
|
+
| `isShowDialogIcon` | 是否显示对话框图标 | `boolean` | `false` |
|
|
99
|
+
| `stream` | 是否启用流式传输(已废弃) | `string` | `"True"` |
|
|
100
|
+
| `title` | 对话框标题 | `string` | `"GR水利大模型"` |
|
|
101
|
+
| `greet` | 欢迎语(文本对话框) | `string` | `"您好,我是GR水利大模型智能小助手..."` |
|
|
102
|
+
| `welcomeMessage` | 欢迎消息(气泡对话框) | `string` | `"您好,我是GR水利大模型智能小助手..."` |
|
|
103
|
+
| `waitTxt` | 等待提示文本 | `string` | `"贵仁科技AI正在生成回答"` |
|
|
104
|
+
| `systemName` | 系统标识 | `string` | `"g-ai-robot3"` |
|
|
105
|
+
| `placementBottom` | 对话框底部距离 | `number` | `100` |
|
|
106
|
+
| `placementLeft` | 对话框左侧距离 | `number` | `450` |
|
|
107
|
+
| `useAudio` | 是否启用音频功能 | `boolean` | `true` |
|
|
108
|
+
| `space` | 监听间隔(ms)(已废弃) | `number` | `3000` |
|
|
109
|
+
| `mode` | 交互模式(默认 `video`,其他已废弃) | `string` | `"video"` |
|
|
110
|
+
| `modelType` | 模型类型(`local` 或 `online`) | `string` | `"online"` |
|
|
111
|
+
| `showModelTypeToggle` | 显示模型类型切换开关 | `boolean` | `false` |
|
|
112
|
+
| `driverMode` | AI 结果驱动模式 | `string` | `"workflow"` |
|
|
113
|
+
| `data` | `agent` 模式下随消息透传给后端的动态上下文 | `Record<string, any>` | `{}` |
|
|
114
|
+
|
|
115
|
+
### API 配置
|
|
116
|
+
|
|
117
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
118
|
+
| ----------------------- | ----------------------------- | -------- | ------------------------------------------ |
|
|
119
|
+
| `apiPrefix` | API 基础路径(可自定义跨域) | `string` | `"/api21216"` |
|
|
120
|
+
| `createConversationUrl` | 创建会话接口 | `string` | `${apiPrefix}/chatGlm/createConversation` |
|
|
121
|
+
| `wakeupAudio` | 音频打标接口 | `string` | `${apiPrefix}/asr/saveWakeUpAudio` |
|
|
122
|
+
| `interrupt` | 中断请求接口 | `string` | `${apiPrefix}/chatGlm/cancelChat` |
|
|
123
|
+
| `qaServer` | 问答服务接口 | `string` | `${apiPrefix}/chatGlm/searchTextNew` |
|
|
124
|
+
| `offer` | 数字人形象接口 | `string` | `${apiPrefix}/metahuman/offer` |
|
|
125
|
+
| `humanaudio` | 数字人音频接口 | `string` | `${apiPrefix}/metahuman/humanaudio` |
|
|
126
|
+
| `stop_audio` | 停止音频接口 | `string` | `${apiPrefix}/metahuman/stop_audio` |
|
|
127
|
+
| `textDriven` | 文本驱动接口 | `string` | `${apiPrefix}/intelligentVoice/tts` |
|
|
128
|
+
| `audioWs` | 语音 WebSocket 服务 | `string` | `wss://model.keepsoft.net:39002/funasrWs` |
|
|
129
|
+
| `voiceprintWs` | 声纹识别 WebSocket 服务 | `string` | `wss://model.keepsoft.net:39002/speakerWs` |
|
|
130
|
+
| `instructWs` | 指令 WebSocket 服务(已废弃) | `string` | `wss://model.keepsoft.net:39002/commandWs` |
|
|
131
|
+
|
|
132
|
+
### 数字人配置
|
|
133
|
+
|
|
134
|
+
| 参数 | 说明 | 类型 | 默认值 | 注意事项 |
|
|
135
|
+
| --------------------- | ------------ | --------------- | --------------------------------------------------------- | ---------------------------------------------------- |
|
|
136
|
+
| `videoStyle` | 视频样式 | `CSSProperties` | `{ width: "180px", opacity: "0", pointerEvents: "none" }` | 建议 `width` 与 `canvasWidth` 一致 |
|
|
137
|
+
| `digitalStyle` | 数字人样式 | `CSSProperties` | `{ width: "180px", height: "180px" }` | 与 `canvasWidth` / `canvasHeight` 保持一致 |
|
|
138
|
+
| `canvasStyle` | 画布样式 | `CSSProperties` | `{ width: "180px", height: "180px" }` | 与 `canvasWidth` / `canvasHeight` 保持一致 |
|
|
139
|
+
| `bubbleStyle` | 气泡样式 | `CSSProperties` | `{ width: "30%", height: "30%" }` | - |
|
|
140
|
+
| `canvasWidth` | 画布宽度 | `number` | `180` | 建议与 `videoStyle.width`、`digitalStyle.width` 一致 |
|
|
141
|
+
| `canvasHeight` | 画布高度 | `number` | `180` | 建议与 `digitalStyle.height` 一致 |
|
|
142
|
+
| `canvasCartoonWidth` | 卡通形象宽度 | `number` | `200` | - |
|
|
143
|
+
| `canvasCartoonHeight` | 卡通形象高度 | `number` | `320` | - |
|
|
144
|
+
|
|
145
|
+
### 消息气泡配置
|
|
146
|
+
|
|
147
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
148
|
+
| ----------------- | -------------------------------------- | --------------------- | ----------------------------------- |
|
|
149
|
+
| `showMsgNumber` | 显示消息数量 | `number` | `5` |
|
|
150
|
+
| `bubbleTheme` | 气泡主题 | `string` | `"dark"` |
|
|
151
|
+
| `useCustomDialog` | 是否使用自定义对话框 | `boolean` | `false` |
|
|
152
|
+
| `BubbleWidth` | 气泡容器样式 | `CSSProperties` | `{ width: "220px", bottom: "85%" }` |
|
|
153
|
+
| `BubbleBottom` | 气泡底部距离 | `number` | `85` |
|
|
154
|
+
| `initialQuestion` | 外部传入的首条问题(仅展示不请求接口) | `string` | `-` |
|
|
155
|
+
| `streamChunks` | 外部传入的单条流式消息块 | `StreamChunk[]` | `[]` |
|
|
156
|
+
| `conversations` | 外部传入的多轮对话展示数据 | `ConversationInput[]` | `[]` |
|
|
158
157
|
|
|
159
158
|
## 类型导出
|
|
160
159
|
|
|
161
160
|
本包会导出常用类型,内部项目可以直接引用:
|
|
162
161
|
|
|
163
162
|
```ts
|
|
164
|
-
import type {
|
|
165
|
-
ConversationInput,
|
|
166
|
-
IndexProps,
|
|
167
|
-
StreamChunk,
|
|
168
|
-
} from "g-ai-robot3";
|
|
163
|
+
import type { ConversationInput, IndexProps, StreamChunk } from "g-ai-robot3";
|
|
169
164
|
```
|
|
170
165
|
|
|
171
166
|
## 工作流事件示例
|
|
@@ -193,49 +188,49 @@ const eventFun = [
|
|
|
193
188
|
|
|
194
189
|
`driverMode` 默认为 `workflow`,老项目不需要改动。切换到 `agent` 后:
|
|
195
190
|
|
|
196
|
-
- 忽略 `eventFun`
|
|
197
|
-
- 不做关键词匹配
|
|
198
|
-
- 每次 AI 返回 `data` 时直接触发 `agent-response`
|
|
199
|
-
- 由业务层自行决定如何处理返回 JSON
|
|
200
|
-
- 发送请求时 `searchText` 会升级为 `JSON.stringify({ msg, data })` 后的字符串;`msg` 为用户输入或补问组装文本,`data` 为外部传入的最新 `data` prop
|
|
201
|
-
|
|
202
|
-
```vue
|
|
203
|
-
<script setup lang="ts">
|
|
204
|
-
import { ref } from "vue";
|
|
205
|
-
|
|
206
|
-
const agentContext = ref({
|
|
207
|
-
anything: "from parent",
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
const handleAgentResponse = (params: any) => {
|
|
211
|
-
console.log("agent response", params);
|
|
212
|
-
};
|
|
191
|
+
- 忽略 `eventFun`
|
|
192
|
+
- 不做关键词匹配
|
|
193
|
+
- 每次 AI 返回 `data` 时直接触发 `agent-response`
|
|
194
|
+
- 由业务层自行决定如何处理返回 JSON
|
|
195
|
+
- 发送请求时 `searchText` 会升级为 `JSON.stringify({ msg, data })` 后的字符串;`msg` 为用户输入或补问组装文本,`data` 为外部传入的最新 `data` prop
|
|
196
|
+
|
|
197
|
+
```vue
|
|
198
|
+
<script setup lang="ts">
|
|
199
|
+
import { ref } from "vue";
|
|
200
|
+
|
|
201
|
+
const agentContext = ref({
|
|
202
|
+
anything: "from parent",
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
const handleAgentResponse = (params: any) => {
|
|
206
|
+
console.log("agent response", params);
|
|
207
|
+
};
|
|
213
208
|
</script>
|
|
214
209
|
|
|
215
210
|
<template>
|
|
216
|
-
<GAiRobot3
|
|
217
|
-
mode="video"
|
|
218
|
-
driverMode="agent"
|
|
219
|
-
:data="agentContext"
|
|
220
|
-
@agent-response="handleAgentResponse"
|
|
221
|
-
/>
|
|
222
|
-
</template>
|
|
211
|
+
<GAiRobot3
|
|
212
|
+
mode="video"
|
|
213
|
+
driverMode="agent"
|
|
214
|
+
:data="agentContext"
|
|
215
|
+
@agent-response="handleAgentResponse"
|
|
216
|
+
/>
|
|
217
|
+
</template>
|
|
223
218
|
```
|
|
224
219
|
|
|
225
220
|
业务侧可以直接拿到类似下面的结构:
|
|
226
221
|
|
|
227
222
|
```ts
|
|
228
|
-
function handleAgentResponse(params: any) {
|
|
229
|
-
// {
|
|
230
|
-
// reply,
|
|
231
|
-
// targetState,
|
|
232
|
-
// commands
|
|
233
|
-
// }
|
|
234
|
-
applyAgentResponse(params);
|
|
235
|
-
}
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
`workflow` 模式继续保持旧请求结构,不启用 `{ msg, data }` 和补问组装,老项目不需要调整后端接口。
|
|
223
|
+
function handleAgentResponse(params: any) {
|
|
224
|
+
// {
|
|
225
|
+
// reply,
|
|
226
|
+
// targetState,
|
|
227
|
+
// commands
|
|
228
|
+
// }
|
|
229
|
+
applyAgentResponse(params);
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
`workflow` 模式继续保持旧请求结构,不启用 `{ msg, data }` 和补问组装,老项目不需要调整后端接口。
|
|
239
234
|
|
|
240
235
|
## 注意事项
|
|
241
236
|
|