@opentiny/genui-sdk-vue 1.0.1-feature-github-action-test.0 → 1.1.0-alpha.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/dist/index.d.ts +215 -3
- package/dist/index.js +78863 -85610
- package/package.json +9 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { AIClient } from '@opentiny/tiny-robot-kit';
|
|
2
|
+
import { BubbleCommonProps } from '@opentiny/tiny-robot';
|
|
3
|
+
import { BubbleMarkdownContentRenderer } from '@opentiny/tiny-robot';
|
|
1
4
|
import { BubbleProps } from '@opentiny/tiny-robot';
|
|
2
5
|
import { BubbleRoleConfig } from '@opentiny/tiny-robot';
|
|
3
6
|
import { ChatMessage } from '@opentiny/tiny-robot-kit';
|
|
@@ -7,19 +10,76 @@ import { ComponentProvideOptions } from 'vue';
|
|
|
7
10
|
import { ComputedRef } from 'vue';
|
|
8
11
|
import { Conversation } from '@opentiny/tiny-robot-kit';
|
|
9
12
|
import { ConversationState } from '@opentiny/tiny-robot-kit';
|
|
13
|
+
import { ConversationStorageStrategy } from '@opentiny/tiny-robot-kit';
|
|
10
14
|
import { DefineComponent } from 'vue';
|
|
11
15
|
import { MessageState } from '@opentiny/tiny-robot-kit';
|
|
12
16
|
import { PublicProps } from 'vue';
|
|
13
17
|
import { Reactive } from 'vue';
|
|
14
18
|
import { Ref } from 'vue';
|
|
19
|
+
import { RendererElement } from 'vue';
|
|
20
|
+
import { RendererNode } from 'vue';
|
|
15
21
|
import { UnwrapNestedRefs } from 'vue';
|
|
22
|
+
import { UseConversationOptions } from '@opentiny/tiny-robot-kit';
|
|
16
23
|
import { UseMessageReturn as UseMessageReturn_2 } from '@opentiny/tiny-robot-kit';
|
|
24
|
+
import { UserItem } from '@opentiny/tiny-robot';
|
|
17
25
|
import { VNode } from 'vue';
|
|
18
26
|
|
|
19
27
|
declare const __VLS_component: DefineComponent<IChatProps, {
|
|
20
28
|
setInputMessage: (message: string) => void;
|
|
21
29
|
handleNewConversation: () => void;
|
|
22
30
|
getConversation: () => UseConversationReturn;
|
|
31
|
+
getResponseHandlers: () => IResponseHandler<IStreamData>[];
|
|
32
|
+
setResponseHandlers: (handlers: IResponseHandler<IStreamData>[]) => void;
|
|
33
|
+
getMessageRenderers: () => {
|
|
34
|
+
'custom-text': (props: BubbleCommonProps & {
|
|
35
|
+
content: string;
|
|
36
|
+
}) => VNode<RendererNode, RendererElement, {
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
}>;
|
|
39
|
+
'schema-card': (schemaCardProps: IRendererProps) => VNode<RendererNode, RendererElement, {
|
|
40
|
+
[key: string]: any;
|
|
41
|
+
}>;
|
|
42
|
+
tool: DefineComponent< {
|
|
43
|
+
name: string;
|
|
44
|
+
status: "running" | "success" | "failed" | "cancelled";
|
|
45
|
+
content?: string | {
|
|
46
|
+
params?: object;
|
|
47
|
+
result?: object;
|
|
48
|
+
[x: string]: unknown;
|
|
49
|
+
};
|
|
50
|
+
formatPretty?: boolean;
|
|
51
|
+
defaultOpen?: boolean;
|
|
52
|
+
}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{
|
|
53
|
+
name: string;
|
|
54
|
+
status: "running" | "success" | "failed" | "cancelled";
|
|
55
|
+
content?: string | {
|
|
56
|
+
params?: object;
|
|
57
|
+
result?: object;
|
|
58
|
+
[x: string]: unknown;
|
|
59
|
+
};
|
|
60
|
+
formatPretty?: boolean;
|
|
61
|
+
defaultOpen?: boolean;
|
|
62
|
+
}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
63
|
+
reasoning: DefineComponent< {
|
|
64
|
+
content: string;
|
|
65
|
+
thinking?: boolean;
|
|
66
|
+
}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{
|
|
67
|
+
content: string;
|
|
68
|
+
thinking?: boolean;
|
|
69
|
+
}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
70
|
+
markdown: BubbleMarkdownContentRenderer;
|
|
71
|
+
templateData: DefineComponent<Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
72
|
+
attachments: FileMeta[];
|
|
73
|
+
templateData: UserItem[];
|
|
74
|
+
}, {}, {}, {}, string, ComponentProvideOptions, true, {}, HTMLDivElement>;
|
|
75
|
+
'loading-text': Component<BubbleProps> | DefineComponent<IThinkComponentProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<IThinkComponentProps> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>;
|
|
76
|
+
'error-text': DefineComponent< {
|
|
77
|
+
content: string;
|
|
78
|
+
}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{
|
|
79
|
+
content: string;
|
|
80
|
+
}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
81
|
+
};
|
|
82
|
+
setMessageRenderer: (key: string, renderer: Component<IRendererProps>) => void;
|
|
23
83
|
}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<IChatProps> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {
|
|
24
84
|
messagesContainer: HTMLDivElement;
|
|
25
85
|
}, HTMLDivElement>;
|
|
@@ -253,6 +313,8 @@ declare type Effect<T> = RefinementEffect<T> | TransformEffect<T> | PreprocessEf
|
|
|
253
313
|
|
|
254
314
|
declare const effectsType: <I extends ZodTypeAny>(schema: I, effect: Effect<I["_output"]>, params?: RawCreateParams) => ZodEffects<I, I["_output"]>;
|
|
255
315
|
|
|
316
|
+
export declare const emitter: EventEmitter;
|
|
317
|
+
|
|
256
318
|
declare const EMPTY_PATH: ParsePath;
|
|
257
319
|
|
|
258
320
|
declare type EnumLike = {
|
|
@@ -298,6 +360,40 @@ declare namespace errorUtil {
|
|
|
298
360
|
const toString: (message?: ErrMessage) => string | undefined;
|
|
299
361
|
}
|
|
300
362
|
|
|
363
|
+
export declare class EventEmitter {
|
|
364
|
+
private events;
|
|
365
|
+
constructor();
|
|
366
|
+
/**
|
|
367
|
+
* @param {string} eventName - 事件名
|
|
368
|
+
* @param {Function} callback - 回调函数
|
|
369
|
+
* @param {boolean} [once=false] - 是否只触发一次
|
|
370
|
+
*/
|
|
371
|
+
on(eventName: string, callback: Function, once?: boolean): void;
|
|
372
|
+
/**
|
|
373
|
+
* @param {string} eventName - 事件名
|
|
374
|
+
* @param {Function} callback - 要移除的回调(必须是注册时的同一个函数引用)
|
|
375
|
+
*/
|
|
376
|
+
off(eventName: string, callback: Function): void;
|
|
377
|
+
/**
|
|
378
|
+
* @param {string} eventName - 事件名
|
|
379
|
+
* @param {...any} args - 传递给回调的参数
|
|
380
|
+
*/
|
|
381
|
+
emit(eventName: string, ...args: any[]): void;
|
|
382
|
+
/**
|
|
383
|
+
* @param {string} eventName - 事件名
|
|
384
|
+
* @param {Function} callback - 回调函数
|
|
385
|
+
*/
|
|
386
|
+
once(eventName: string, callback: Function): void;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
declare interface FileMeta {
|
|
390
|
+
name: string;
|
|
391
|
+
type: string;
|
|
392
|
+
size: number;
|
|
393
|
+
lastModified: number;
|
|
394
|
+
base64: string;
|
|
395
|
+
}
|
|
396
|
+
|
|
301
397
|
declare type FilterEnum<Values, ToExclude> = Values extends [] ? [] : Values extends [infer Head, ...infer Rest] ? Head extends ToExclude ? FilterEnum<Rest, ToExclude> : [Head, ...FilterEnum<Rest, ToExclude>] : never;
|
|
302
398
|
|
|
303
399
|
declare const functionType: typeof ZodFunction.create;
|
|
@@ -348,6 +444,7 @@ export declare interface IBubbleSlotsProps {
|
|
|
348
444
|
bubbleProps: BubbleProps;
|
|
349
445
|
isFinished: boolean;
|
|
350
446
|
messageManager: UseMessageReturn_2;
|
|
447
|
+
chatMessage: IChatMessage;
|
|
351
448
|
}
|
|
352
449
|
|
|
353
450
|
export declare interface IChatConfig {
|
|
@@ -362,6 +459,7 @@ declare interface IChatMessage {
|
|
|
362
459
|
role: 'assistant';
|
|
363
460
|
content: string;
|
|
364
461
|
messages: IMessageItem_2[];
|
|
462
|
+
[customKey: string]: any;
|
|
365
463
|
}
|
|
366
464
|
|
|
367
465
|
export declare interface IChatProps {
|
|
@@ -382,6 +480,15 @@ export declare interface IChatProps {
|
|
|
382
480
|
customFetch?: CustomFetch;
|
|
383
481
|
}
|
|
384
482
|
|
|
483
|
+
/**
|
|
484
|
+
* 单次流式响应中的一条 choice(与 OpenAI chat.completion.chunk 对齐)
|
|
485
|
+
*/
|
|
486
|
+
declare interface IChatStreamChoice {
|
|
487
|
+
index: number;
|
|
488
|
+
delta?: IStreamDelta;
|
|
489
|
+
finish_reason?: string | null;
|
|
490
|
+
}
|
|
491
|
+
|
|
385
492
|
export declare interface ICustomActionItem extends IGenPromptAction {
|
|
386
493
|
execute: (params: any, context: Record<string, any>) => void;
|
|
387
494
|
}
|
|
@@ -468,7 +575,7 @@ export declare interface IMessage {
|
|
|
468
575
|
messages?: IMessageItem[];
|
|
469
576
|
}
|
|
470
577
|
|
|
471
|
-
declare interface IMessageItem {
|
|
578
|
+
export declare interface IMessageItem {
|
|
472
579
|
type: string;
|
|
473
580
|
content: string;
|
|
474
581
|
[customKey: string]: any;
|
|
@@ -479,6 +586,17 @@ declare interface IMessageItem {
|
|
|
479
586
|
*/
|
|
480
587
|
declare type IMessageItem_2 = IMarkdownMessageItem | ISchemaCardMessageItem | IToolMessageItem | IReasoningMessageItem;
|
|
481
588
|
|
|
589
|
+
export declare class IndexedDBStrategy implements ConversationStorageStrategy {
|
|
590
|
+
private dbName;
|
|
591
|
+
private storeName;
|
|
592
|
+
private dataKey;
|
|
593
|
+
private db;
|
|
594
|
+
constructor(dbName?: string, storeName?: string, dataKey?: string);
|
|
595
|
+
private openDB;
|
|
596
|
+
saveConversations(conversations: Conversation[]): Promise<void>;
|
|
597
|
+
loadConversations(): Promise<Conversation[]>;
|
|
598
|
+
}
|
|
599
|
+
|
|
482
600
|
declare type Indices<T> = Exclude<keyof T, ArrayKeys>;
|
|
483
601
|
|
|
484
602
|
declare type inferFlattenedErrors<T extends ZodType<any, any, any>, U = string> = typeToFlattenedError<TypeOf<T>, U>;
|
|
@@ -562,6 +680,19 @@ export declare interface IRendererSlotsProps {
|
|
|
562
680
|
isFinished: boolean;
|
|
563
681
|
}
|
|
564
682
|
|
|
683
|
+
declare interface IResponseHandler<T> {
|
|
684
|
+
name: string;
|
|
685
|
+
match: (data: T, context: any) => boolean;
|
|
686
|
+
handler: (data: T, context: any) => boolean;
|
|
687
|
+
notMatchHandler?: (data: T, context: any) => boolean;
|
|
688
|
+
start?: (context: any, handlers: {
|
|
689
|
+
onData: (data: IChatMessage) => void;
|
|
690
|
+
onDone: () => void;
|
|
691
|
+
onError: (error: Error) => void;
|
|
692
|
+
}) => void;
|
|
693
|
+
end?: (context: any) => void;
|
|
694
|
+
}
|
|
695
|
+
|
|
565
696
|
export declare interface IRolesConfig {
|
|
566
697
|
user: Partial<BubbleRoleConfig>;
|
|
567
698
|
assistant: Partial<BubbleRoleConfig>;
|
|
@@ -580,15 +711,35 @@ declare interface ISchemaCardMessageItem {
|
|
|
580
711
|
|
|
581
712
|
declare const isDirty: <T>(x: ParseReturnType<T>) => x is OK<T> | DIRTY<T>;
|
|
582
713
|
|
|
714
|
+
declare type ISlotProps = any;
|
|
715
|
+
|
|
583
716
|
declare type IssueData = stripPath<ZodIssueOptionalMessage> & {
|
|
584
717
|
path?: (string | number)[];
|
|
585
718
|
fatal?: boolean | undefined;
|
|
586
719
|
};
|
|
587
720
|
|
|
721
|
+
/**
|
|
722
|
+
* 单次 SSE data 行解析后的完整负载(含 id、model、choices 等顶层字段)
|
|
723
|
+
*/
|
|
724
|
+
declare interface IStreamData {
|
|
725
|
+
id?: string;
|
|
726
|
+
object?: string;
|
|
727
|
+
model?: string;
|
|
728
|
+
type?: string;
|
|
729
|
+
created?: number;
|
|
730
|
+
choices?: IChatStreamChoice[];
|
|
731
|
+
usage?: {
|
|
732
|
+
prompt_tokens?: number;
|
|
733
|
+
completion_tokens?: number;
|
|
734
|
+
total_tokens?: number;
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
|
|
588
738
|
/**
|
|
589
739
|
* 流式响应的增量数据
|
|
590
740
|
*/
|
|
591
741
|
declare interface IStreamDelta {
|
|
742
|
+
reasoning_content?: string;
|
|
592
743
|
content?: string;
|
|
593
744
|
tool_calls?: Array<{
|
|
594
745
|
id: string;
|
|
@@ -840,6 +991,16 @@ declare type mergeTypes<A, B> = {
|
|
|
840
991
|
[k in keyof A | keyof B]: k extends keyof B ? B[k] : k extends keyof A ? A[k] : never;
|
|
841
992
|
};
|
|
842
993
|
|
|
994
|
+
export declare class MessageManager {
|
|
995
|
+
messageManagerMap: Map<string, UseMessageReturn>;
|
|
996
|
+
conversationState: Reactive<ConversationState>;
|
|
997
|
+
options: UseMessageOptions;
|
|
998
|
+
constructor(conversationState: Reactive<ConversationState>, options: UseMessageOptions);
|
|
999
|
+
getMessageManager(conversationId: string): UseMessageReturn;
|
|
1000
|
+
setMessageManager(id: string, options?: UseMessageOptions): UseMessageReturn;
|
|
1001
|
+
deleteMessageManager(id: string): void;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
843
1004
|
declare type Methods = Record<string, JSFunction>;
|
|
844
1005
|
|
|
845
1006
|
export declare interface ModelCapability {
|
|
@@ -1062,6 +1223,11 @@ declare type ProcessedCreateParams = {
|
|
|
1062
1223
|
|
|
1063
1224
|
declare const promiseType: <Inner extends ZodTypeAny>(schema: Inner, params?: RawCreateParams) => ZodPromise<Inner>;
|
|
1064
1225
|
|
|
1226
|
+
declare interface Props {
|
|
1227
|
+
templateData?: UserItem[];
|
|
1228
|
+
attachments?: FileMeta[];
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1065
1231
|
declare const quotelessJson: (obj: any) => string;
|
|
1066
1232
|
|
|
1067
1233
|
declare type RawCreateParams = {
|
|
@@ -1131,6 +1297,14 @@ declare type SafeParseSuccess<Output> = {
|
|
|
1131
1297
|
|
|
1132
1298
|
declare type Scalars = Primitive | Primitive[];
|
|
1133
1299
|
|
|
1300
|
+
export declare const scrollEnd: (container: Ref<HTMLElement | undefined>) => {
|
|
1301
|
+
scrollToBottom: () => void;
|
|
1302
|
+
scrollToBottomWithRetry: (maxRetries?: number, retryDelay?: number) => void;
|
|
1303
|
+
autoScrollToBottom: () => void;
|
|
1304
|
+
isLastMessageInBottom: Ref<boolean, boolean>;
|
|
1305
|
+
updateIsLastMessageInBottom: () => void;
|
|
1306
|
+
};
|
|
1307
|
+
|
|
1134
1308
|
declare function setErrorMap(map: ZodErrorMap): void;
|
|
1135
1309
|
|
|
1136
1310
|
declare const setType: <ValueSchema extends ZodTypeAny = ZodTypeAny>(valueType: ValueSchema, params?: RawCreateParams) => ZodSet<ValueSchema>;
|
|
@@ -1264,6 +1438,10 @@ declare const symbolType: (params?: RawCreateParams) => ZodSymbol;
|
|
|
1264
1438
|
|
|
1265
1439
|
declare type SyncParseReturnType<T = any> = OK<T> | DIRTY<T> | INVALID;
|
|
1266
1440
|
|
|
1441
|
+
export declare function throttle<T extends (...args: any[]) => any>(fn: T, delay: number): (...args: Parameters<T>) => void;
|
|
1442
|
+
|
|
1443
|
+
export declare const toSlotFunction: (slot: Component<ISlotProps> | ((props: ISlotProps) => VNode | VNode[]) | undefined) => (props: ISlotProps) => VNode | VNode[];
|
|
1444
|
+
|
|
1267
1445
|
declare type TransformEffect<T> = {
|
|
1268
1446
|
type: "transform";
|
|
1269
1447
|
transform: (arg: T, ctx: RefinementCtx) => any;
|
|
@@ -1290,10 +1468,19 @@ declare type UnknownKeysParam = "passthrough" | "strict" | "strip";
|
|
|
1290
1468
|
|
|
1291
1469
|
declare const unknownType: (params?: RawCreateParams) => ZodUnknown;
|
|
1292
1470
|
|
|
1471
|
+
/**
|
|
1472
|
+
* useConversation composable
|
|
1473
|
+
* 提供会话管理和持久化功能
|
|
1474
|
+
*
|
|
1475
|
+
* @param options useConversation选项
|
|
1476
|
+
* @returns UseConversationReturn
|
|
1477
|
+
*/
|
|
1478
|
+
export declare function useConversation(options: UseConversationOptions): UseConversationReturn;
|
|
1479
|
+
|
|
1293
1480
|
/**
|
|
1294
1481
|
* useConversation返回值接口
|
|
1295
1482
|
*/
|
|
1296
|
-
declare interface UseConversationReturn {
|
|
1483
|
+
export declare interface UseConversationReturn {
|
|
1297
1484
|
/** 会话状态 */
|
|
1298
1485
|
state: ConversationState;
|
|
1299
1486
|
/** 消息管理 */
|
|
@@ -1324,10 +1511,35 @@ export declare const useMediaTheme: () => {
|
|
|
1324
1511
|
theme: Readonly<Ref<"dark" | "light", "dark" | "light">>;
|
|
1325
1512
|
};
|
|
1326
1513
|
|
|
1514
|
+
export declare function useMessage(options: UseMessageOptions): UseMessageReturn;
|
|
1515
|
+
|
|
1516
|
+
/**
|
|
1517
|
+
* useMessage选项接口
|
|
1518
|
+
*/
|
|
1519
|
+
export declare interface UseMessageOptions {
|
|
1520
|
+
/** AI客户端实例 */
|
|
1521
|
+
client: AIClient;
|
|
1522
|
+
/** 消息ID */
|
|
1523
|
+
conversationId: string;
|
|
1524
|
+
/** 是否默认使用流式响应 */
|
|
1525
|
+
useStreamByDefault?: boolean;
|
|
1526
|
+
/** 错误消息模板 */
|
|
1527
|
+
errorMessage?: string;
|
|
1528
|
+
/** 初始消息列表 */
|
|
1529
|
+
initialMessages?: ChatMessage[];
|
|
1530
|
+
events?: {
|
|
1531
|
+
onReceiveData?: <T = any>(data: T, messages: Ref<ChatMessage[]>, preventDefault: () => void) => void;
|
|
1532
|
+
onFinish?: (finishReason: string | undefined, context: {
|
|
1533
|
+
messages: Ref<ChatMessage[]>;
|
|
1534
|
+
messageState: Reactive<MessageState>;
|
|
1535
|
+
}, preventDefault: () => void) => void;
|
|
1536
|
+
};
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1327
1539
|
/**
|
|
1328
1540
|
* useMessage返回值接口
|
|
1329
1541
|
*/
|
|
1330
|
-
declare interface UseMessageReturn {
|
|
1542
|
+
export declare interface UseMessageReturn {
|
|
1331
1543
|
/** 消息ID */
|
|
1332
1544
|
conversationId: string;
|
|
1333
1545
|
/** 消息列表 */
|