@opentiny/genui-sdk-vue 1.0.0-alpha.1 → 1.0.0-alpha.6
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 +37 -0
- package/dist/index.d.ts +226 -7
- package/dist/index.js +76341 -80537
- package/package.json +23 -2
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# @opentiny/genui-sdk-vue
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
A Vue 3 component library for enhanced LLM display and interaction. Stream AI-generated structured output into OpenTiny interactive UI components with bidirectional conversation support.
|
|
5
|
+
|
|
6
|
+
* **Streaming Rendering:** Content renders progressively as the model generates—no long waits for full responses.
|
|
7
|
+
* **Structured Output:** LLM output conforms to JSON Schema, enabling reliable parsing and rendering.
|
|
8
|
+
* **Interaction:** User actions (form submit, button click) feed back into the conversation context for seamless multi-turn flows.
|
|
9
|
+
|
|
10
|
+
[Learn more about GenUI SDK](https://opentiny.design/genui-sdk).
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```vue
|
|
15
|
+
<script setup>
|
|
16
|
+
import { GenuiChat, GenuiConfigProvider } from '@opentiny/genui-sdk-vue';
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<GenuiConfigProvider theme="dark">
|
|
21
|
+
<GenuiChat
|
|
22
|
+
url="/api/chat"
|
|
23
|
+
model="deepseek-chat"
|
|
24
|
+
/>
|
|
25
|
+
</GenuiConfigProvider>
|
|
26
|
+
</template>
|
|
27
|
+
```
|
|
28
|
+
## Documentation
|
|
29
|
+
|
|
30
|
+
* [quick-start](https://docs.opentiny.design/genui-sdk/guide/quick-start)
|
|
31
|
+
* [start-with-render](https://docs.opentiny.design/genui-sdk/guide/start-with-renderer)
|
|
32
|
+
|
|
33
|
+
## API
|
|
34
|
+
|
|
35
|
+
* [GenuiRender](https://docs.opentiny.design/genui-sdk/components/renderer)
|
|
36
|
+
* [GenuiChat](https://docs.opentiny.design/genui-sdk/components/chat)
|
|
37
|
+
* [GenuiConfigProvider](https://docs.opentiny.design/genui-sdk/components/config-provider)
|
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>;
|
|
@@ -31,7 +91,7 @@ rendererInstance: any;
|
|
|
31
91
|
declare const __VLS_component_3: DefineComponent<ConfigProviderProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ConfigProviderProps> & Readonly<{}>, {
|
|
32
92
|
id: string;
|
|
33
93
|
locale: string;
|
|
34
|
-
}, {}, {}, {}, string, ComponentProvideOptions,
|
|
94
|
+
}, {}, {}, {}, string, ComponentProvideOptions, true, {
|
|
35
95
|
providerRef: unknown;
|
|
36
96
|
}, any>;
|
|
37
97
|
|
|
@@ -176,7 +236,7 @@ declare const coerce: {
|
|
|
176
236
|
};
|
|
177
237
|
|
|
178
238
|
declare interface ConfigProviderProps {
|
|
179
|
-
theme
|
|
239
|
+
theme?: 'light' | 'dark' | 'lite' | 'auto';
|
|
180
240
|
id?: string;
|
|
181
241
|
locale?: string;
|
|
182
242
|
i18n?: I18nMessages;
|
|
@@ -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
|
}
|
|
@@ -438,6 +545,7 @@ declare interface IGenPromptComponentSchema {
|
|
|
438
545
|
}
|
|
439
546
|
|
|
440
547
|
declare interface IGenPromptExample {
|
|
548
|
+
id?: string;
|
|
441
549
|
name: string;
|
|
442
550
|
description?: string;
|
|
443
551
|
schema: CardSchema;
|
|
@@ -468,7 +576,7 @@ export declare interface IMessage {
|
|
|
468
576
|
messages?: IMessageItem[];
|
|
469
577
|
}
|
|
470
578
|
|
|
471
|
-
declare interface IMessageItem {
|
|
579
|
+
export declare interface IMessageItem {
|
|
472
580
|
type: string;
|
|
473
581
|
content: string;
|
|
474
582
|
[customKey: string]: any;
|
|
@@ -477,7 +585,18 @@ declare interface IMessageItem {
|
|
|
477
585
|
/**
|
|
478
586
|
* 消息项类型
|
|
479
587
|
*/
|
|
480
|
-
declare type IMessageItem_2 = IMarkdownMessageItem | ISchemaCardMessageItem | IToolMessageItem;
|
|
588
|
+
declare type IMessageItem_2 = IMarkdownMessageItem | ISchemaCardMessageItem | IToolMessageItem | IReasoningMessageItem;
|
|
589
|
+
|
|
590
|
+
export declare class IndexedDBStrategy implements ConversationStorageStrategy {
|
|
591
|
+
private dbName;
|
|
592
|
+
private storeName;
|
|
593
|
+
private dataKey;
|
|
594
|
+
private db;
|
|
595
|
+
constructor(dbName?: string, storeName?: string, dataKey?: string);
|
|
596
|
+
private openDB;
|
|
597
|
+
saveConversations(conversations: Conversation[]): Promise<void>;
|
|
598
|
+
loadConversations(): Promise<Conversation[]>;
|
|
599
|
+
}
|
|
481
600
|
|
|
482
601
|
declare type Indices<T> = Exclude<keyof T, ArrayKeys>;
|
|
483
602
|
|
|
@@ -533,11 +652,17 @@ declare const INVALID: INVALID;
|
|
|
533
652
|
|
|
534
653
|
declare type IpVersion = "v4" | "v6";
|
|
535
654
|
|
|
655
|
+
declare interface IReasoningMessageItem {
|
|
656
|
+
type: 'reasoning';
|
|
657
|
+
content: string;
|
|
658
|
+
thinking?: boolean;
|
|
659
|
+
}
|
|
660
|
+
|
|
536
661
|
export declare interface IRendererProps {
|
|
537
662
|
content: string | {
|
|
538
663
|
[prop: string]: any;
|
|
539
664
|
};
|
|
540
|
-
generating
|
|
665
|
+
generating?: boolean;
|
|
541
666
|
customComponents?: Record<string, Component>;
|
|
542
667
|
customActions?: any;
|
|
543
668
|
requiredCompleteFieldSelectors?: string[];
|
|
@@ -556,6 +681,19 @@ export declare interface IRendererSlotsProps {
|
|
|
556
681
|
isFinished: boolean;
|
|
557
682
|
}
|
|
558
683
|
|
|
684
|
+
declare interface IResponseHandler<T> {
|
|
685
|
+
name: string;
|
|
686
|
+
match: (data: T, context: any) => boolean;
|
|
687
|
+
handler: (data: T, context: any) => boolean;
|
|
688
|
+
notMatchHandler?: (data: T, context: any) => boolean;
|
|
689
|
+
start?: (context: any, handlers: {
|
|
690
|
+
onData: (data: IChatMessage) => void;
|
|
691
|
+
onDone: () => void;
|
|
692
|
+
onError: (error: Error) => void;
|
|
693
|
+
}) => void;
|
|
694
|
+
end?: (context: any) => void;
|
|
695
|
+
}
|
|
696
|
+
|
|
559
697
|
export declare interface IRolesConfig {
|
|
560
698
|
user: Partial<BubbleRoleConfig>;
|
|
561
699
|
assistant: Partial<BubbleRoleConfig>;
|
|
@@ -574,15 +712,35 @@ declare interface ISchemaCardMessageItem {
|
|
|
574
712
|
|
|
575
713
|
declare const isDirty: <T>(x: ParseReturnType<T>) => x is OK<T> | DIRTY<T>;
|
|
576
714
|
|
|
715
|
+
declare type ISlotProps = any;
|
|
716
|
+
|
|
577
717
|
declare type IssueData = stripPath<ZodIssueOptionalMessage> & {
|
|
578
718
|
path?: (string | number)[];
|
|
579
719
|
fatal?: boolean | undefined;
|
|
580
720
|
};
|
|
581
721
|
|
|
722
|
+
/**
|
|
723
|
+
* 单次 SSE data 行解析后的完整负载(含 id、model、choices 等顶层字段)
|
|
724
|
+
*/
|
|
725
|
+
declare interface IStreamData {
|
|
726
|
+
id?: string;
|
|
727
|
+
object?: string;
|
|
728
|
+
model?: string;
|
|
729
|
+
type?: string;
|
|
730
|
+
created?: number;
|
|
731
|
+
choices?: IChatStreamChoice[];
|
|
732
|
+
usage?: {
|
|
733
|
+
prompt_tokens?: number;
|
|
734
|
+
completion_tokens?: number;
|
|
735
|
+
total_tokens?: number;
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
|
|
582
739
|
/**
|
|
583
740
|
* 流式响应的增量数据
|
|
584
741
|
*/
|
|
585
742
|
declare interface IStreamDelta {
|
|
743
|
+
reasoning_content?: string;
|
|
586
744
|
content?: string;
|
|
587
745
|
tool_calls?: Array<{
|
|
588
746
|
id: string;
|
|
@@ -834,6 +992,16 @@ declare type mergeTypes<A, B> = {
|
|
|
834
992
|
[k in keyof A | keyof B]: k extends keyof B ? B[k] : k extends keyof A ? A[k] : never;
|
|
835
993
|
};
|
|
836
994
|
|
|
995
|
+
export declare class MessageManager {
|
|
996
|
+
messageManagerMap: Map<string, UseMessageReturn>;
|
|
997
|
+
conversationState: Reactive<ConversationState>;
|
|
998
|
+
options: UseMessageOptions;
|
|
999
|
+
constructor(conversationState: Reactive<ConversationState>, options: UseMessageOptions);
|
|
1000
|
+
getMessageManager(conversationId: string): UseMessageReturn;
|
|
1001
|
+
setMessageManager(id: string, options?: UseMessageOptions): UseMessageReturn;
|
|
1002
|
+
deleteMessageManager(id: string): void;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
837
1005
|
declare type Methods = Record<string, JSFunction>;
|
|
838
1006
|
|
|
839
1007
|
export declare interface ModelCapability {
|
|
@@ -1056,6 +1224,11 @@ declare type ProcessedCreateParams = {
|
|
|
1056
1224
|
|
|
1057
1225
|
declare const promiseType: <Inner extends ZodTypeAny>(schema: Inner, params?: RawCreateParams) => ZodPromise<Inner>;
|
|
1058
1226
|
|
|
1227
|
+
declare interface Props {
|
|
1228
|
+
templateData?: UserItem[];
|
|
1229
|
+
attachments?: FileMeta[];
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1059
1232
|
declare const quotelessJson: (obj: any) => string;
|
|
1060
1233
|
|
|
1061
1234
|
declare type RawCreateParams = {
|
|
@@ -1125,6 +1298,14 @@ declare type SafeParseSuccess<Output> = {
|
|
|
1125
1298
|
|
|
1126
1299
|
declare type Scalars = Primitive | Primitive[];
|
|
1127
1300
|
|
|
1301
|
+
export declare const scrollEnd: (container: Ref<HTMLElement | undefined>) => {
|
|
1302
|
+
scrollToBottom: () => void;
|
|
1303
|
+
scrollToBottomWithRetry: (maxRetries?: number, retryDelay?: number) => void;
|
|
1304
|
+
autoScrollToBottom: () => void;
|
|
1305
|
+
isLastMessageInBottom: Ref<boolean, boolean>;
|
|
1306
|
+
updateIsLastMessageInBottom: () => void;
|
|
1307
|
+
};
|
|
1308
|
+
|
|
1128
1309
|
declare function setErrorMap(map: ZodErrorMap): void;
|
|
1129
1310
|
|
|
1130
1311
|
declare const setType: <ValueSchema extends ZodTypeAny = ZodTypeAny>(valueType: ValueSchema, params?: RawCreateParams) => ZodSet<ValueSchema>;
|
|
@@ -1258,6 +1439,10 @@ declare const symbolType: (params?: RawCreateParams) => ZodSymbol;
|
|
|
1258
1439
|
|
|
1259
1440
|
declare type SyncParseReturnType<T = any> = OK<T> | DIRTY<T> | INVALID;
|
|
1260
1441
|
|
|
1442
|
+
export declare function throttle<T extends (...args: any[]) => any>(fn: T, delay: number): (...args: Parameters<T>) => void;
|
|
1443
|
+
|
|
1444
|
+
export declare const toSlotFunction: (slot: Component<ISlotProps> | ((props: ISlotProps) => VNode | VNode[]) | undefined) => (props: ISlotProps) => VNode | VNode[];
|
|
1445
|
+
|
|
1261
1446
|
declare type TransformEffect<T> = {
|
|
1262
1447
|
type: "transform";
|
|
1263
1448
|
transform: (arg: T, ctx: RefinementCtx) => any;
|
|
@@ -1284,10 +1469,19 @@ declare type UnknownKeysParam = "passthrough" | "strict" | "strip";
|
|
|
1284
1469
|
|
|
1285
1470
|
declare const unknownType: (params?: RawCreateParams) => ZodUnknown;
|
|
1286
1471
|
|
|
1472
|
+
/**
|
|
1473
|
+
* useConversation composable
|
|
1474
|
+
* 提供会话管理和持久化功能
|
|
1475
|
+
*
|
|
1476
|
+
* @param options useConversation选项
|
|
1477
|
+
* @returns UseConversationReturn
|
|
1478
|
+
*/
|
|
1479
|
+
export declare function useConversation(options: UseConversationOptions): UseConversationReturn;
|
|
1480
|
+
|
|
1287
1481
|
/**
|
|
1288
1482
|
* useConversation返回值接口
|
|
1289
1483
|
*/
|
|
1290
|
-
declare interface UseConversationReturn {
|
|
1484
|
+
export declare interface UseConversationReturn {
|
|
1291
1485
|
/** 会话状态 */
|
|
1292
1486
|
state: ConversationState;
|
|
1293
1487
|
/** 消息管理 */
|
|
@@ -1318,10 +1512,35 @@ export declare const useMediaTheme: () => {
|
|
|
1318
1512
|
theme: Readonly<Ref<"dark" | "light", "dark" | "light">>;
|
|
1319
1513
|
};
|
|
1320
1514
|
|
|
1515
|
+
export declare function useMessage(options: UseMessageOptions): UseMessageReturn;
|
|
1516
|
+
|
|
1517
|
+
/**
|
|
1518
|
+
* useMessage选项接口
|
|
1519
|
+
*/
|
|
1520
|
+
export declare interface UseMessageOptions {
|
|
1521
|
+
/** AI客户端实例 */
|
|
1522
|
+
client: AIClient;
|
|
1523
|
+
/** 消息ID */
|
|
1524
|
+
conversationId: string;
|
|
1525
|
+
/** 是否默认使用流式响应 */
|
|
1526
|
+
useStreamByDefault?: boolean;
|
|
1527
|
+
/** 错误消息模板 */
|
|
1528
|
+
errorMessage?: string;
|
|
1529
|
+
/** 初始消息列表 */
|
|
1530
|
+
initialMessages?: ChatMessage[];
|
|
1531
|
+
events?: {
|
|
1532
|
+
onReceiveData?: <T = any>(data: T, messages: Ref<ChatMessage[]>, preventDefault: () => void) => void;
|
|
1533
|
+
onFinish?: (finishReason: string | undefined, context: {
|
|
1534
|
+
messages: Ref<ChatMessage[]>;
|
|
1535
|
+
messageState: Reactive<MessageState>;
|
|
1536
|
+
}, preventDefault: () => void) => void;
|
|
1537
|
+
};
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1321
1540
|
/**
|
|
1322
1541
|
* useMessage返回值接口
|
|
1323
1542
|
*/
|
|
1324
|
-
declare interface UseMessageReturn {
|
|
1543
|
+
export declare interface UseMessageReturn {
|
|
1325
1544
|
/** 消息ID */
|
|
1326
1545
|
conversationId: string;
|
|
1327
1546
|
/** 消息列表 */
|