@blueking/ai-blueking 0.1.7 → 0.2.0-beta.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 +86 -51
- package/dist/ai-blueking.vue.d.ts +8 -2
- package/dist/components/render-content.vue.d.ts +11 -2
- package/dist/components/render-stop.vue.d.ts +18 -1
- package/dist/components/render-time.vue.d.ts +16 -0
- package/dist/lang/index.d.ts +14 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/util/index.d.ts +7 -0
- package/dist/vue2/index.es.min.js +6060 -5854
- package/dist/vue2/index.iife.min.js +42 -43
- package/dist/vue2/index.umd.min.js +33 -34
- package/dist/vue2/style.css +1 -1
- package/dist/vue3/index.es.min.js +3611 -3418
- package/dist/vue3/index.iife.min.js +34 -35
- package/dist/vue3/index.umd.min.js +16 -17
- package/dist/vue3/style.css +1 -1
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ npm i @blueking/ai-blueking
|
|
|
17
17
|
:messages="messages"
|
|
18
18
|
@clear="handleClear"
|
|
19
19
|
@send="handleSend"
|
|
20
|
+
@stop="handleStop"
|
|
20
21
|
/>
|
|
21
22
|
</template>
|
|
22
23
|
|
|
@@ -113,6 +114,11 @@ npm i @blueking/ai-blueking
|
|
|
113
114
|
1,
|
|
114
115
|
);
|
|
115
116
|
};
|
|
117
|
+
|
|
118
|
+
// 暂停聊天
|
|
119
|
+
const handleStop = () => {
|
|
120
|
+
chatHelper.stop(1);
|
|
121
|
+
};
|
|
116
122
|
</script>
|
|
117
123
|
```
|
|
118
124
|
|
|
@@ -120,63 +126,67 @@ npm i @blueking/ai-blueking
|
|
|
120
126
|
|
|
121
127
|
```vue
|
|
122
128
|
<template>
|
|
123
|
-
<
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
129
|
+
<AIBlueking
|
|
130
|
+
:background="background"
|
|
131
|
+
:head-background="headBackground"
|
|
132
|
+
:loading="loading"
|
|
133
|
+
:messages="messages"
|
|
134
|
+
:position-limit="positionLimit"
|
|
135
|
+
:prompts="prompts"
|
|
136
|
+
:scroll-loading="scrollLoading"
|
|
137
|
+
:scroll-loading-end="scrollLoadingEnd"
|
|
138
|
+
:size-limit="sizeLimit"
|
|
139
|
+
:start-position="startPosition"
|
|
140
|
+
@choose-prompt="handleChoosePrompt"
|
|
141
|
+
@clear="handleClear"
|
|
142
|
+
@close="handleClose"
|
|
143
|
+
@scroll-load="handleScrollLoad"
|
|
144
|
+
@send="handleSend"
|
|
145
|
+
@stop="handleStop"
|
|
146
|
+
/>
|
|
140
147
|
</template>
|
|
141
148
|
<script setup lang="ts">
|
|
142
149
|
import { ref } from 'vue';
|
|
143
150
|
|
|
144
|
-
import AIBlueking from '@blueking/ai-blueking';
|
|
151
|
+
import AIBlueking, { type IPrompt, type IMessage, RoleType } from '@blueking/ai-blueking';
|
|
152
|
+
|
|
145
153
|
import '@blueking/ai-blueking/dist/vue3/style.css';
|
|
146
154
|
|
|
147
|
-
//
|
|
148
|
-
const messages = [
|
|
149
|
-
{
|
|
150
|
-
content: '你好呀',
|
|
151
|
-
role: 'assistant',
|
|
152
|
-
},
|
|
155
|
+
// 展示的消息,其中 time 可以不传
|
|
156
|
+
const messages = ref<IMessage[]>([
|
|
153
157
|
{
|
|
154
158
|
content: '1+1=?',
|
|
155
|
-
|
|
159
|
+
time: '2023-08-12 10:28',
|
|
160
|
+
role: RoleType.User,
|
|
156
161
|
},
|
|
157
162
|
{
|
|
158
163
|
content: '1+1=3',
|
|
159
|
-
|
|
164
|
+
time: '2024-08-07 14:29',
|
|
165
|
+
role: RoleType.Assistant,
|
|
160
166
|
status: 'error',
|
|
161
167
|
},
|
|
162
168
|
{
|
|
163
169
|
content: '不对',
|
|
164
|
-
|
|
170
|
+
time: '2024-08-12 09:29',
|
|
171
|
+
role: RoleType.User,
|
|
165
172
|
},
|
|
166
173
|
{
|
|
167
174
|
content: '1+1=2',
|
|
168
|
-
|
|
175
|
+
time: '2024-08-12 09:31',
|
|
176
|
+
role: RoleType.Assistant,
|
|
169
177
|
status: 'loading',
|
|
170
178
|
},
|
|
171
179
|
{
|
|
172
180
|
content: '对了',
|
|
173
|
-
|
|
181
|
+
time: '2024-08-13 10:20',
|
|
182
|
+
role: RoleType.User,
|
|
174
183
|
},
|
|
175
184
|
{
|
|
176
185
|
content: '好的,任务已完成',
|
|
177
|
-
|
|
186
|
+
time: '2024-08-13 10:23',
|
|
187
|
+
role: RoleType.Assistant,
|
|
178
188
|
},
|
|
179
|
-
];
|
|
189
|
+
]);
|
|
180
190
|
// 内置 prompt
|
|
181
191
|
const prompts = [
|
|
182
192
|
{
|
|
@@ -214,6 +224,9 @@ npm i @blueking/ai-blueking
|
|
|
214
224
|
left: window.innerWidth - 400,
|
|
215
225
|
right: 0,
|
|
216
226
|
};
|
|
227
|
+
// 向上滚动加载
|
|
228
|
+
const scrollLoading = ref(false);
|
|
229
|
+
const scrollLoadingEnd = ref(false);
|
|
217
230
|
|
|
218
231
|
const handleClear = () => {
|
|
219
232
|
console.log('trigger clear');
|
|
@@ -223,15 +236,39 @@ npm i @blueking/ai-blueking
|
|
|
223
236
|
console.log('trigger send', val);
|
|
224
237
|
};
|
|
225
238
|
|
|
226
|
-
const
|
|
227
|
-
console.log('trigger
|
|
239
|
+
const handleStop = () => {
|
|
240
|
+
console.log('trigger stop');
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
const handleScrollLoad = () => {
|
|
244
|
+
scrollLoading.value = true;
|
|
245
|
+
setTimeout(() => {
|
|
246
|
+
// 模拟异步请求
|
|
247
|
+
messages.value.unshift(
|
|
248
|
+
...[
|
|
249
|
+
{
|
|
250
|
+
content: '1+1=?',
|
|
251
|
+
time: '2023-08-12 9:28',
|
|
252
|
+
role: RoleType.User,
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
content: '2',
|
|
256
|
+
time: '2023-08-12 9:30',
|
|
257
|
+
role: RoleType.Assistant,
|
|
258
|
+
},
|
|
259
|
+
],
|
|
260
|
+
);
|
|
261
|
+
// 设置状态
|
|
262
|
+
scrollLoading.value = false;
|
|
263
|
+
scrollLoadingEnd.value = true;
|
|
264
|
+
}, 1000);
|
|
228
265
|
};
|
|
229
266
|
|
|
230
267
|
const handleClose = () => {
|
|
231
268
|
console.log('trigger close');
|
|
232
269
|
};
|
|
233
270
|
|
|
234
|
-
const handleChoosePrompt = prompt => {
|
|
271
|
+
const handleChoosePrompt = (prompt: IPrompt) => {
|
|
235
272
|
console.log('choose prompt', prompt);
|
|
236
273
|
};
|
|
237
274
|
</script>
|
|
@@ -247,23 +284,21 @@ npm i @blueking/bkui-library
|
|
|
247
284
|
|
|
248
285
|
```vue
|
|
249
286
|
<template>
|
|
250
|
-
<
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
/>
|
|
266
|
-
</div>
|
|
287
|
+
<AIBlueking
|
|
288
|
+
:background="background"
|
|
289
|
+
:head-background="headBackground"
|
|
290
|
+
:loading="loading"
|
|
291
|
+
:messages="messages"
|
|
292
|
+
:position-limit="positionLimit"
|
|
293
|
+
:prompts="prompts"
|
|
294
|
+
:size-limit="sizeLimit"
|
|
295
|
+
:start-position="startPosition"
|
|
296
|
+
@choose-prompt="handleChoosePrompt"
|
|
297
|
+
@clear="handleClear"
|
|
298
|
+
@close="handleClose"
|
|
299
|
+
@send="handleSend"
|
|
300
|
+
@scroll="handleScroll"
|
|
301
|
+
/>
|
|
267
302
|
</template>
|
|
268
303
|
<script lang="ts">
|
|
269
304
|
import { ref } from 'vue';
|
|
@@ -10,12 +10,15 @@ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<{
|
|
|
10
10
|
startPosition?: IStartPosition | undefined;
|
|
11
11
|
userPhoto?: string | undefined;
|
|
12
12
|
logo?: string | undefined;
|
|
13
|
+
scrollLoading?: boolean | undefined;
|
|
14
|
+
scrollLoadingEnd?: boolean | undefined;
|
|
13
15
|
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
14
16
|
close: () => void;
|
|
17
|
+
stop: () => void;
|
|
15
18
|
clear: () => void;
|
|
19
|
+
"scroll-load": () => void;
|
|
16
20
|
send: (val: string) => void;
|
|
17
21
|
"choose-prompt": (prompt: IPrompt) => void;
|
|
18
|
-
scroll: (data: Event) => void;
|
|
19
22
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<{
|
|
20
23
|
messages: IMessage[];
|
|
21
24
|
prompts?: IPrompt[] | undefined;
|
|
@@ -27,11 +30,14 @@ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<{
|
|
|
27
30
|
startPosition?: IStartPosition | undefined;
|
|
28
31
|
userPhoto?: string | undefined;
|
|
29
32
|
logo?: string | undefined;
|
|
33
|
+
scrollLoading?: boolean | undefined;
|
|
34
|
+
scrollLoadingEnd?: boolean | undefined;
|
|
30
35
|
}>>> & {
|
|
31
|
-
onScroll?: ((data: Event) => any) | undefined;
|
|
32
36
|
"onChoose-prompt"?: ((prompt: IPrompt) => any) | undefined;
|
|
33
37
|
onClear?: (() => any) | undefined;
|
|
38
|
+
onStop?: (() => any) | undefined;
|
|
34
39
|
onSend?: ((val: string) => any) | undefined;
|
|
40
|
+
"onScroll-load"?: (() => any) | undefined;
|
|
35
41
|
onClose?: (() => any) | undefined;
|
|
36
42
|
}, {}, {}>;
|
|
37
43
|
export default _default;
|
|
@@ -5,26 +5,35 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
5
5
|
loading?: boolean | undefined;
|
|
6
6
|
background?: string | undefined;
|
|
7
7
|
userPhoto?: string | undefined;
|
|
8
|
+
scrollLoading?: boolean | undefined;
|
|
9
|
+
scrollLoadingEnd?: boolean | undefined;
|
|
8
10
|
}>, {
|
|
9
11
|
background: string;
|
|
12
|
+
scrollLoadingEnd: boolean;
|
|
10
13
|
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
11
14
|
send: (userInput: string) => void;
|
|
12
15
|
"choose-prompt": (prompt: IPrompt) => void;
|
|
13
|
-
|
|
16
|
+
stop: () => void;
|
|
17
|
+
"scroll-load": () => void;
|
|
14
18
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<{
|
|
15
19
|
messages: IMessage[];
|
|
16
20
|
prompts?: IPrompt[] | undefined;
|
|
17
21
|
loading?: boolean | undefined;
|
|
18
22
|
background?: string | undefined;
|
|
19
23
|
userPhoto?: string | undefined;
|
|
24
|
+
scrollLoading?: boolean | undefined;
|
|
25
|
+
scrollLoadingEnd?: boolean | undefined;
|
|
20
26
|
}>, {
|
|
21
27
|
background: string;
|
|
28
|
+
scrollLoadingEnd: boolean;
|
|
22
29
|
}>>> & {
|
|
23
|
-
onScroll?: ((data: Event) => any) | undefined;
|
|
24
30
|
"onChoose-prompt"?: ((prompt: IPrompt) => any) | undefined;
|
|
31
|
+
onStop?: (() => any) | undefined;
|
|
25
32
|
onSend?: ((userInput: string) => any) | undefined;
|
|
33
|
+
"onScroll-load"?: (() => any) | undefined;
|
|
26
34
|
}, {
|
|
27
35
|
background: string;
|
|
36
|
+
scrollLoadingEnd: boolean;
|
|
28
37
|
}, {}>;
|
|
29
38
|
export default _default;
|
|
30
39
|
type __VLS_WithDefaults<P, D> = {
|
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
declare const _default: import("vue").DefineComponent<
|
|
1
|
+
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<{
|
|
2
|
+
isShow?: boolean | undefined;
|
|
3
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
4
|
+
stop: () => void;
|
|
5
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<{
|
|
6
|
+
isShow?: boolean | undefined;
|
|
7
|
+
}>>> & {
|
|
8
|
+
onStop?: (() => any) | undefined;
|
|
9
|
+
}, {}, {}>;
|
|
2
10
|
export default _default;
|
|
11
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
12
|
+
type __VLS_TypePropsToOption<T> = {
|
|
13
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
14
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
15
|
+
} : {
|
|
16
|
+
type: import('vue').PropType<T[K]>;
|
|
17
|
+
required: true;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IMessage } from '../types';
|
|
2
|
+
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<{
|
|
3
|
+
message: IMessage;
|
|
4
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<{
|
|
5
|
+
message: IMessage;
|
|
6
|
+
}>>>, {}, {}>;
|
|
7
|
+
export default _default;
|
|
8
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
9
|
+
type __VLS_TypePropsToOption<T> = {
|
|
10
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
11
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
12
|
+
} : {
|
|
13
|
+
type: import('vue').PropType<T[K]>;
|
|
14
|
+
required: true;
|
|
15
|
+
};
|
|
16
|
+
};
|
package/dist/lang/index.d.ts
CHANGED
|
@@ -9,5 +9,18 @@ export declare const langData: {
|
|
|
9
9
|
readonly 发送: "Send";
|
|
10
10
|
readonly '\u60A8\u53EF\u4EE5\u952E\u5165 \u201C/\u201D \u67E5\u770B\u66F4\u591APrompt': "You can type \"/\" to see more Prompts";
|
|
11
11
|
readonly 请输入: "Please input";
|
|
12
|
+
readonly 返回最新: "Scroll to bottom";
|
|
13
|
+
readonly 终止生成: "Stop";
|
|
14
|
+
readonly 向上滚动加载更多记录: "Scroll up to load more records";
|
|
15
|
+
readonly 日: "sunday";
|
|
16
|
+
readonly 一: "monday";
|
|
17
|
+
readonly 二: "tuesday";
|
|
18
|
+
readonly 三: "wednesday";
|
|
19
|
+
readonly 四: "thursday";
|
|
20
|
+
readonly 五: "friday";
|
|
21
|
+
readonly 六: "saturday";
|
|
22
|
+
readonly 昨天: "yesterday";
|
|
23
|
+
readonly 本周: "this week";
|
|
24
|
+
readonly 上周: "last week";
|
|
12
25
|
};
|
|
13
|
-
export declare const t: (key: keyof typeof langData) => "BK GPT" | "shrink down" | "expand upward" | "Empty chat records" | "close" | "The content is being executed, please enter it again after the execution is completed." | "Send" | "You can type \"/\" to see more Prompts" | "Please input" | "小鲸" | "向下收缩" | "向上扩展" | "清空聊天记录" | "关闭" | "内容正在执行中,请执行完成后再输入" | "发送" | "您可以键入 “/” 查看更多Prompt" | "请输入";
|
|
26
|
+
export declare const t: (key: keyof typeof langData) => "BK GPT" | "shrink down" | "expand upward" | "Empty chat records" | "close" | "The content is being executed, please enter it again after the execution is completed." | "Send" | "You can type \"/\" to see more Prompts" | "Please input" | "Scroll to bottom" | "Stop" | "Scroll up to load more records" | "sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday" | "yesterday" | "this week" | "last week" | "小鲸" | "向下收缩" | "向上扩展" | "清空聊天记录" | "关闭" | "内容正在执行中,请执行完成后再输入" | "发送" | "您可以键入 “/” 查看更多Prompt" | "请输入" | "返回最新" | "终止生成" | "向上滚动加载更多记录" | "日" | "一" | "二" | "三" | "四" | "五" | "六" | "昨天" | "本周" | "上周";
|
package/dist/types/index.d.ts
CHANGED
package/dist/util/index.d.ts
CHANGED
|
@@ -9,3 +9,10 @@ export declare const getCookieByName: (name: string) => string;
|
|
|
9
9
|
* @returns
|
|
10
10
|
*/
|
|
11
11
|
export declare const isJSON: (str: string) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* 节流,每隔一段时间执行
|
|
14
|
+
* @param {*} fn 需要执行的函数
|
|
15
|
+
* @param {*} delay 延迟时间,默认200
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
export declare const throttle: <T>(fn: (t: T) => void, delay?: number) => (t: T) => false | undefined;
|