@kernelift/ai-chat 1.0.1-beta.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 +711 -0
- package/SSE-Client.md +451 -0
- package/dist/ai-chat.css +10 -0
- package/dist/index.d.ts +361 -0
- package/dist/index.js +137813 -0
- package/dist/markdown-D2pK0c45-D2pK0c45.js +235 -0
- package/package.json +52 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import { ComponentOptionsMixin } from 'vue';
|
|
2
|
+
import { ComponentProvideOptions } from 'vue';
|
|
3
|
+
import { DefineComponent } from 'vue';
|
|
4
|
+
import { PublicProps } from 'vue';
|
|
5
|
+
|
|
6
|
+
declare const __VLS_component: DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
7
|
+
"update:modelValue": (value: ChatMessage) => any;
|
|
8
|
+
} & {
|
|
9
|
+
"bubble-event": (eventName: BubbleEvent, data: ChatMessage) => any;
|
|
10
|
+
}, string, PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
11
|
+
"onBubble-event"?: ((eventName: BubbleEvent, data: ChatMessage) => any) | undefined;
|
|
12
|
+
"onUpdate:modelValue"?: ((value: ChatMessage) => any) | undefined;
|
|
13
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
14
|
+
|
|
15
|
+
declare const __VLS_component_2: DefineComponent<__VLS_PublicProps_2, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
16
|
+
"update:modelValue": (value: string) => any;
|
|
17
|
+
"update:messages": (value: ChatMessage[]) => any;
|
|
18
|
+
"update:loading": (value: boolean) => any;
|
|
19
|
+
} & {
|
|
20
|
+
"bubble-event": (eventName: BubbleEvent, data: ChatMessage) => any;
|
|
21
|
+
"change-collapse": (collapse: boolean) => any;
|
|
22
|
+
"change-theme": (themeMode: "light" | "dark") => any;
|
|
23
|
+
"click-logo": () => any;
|
|
24
|
+
send: (value: string) => any;
|
|
25
|
+
"change-record": (value?: ChatRecord | undefined) => any;
|
|
26
|
+
"change-aside-width": (width: number) => any;
|
|
27
|
+
"close-workspace": () => any;
|
|
28
|
+
}, string, PublicProps, Readonly<__VLS_PublicProps_2> & Readonly<{
|
|
29
|
+
"onBubble-event"?: ((eventName: BubbleEvent, data: ChatMessage) => any) | undefined;
|
|
30
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
31
|
+
"onChange-collapse"?: ((collapse: boolean) => any) | undefined;
|
|
32
|
+
"onChange-theme"?: ((themeMode: "light" | "dark") => any) | undefined;
|
|
33
|
+
"onClick-logo"?: (() => any) | undefined;
|
|
34
|
+
onSend?: ((value: string) => any) | undefined;
|
|
35
|
+
"onChange-record"?: ((value?: ChatRecord | undefined) => any) | undefined;
|
|
36
|
+
"onChange-aside-width"?: ((width: number) => any) | undefined;
|
|
37
|
+
"onClose-workspace"?: (() => any) | undefined;
|
|
38
|
+
"onUpdate:messages"?: ((value: ChatMessage[]) => any) | undefined;
|
|
39
|
+
"onUpdate:loading"?: ((value: boolean) => any) | undefined;
|
|
40
|
+
}>, {
|
|
41
|
+
themeMode: "light" | "dark";
|
|
42
|
+
hasThemeMode: boolean;
|
|
43
|
+
records: ChatRecord[];
|
|
44
|
+
hasHeader: boolean;
|
|
45
|
+
hasSenderTools: boolean;
|
|
46
|
+
showWorkspace: boolean;
|
|
47
|
+
defaultCollapse: boolean;
|
|
48
|
+
defaultAsideWidth: number;
|
|
49
|
+
primaryColor: string;
|
|
50
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
51
|
+
|
|
52
|
+
declare const __VLS_component_3: DefineComponent<__VLS_PublicProps_3, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
53
|
+
"update:modelValue": (value: string) => any;
|
|
54
|
+
} & {
|
|
55
|
+
send: (text: string) => any;
|
|
56
|
+
}, string, PublicProps, Readonly<__VLS_PublicProps_3> & Readonly<{
|
|
57
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
58
|
+
onSend?: ((text: string) => any) | undefined;
|
|
59
|
+
}>, {
|
|
60
|
+
loading: boolean;
|
|
61
|
+
hasThinking: boolean;
|
|
62
|
+
hasNetSearch: boolean;
|
|
63
|
+
}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
64
|
+
|
|
65
|
+
declare const __VLS_component_4: DefineComponent<__VLS_PublicProps_4, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {
|
|
66
|
+
"update:collapse": (value: boolean) => any;
|
|
67
|
+
}, string, PublicProps, Readonly<__VLS_PublicProps_4> & Readonly<{
|
|
68
|
+
"onUpdate:collapse"?: ((value: boolean) => any) | undefined;
|
|
69
|
+
}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
70
|
+
|
|
71
|
+
declare type __VLS_Props = {
|
|
72
|
+
isLast?: boolean;
|
|
73
|
+
markdownClass?: string;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
declare type __VLS_Props_2 = {
|
|
77
|
+
records?: ChatRecord[];
|
|
78
|
+
hasHeader?: boolean;
|
|
79
|
+
hasThemeMode?: boolean;
|
|
80
|
+
hasSenderTools?: boolean;
|
|
81
|
+
showWorkspace?: boolean;
|
|
82
|
+
isGenerateLoading?: boolean;
|
|
83
|
+
defaultRecordId?: string;
|
|
84
|
+
defaultCollapse?: boolean;
|
|
85
|
+
defaultAsideWidth?: number;
|
|
86
|
+
markdownClassName?: string;
|
|
87
|
+
primaryColor?: string;
|
|
88
|
+
themeMode?: 'light' | 'dark';
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
declare type __VLS_Props_3 = {
|
|
92
|
+
record?: ChatRecord | null;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
declare type __VLS_Props_4 = {
|
|
96
|
+
loading?: boolean;
|
|
97
|
+
hasThinking?: boolean;
|
|
98
|
+
hasNetSearch?: boolean;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
declare type __VLS_Props_5 = {
|
|
102
|
+
data: string;
|
|
103
|
+
markdownClass?: string;
|
|
104
|
+
loading?: boolean;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
declare type __VLS_PublicProps = {
|
|
108
|
+
modelValue: ChatMessage;
|
|
109
|
+
} & __VLS_Props;
|
|
110
|
+
|
|
111
|
+
declare type __VLS_PublicProps_2 = {
|
|
112
|
+
'messages': ChatMessage[];
|
|
113
|
+
modelValue?: string;
|
|
114
|
+
'loading'?: boolean;
|
|
115
|
+
} & __VLS_Props_2;
|
|
116
|
+
|
|
117
|
+
declare type __VLS_PublicProps_3 = {
|
|
118
|
+
modelValue?: string;
|
|
119
|
+
} & __VLS_Props_4;
|
|
120
|
+
|
|
121
|
+
declare type __VLS_PublicProps_4 = {
|
|
122
|
+
'collapse'?: boolean;
|
|
123
|
+
} & __VLS_Props_5;
|
|
124
|
+
|
|
125
|
+
declare function __VLS_template(): {
|
|
126
|
+
attrs: Partial<{}>;
|
|
127
|
+
slots: {
|
|
128
|
+
header?(_: {}): any;
|
|
129
|
+
'thinking-header'?(_: {}): any;
|
|
130
|
+
content?(_: {}): any;
|
|
131
|
+
'content-footer'?(_: {}): any;
|
|
132
|
+
footer?(_: {}): any;
|
|
133
|
+
'bubble-event'?(_: {}): any;
|
|
134
|
+
};
|
|
135
|
+
refs: {};
|
|
136
|
+
rootEl: HTMLDivElement;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
declare function __VLS_template_2(): {
|
|
140
|
+
attrs: Partial<{}>;
|
|
141
|
+
slots: {
|
|
142
|
+
aside?(_: {}): any;
|
|
143
|
+
aside?(_: {
|
|
144
|
+
record: ChatRecord | null | undefined;
|
|
145
|
+
}): any;
|
|
146
|
+
logo?(_: {}): any;
|
|
147
|
+
header?(_: {
|
|
148
|
+
record: ChatRecord | null | undefined;
|
|
149
|
+
}): any;
|
|
150
|
+
'header-logo'?(_: {}): any;
|
|
151
|
+
'bubble-header'?(_: {
|
|
152
|
+
data: ChatMessage;
|
|
153
|
+
}): any;
|
|
154
|
+
'bubble-footer'?(_: {
|
|
155
|
+
data: ChatMessage;
|
|
156
|
+
}): any;
|
|
157
|
+
'bubble-event'?(_: {
|
|
158
|
+
data: ChatMessage;
|
|
159
|
+
}): any;
|
|
160
|
+
'bubble-content-footer'?(_: {
|
|
161
|
+
data: ChatMessage;
|
|
162
|
+
}): any;
|
|
163
|
+
'bubble-thinking-header'?(_: {
|
|
164
|
+
data: ChatMessage;
|
|
165
|
+
}): any;
|
|
166
|
+
'bubble-loading-content'?(_: {}): any;
|
|
167
|
+
'sender-tools'?(_: {}): any;
|
|
168
|
+
'sender-footer-tools'?(_: {
|
|
169
|
+
value: string;
|
|
170
|
+
loading: boolean;
|
|
171
|
+
}): any;
|
|
172
|
+
footer?(_: {}): any;
|
|
173
|
+
workspace?(_: {
|
|
174
|
+
record: ChatRecord | null | undefined;
|
|
175
|
+
}): any;
|
|
176
|
+
};
|
|
177
|
+
refs: {};
|
|
178
|
+
rootEl: HTMLDivElement;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
declare function __VLS_template_3(): {
|
|
182
|
+
attrs: Partial<{}>;
|
|
183
|
+
slots: {
|
|
184
|
+
tools?(_: {
|
|
185
|
+
value: string;
|
|
186
|
+
loading: boolean;
|
|
187
|
+
}): any;
|
|
188
|
+
};
|
|
189
|
+
refs: {};
|
|
190
|
+
rootEl: HTMLDivElement;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
declare function __VLS_template_4(): {
|
|
194
|
+
attrs: Partial<{}>;
|
|
195
|
+
slots: {
|
|
196
|
+
header?(_: {}): any;
|
|
197
|
+
};
|
|
198
|
+
refs: {};
|
|
199
|
+
rootEl: HTMLDivElement;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
declare type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
203
|
+
|
|
204
|
+
declare type __VLS_TemplateResult_2 = ReturnType<typeof __VLS_template_2>;
|
|
205
|
+
|
|
206
|
+
declare type __VLS_TemplateResult_3 = ReturnType<typeof __VLS_template_3>;
|
|
207
|
+
|
|
208
|
+
declare type __VLS_TemplateResult_4 = ReturnType<typeof __VLS_template_4>;
|
|
209
|
+
|
|
210
|
+
declare type __VLS_WithTemplateSlots<T, S> = T & {
|
|
211
|
+
new (): {
|
|
212
|
+
$slots: S;
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
declare type __VLS_WithTemplateSlots_2<T, S> = T & {
|
|
217
|
+
new (): {
|
|
218
|
+
$slots: S;
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
declare type __VLS_WithTemplateSlots_3<T, S> = T & {
|
|
223
|
+
new (): {
|
|
224
|
+
$slots: S;
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
declare type __VLS_WithTemplateSlots_4<T, S> = T & {
|
|
229
|
+
new (): {
|
|
230
|
+
$slots: S;
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
declare type BubbleEvent = 'like' | 'dislike' | 'bookmark' | 'terminate' | 'reload' | 'copy';
|
|
235
|
+
|
|
236
|
+
export declare const ChatBubble: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
237
|
+
|
|
238
|
+
export declare const ChatContainer: __VLS_WithTemplateSlots_2<typeof __VLS_component_2, __VLS_TemplateResult_2["slots"]>;
|
|
239
|
+
|
|
240
|
+
export declare const ChatHeader: DefineComponent<__VLS_Props_3, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props_3> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* @description 聊天消息
|
|
244
|
+
*/
|
|
245
|
+
export declare interface ChatMessage {
|
|
246
|
+
/**
|
|
247
|
+
* 消息id
|
|
248
|
+
*/
|
|
249
|
+
id: string;
|
|
250
|
+
/**
|
|
251
|
+
* 角色
|
|
252
|
+
*/
|
|
253
|
+
role: 'user' | 'assistant' | 'system';
|
|
254
|
+
/**
|
|
255
|
+
* 内容
|
|
256
|
+
*/
|
|
257
|
+
content: string;
|
|
258
|
+
/**
|
|
259
|
+
* 是否正在加载
|
|
260
|
+
*/
|
|
261
|
+
loading?: boolean;
|
|
262
|
+
/**
|
|
263
|
+
* 是否正在思考
|
|
264
|
+
*/
|
|
265
|
+
isThinking?: boolean;
|
|
266
|
+
/**
|
|
267
|
+
* 思考是否折叠
|
|
268
|
+
*/
|
|
269
|
+
thoughtCollapse?: boolean;
|
|
270
|
+
/**
|
|
271
|
+
* 思考过程
|
|
272
|
+
*/
|
|
273
|
+
thoughtProcess?: string;
|
|
274
|
+
/**
|
|
275
|
+
* 创建时间
|
|
276
|
+
*/
|
|
277
|
+
timestamp: number;
|
|
278
|
+
/**
|
|
279
|
+
* 是否终止
|
|
280
|
+
*/
|
|
281
|
+
isTerminated?: boolean;
|
|
282
|
+
/**
|
|
283
|
+
* 是否点赞
|
|
284
|
+
*/
|
|
285
|
+
isLiked?: boolean;
|
|
286
|
+
/**
|
|
287
|
+
* 是否踩
|
|
288
|
+
*/
|
|
289
|
+
isDisliked?: boolean;
|
|
290
|
+
/**
|
|
291
|
+
* 是否错误
|
|
292
|
+
*/
|
|
293
|
+
isError?: boolean;
|
|
294
|
+
/**
|
|
295
|
+
* 错误信息
|
|
296
|
+
*/
|
|
297
|
+
error?: string;
|
|
298
|
+
/**
|
|
299
|
+
* 是否收藏
|
|
300
|
+
*/
|
|
301
|
+
isBookmarked?: boolean;
|
|
302
|
+
/**
|
|
303
|
+
* 下一步提示
|
|
304
|
+
*/
|
|
305
|
+
nextTips?: string[];
|
|
306
|
+
/**
|
|
307
|
+
* 工具调用
|
|
308
|
+
*/
|
|
309
|
+
toolCalls?: any[];
|
|
310
|
+
/**
|
|
311
|
+
* 额外的数据
|
|
312
|
+
*/
|
|
313
|
+
extraData?: {
|
|
314
|
+
[key: string]: any;
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* @description ai聊天历史记录
|
|
320
|
+
*/
|
|
321
|
+
export declare interface ChatRecord {
|
|
322
|
+
id: string;
|
|
323
|
+
name: string;
|
|
324
|
+
content: string;
|
|
325
|
+
type: string;
|
|
326
|
+
createTime: string;
|
|
327
|
+
userId: string;
|
|
328
|
+
updateTime?: string;
|
|
329
|
+
extraData?: {
|
|
330
|
+
[key: string]: any;
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export declare const ChatSender: __VLS_WithTemplateSlots_3<typeof __VLS_component_3, __VLS_TemplateResult_3["slots"]>;
|
|
335
|
+
|
|
336
|
+
export declare class SSEClient {
|
|
337
|
+
private controller;
|
|
338
|
+
private buffer;
|
|
339
|
+
private token;
|
|
340
|
+
private baseUrl;
|
|
341
|
+
constructor(token: string, baseUrl: string);
|
|
342
|
+
connect(url: string, handlers: {
|
|
343
|
+
onContent: (content: string) => void;
|
|
344
|
+
onToolCallDelta: (data: any) => void;
|
|
345
|
+
onComplete: (finalData: {
|
|
346
|
+
content: string;
|
|
347
|
+
toolCalls: any[];
|
|
348
|
+
}) => void;
|
|
349
|
+
onError: (error: Error) => void;
|
|
350
|
+
onDone?: () => void;
|
|
351
|
+
}, options?: RequestInit): Promise<void>;
|
|
352
|
+
private processBuffer;
|
|
353
|
+
private handleRemainingBuffer;
|
|
354
|
+
private parseEvent;
|
|
355
|
+
private dispatchEvent;
|
|
356
|
+
disconnect(): void;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export declare const ThinkingProcess: __VLS_WithTemplateSlots_4<typeof __VLS_component_4, __VLS_TemplateResult_4["slots"]>;
|
|
360
|
+
|
|
361
|
+
export { }
|