@blueking/ai-blueking 0.0.0
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 +116 -0
- package/dist/ai-blueking.vue.d.ts +43 -0
- package/dist/components/render-content.vue.d.ts +44 -0
- package/dist/components/render-message.vue.d.ts +32 -0
- package/dist/components/render-modal.vue.d.ts +74 -0
- package/dist/components/render-send.vue.d.ts +26 -0
- package/dist/lang/index.d.ts +12 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/util/index.d.ts +5 -0
- package/dist/vue2/config.json +1 -0
- package/dist/vue2/index.es.min.js +17137 -0
- package/dist/vue2/index.iife.min.js +88 -0
- package/dist/vue2/index.umd.min.js +68 -0
- package/dist/vue2/style.css +1 -0
- package/dist/vue2.d.ts +2 -0
- package/dist/vue3/config.json +1 -0
- package/dist/vue3/index.es.min.js +5553 -0
- package/dist/vue3/index.iife.min.js +69 -0
- package/dist/vue3/index.umd.min.js +18 -0
- package/dist/vue3/style.css +1 -0
- package/dist/vue3.d.ts +27 -0
- package/package.json +59 -0
package/README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
## AI 小鲸业务组件
|
|
2
|
+
|
|
3
|
+
#### 安装
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm i @blueking/ai-blueking
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
#### 使用
|
|
10
|
+
|
|
11
|
+
- vue3框架下使用
|
|
12
|
+
|
|
13
|
+
```vue
|
|
14
|
+
<template>
|
|
15
|
+
<div class="app">
|
|
16
|
+
<AIBlueking
|
|
17
|
+
:background="background"
|
|
18
|
+
:head-background="headBackground"
|
|
19
|
+
:loading="loading"
|
|
20
|
+
:messages="messages"
|
|
21
|
+
:position-limit="positionLimit"
|
|
22
|
+
:prompts="prompts"
|
|
23
|
+
:size-limit="sizeLimit"
|
|
24
|
+
@choose-prompt="handleChoosePrompt"
|
|
25
|
+
@clear="handleClear"
|
|
26
|
+
@close="handleClose"
|
|
27
|
+
@send="handleSend"
|
|
28
|
+
/>
|
|
29
|
+
</div>
|
|
30
|
+
</template>
|
|
31
|
+
<script setup lang="ts">
|
|
32
|
+
import { ref } from 'vue';
|
|
33
|
+
|
|
34
|
+
import AIBlueking from '@blueking/ai-blueking';
|
|
35
|
+
|
|
36
|
+
// 展示的消息
|
|
37
|
+
const messages = [
|
|
38
|
+
{
|
|
39
|
+
content: '你好呀',
|
|
40
|
+
type: 'ai',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
content: '1+1=?',
|
|
44
|
+
type: 'user',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
content: '1+1=3',
|
|
48
|
+
type: 'ai',
|
|
49
|
+
status: 'error',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
content: '不对',
|
|
53
|
+
type: 'user',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
content: '1+1=2',
|
|
57
|
+
type: 'ai',
|
|
58
|
+
status: 'loading',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
content: '对了',
|
|
62
|
+
type: 'user',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
content: '好的,任务已完成',
|
|
66
|
+
type: 'ai',
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
// 内置 prompt
|
|
70
|
+
const prompts = [
|
|
71
|
+
{
|
|
72
|
+
id: 1,
|
|
73
|
+
content: '帮我计算1+1的结果',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: 2,
|
|
77
|
+
content: '帮我计算2+2的结果',
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
// 处理ai消息的loading状态
|
|
82
|
+
const loading = ref(false);
|
|
83
|
+
// 聊天背景色
|
|
84
|
+
const background = '#f5f7fa';
|
|
85
|
+
// 头部背景色
|
|
86
|
+
const headBackground = 'linear-gradient(267deg, #2dd1f4 0%, #1482ff 95%)';
|
|
87
|
+
// 弹框位于屏幕四边的最小距离
|
|
88
|
+
const positionLimit = {
|
|
89
|
+
top: 0,
|
|
90
|
+
bottom: 0,
|
|
91
|
+
left: 0,
|
|
92
|
+
right: 0,
|
|
93
|
+
};
|
|
94
|
+
// 组件最小尺寸
|
|
95
|
+
const sizeLimit = {
|
|
96
|
+
height: 500,
|
|
97
|
+
width: 294,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const handleClear = () => {
|
|
101
|
+
console.log('trigger clear');
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const handleSend = (val: string) => {
|
|
105
|
+
console.log('trigger send', val);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const handleClose = () => {
|
|
109
|
+
console.log('trigger close');
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const handleChoosePrompt = prompt => {
|
|
113
|
+
console.log('choose prompt', prompt);
|
|
114
|
+
};
|
|
115
|
+
</script>
|
|
116
|
+
```
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { IMessage, IPrompt, IPositionLimit, ISizeLimit } from './types';
|
|
2
|
+
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<{
|
|
3
|
+
messages: IMessage[];
|
|
4
|
+
prompts?: IPrompt[] | undefined;
|
|
5
|
+
loading?: boolean | undefined;
|
|
6
|
+
headBackground?: string | undefined;
|
|
7
|
+
background?: string | undefined;
|
|
8
|
+
positionLimit?: IPositionLimit | undefined;
|
|
9
|
+
sizeLimit?: ISizeLimit | undefined;
|
|
10
|
+
userPhoto?: string | undefined;
|
|
11
|
+
logo?: string | undefined;
|
|
12
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
13
|
+
close: () => void;
|
|
14
|
+
clear: () => void;
|
|
15
|
+
send: (val: string) => void;
|
|
16
|
+
"choose-prompt": (prompt: IPrompt) => void;
|
|
17
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<{
|
|
18
|
+
messages: IMessage[];
|
|
19
|
+
prompts?: IPrompt[] | undefined;
|
|
20
|
+
loading?: boolean | undefined;
|
|
21
|
+
headBackground?: string | undefined;
|
|
22
|
+
background?: string | undefined;
|
|
23
|
+
positionLimit?: IPositionLimit | undefined;
|
|
24
|
+
sizeLimit?: ISizeLimit | undefined;
|
|
25
|
+
userPhoto?: string | undefined;
|
|
26
|
+
logo?: string | undefined;
|
|
27
|
+
}>>> & {
|
|
28
|
+
"onChoose-prompt"?: ((prompt: IPrompt) => any) | undefined;
|
|
29
|
+
onClear?: (() => any) | undefined;
|
|
30
|
+
onSend?: ((val: string) => any) | undefined;
|
|
31
|
+
onClose?: (() => any) | undefined;
|
|
32
|
+
}, {}, {}>;
|
|
33
|
+
export default _default;
|
|
34
|
+
|
|
35
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
36
|
+
type __VLS_TypePropsToOption<T> = {
|
|
37
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
38
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
39
|
+
} : {
|
|
40
|
+
type: import('vue').PropType<T[K]>;
|
|
41
|
+
required: true;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { IMessage, IPrompt } from '../types/index';
|
|
2
|
+
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<{
|
|
3
|
+
messages: IMessage[];
|
|
4
|
+
prompts?: IPrompt[] | undefined;
|
|
5
|
+
loading?: boolean | undefined;
|
|
6
|
+
background?: string | undefined;
|
|
7
|
+
userPhoto?: string | undefined;
|
|
8
|
+
}>, {
|
|
9
|
+
background: string;
|
|
10
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
11
|
+
send: (userInput: string) => void;
|
|
12
|
+
"choose-prompt": (prompt: IPrompt) => void;
|
|
13
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<{
|
|
14
|
+
messages: IMessage[];
|
|
15
|
+
prompts?: IPrompt[] | undefined;
|
|
16
|
+
loading?: boolean | undefined;
|
|
17
|
+
background?: string | undefined;
|
|
18
|
+
userPhoto?: string | undefined;
|
|
19
|
+
}>, {
|
|
20
|
+
background: string;
|
|
21
|
+
}>>> & {
|
|
22
|
+
"onChoose-prompt"?: ((prompt: IPrompt) => any) | undefined;
|
|
23
|
+
onSend?: ((userInput: string) => any) | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
background: string;
|
|
26
|
+
}, {}>;
|
|
27
|
+
export default _default;
|
|
28
|
+
type __VLS_WithDefaults<P, D> = {
|
|
29
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
30
|
+
default: D[K];
|
|
31
|
+
}> : P[K];
|
|
32
|
+
};
|
|
33
|
+
type __VLS_Prettify<T> = {
|
|
34
|
+
[K in keyof T]: T[K];
|
|
35
|
+
} & {};
|
|
36
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
37
|
+
type __VLS_TypePropsToOption<T> = {
|
|
38
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
39
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
40
|
+
} : {
|
|
41
|
+
type: import('vue').PropType<T[K]>;
|
|
42
|
+
required: true;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { IMessage } from '../types';
|
|
2
|
+
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<{
|
|
3
|
+
message: IMessage;
|
|
4
|
+
userPhoto?: string | undefined;
|
|
5
|
+
}>, {
|
|
6
|
+
userPhoto: string;
|
|
7
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<{
|
|
8
|
+
message: IMessage;
|
|
9
|
+
userPhoto?: string | undefined;
|
|
10
|
+
}>, {
|
|
11
|
+
userPhoto: string;
|
|
12
|
+
}>>>, {
|
|
13
|
+
userPhoto: string;
|
|
14
|
+
}, {}>;
|
|
15
|
+
export default _default;
|
|
16
|
+
type __VLS_WithDefaults<P, D> = {
|
|
17
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
18
|
+
default: D[K];
|
|
19
|
+
}> : P[K];
|
|
20
|
+
};
|
|
21
|
+
type __VLS_Prettify<T> = {
|
|
22
|
+
[K in keyof T]: T[K];
|
|
23
|
+
} & {};
|
|
24
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
25
|
+
type __VLS_TypePropsToOption<T> = {
|
|
26
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
27
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
28
|
+
} : {
|
|
29
|
+
type: import('vue').PropType<T[K]>;
|
|
30
|
+
required: true;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { IPositionLimit, ISizeLimit } from '../types';
|
|
2
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<{
|
|
3
|
+
headBackground: string;
|
|
4
|
+
positionLimit?: IPositionLimit | undefined;
|
|
5
|
+
sizeLimit?: ISizeLimit | undefined;
|
|
6
|
+
logo?: string | undefined;
|
|
7
|
+
}>, {
|
|
8
|
+
headBackground: string;
|
|
9
|
+
positionLimit: () => {
|
|
10
|
+
top: number;
|
|
11
|
+
bottom: number;
|
|
12
|
+
left: number;
|
|
13
|
+
right: number;
|
|
14
|
+
};
|
|
15
|
+
sizeLimit: () => {
|
|
16
|
+
height: number;
|
|
17
|
+
width: number;
|
|
18
|
+
};
|
|
19
|
+
logo: string;
|
|
20
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
21
|
+
close: () => void;
|
|
22
|
+
clear: () => void;
|
|
23
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<{
|
|
24
|
+
headBackground: string;
|
|
25
|
+
positionLimit?: IPositionLimit | undefined;
|
|
26
|
+
sizeLimit?: ISizeLimit | undefined;
|
|
27
|
+
logo?: string | undefined;
|
|
28
|
+
}>, {
|
|
29
|
+
headBackground: string;
|
|
30
|
+
positionLimit: () => {
|
|
31
|
+
top: number;
|
|
32
|
+
bottom: number;
|
|
33
|
+
left: number;
|
|
34
|
+
right: number;
|
|
35
|
+
};
|
|
36
|
+
sizeLimit: () => {
|
|
37
|
+
height: number;
|
|
38
|
+
width: number;
|
|
39
|
+
};
|
|
40
|
+
logo: string;
|
|
41
|
+
}>>> & {
|
|
42
|
+
onClear?: (() => any) | undefined;
|
|
43
|
+
onClose?: (() => any) | undefined;
|
|
44
|
+
}, {
|
|
45
|
+
headBackground: string;
|
|
46
|
+
positionLimit: IPositionLimit;
|
|
47
|
+
sizeLimit: ISizeLimit;
|
|
48
|
+
logo: string;
|
|
49
|
+
}, {}>, {
|
|
50
|
+
default?(_: {}): any;
|
|
51
|
+
}>;
|
|
52
|
+
export default _default;
|
|
53
|
+
type __VLS_WithDefaults<P, D> = {
|
|
54
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
55
|
+
default: D[K];
|
|
56
|
+
}> : P[K];
|
|
57
|
+
};
|
|
58
|
+
type __VLS_Prettify<T> = {
|
|
59
|
+
[K in keyof T]: T[K];
|
|
60
|
+
} & {};
|
|
61
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
62
|
+
new (): {
|
|
63
|
+
$slots: S;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
67
|
+
type __VLS_TypePropsToOption<T> = {
|
|
68
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
69
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
70
|
+
} : {
|
|
71
|
+
type: import('vue').PropType<T[K]>;
|
|
72
|
+
required: true;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { IPrompt } from '../types';
|
|
2
|
+
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<{
|
|
3
|
+
prompts?: IPrompt[] | undefined;
|
|
4
|
+
value: string;
|
|
5
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
|
+
"update:value": (val: string) => void;
|
|
7
|
+
enter: () => void;
|
|
8
|
+
"choose-prompt": (prompt: IPrompt) => void;
|
|
9
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<{
|
|
10
|
+
prompts?: IPrompt[] | undefined;
|
|
11
|
+
value: string;
|
|
12
|
+
}>>> & {
|
|
13
|
+
"onUpdate:value"?: ((val: string) => any) | undefined;
|
|
14
|
+
onEnter?: (() => any) | undefined;
|
|
15
|
+
"onChoose-prompt"?: ((prompt: IPrompt) => any) | undefined;
|
|
16
|
+
}, {}, {}>;
|
|
17
|
+
export default _default;
|
|
18
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
19
|
+
type __VLS_TypePropsToOption<T> = {
|
|
20
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
21
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
22
|
+
} : {
|
|
23
|
+
type: import('vue').PropType<T[K]>;
|
|
24
|
+
required: true;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const lang: string;
|
|
2
|
+
export declare const langData: {
|
|
3
|
+
readonly 小鲸: "BK GPT";
|
|
4
|
+
readonly 向下收缩: "shrink down";
|
|
5
|
+
readonly 向上扩展: "expand upward";
|
|
6
|
+
readonly 清空聊天记录: "Empty chat records";
|
|
7
|
+
readonly 关闭: "close";
|
|
8
|
+
readonly '\u5185\u5BB9\u6B63\u5728\u6267\u884C\u4E2D\uFF0C\u8BF7\u6267\u884C\u5B8C\u6210\u540E\u518D\u8F93\u5165': "The content is being executed, please enter it again after the execution is completed.";
|
|
9
|
+
readonly 发送: "Send";
|
|
10
|
+
readonly '\u60A8\u53EF\u4EE5\u952E\u5165 \u201C/\u201D \u67E5\u770B\u66F4\u591APrompt': "You can type \"/\" to see more Prompts";
|
|
11
|
+
};
|
|
12
|
+
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" | "小鲸" | "向下收缩" | "向上扩展" | "清空聊天记录" | "关闭" | "内容正在执行中,请执行完成后再输入" | "发送" | "您可以键入 “/” 查看更多Prompt";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface IMessage {
|
|
2
|
+
content: string;
|
|
3
|
+
type: 'ai' | 'user';
|
|
4
|
+
status?: 'error' | 'loading';
|
|
5
|
+
}
|
|
6
|
+
export interface IPrompt {
|
|
7
|
+
id: number | string;
|
|
8
|
+
content: string;
|
|
9
|
+
}
|
|
10
|
+
export interface IPositionLimit {
|
|
11
|
+
top: number;
|
|
12
|
+
bottom: number;
|
|
13
|
+
left: number;
|
|
14
|
+
right: number;
|
|
15
|
+
}
|
|
16
|
+
export interface ISizeLimit {
|
|
17
|
+
height: number;
|
|
18
|
+
width: number;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"ai-blueking","name":"ai-blueking","displayName":"AI 小鲸","framework":"vue2","props":{"messages":{"type":"array","tips":"聊天框展示的内容"},"prompts":{"type":"array","tips":"快捷prompt列表"},"loading":{"type":"boolean","tips":"处理 ai 消息的loading状态"},"headBackground":{"type":"string","tips":"头部背景色"},"background":{"type":"string","tips":"背景色"},"positionLimit":{"type":"object","val":{"top":0,"bottom":0,"left":0,"right":0},"tips":"位置范围限制"},"sizeLimit":{"type":"object","val":{"height":500,"width":294},"tips":"大小限制"},"userPhoto":{"type":"string","tips":"用户头像地址"},"logo":{"type":"string","tips":"icon class"}},"events":[{"name":"clear","tips":"点击清空事件"},{"name":"close","tips":"点击关闭事件"},{"name":"send","tips":"点击发送事件"},{"name":"choose-prompt","tips":"选择prompt事件"}]}
|