@blueking/ai-blueking 0.5.0-beta.8 → 0.5.2
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 +425 -542
- package/dist/ai-blueking-new.vue.d.ts +44 -36
- package/dist/ai-blueking.vue.d.ts +87 -0
- package/dist/chat-helper.d.ts +23 -0
- package/dist/components/ai-avatar.vue.d.ts +28 -0
- package/dist/components/ai-cite.vue.d.ts +21 -0
- package/dist/components/render-back.vue.d.ts +2 -0
- package/dist/components/render-content.vue.d.ts +73 -0
- package/dist/components/render-message.vue.d.ts +32 -0
- package/dist/components/render-modal.vue.d.ts +99 -0
- package/dist/components/render-popup.vue.d.ts +21 -0
- package/dist/components/render-send.vue.d.ts +30 -0
- package/dist/components/render-shortcuts.vue.d.ts +19 -0
- package/dist/components/render-stop.vue.d.ts +19 -0
- package/dist/components/render-time.vue.d.ts +16 -0
- package/dist/components-new/ai-cite.vue.d.ts +7 -18
- package/dist/components-new/ai-header.vue.d.ts +7 -17
- package/dist/components-new/ai-selected-box.vue.d.ts +6 -17
- package/dist/components-new/bar-button.vue.d.ts +7 -19
- package/dist/components-new/chat-input-box.vue.d.ts +6 -18
- package/dist/components-new/delete-confirm.vue.d.ts +5 -18
- package/dist/components-new/prompt-list.vue.d.ts +9 -20
- package/dist/components-new/render-message.vue.d.ts +7 -30
- package/dist/components-new/render-popup.vue.d.ts +3 -12
- package/dist/components-new/shortcuts-bar.vue.d.ts +6 -16
- package/dist/components-new/text-editor.vue.d.ts +13 -44
- package/dist/composables/use-input-interaction.d.ts +1 -1
- package/dist/composables/use-nimbus.d.ts +6 -6
- package/dist/composables/use-reference-docs.d.ts +19 -0
- package/dist/composables/use-resizable-container.d.ts +6 -6
- package/dist/composables/use-scroll-show.d.ts +1 -1
- package/dist/composables/use-select-pop.d.ts +13 -5
- package/dist/composables/use-textarea-height.d.ts +2 -2
- package/dist/composables/use-think.d.ts +26 -0
- package/dist/types/index.d.ts +8 -2
- package/dist/util/index.d.ts +38 -0
- package/dist/views/nimbus.vue.d.ts +10 -17
- package/dist/vue2/index.es.min.js +5906 -6106
- package/dist/vue2/index.iife.min.js +79 -105
- package/dist/vue2/index.umd.min.js +38 -38
- package/dist/vue2/style.css +1 -1
- package/dist/vue3/index.es.min.js +3383 -3387
- package/dist/vue3/index.iife.min.js +78 -104
- package/dist/vue3/index.umd.min.js +16 -16
- package/dist/vue3/style.css +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,644 +1,527 @@
|
|
|
1
|
-
# AI
|
|
1
|
+
# AI 小鲸 (AI Blueking) 使用文档
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 简介
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
- [安装](#安装)
|
|
7
|
-
- [特性](#特性)
|
|
8
|
-
- [使用指南](#使用指南)
|
|
9
|
-
- [开发调试](#开发调试)
|
|
5
|
+
AI 小鲸是一个智能对话组件,支持 Vue2/Vue3 框架,提供丰富的交互功能和灵活的配置选项。只需简单配置,即可快速接入智能对话能力,提升应用的用户体验。
|
|
10
6
|
|
|
11
|
-
##
|
|
7
|
+
## 特性
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
- **实时对话**:支持流式输出,让对话更自然流畅
|
|
10
|
+
- **内容引用**:选中文本即可快速引用并提问
|
|
11
|
+
- **快捷操作**:支持预设常用功能和提示词
|
|
12
|
+
- **可拖拽界面**:自由调整窗口位置和大小
|
|
13
|
+
- **开箱即用**:传入 Agent 地址即可快速接入业务
|
|
14
|
+
- **跨框架支持**:同时支持 Vue2 和 Vue3 框架
|
|
14
15
|
|
|
15
16
|
## 安装
|
|
16
17
|
|
|
17
18
|
```bash
|
|
18
|
-
npm
|
|
19
|
+
npm install @blueking/ai-blueking
|
|
19
20
|
```
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- 支持 popup 弹框唤起
|
|
24
|
-
- 支持引用提问功能
|
|
25
|
-
- 支持快捷提问(当前支持翻译、解释功能)
|
|
26
|
-
- 支持使用 `enablePopup` 属性控制弹框唤起(默认为 true)
|
|
22
|
+
或
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
```bash
|
|
25
|
+
yarn add @blueking/ai-blueking
|
|
26
|
+
```
|
|
31
27
|
|
|
32
|
-
|
|
28
|
+
## 基本使用
|
|
33
29
|
|
|
34
|
-
|
|
30
|
+
### Vue 3
|
|
35
31
|
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
```vue
|
|
33
|
+
<template>
|
|
34
|
+
<div>
|
|
35
|
+
<button @click="showAI">打开 AI 小鲸</button>
|
|
36
|
+
|
|
37
|
+
<AIBlueking
|
|
38
|
+
ref="aiBlueking"
|
|
39
|
+
:url="apiUrl"
|
|
40
|
+
@show="handleShow"
|
|
41
|
+
@close="handleClose"
|
|
42
|
+
/>
|
|
43
|
+
</div>
|
|
44
|
+
</template>
|
|
38
45
|
|
|
39
|
-
|
|
46
|
+
<script lang="ts" setup>
|
|
47
|
+
import { ref } from 'vue';
|
|
48
|
+
import AIBlueking from '@blueking/ai-blueking';
|
|
49
|
+
import '@blueking/ai-blueking/dist/vue3/style.css';
|
|
40
50
|
|
|
41
|
-
|
|
51
|
+
const aiBlueking = ref(null);
|
|
52
|
+
const apiUrl = 'https://your-api-endpoint.com/assistant/';
|
|
42
53
|
|
|
43
|
-
|
|
54
|
+
const showAI = () => {
|
|
55
|
+
console.log('AI 小鲸已显示');
|
|
56
|
+
};
|
|
44
57
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
prompt?: string; // 使用的 prompt 模板(可选)
|
|
50
|
-
}
|
|
58
|
+
const handleClose = () => {
|
|
59
|
+
console.log('AI 小鲸已关闭');
|
|
60
|
+
};
|
|
61
|
+
</script>
|
|
51
62
|
```
|
|
52
63
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
```typescript
|
|
56
|
-
const handleSend = (args: ISendData) => {
|
|
57
|
-
// 记录当前消息记录
|
|
58
|
-
const chatHistory = [...messages.value];
|
|
64
|
+
### Vue 2
|
|
59
65
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
```vue
|
|
67
|
+
<template>
|
|
68
|
+
<div>
|
|
69
|
+
<button @click="showAI">打开 AI 小鲸</button>
|
|
70
|
+
|
|
71
|
+
<AIBlueking
|
|
72
|
+
ref="aiBlueking"
|
|
73
|
+
:url="apiUrl"
|
|
74
|
+
@show="handleShow"
|
|
75
|
+
@close="handleClose"
|
|
76
|
+
/>
|
|
77
|
+
</div>
|
|
78
|
+
</template>
|
|
66
79
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
<script>
|
|
81
|
+
import AIBlueking from '@blueking/ai-blueking/vue2';
|
|
82
|
+
import '@blueking/ai-blueking/dist/vue2/style.css';
|
|
83
|
+
|
|
84
|
+
export default {
|
|
85
|
+
components: {
|
|
86
|
+
AIBlueking
|
|
87
|
+
},
|
|
88
|
+
data() {
|
|
89
|
+
return {
|
|
90
|
+
apiUrl: 'https://your-api-endpoint.com/assistant/'
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
methods: {
|
|
94
|
+
showAI() {
|
|
95
|
+
this.$refs.aiBlueking.handleShow();
|
|
82
96
|
},
|
|
83
|
-
|
|
84
|
-
|
|
97
|
+
handleShow() {
|
|
98
|
+
console.log('AI 小鲸已显示');
|
|
99
|
+
},
|
|
100
|
+
handleClose() {
|
|
101
|
+
console.log('AI 小鲸已关闭');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
85
104
|
};
|
|
105
|
+
</script>
|
|
86
106
|
```
|
|
87
107
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
108
|
+
## 属性 (Props)
|
|
109
|
+
|
|
110
|
+
| 属性名 | 类型 | 默认值 | 描述 |
|
|
111
|
+
|--------|------|--------|------|
|
|
112
|
+
| url | String | '' | AI 服务接口地址,必须设置 |
|
|
113
|
+
| enablePopup | Boolean | true | 是否启用选中文本后的弹出操作窗口 |
|
|
114
|
+
| shortcuts | Array | [...] | 快捷操作列表 |
|
|
115
|
+
| prompts | Array | [] | 预设提示词列表 |
|
|
116
|
+
| requestOptions | Object | {} | 自定义请求选项,可设置headers和data属性,分别合并到请求头和请求体 |
|
|
117
|
+
| defaultMinimize | Boolean | false | 控制 Nimbus 组件初始是否处于最小化状态 |
|
|
118
|
+
| sessionContents | Array | [] | 暴露当前会话内容,可用于外部访问和操作 |
|
|
119
|
+
|
|
120
|
+
### shortcuts 格式示例
|
|
121
|
+
|
|
122
|
+
```javascript
|
|
123
|
+
[
|
|
124
|
+
{
|
|
125
|
+
label: '解释',
|
|
126
|
+
key: 'explanation',
|
|
127
|
+
prompt: '解释一下内容: {{ SELECTED_TEXT }}',
|
|
128
|
+
icon: 'icon-explanation'
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
label: '翻译',
|
|
132
|
+
key: 'translate',
|
|
133
|
+
prompt: '翻译一下内容: {{ SELECTED_TEXT }}',
|
|
134
|
+
icon: 'icon-translate'
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
```
|
|
91
138
|
|
|
92
|
-
|
|
139
|
+
### prompts 格式示例
|
|
93
140
|
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
</span>
|
|
101
|
-
<a href="xxx" target="_blank" class="knowledge-link">
|
|
102
|
-
1. vivo 容器平台如何实现资源超卖方案
|
|
103
|
-
<i class="ai-blueking-icon ai-blueking-cc-jump-link"></i>
|
|
104
|
-
</a>
|
|
105
|
-
</section>
|
|
141
|
+
```javascript
|
|
142
|
+
[
|
|
143
|
+
'请概括这段内容的主要观点',
|
|
144
|
+
'请帮我分析这段文字中的问题',
|
|
145
|
+
'请用简单的语言解释这个概念'
|
|
146
|
+
]
|
|
106
147
|
```
|
|
107
148
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
AI 小鲸支持渲染可点击的交互式 HTML 元素。以下是如何实现这一功能的指南:
|
|
149
|
+
## 事件 (Events)
|
|
111
150
|
|
|
112
|
-
|
|
151
|
+
| 事件名 | 参数 | 描述 |
|
|
152
|
+
|--------|------|------|
|
|
153
|
+
| show | - | AI 小鲸窗口显示时触发 |
|
|
154
|
+
| close | - | AI 小鲸窗口关闭时触发 |
|
|
155
|
+
| stop | - | 停止生成内容时触发 |
|
|
156
|
+
| shortcut-click | shortcut: ShortCut | 点击快捷操作时触发,返回所点击的快捷操作对象 |
|
|
113
157
|
|
|
114
|
-
|
|
158
|
+
## 方法 (Methods)
|
|
115
159
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
160
|
+
| 方法名 | 参数 | 返回值 | 描述 |
|
|
161
|
+
|--------|------|--------|------|
|
|
162
|
+
| handleShow | - | - | 显示 AI 小鲸窗口 |
|
|
163
|
+
| handleStop | - | - | 停止当前正在生成的内容 |
|
|
164
|
+
| sendChat | options: {message, cite, shortcut} | - | 发送消息到 AI 小鲸 |
|
|
165
|
+
| handleShortcutClick | shortcut: ShortCut | - | 处理快捷操作点击 |
|
|
120
166
|
|
|
121
|
-
|
|
167
|
+
## 高级用法
|
|
122
168
|
|
|
123
|
-
|
|
124
|
-
handleCustomButtonClick(dataAIValue) {
|
|
125
|
-
// 假设 'aiRef' 是组件的引用
|
|
126
|
-
const val = dataAIValue; //从 data-ai 属性获取的数据'
|
|
127
|
-
|
|
128
|
-
... // 业务处理逻辑,比如以下将`data-ai`上的字符串赋值到输入框
|
|
129
|
-
aiRef.value?.setInputMessage(val);
|
|
130
|
-
}
|
|
131
|
-
```
|
|
169
|
+
### Vue 3 快捷操作演示
|
|
132
170
|
|
|
133
|
-
|
|
171
|
+
```vue
|
|
172
|
+
<template>
|
|
173
|
+
<div>
|
|
174
|
+
<div class="article">
|
|
175
|
+
<h3>AI 技术的发展与应用</h3>
|
|
176
|
+
<p>{{ articleContent }}</p>
|
|
177
|
+
</div>
|
|
178
|
+
|
|
179
|
+
<div class="quick-actions">
|
|
180
|
+
<button @click="quickActions('解释', '解释一下这段内容:', articleTitle)">
|
|
181
|
+
解释标题
|
|
182
|
+
</button>
|
|
183
|
+
<button @click="quickActions('翻译', '翻译成英文:', articleTitle)">
|
|
184
|
+
翻译标题
|
|
185
|
+
</button>
|
|
186
|
+
</div>
|
|
187
|
+
|
|
188
|
+
<AIBlueking ref="aiBlueking" :url="apiUrl" />
|
|
189
|
+
</div>
|
|
190
|
+
</template>
|
|
134
191
|
|
|
135
|
-
|
|
192
|
+
<script lang="ts" setup>
|
|
193
|
+
import { ref } from 'vue';
|
|
194
|
+
import AIBlueking from '@blueking/ai-blueking';
|
|
195
|
+
import '@blueking/ai-blueking/dist/vue3/style.css';
|
|
136
196
|
|
|
137
|
-
|
|
197
|
+
const aiBlueking = ref(null);
|
|
198
|
+
const apiUrl = 'https://your-api-endpoint.com/assistant/';
|
|
199
|
+
const articleTitle = 'AI 技术的发展与应用';
|
|
200
|
+
const articleContent = '人工智能技术在近年来取得了突飞猛进的发展...';
|
|
138
201
|
|
|
139
|
-
|
|
202
|
+
const quickActions = (label, promptPrefix, cite) => {
|
|
203
|
+
aiBlueking.value?.handleShow();
|
|
204
|
+
|
|
205
|
+
aiBlueking.value?.sendChat({
|
|
206
|
+
message: label,
|
|
207
|
+
cite,
|
|
208
|
+
shortcut: {
|
|
209
|
+
label,
|
|
210
|
+
key: label.toLowerCase(),
|
|
211
|
+
prompt: `${promptPrefix} {{ SELECTED_TEXT }}`,
|
|
212
|
+
icon: 'icon-explanation'
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
</script>
|
|
217
|
+
```
|
|
140
218
|
|
|
141
|
-
|
|
219
|
+
### Vue 2 快捷操作演示
|
|
142
220
|
|
|
143
221
|
```vue
|
|
144
222
|
<template>
|
|
145
|
-
<
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
223
|
+
<div>
|
|
224
|
+
<div class="article">
|
|
225
|
+
<h3>AI 技术的发展与应用</h3>
|
|
226
|
+
<p>{{ articleContent }}</p>
|
|
227
|
+
</div>
|
|
228
|
+
|
|
229
|
+
<div class="quick-actions">
|
|
230
|
+
<button @click="quickActions('解释', '解释一下这段内容:', articleTitle)">
|
|
231
|
+
解释标题
|
|
232
|
+
</button>
|
|
233
|
+
<button @click="quickActions('翻译', '翻译成英文:', articleTitle)">
|
|
234
|
+
翻译标题
|
|
235
|
+
</button>
|
|
236
|
+
</div>
|
|
237
|
+
|
|
238
|
+
<AIBlueking ref="aiBlueking" :url="apiUrl" />
|
|
239
|
+
</div>
|
|
153
240
|
</template>
|
|
154
241
|
|
|
155
|
-
<script
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
// 如果是loading状态,直接覆盖
|
|
185
|
-
currentMessage.content = message;
|
|
186
|
-
currentMessage.status = MessageStatus.Success;
|
|
187
|
-
} else if (currentMessage?.status === MessageStatus.Success) {
|
|
188
|
-
// 根据 cover 参数决定是追加还是覆盖
|
|
189
|
-
currentMessage.content = cover ? message : currentMessage.content + message;
|
|
242
|
+
<script>
|
|
243
|
+
import AIBlueking from '@blueking/ai-blueking/vue2';
|
|
244
|
+
import '@blueking/ai-blueking/dist/vue2/style.css';
|
|
245
|
+
|
|
246
|
+
export default {
|
|
247
|
+
components: {
|
|
248
|
+
AIBlueking
|
|
249
|
+
},
|
|
250
|
+
data() {
|
|
251
|
+
return {
|
|
252
|
+
apiUrl: 'https://your-api-endpoint.com/assistant/',
|
|
253
|
+
articleTitle: 'AI 技术的发展与应用',
|
|
254
|
+
articleContent: '人工智能技术在近年来取得了突飞猛进的发展...'
|
|
255
|
+
};
|
|
256
|
+
},
|
|
257
|
+
methods: {
|
|
258
|
+
quickActions(label, promptPrefix, cite) {
|
|
259
|
+
|
|
260
|
+
this.$refs.aiBlueking.handleShow(); // 显示AI小鲸
|
|
261
|
+
|
|
262
|
+
this.$refs.aiBlueking.sendChat({ // 主动调用发送消息
|
|
263
|
+
message: label,
|
|
264
|
+
cite,
|
|
265
|
+
shortcut: {
|
|
266
|
+
label,
|
|
267
|
+
key: label.toLowerCase(),
|
|
268
|
+
prompt: `${promptPrefix} {{ SELECTED_TEXT }}`
|
|
269
|
+
}
|
|
270
|
+
});
|
|
190
271
|
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// 聊天结束
|
|
194
|
-
const handleEnd = (id: number | string) => {
|
|
195
|
-
loading.value = false;
|
|
196
|
-
const currentMessage = messages.value.at(-1);
|
|
197
|
-
// 在 loading 状态或思考状态下终止时,标记为错误
|
|
198
|
-
if (currentMessage?.status === MessageStatus.Loading || isThinking(currentMessage?.content || '')) {
|
|
199
|
-
currentMessage.content = '聊天内容已中断';
|
|
200
|
-
currentMessage.status = MessageStatus.Error;
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
// 错误处理
|
|
205
|
-
const handleError = (message: string, code: string | number, id: number | string) => {
|
|
206
|
-
if (message.includes('user authentication failed')) {
|
|
207
|
-
// 未登录,跳转登录
|
|
208
|
-
const loginUrl = new URL(process.env.BK_LOGIN_URL);
|
|
209
|
-
loginUrl.searchParams.append('c_url', location.origin);
|
|
210
|
-
window.location.href = loginUrl.href;
|
|
211
|
-
} else {
|
|
212
|
-
// 处理错误消息
|
|
213
|
-
const currentMessage = messages.value.at(-1);
|
|
214
|
-
currentMessage.status = MessageStatus.Error;
|
|
215
|
-
currentMessage.content = message;
|
|
216
|
-
loading.value = false;
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
const prefix = process.env.BK_API_URL_TMPL.replace('{api_name}', '<网关名>').replace('http', 'https');
|
|
221
|
-
const chatHelper = new ChatHelper(
|
|
222
|
-
`${prefix}/prod/bk_plugin/plugin_api/assistant/`,
|
|
223
|
-
handleStart,
|
|
224
|
-
handleReceiveMessage,
|
|
225
|
-
handleEnd,
|
|
226
|
-
handleError,
|
|
227
|
-
messages.value,
|
|
228
|
-
);
|
|
229
|
-
|
|
230
|
-
// 清空消息
|
|
231
|
-
const handleClear = () => {
|
|
232
|
-
messages.value.splice(0); // 必须使用这种方式清空消息, 不能使用 messages.value = [],否则 ChatHelper 无法感知消息数组的变化
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
// 发送消息
|
|
236
|
-
const handleSend = (args: ISendData) => {
|
|
237
|
-
// 记录当前消息记录
|
|
238
|
-
const chatHistory = [...messages.value];
|
|
239
|
-
// 添加一条消息
|
|
240
|
-
messages.value.push({
|
|
241
|
-
role: 'user',
|
|
242
|
-
content: args.content,
|
|
243
|
-
cite: args.cite,
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
// 根据参数构造输入内容
|
|
247
|
-
const input = args.prompt
|
|
248
|
-
? args.prompt // 如果有 prompt,直接使用
|
|
249
|
-
: args.cite
|
|
250
|
-
? `${args.content}: ${args.cite}` // 如果有 cite,拼接 content 和 cite
|
|
251
|
-
: args.content; // 否则只使用 content
|
|
252
|
-
|
|
253
|
-
// ai 消息,id是唯一标识当前流,调用 chatHelper.stop 的时候需要传入
|
|
254
|
-
chatHelper.stream(
|
|
255
|
-
{
|
|
256
|
-
inputs: {
|
|
257
|
-
input,
|
|
258
|
-
chat_history: chatHistory,
|
|
259
|
-
},
|
|
260
|
-
},
|
|
261
|
-
1,
|
|
262
|
-
);
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
// 暂停聊天
|
|
266
|
-
const handleStop = () => {
|
|
267
|
-
chatHelper.stop(1);
|
|
268
|
-
};
|
|
272
|
+
}
|
|
273
|
+
};
|
|
269
274
|
</script>
|
|
270
275
|
```
|
|
271
276
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
##### Vue3 示例:
|
|
277
|
+
### Vue 3 自定义提示词
|
|
275
278
|
|
|
276
279
|
```vue
|
|
277
280
|
<template>
|
|
278
281
|
<AIBlueking
|
|
279
|
-
|
|
280
|
-
:
|
|
281
|
-
:
|
|
282
|
-
:messages="messages"
|
|
283
|
-
:position-limit="positionLimit"
|
|
284
|
-
:prompts="prompts"
|
|
285
|
-
:scroll-loading="scrollLoading"
|
|
286
|
-
:scroll-loading-end="scrollLoadingEnd"
|
|
287
|
-
:size-limit="sizeLimit"
|
|
288
|
-
:start-position="startPosition"
|
|
289
|
-
@ai-click="handleAIClick"
|
|
290
|
-
@choose-prompt="handleChoosePrompt"
|
|
291
|
-
@clear="handleClear"
|
|
292
|
-
@close="handleClose"
|
|
293
|
-
@scroll-load="handleScrollLoad"
|
|
294
|
-
@send="handleSend"
|
|
295
|
-
@stop="handleStop"
|
|
282
|
+
ref="aiBlueking"
|
|
283
|
+
:url="apiUrl"
|
|
284
|
+
:prompts="customPrompts"
|
|
296
285
|
/>
|
|
297
286
|
</template>
|
|
298
|
-
<script setup lang="ts">
|
|
299
|
-
import { type ComponentInstance, ref } from 'vue';
|
|
300
|
-
|
|
301
|
-
import AIBlueking, { type IPrompt, type IMessage, RoleType, MessageStatus } from '@blueking/ai-blueking';
|
|
302
|
-
|
|
303
|
-
import '@blueking/ai-blueking/dist/vue3/style.css';
|
|
304
287
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
{
|
|
319
|
-
content: '不对',
|
|
320
|
-
time: '2024-08-12 09:29',
|
|
321
|
-
role: RoleType.User,
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
content: '1+1=2',
|
|
325
|
-
time: '2024-08-12 09:31',
|
|
326
|
-
role: RoleType.Assistant,
|
|
327
|
-
status: MessageStatus.Loading,
|
|
328
|
-
},
|
|
329
|
-
{
|
|
330
|
-
content: '对了',
|
|
331
|
-
time: '2024-08-13 10:20',
|
|
332
|
-
role: RoleType.User,
|
|
333
|
-
},
|
|
334
|
-
{
|
|
335
|
-
content: '好的,任务已完成',
|
|
336
|
-
time: '2024-08-13 10:23',
|
|
337
|
-
role: RoleType.Assistant,
|
|
338
|
-
},
|
|
339
|
-
]);
|
|
340
|
-
// 内置 prompt
|
|
341
|
-
const prompts = [
|
|
342
|
-
{
|
|
343
|
-
id: 1,
|
|
344
|
-
content: '帮我计算1+1的结果',
|
|
345
|
-
},
|
|
346
|
-
{
|
|
347
|
-
id: 2,
|
|
348
|
-
content: '帮我计算2+2的结果',
|
|
349
|
-
},
|
|
350
|
-
];
|
|
351
|
-
|
|
352
|
-
// 处理ai消息的loading状态
|
|
353
|
-
const loading = ref(false);
|
|
354
|
-
// 聊天背景色
|
|
355
|
-
const background = '#f5f7fa';
|
|
356
|
-
// 头部背景色
|
|
357
|
-
const headBackground = 'linear-gradient(267deg, #2dd1f4 0%, #1482ff 95%)';
|
|
358
|
-
// 弹框位于屏幕四边的最小距离
|
|
359
|
-
const positionLimit = {
|
|
360
|
-
top: 0,
|
|
361
|
-
bottom: 0,
|
|
362
|
-
left: 0,
|
|
363
|
-
right: 0,
|
|
364
|
-
};
|
|
365
|
-
// 组件最小尺寸
|
|
366
|
-
const sizeLimit = {
|
|
367
|
-
height: 320,
|
|
368
|
-
width: 400,
|
|
369
|
-
};
|
|
370
|
-
// 初始位置
|
|
371
|
-
const startPosition = {
|
|
372
|
-
top: window.innerHeight - 560,
|
|
373
|
-
bottom: 0,
|
|
374
|
-
left: window.innerWidth - 400,
|
|
375
|
-
right: 0,
|
|
376
|
-
};
|
|
377
|
-
// 向上滚动加载
|
|
378
|
-
const scrollLoading = ref(false);
|
|
379
|
-
const scrollLoadingEnd = ref(false);
|
|
380
|
-
// 组件实例
|
|
381
|
-
const aiRef = ref<ComponentInstance<typeof AIBlueking>>();
|
|
382
|
-
|
|
383
|
-
const handleClear = () => {
|
|
384
|
-
console.log('trigger clear');
|
|
385
|
-
};
|
|
386
|
-
|
|
387
|
-
const handleSend = (val: string) => {
|
|
388
|
-
console.log('trigger send', val);
|
|
389
|
-
// args 包含:
|
|
390
|
-
// - content: 用户输入的内容
|
|
391
|
-
// - cite: 引用的内容(可选)
|
|
392
|
-
// - prompt: 使用的 prompt 模板(可选)
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
const handleStop = () => {
|
|
396
|
-
console.log('trigger stop');
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
const handleScrollLoad = () => {
|
|
400
|
-
scrollLoading.value = true;
|
|
401
|
-
setTimeout(() => {
|
|
402
|
-
// 模拟异步请求
|
|
403
|
-
messages.value.unshift(
|
|
404
|
-
...[
|
|
405
|
-
{
|
|
406
|
-
content: '1+1=?',
|
|
407
|
-
time: '2023-08-12 9:28',
|
|
408
|
-
role: RoleType.User,
|
|
409
|
-
},
|
|
410
|
-
{
|
|
411
|
-
content: '2',
|
|
412
|
-
time: '2023-08-12 9:30',
|
|
413
|
-
role: RoleType.Assistant,
|
|
414
|
-
},
|
|
415
|
-
],
|
|
416
|
-
);
|
|
417
|
-
// 设置状态
|
|
418
|
-
scrollLoading.value = false;
|
|
419
|
-
scrollLoadingEnd.value = true;
|
|
420
|
-
}, 1000);
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
const handleClose = () => {
|
|
424
|
-
console.log('trigger close');
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
const handleChoosePrompt = (prompt: IPrompt) => {
|
|
428
|
-
console.log('choose prompt', prompt);
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
const handleAIClick = (val: string) => {
|
|
432
|
-
aiRef.value?.setInputMessage(val);
|
|
433
|
-
};
|
|
288
|
+
<script lang="ts" setup>
|
|
289
|
+
import { ref } from 'vue';
|
|
290
|
+
import AIBlueking from '@blueking/ai-blueking';
|
|
291
|
+
import '@blueking/ai-blueking/dist/vue3/style.css';
|
|
292
|
+
|
|
293
|
+
const aiBlueking = ref(null);
|
|
294
|
+
const apiUrl = 'https://your-api-endpoint.com/assistant/';
|
|
295
|
+
|
|
296
|
+
const customPrompts = [
|
|
297
|
+
'我给一段文字,概括文字的主题和主要观点,找出支持主题的关键事实、论据或观点,使用中文回答。',
|
|
298
|
+
'假设你是一名关系型数据库专家,后续的对话我会直接描述我想要的查询效果,请告诉我如何写对应的SQL查询,并解释它,如果有多个版本的SQL,以MySQL数据库为主。',
|
|
299
|
+
'你是一名经验丰富的前端开发工程师,请帮我解决以下问题...'
|
|
300
|
+
];
|
|
434
301
|
</script>
|
|
435
302
|
```
|
|
436
303
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
Vue2 下,需要安装 npm 包,里面是 vue3 资源
|
|
440
|
-
|
|
441
|
-
```bash
|
|
442
|
-
npm i @blueking/ai-blueking
|
|
443
|
-
```
|
|
304
|
+
### Vue 3 设置 Nimbus 初始最小化状态
|
|
444
305
|
|
|
445
306
|
```vue
|
|
446
307
|
<template>
|
|
447
308
|
<AIBlueking
|
|
448
|
-
|
|
449
|
-
:
|
|
450
|
-
:
|
|
451
|
-
:messages="messages"
|
|
452
|
-
:position-limit="positionLimit"
|
|
453
|
-
:prompts="prompts"
|
|
454
|
-
:size-limit="sizeLimit"
|
|
455
|
-
:start-position="startPosition"
|
|
456
|
-
@choose-prompt="handleChoosePrompt"
|
|
457
|
-
@clear="handleClear"
|
|
458
|
-
@close="handleClose"
|
|
459
|
-
@send="handleSend"
|
|
460
|
-
@scroll="handleScroll"
|
|
461
|
-
@stop="handleStop"
|
|
309
|
+
ref="aiBlueking"
|
|
310
|
+
:url="apiUrl"
|
|
311
|
+
:default-minimize="true"
|
|
462
312
|
/>
|
|
463
313
|
</template>
|
|
464
|
-
<script lang="ts">
|
|
465
|
-
import { ref } from 'vue';
|
|
466
314
|
|
|
467
|
-
|
|
468
|
-
|
|
315
|
+
<script lang="ts" setup>
|
|
316
|
+
import { ref } from 'vue';
|
|
317
|
+
import AIBlueking from '@blueking/ai-blueking';
|
|
318
|
+
import '@blueking/ai-blueking/dist/vue3/style.css';
|
|
469
319
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
{
|
|
486
|
-
content: '1+1=3',
|
|
487
|
-
role: 'assistant',
|
|
488
|
-
status: 'error',
|
|
489
|
-
},
|
|
490
|
-
{
|
|
491
|
-
content: '不对',
|
|
492
|
-
role: 'user',
|
|
493
|
-
},
|
|
494
|
-
{
|
|
495
|
-
content: '1+1=2',
|
|
496
|
-
role: 'assistant',
|
|
497
|
-
status: 'loading',
|
|
498
|
-
},
|
|
499
|
-
{
|
|
500
|
-
content: '对了',
|
|
501
|
-
role: 'user',
|
|
502
|
-
},
|
|
503
|
-
{
|
|
504
|
-
content: '好的,任务已完成',
|
|
505
|
-
role: 'assistant',
|
|
506
|
-
},
|
|
507
|
-
],
|
|
508
|
-
prompts: [
|
|
509
|
-
{
|
|
510
|
-
id: 1,
|
|
511
|
-
content: '帮我计算1+1的结果',
|
|
512
|
-
},
|
|
513
|
-
{
|
|
514
|
-
id: 2,
|
|
515
|
-
content: '帮我计算2+2的结果',
|
|
516
|
-
},
|
|
517
|
-
],
|
|
518
|
-
loading: false,
|
|
519
|
-
background: '#f5f7fa',
|
|
520
|
-
headBackground: 'linear-gradient(267deg, #2dd1f4 0%, #1482ff 95%)',
|
|
521
|
-
positionLimit: {
|
|
522
|
-
top: 0,
|
|
523
|
-
bottom: 0,
|
|
524
|
-
left: 0,
|
|
525
|
-
right: 0,
|
|
526
|
-
},
|
|
527
|
-
sizeLimit: {
|
|
528
|
-
height: 320,
|
|
529
|
-
width: 400,
|
|
530
|
-
},
|
|
531
|
-
startPosition: {
|
|
532
|
-
top: window.innerHeight - 560,
|
|
533
|
-
bottom: 0,
|
|
534
|
-
left: window.innerWidth - 400,
|
|
535
|
-
right: 0,
|
|
536
|
-
},
|
|
537
|
-
};
|
|
538
|
-
},
|
|
539
|
-
methods: {
|
|
540
|
-
handleClear() {
|
|
541
|
-
console.log('trigger clear');
|
|
542
|
-
},
|
|
543
|
-
handleSend(val: string) {
|
|
544
|
-
console.log('trigger send', val);
|
|
545
|
-
},
|
|
546
|
-
handleClose() {
|
|
547
|
-
console.log('trigger close');
|
|
548
|
-
},
|
|
549
|
-
handleChoosePrompt(prompt) {
|
|
550
|
-
console.log('choose prompt', prompt);
|
|
551
|
-
},
|
|
552
|
-
handleScroll(event: Event) {
|
|
553
|
-
console.log('trigger scroll', event);
|
|
320
|
+
const aiBlueking = ref(null);
|
|
321
|
+
const apiUrl = 'https://your-api-endpoint.com/assistant/';
|
|
322
|
+
</script>
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
### Vue 3 自定义请求选项
|
|
326
|
+
|
|
327
|
+
```vue
|
|
328
|
+
<template>
|
|
329
|
+
<AIBlueking
|
|
330
|
+
ref="aiBlueking"
|
|
331
|
+
:url="apiUrl"
|
|
332
|
+
:request-options="{
|
|
333
|
+
headers: {
|
|
334
|
+
preset: 'QA',
|
|
554
335
|
},
|
|
555
|
-
|
|
556
|
-
|
|
336
|
+
data: {
|
|
337
|
+
preset: 'QA',
|
|
557
338
|
},
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
</
|
|
339
|
+
}"
|
|
340
|
+
/>
|
|
341
|
+
</template>
|
|
561
342
|
```
|
|
562
343
|
|
|
563
|
-
|
|
344
|
+
这将使得发送请求时,会携带 `preset` 参数,headers 的数据会合并到请求头中,请求体数据会合并到请求体中:
|
|
345
|
+
```diff
|
|
346
|
+
{
|
|
347
|
+
inputs: {},
|
|
348
|
+
chat_history: [],
|
|
349
|
+
input: 'xxx',
|
|
350
|
+
+ preset: "QA"
|
|
351
|
+
}
|
|
352
|
+
```
|
|
564
353
|
|
|
565
|
-
###
|
|
354
|
+
### Vue 3 访问会话内容
|
|
566
355
|
|
|
567
|
-
|
|
356
|
+
```vue
|
|
357
|
+
<template>
|
|
358
|
+
<AIBlueking ref="aiBlueking" :url="apiUrl" />
|
|
359
|
+
<button @click="showSessionContents">显示会话内容</button>
|
|
360
|
+
</template>
|
|
568
361
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
362
|
+
<script lang="ts" setup>
|
|
363
|
+
import { ref } from 'vue';
|
|
364
|
+
import AIBlueking from '@blueking/ai-blueking';
|
|
365
|
+
import '@blueking/ai-blueking/dist/vue3/style.css';
|
|
572
366
|
|
|
573
|
-
|
|
367
|
+
const aiBlueking = ref<InstanceType<typeof AIBlueking>>();
|
|
368
|
+
const apiUrl = 'https://your-api-endpoint.com/assistant/';
|
|
574
369
|
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
370
|
+
const showSessionContents = () => {
|
|
371
|
+
const sessionContents = aiBlueking.value?.sessionContents;
|
|
372
|
+
console.log('当前会话内容:', sessionContents);
|
|
373
|
+
}
|
|
374
|
+
</script>
|
|
578
375
|
|
|
579
|
-
|
|
376
|
+
### Vue 2 自定义请求选项
|
|
580
377
|
|
|
581
|
-
```
|
|
582
|
-
|
|
583
|
-
|
|
378
|
+
```vue
|
|
379
|
+
<template>
|
|
380
|
+
<AIBlueking
|
|
381
|
+
ref="aiBlueking"
|
|
382
|
+
:url="apiUrl"
|
|
383
|
+
:request-options="{
|
|
384
|
+
headers: {
|
|
385
|
+
preset: 'QA',
|
|
386
|
+
},
|
|
387
|
+
data: {
|
|
388
|
+
preset: 'QA',
|
|
389
|
+
},
|
|
390
|
+
}"
|
|
391
|
+
/>
|
|
392
|
+
</template>
|
|
584
393
|
```
|
|
585
394
|
|
|
586
|
-
###
|
|
395
|
+
### Vue 2 访问会话内容
|
|
587
396
|
|
|
588
|
-
|
|
397
|
+
```vue
|
|
398
|
+
<template>
|
|
399
|
+
<AIBlueking ref="aiBlueking" :url="apiUrl" />
|
|
400
|
+
<button @click="showSessionContents">显示会话内容</button>
|
|
401
|
+
</template>
|
|
589
402
|
|
|
590
|
-
|
|
403
|
+
<script>
|
|
404
|
+
import AIBlueking from '@blueking/ai-blueking/vue2';
|
|
405
|
+
import '@blueking/ai-blueking/dist/vue2/style.css';
|
|
406
|
+
|
|
407
|
+
export default {
|
|
408
|
+
components: {
|
|
409
|
+
AIBlueking
|
|
410
|
+
},
|
|
411
|
+
data() {
|
|
412
|
+
return {
|
|
413
|
+
apiUrl: 'https://your-api-endpoint.com/assistant/'
|
|
414
|
+
};
|
|
415
|
+
},
|
|
416
|
+
methods: {
|
|
417
|
+
showSessionContents() {
|
|
418
|
+
const sessionContents = this.$refs.aiBlueking.sessionContents;
|
|
419
|
+
console.log('当前会话内容:', sessionContents);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
</script>
|
|
424
|
+
```
|
|
591
425
|
|
|
592
|
-
|
|
593
|
-
- 展示所有功能和配置项
|
|
594
|
-
- 通过 `/playground/static.vue` 查看示例
|
|
426
|
+
### Vue 2 自定义提示词
|
|
595
427
|
|
|
596
|
-
|
|
428
|
+
```vue
|
|
429
|
+
<template>
|
|
430
|
+
<AIBlueking
|
|
431
|
+
ref="aiBlueking"
|
|
432
|
+
:url="apiUrl"
|
|
433
|
+
:prompts="customPrompts"
|
|
434
|
+
/>
|
|
435
|
+
</template>
|
|
597
436
|
|
|
598
|
-
|
|
599
|
-
-
|
|
600
|
-
|
|
437
|
+
<script>
|
|
438
|
+
import AIBlueking from '@blueking/ai-blueking/vue2';
|
|
439
|
+
import '@blueking/ai-blueking/dist/vue2/style.css';
|
|
440
|
+
|
|
441
|
+
export default {
|
|
442
|
+
components: {
|
|
443
|
+
AIBlueking
|
|
444
|
+
},
|
|
445
|
+
data() {
|
|
446
|
+
return {
|
|
447
|
+
apiUrl: 'https://your-api-endpoint.com/assistant/',
|
|
448
|
+
customPrompts: [
|
|
449
|
+
'我给一段文字,概括文字的主题和主要观点,找出支持主题的关键事实、论据或观点,使用中文回答。',
|
|
450
|
+
'假设你是一名关系型数据库专家,后续的对话我会直接描述我想要的查询效果,请告诉我如何写对应的SQL查询,并解释它,如果有多个版本的SQL,以MySQL数据库为主。',
|
|
451
|
+
'你是一名经验丰富的前端开发工程师,请帮我解决以下问题...'
|
|
452
|
+
]
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
</script>
|
|
457
|
+
```
|
|
601
458
|
|
|
602
|
-
|
|
459
|
+
### Vue 2 设置 Nimbus 初始最小化状态
|
|
603
460
|
|
|
604
|
-
|
|
461
|
+
```vue
|
|
462
|
+
<template>
|
|
463
|
+
<AIBlueking
|
|
464
|
+
ref="aiBlueking"
|
|
465
|
+
:url="apiUrl"
|
|
466
|
+
:default-minimize="true"
|
|
467
|
+
/>
|
|
468
|
+
</template>
|
|
605
469
|
|
|
606
|
-
|
|
470
|
+
<script>
|
|
471
|
+
import AIBlueking from '@blueking/ai-blueking/vue2';
|
|
472
|
+
import '@blueking/ai-blueking/dist/vue2/style.css';
|
|
473
|
+
|
|
474
|
+
export default {
|
|
475
|
+
components: {
|
|
476
|
+
AIBlueking
|
|
477
|
+
},
|
|
478
|
+
data() {
|
|
479
|
+
return {
|
|
480
|
+
apiUrl: 'https://your-api-endpoint.com/assistant/'
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
</script>
|
|
485
|
+
```
|
|
607
486
|
|
|
487
|
+
## 框架差异注意事项
|
|
608
488
|
|
|
609
|
-
2
|
|
489
|
+
### Vue 2 与 Vue 3 的区别
|
|
610
490
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
491
|
+
1. **引入方式不同**:
|
|
492
|
+
- Vue 3: `import AIBlueking from '@blueking/ai-blueking'`
|
|
493
|
+
- Vue 2: `import AIBlueking from '@blueking/ai-blueking/vue2'`
|
|
614
494
|
|
|
615
|
-
|
|
616
|
-
|
|
495
|
+
2. **样式引入不同**:
|
|
496
|
+
- Vue 3: `import '@blueking/ai-blueking/dist/vue3/style.css'`
|
|
497
|
+
- Vue 2: `import '@blueking/ai-blueking/dist/vue2/style.css'`
|
|
617
498
|
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
499
|
+
3. **组件实例获取**:
|
|
500
|
+
- Vue 3: 通过 ref 值获取,如 `aiBlueking.value?.handleShow()`
|
|
501
|
+
- Vue 2: 通过 $refs 获取,如 `this.$refs.aiBlueking.handleShow()`
|
|
621
502
|
|
|
622
|
-
|
|
503
|
+
4. **组件定义方式**:
|
|
504
|
+
- Vue 3: 使用 Composition API 或 Options API
|
|
505
|
+
- Vue 2: 使用 Options API
|
|
623
506
|
|
|
624
|
-
|
|
625
|
-
- Demo 中简化了登录相关的代码实现
|
|
626
|
-
- 未登录时会自动跳转到登录页面
|
|
507
|
+
## 通用注意事项
|
|
627
508
|
|
|
628
|
-
|
|
509
|
+
1. 必须设置有效的 `url` 属性,指向您的 AI 服务接口
|
|
510
|
+
2. 为了获得最佳体验,建议将 AI 小鲸放在全局组件中,以便在应用的任何地方都能访问
|
|
511
|
+
3. 快捷操作中的提示词模板使用 `{{ SELECTED_TEXT }}` 作为选中文本的占位符
|
|
512
|
+
4. Vue 2 中导入的是 `@blueking/ai-blueking/vue2`,而非根路径
|
|
629
513
|
|
|
630
|
-
|
|
514
|
+
## 示例项目
|
|
631
515
|
|
|
632
|
-
-
|
|
633
|
-
- 需要确保网关配置正确且有访问权限
|
|
516
|
+
可以参考 `packages/ai-blueking/playground/dynamic-demo.vue` 了解更多使用示例。
|
|
634
517
|
|
|
635
|
-
|
|
518
|
+
## 常见问题
|
|
636
519
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
- 其他错误会在界面上显示错误信息
|
|
520
|
+
1. **Q: AI 小鲸窗口如何调整大小?**
|
|
521
|
+
A: 用户可以通过拖动窗口边缘或右下角来调整窗口大小。
|
|
640
522
|
|
|
641
|
-
|
|
523
|
+
2. **Q: 如何实现选中文本弹出快捷操作?**
|
|
524
|
+
A: 这是 AI 小鲸的内置功能,设置 `enablePopup` 为 true 即可启用。
|
|
642
525
|
|
|
643
|
-
|
|
644
|
-
-
|
|
526
|
+
3. **Q: 在 Vue 2 项目中使用时遇到兼容性问题怎么办?**
|
|
527
|
+
A: 确保正确导入 Vue 2 版本的组件和样式,路径分别为 `@blueking/ai-blueking/vue2` 和 `@blueking/ai-blueking/dist/vue2/style.css`。
|