langchat-widget 0.1.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 +0 -0
- package/dist/favicon.ico +0 -0
- package/dist/index.d.ts +635 -0
- package/dist/langchat-widget.css +1 -0
- package/dist/langchat-widget.es.js +22094 -0
- package/dist/langchat-widget.es.js.map +1 -0
- package/dist/langchat-widget.umd.js +25 -0
- package/dist/langchat-widget.umd.js.map +1 -0
- package/package.json +80 -0
package/README.md
ADDED
|
File without changes
|
package/dist/favicon.ico
ADDED
|
Binary file
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,635 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import { ComputedRef } from 'vue';
|
|
3
|
+
|
|
4
|
+
export declare interface AvatarConfig {
|
|
5
|
+
ai?: string;
|
|
6
|
+
user?: string;
|
|
7
|
+
size?: number;
|
|
8
|
+
borderRadius?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export declare interface BackendAPI {
|
|
12
|
+
getSuggestedQuestions: (context: string) => Promise<QuestionItem[]>;
|
|
13
|
+
getWelcomeMessage: () => Promise<WelcomeData>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export declare interface ChatMessage {
|
|
17
|
+
id: string;
|
|
18
|
+
type: 'ai' | 'questions' | 'user' | 'welcome';
|
|
19
|
+
content: string;
|
|
20
|
+
timestamp: Date;
|
|
21
|
+
status?: 'error' | 'sending' | 'sent' | 'streaming';
|
|
22
|
+
error?: string;
|
|
23
|
+
isStreaming?: boolean;
|
|
24
|
+
streamContent?: string;
|
|
25
|
+
questions?: QuestionItem[];
|
|
26
|
+
welcomeData?: WelcomeData;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export declare interface ChatRequest {
|
|
30
|
+
messages: Array<{
|
|
31
|
+
content: string;
|
|
32
|
+
role: 'assistant' | 'system' | 'user';
|
|
33
|
+
}>;
|
|
34
|
+
model?: string;
|
|
35
|
+
temperature?: number;
|
|
36
|
+
maxTokens?: number;
|
|
37
|
+
stream?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export declare interface ChatResponse {
|
|
41
|
+
id: string;
|
|
42
|
+
object: string;
|
|
43
|
+
created: number;
|
|
44
|
+
model: string;
|
|
45
|
+
choices: Array<{
|
|
46
|
+
finishReason: string;
|
|
47
|
+
index: number;
|
|
48
|
+
message: {
|
|
49
|
+
content: string;
|
|
50
|
+
role: string;
|
|
51
|
+
};
|
|
52
|
+
}>;
|
|
53
|
+
usage: {
|
|
54
|
+
completionTokens: number;
|
|
55
|
+
promptTokens: number;
|
|
56
|
+
totalTokens: number;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export declare interface ChatSession {
|
|
61
|
+
id: string;
|
|
62
|
+
messages: ChatMessage[];
|
|
63
|
+
createdAt: Date;
|
|
64
|
+
updatedAt: Date;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export declare interface CopyrightConfig {
|
|
68
|
+
text?: string;
|
|
69
|
+
link?: string;
|
|
70
|
+
linkText?: string;
|
|
71
|
+
className?: string;
|
|
72
|
+
backgroundColor?: string;
|
|
73
|
+
textColor?: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export declare function createErrorHandler(config?: Partial<ErrorHandlerConfig>): ErrorHandler;
|
|
77
|
+
|
|
78
|
+
export declare function createMessageStore(options?: {
|
|
79
|
+
maxHistoryItems?: number;
|
|
80
|
+
enableHistory?: boolean;
|
|
81
|
+
}): MessageStore;
|
|
82
|
+
|
|
83
|
+
export declare function createOpenAIClient(config: OpenAIConfig): OpenAIClient;
|
|
84
|
+
|
|
85
|
+
export declare function createThemeManager(initialTheme?: Partial<ThemeConfig_2>): ThemeManager;
|
|
86
|
+
|
|
87
|
+
export declare type DeepPartial<T> = {
|
|
88
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export declare const DEFAULT_CONFIG: Required<LangChatConfig>;
|
|
92
|
+
|
|
93
|
+
declare class ErrorHandler {
|
|
94
|
+
private config;
|
|
95
|
+
private errorHistory;
|
|
96
|
+
private retryQueue;
|
|
97
|
+
constructor(config?: Partial<ErrorHandlerConfig>);
|
|
98
|
+
handleError(error: any, context?: Record<string, any>): ErrorInfo;
|
|
99
|
+
private createErrorInfo;
|
|
100
|
+
private scheduleRetry;
|
|
101
|
+
private executeRetry;
|
|
102
|
+
private logError;
|
|
103
|
+
private getLogLevel;
|
|
104
|
+
getErrorHistory(): ErrorInfo[];
|
|
105
|
+
getErrorsByType(type: ErrorType): ErrorInfo[];
|
|
106
|
+
getErrorsBySeverity(severity: ErrorSeverity): ErrorInfo[];
|
|
107
|
+
getRetryableErrors(): ErrorInfo[];
|
|
108
|
+
clearErrorHistory(): void;
|
|
109
|
+
cleanupOldErrors(olderThanHours?: number): number;
|
|
110
|
+
getErrorStats(): Record<string, any>;
|
|
111
|
+
updateConfig(config: Partial<ErrorHandlerConfig>): void;
|
|
112
|
+
getConfig(): ErrorHandlerConfig;
|
|
113
|
+
destroy(): void;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export declare const errorHandler: ErrorHandler;
|
|
117
|
+
|
|
118
|
+
declare interface ErrorHandlerConfig {
|
|
119
|
+
enableRetry: boolean;
|
|
120
|
+
maxRetries: number;
|
|
121
|
+
retryDelay: number;
|
|
122
|
+
showTechnicalDetails: boolean;
|
|
123
|
+
logErrors: boolean;
|
|
124
|
+
onError?: (error: ErrorInfo) => void;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
declare interface ErrorInfo {
|
|
128
|
+
type: ErrorType;
|
|
129
|
+
severity: ErrorSeverity;
|
|
130
|
+
code: string;
|
|
131
|
+
message: string;
|
|
132
|
+
userMessage: string;
|
|
133
|
+
technicalDetails?: string;
|
|
134
|
+
retryable: boolean;
|
|
135
|
+
retryCount?: number;
|
|
136
|
+
maxRetries?: number;
|
|
137
|
+
timestamp: Date;
|
|
138
|
+
context?: Record<string, any>;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
declare enum ErrorSeverity {
|
|
142
|
+
LOW = "LOW",
|
|
143
|
+
MEDIUM = "MEDIUM",
|
|
144
|
+
HIGH = "HIGH",
|
|
145
|
+
CRITICAL = "CRITICAL"
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
declare enum ErrorType {
|
|
149
|
+
NETWORK = "NETWORK",
|
|
150
|
+
API = "API",
|
|
151
|
+
VALIDATION = "VALIDATION",
|
|
152
|
+
AUTHENTICATION = "AUTHENTICATION",
|
|
153
|
+
RATE_LIMIT = "RATE_LIMIT",
|
|
154
|
+
TIMEOUT = "TIMEOUT",
|
|
155
|
+
UNKNOWN = "UNKNOWN"
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export declare interface HeaderConfig {
|
|
159
|
+
title?: string;
|
|
160
|
+
className?: string;
|
|
161
|
+
backgroundColor?: string;
|
|
162
|
+
textColor?: string;
|
|
163
|
+
showCloseButton?: boolean;
|
|
164
|
+
draggable?: boolean;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
declare class LangChatBot implements LangChatInstance {
|
|
168
|
+
private _isLoading;
|
|
169
|
+
private _isOpen;
|
|
170
|
+
private app;
|
|
171
|
+
private config;
|
|
172
|
+
private container;
|
|
173
|
+
private eventListeners;
|
|
174
|
+
private isInitialized;
|
|
175
|
+
private messages;
|
|
176
|
+
private openaiClient;
|
|
177
|
+
private streamingMessageId;
|
|
178
|
+
private suggestedQuestions;
|
|
179
|
+
private welcomeData;
|
|
180
|
+
constructor(config: LangChatConfig);
|
|
181
|
+
clearHistory(): void;
|
|
182
|
+
close(): void;
|
|
183
|
+
destroy(): void;
|
|
184
|
+
getConfig(): LangChatConfig;
|
|
185
|
+
getHistory(): ChatMessage[];
|
|
186
|
+
getSuggestedQuestions(context?: string): Promise<QuestionItem[]>;
|
|
187
|
+
init(): void;
|
|
188
|
+
isLoading(): boolean;
|
|
189
|
+
isOpen(): boolean;
|
|
190
|
+
off(event: LangChatEvent, callback: Function): void;
|
|
191
|
+
on(event: LangChatEvent, callback: Function): void;
|
|
192
|
+
open(): void;
|
|
193
|
+
sendMessage(content: string): Promise<void>;
|
|
194
|
+
startStreaming(messageId: string): void;
|
|
195
|
+
stopStreaming(messageId: string): void;
|
|
196
|
+
toggle(): void;
|
|
197
|
+
updateConfig(config: Partial<LangChatConfig>): void;
|
|
198
|
+
private createContainer;
|
|
199
|
+
private createVueApp;
|
|
200
|
+
private emit;
|
|
201
|
+
private generateId;
|
|
202
|
+
private initializeOpenAIClient;
|
|
203
|
+
private initializeThemeManager;
|
|
204
|
+
private initializeWelcomeAndQuestions;
|
|
205
|
+
private mergeConfig;
|
|
206
|
+
private saveToHistory;
|
|
207
|
+
private startStreamingReply;
|
|
208
|
+
private updateContainerPosition;
|
|
209
|
+
private updateOpenAIClient;
|
|
210
|
+
private updateSuggestedQuestions;
|
|
211
|
+
private validateConfig;
|
|
212
|
+
}
|
|
213
|
+
export { LangChatBot }
|
|
214
|
+
export default LangChatBot;
|
|
215
|
+
|
|
216
|
+
export declare interface LangChatConfig {
|
|
217
|
+
apiKey: string;
|
|
218
|
+
modelName: string;
|
|
219
|
+
baseUrl?: string;
|
|
220
|
+
organization?: string;
|
|
221
|
+
header?: HeaderConfig;
|
|
222
|
+
avatars?: AvatarConfig;
|
|
223
|
+
theme?: ThemeConfig;
|
|
224
|
+
messages?: MessageConfig;
|
|
225
|
+
copyright?: CopyrightConfig;
|
|
226
|
+
welcome?: WelcomeConfig;
|
|
227
|
+
questions?: QuestionItem[];
|
|
228
|
+
autoOpen?: boolean;
|
|
229
|
+
position?: 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right';
|
|
230
|
+
zIndex?: number;
|
|
231
|
+
enableMarkdown?: boolean;
|
|
232
|
+
enableHistory?: boolean;
|
|
233
|
+
maxHistoryItems?: number;
|
|
234
|
+
enableStreaming?: boolean;
|
|
235
|
+
enableAutoSuggestions?: boolean;
|
|
236
|
+
backendAPI?: BackendAPI;
|
|
237
|
+
onMessageSent?: (message: ChatMessage) => void;
|
|
238
|
+
onMessageReceived?: (message: ChatMessage) => void;
|
|
239
|
+
onStreamingUpdate?: (messageId: string, content: string) => void;
|
|
240
|
+
onError?: (error: Error) => void;
|
|
241
|
+
onOpen?: () => void;
|
|
242
|
+
onClose?: () => void;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export declare type LangChatEvent = 'close' | 'config-updated' | 'error' | 'init' | 'message-received' | 'message-sent' | 'open' | 'questions-updated' | 'streaming-update';
|
|
246
|
+
|
|
247
|
+
export declare interface LangChatInstance {
|
|
248
|
+
init(): void;
|
|
249
|
+
destroy(): void;
|
|
250
|
+
open(): void;
|
|
251
|
+
close(): void;
|
|
252
|
+
toggle(): void;
|
|
253
|
+
sendMessage(content: string): Promise<void>;
|
|
254
|
+
clearHistory(): void;
|
|
255
|
+
getHistory(): ChatMessage[];
|
|
256
|
+
startStreaming(messageId: string): void;
|
|
257
|
+
stopStreaming(messageId: string): void;
|
|
258
|
+
getSuggestedQuestions(context?: string): Promise<QuestionItem[]>;
|
|
259
|
+
updateConfig(config: Partial<LangChatConfig>): void;
|
|
260
|
+
getConfig(): LangChatConfig;
|
|
261
|
+
isOpen(): boolean;
|
|
262
|
+
isLoading(): boolean;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export declare interface MarkdownOptions {
|
|
266
|
+
html?: boolean;
|
|
267
|
+
linkify?: boolean;
|
|
268
|
+
typographer?: boolean;
|
|
269
|
+
breaks?: boolean;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export declare interface MessageConfig {
|
|
273
|
+
aiBackgroundColor?: string;
|
|
274
|
+
userBackgroundColor?: string;
|
|
275
|
+
aiTextColor?: string;
|
|
276
|
+
userTextColor?: string;
|
|
277
|
+
maxHeight?: string;
|
|
278
|
+
showTimestamp?: boolean;
|
|
279
|
+
markdownOptions?: MarkdownOptions;
|
|
280
|
+
placeholder?: string;
|
|
281
|
+
maxLength?: number;
|
|
282
|
+
showAudioButton?: boolean;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
declare class MessageStore {
|
|
286
|
+
private messages;
|
|
287
|
+
private sessions;
|
|
288
|
+
private currentSessionId;
|
|
289
|
+
private questions;
|
|
290
|
+
private enableHistory;
|
|
291
|
+
constructor(options?: {
|
|
292
|
+
maxHistoryItems?: number;
|
|
293
|
+
enableHistory?: boolean;
|
|
294
|
+
});
|
|
295
|
+
get allMessages(): ComputedRef< {
|
|
296
|
+
id: string;
|
|
297
|
+
type: "ai" | "questions" | "user" | "welcome";
|
|
298
|
+
content: string;
|
|
299
|
+
timestamp: Date;
|
|
300
|
+
status?: "error" | "sending" | "sent" | "streaming" | undefined;
|
|
301
|
+
error?: string | undefined;
|
|
302
|
+
isStreaming?: boolean | undefined;
|
|
303
|
+
streamContent?: string | undefined;
|
|
304
|
+
questions?: {
|
|
305
|
+
id: string;
|
|
306
|
+
text: string;
|
|
307
|
+
value?: string | undefined;
|
|
308
|
+
category?: string | undefined;
|
|
309
|
+
priority?: number | undefined;
|
|
310
|
+
}[] | undefined;
|
|
311
|
+
welcomeData?: {
|
|
312
|
+
title: string;
|
|
313
|
+
subtitle?: string | undefined;
|
|
314
|
+
icon?: string | undefined;
|
|
315
|
+
} | undefined;
|
|
316
|
+
}[]>;
|
|
317
|
+
get currentMessages(): ComputedRef< {
|
|
318
|
+
id: string;
|
|
319
|
+
type: "ai" | "questions" | "user" | "welcome";
|
|
320
|
+
content: string;
|
|
321
|
+
timestamp: Date;
|
|
322
|
+
status?: "error" | "sending" | "sent" | "streaming" | undefined;
|
|
323
|
+
error?: string | undefined;
|
|
324
|
+
isStreaming?: boolean | undefined;
|
|
325
|
+
streamContent?: string | undefined;
|
|
326
|
+
questions?: {
|
|
327
|
+
id: string;
|
|
328
|
+
text: string;
|
|
329
|
+
value?: string | undefined;
|
|
330
|
+
category?: string | undefined;
|
|
331
|
+
priority?: number | undefined;
|
|
332
|
+
}[] | undefined;
|
|
333
|
+
welcomeData?: {
|
|
334
|
+
title: string;
|
|
335
|
+
subtitle?: string | undefined;
|
|
336
|
+
icon?: string | undefined;
|
|
337
|
+
} | undefined;
|
|
338
|
+
}[]>;
|
|
339
|
+
get messageCount(): ComputedRef<number>;
|
|
340
|
+
get hasMessages(): ComputedRef<boolean>;
|
|
341
|
+
get lastMessage(): ComputedRef< {
|
|
342
|
+
id: string;
|
|
343
|
+
type: "ai" | "questions" | "user" | "welcome";
|
|
344
|
+
content: string;
|
|
345
|
+
timestamp: Date;
|
|
346
|
+
status?: "error" | "sending" | "sent" | "streaming" | undefined;
|
|
347
|
+
error?: string | undefined;
|
|
348
|
+
isStreaming?: boolean | undefined;
|
|
349
|
+
streamContent?: string | undefined;
|
|
350
|
+
questions?: {
|
|
351
|
+
id: string;
|
|
352
|
+
text: string;
|
|
353
|
+
value?: string | undefined;
|
|
354
|
+
category?: string | undefined;
|
|
355
|
+
priority?: number | undefined;
|
|
356
|
+
}[] | undefined;
|
|
357
|
+
welcomeData?: {
|
|
358
|
+
title: string;
|
|
359
|
+
subtitle?: string | undefined;
|
|
360
|
+
icon?: string | undefined;
|
|
361
|
+
} | undefined;
|
|
362
|
+
} | undefined>;
|
|
363
|
+
get userMessages(): ComputedRef< {
|
|
364
|
+
id: string;
|
|
365
|
+
type: "ai" | "questions" | "user" | "welcome";
|
|
366
|
+
content: string;
|
|
367
|
+
timestamp: Date;
|
|
368
|
+
status?: "error" | "sending" | "sent" | "streaming" | undefined;
|
|
369
|
+
error?: string | undefined;
|
|
370
|
+
isStreaming?: boolean | undefined;
|
|
371
|
+
streamContent?: string | undefined;
|
|
372
|
+
questions?: {
|
|
373
|
+
id: string;
|
|
374
|
+
text: string;
|
|
375
|
+
value?: string | undefined;
|
|
376
|
+
category?: string | undefined;
|
|
377
|
+
priority?: number | undefined;
|
|
378
|
+
}[] | undefined;
|
|
379
|
+
welcomeData?: {
|
|
380
|
+
title: string;
|
|
381
|
+
subtitle?: string | undefined;
|
|
382
|
+
icon?: string | undefined;
|
|
383
|
+
} | undefined;
|
|
384
|
+
}[]>;
|
|
385
|
+
get aiMessages(): ComputedRef< {
|
|
386
|
+
id: string;
|
|
387
|
+
type: "ai" | "questions" | "user" | "welcome";
|
|
388
|
+
content: string;
|
|
389
|
+
timestamp: Date;
|
|
390
|
+
status?: "error" | "sending" | "sent" | "streaming" | undefined;
|
|
391
|
+
error?: string | undefined;
|
|
392
|
+
isStreaming?: boolean | undefined;
|
|
393
|
+
streamContent?: string | undefined;
|
|
394
|
+
questions?: {
|
|
395
|
+
id: string;
|
|
396
|
+
text: string;
|
|
397
|
+
value?: string | undefined;
|
|
398
|
+
category?: string | undefined;
|
|
399
|
+
priority?: number | undefined;
|
|
400
|
+
}[] | undefined;
|
|
401
|
+
welcomeData?: {
|
|
402
|
+
title: string;
|
|
403
|
+
subtitle?: string | undefined;
|
|
404
|
+
icon?: string | undefined;
|
|
405
|
+
} | undefined;
|
|
406
|
+
}[]>;
|
|
407
|
+
get streamingMessages(): ComputedRef< {
|
|
408
|
+
id: string;
|
|
409
|
+
type: "ai" | "questions" | "user" | "welcome";
|
|
410
|
+
content: string;
|
|
411
|
+
timestamp: Date;
|
|
412
|
+
status?: "error" | "sending" | "sent" | "streaming" | undefined;
|
|
413
|
+
error?: string | undefined;
|
|
414
|
+
isStreaming?: boolean | undefined;
|
|
415
|
+
streamContent?: string | undefined;
|
|
416
|
+
questions?: {
|
|
417
|
+
id: string;
|
|
418
|
+
text: string;
|
|
419
|
+
value?: string | undefined;
|
|
420
|
+
category?: string | undefined;
|
|
421
|
+
priority?: number | undefined;
|
|
422
|
+
}[] | undefined;
|
|
423
|
+
welcomeData?: {
|
|
424
|
+
title: string;
|
|
425
|
+
subtitle?: string | undefined;
|
|
426
|
+
icon?: string | undefined;
|
|
427
|
+
} | undefined;
|
|
428
|
+
}[]>;
|
|
429
|
+
get errorMessages(): ComputedRef< {
|
|
430
|
+
id: string;
|
|
431
|
+
type: "ai" | "questions" | "user" | "welcome";
|
|
432
|
+
content: string;
|
|
433
|
+
timestamp: Date;
|
|
434
|
+
status?: "error" | "sending" | "sent" | "streaming" | undefined;
|
|
435
|
+
error?: string | undefined;
|
|
436
|
+
isStreaming?: boolean | undefined;
|
|
437
|
+
streamContent?: string | undefined;
|
|
438
|
+
questions?: {
|
|
439
|
+
id: string;
|
|
440
|
+
text: string;
|
|
441
|
+
value?: string | undefined;
|
|
442
|
+
category?: string | undefined;
|
|
443
|
+
priority?: number | undefined;
|
|
444
|
+
}[] | undefined;
|
|
445
|
+
welcomeData?: {
|
|
446
|
+
title: string;
|
|
447
|
+
subtitle?: string | undefined;
|
|
448
|
+
icon?: string | undefined;
|
|
449
|
+
} | undefined;
|
|
450
|
+
}[]>;
|
|
451
|
+
get suggestedQuestions(): ComputedRef< {
|
|
452
|
+
id: string;
|
|
453
|
+
text: string;
|
|
454
|
+
value?: string | undefined;
|
|
455
|
+
category?: string | undefined;
|
|
456
|
+
priority?: number | undefined;
|
|
457
|
+
}[]>;
|
|
458
|
+
get hasQuestions(): ComputedRef<boolean>;
|
|
459
|
+
addMessage(message: Omit<ChatMessage, 'id' | 'timestamp'>): ChatMessage;
|
|
460
|
+
updateMessage(messageId: string, updates: Partial<ChatMessage>): boolean;
|
|
461
|
+
removeMessage(messageId: string): boolean;
|
|
462
|
+
getMessage(messageId: string): ChatMessage | undefined;
|
|
463
|
+
setMessageStatus(messageId: string, status: ChatMessage['status']): boolean;
|
|
464
|
+
setMessageStreaming(messageId: string, isStreaming: boolean): boolean;
|
|
465
|
+
setMessageError(messageId: string, error: string): boolean;
|
|
466
|
+
updateStreamingContent(messageId: string, content: string): boolean;
|
|
467
|
+
addMessages(messages: Omit<ChatMessage, 'id' | 'timestamp'>[]): ChatMessage[];
|
|
468
|
+
clearMessages(): void;
|
|
469
|
+
setQuestions(questions: QuestionItem[]): void;
|
|
470
|
+
addQuestion(question: QuestionItem): void;
|
|
471
|
+
clearQuestions(): void;
|
|
472
|
+
removeQuestion(questionId: string): boolean;
|
|
473
|
+
removeMessages(messageIds: string[]): number;
|
|
474
|
+
filterMessages(predicate: (message: ChatMessage) => boolean): ChatMessage[];
|
|
475
|
+
searchMessages(query: string): ChatMessage[];
|
|
476
|
+
getMessagesByType(type: ChatMessage['type']): ChatMessage[];
|
|
477
|
+
getMessagesByStatus(status: ChatMessage['status']): ChatMessage[];
|
|
478
|
+
createSession(): string;
|
|
479
|
+
switchSession(sessionId: string): boolean;
|
|
480
|
+
deleteSession(sessionId: string): boolean;
|
|
481
|
+
getSession(sessionId: string): ChatSession | undefined;
|
|
482
|
+
getAllSessions(): ChatSession[];
|
|
483
|
+
private saveHistory;
|
|
484
|
+
private loadHistory;
|
|
485
|
+
exportHistory(): string;
|
|
486
|
+
importHistory(historyData: string): boolean;
|
|
487
|
+
getStats(): {
|
|
488
|
+
totalMessages: number;
|
|
489
|
+
userMessages: number;
|
|
490
|
+
aiMessages: number;
|
|
491
|
+
errorMessages: number;
|
|
492
|
+
streamingMessages: number;
|
|
493
|
+
sessions: number;
|
|
494
|
+
averageMessagesPerSession: number;
|
|
495
|
+
};
|
|
496
|
+
cleanup(olderThanDays?: number): number;
|
|
497
|
+
private generateMessageId;
|
|
498
|
+
private generateSessionId;
|
|
499
|
+
destroy(): void;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
export declare const messageStore: MessageStore;
|
|
503
|
+
|
|
504
|
+
declare class OpenAIClient {
|
|
505
|
+
private client;
|
|
506
|
+
private config;
|
|
507
|
+
constructor(config: OpenAIConfig);
|
|
508
|
+
chatCompletionStream(request: ChatRequest): AsyncGenerator<StreamingChatResponse, void, unknown>;
|
|
509
|
+
destroy(): void;
|
|
510
|
+
getConfig(): OpenAIConfig;
|
|
511
|
+
listModels(): Promise<any[]>;
|
|
512
|
+
testConnection(): Promise<boolean>;
|
|
513
|
+
updateConfig(config: Partial<OpenAIConfig>): void;
|
|
514
|
+
private handleError;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
export declare interface OpenAIConfig {
|
|
518
|
+
apiKey: string;
|
|
519
|
+
baseUrl?: string;
|
|
520
|
+
organization?: string;
|
|
521
|
+
timeout?: number;
|
|
522
|
+
maxRetries?: number;
|
|
523
|
+
enableStreaming?: boolean;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
export declare interface QuestionItem {
|
|
527
|
+
id: string;
|
|
528
|
+
text: string;
|
|
529
|
+
value?: string;
|
|
530
|
+
category?: string;
|
|
531
|
+
priority?: number;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
export declare interface QuestionsConfig {
|
|
535
|
+
enabled?: boolean;
|
|
536
|
+
items?: QuestionItem[];
|
|
537
|
+
maxItems?: number;
|
|
538
|
+
showCategories?: boolean;
|
|
539
|
+
autoSuggest?: boolean;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
export declare type RequiredFields<T, K extends keyof T> = Required<Pick<T, K>> & T;
|
|
543
|
+
|
|
544
|
+
export declare interface StreamingChatResponse {
|
|
545
|
+
id: string;
|
|
546
|
+
object: string;
|
|
547
|
+
created: number;
|
|
548
|
+
model: string;
|
|
549
|
+
choices: Array<{
|
|
550
|
+
delta: {
|
|
551
|
+
content?: string;
|
|
552
|
+
role?: string;
|
|
553
|
+
};
|
|
554
|
+
finishReason?: string;
|
|
555
|
+
index: number;
|
|
556
|
+
}>;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
export declare interface ThemeConfig {
|
|
560
|
+
mode?: 'auto' | 'dark' | 'light';
|
|
561
|
+
primaryColor?: string;
|
|
562
|
+
backgroundColor?: string;
|
|
563
|
+
textColor?: string;
|
|
564
|
+
borderRadius?: string;
|
|
565
|
+
shadow?: string;
|
|
566
|
+
customCSS?: string;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
declare interface ThemeConfig_2 {
|
|
570
|
+
mode: ThemeMode;
|
|
571
|
+
primaryColor: string;
|
|
572
|
+
backgroundColor: string;
|
|
573
|
+
textColor: string;
|
|
574
|
+
borderRadius: string;
|
|
575
|
+
shadow: string;
|
|
576
|
+
customCSS?: string;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
declare class ThemeManager {
|
|
580
|
+
private currentTheme;
|
|
581
|
+
private themeMode;
|
|
582
|
+
private customThemes;
|
|
583
|
+
private styleElement;
|
|
584
|
+
constructor(initialTheme?: Partial<ThemeConfig_2>);
|
|
585
|
+
private initializeTheme;
|
|
586
|
+
private setupThemeWatcher;
|
|
587
|
+
private createStyleElement;
|
|
588
|
+
private applyTheme;
|
|
589
|
+
private generateCSSVariables;
|
|
590
|
+
private getSystemTheme;
|
|
591
|
+
private loadThemeFromStorage;
|
|
592
|
+
private saveThemeToStorage;
|
|
593
|
+
getCurrentTheme(): ThemeConfig_2;
|
|
594
|
+
setTheme(theme: Partial<ThemeConfig_2>): void;
|
|
595
|
+
setThemeMode(mode: ThemeMode): void;
|
|
596
|
+
applyPresetTheme(themeName: string): void;
|
|
597
|
+
addCustomTheme(name: string, theme: ThemeConfig_2): void;
|
|
598
|
+
getCustomTheme(name: string): ThemeConfig_2 | null;
|
|
599
|
+
getAvailableThemes(): string[];
|
|
600
|
+
getThemeMode(): ThemeMode;
|
|
601
|
+
isDarkMode(): boolean;
|
|
602
|
+
getCSSVariables(): Record<string, string>;
|
|
603
|
+
exportTheme(): string;
|
|
604
|
+
importTheme(themeData: string): boolean;
|
|
605
|
+
resetToDefault(): void;
|
|
606
|
+
destroy(): void;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
export declare const themeManager: ThemeManager;
|
|
610
|
+
|
|
611
|
+
declare type ThemeMode = 'light' | 'dark' | 'auto';
|
|
612
|
+
|
|
613
|
+
export declare function validateApiKey(apiKey: string): boolean;
|
|
614
|
+
|
|
615
|
+
export declare function validateBaseUrl(baseUrl: string): boolean;
|
|
616
|
+
|
|
617
|
+
export declare const VuePlugin: {
|
|
618
|
+
install: (app: App) => void;
|
|
619
|
+
};
|
|
620
|
+
|
|
621
|
+
export declare interface WelcomeConfig {
|
|
622
|
+
enabled?: boolean;
|
|
623
|
+
title?: string;
|
|
624
|
+
subtitle?: string;
|
|
625
|
+
backgroundColor?: string;
|
|
626
|
+
textColor?: string;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
export declare interface WelcomeData {
|
|
630
|
+
title: string;
|
|
631
|
+
subtitle?: string;
|
|
632
|
+
icon?: string;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
export { }
|