wi-chat 0.0.0-stage → 0.4.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/dist/core/index.cjs +2 -0
- package/dist/core/index.d.ts +13 -0
- package/dist/core/index.js +454 -0
- package/dist/core/useAgent.d.ts +35 -0
- package/dist/core/useChat.d.ts +195 -0
- package/dist/core/useChatSession.d.ts +89 -0
- package/dist/core/useHistory.d.ts +63 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +81 -0
- package/dist/mobile-ui/chat/ChatContainer.vue.d.ts +129 -0
- package/dist/mobile-ui/chat/ChatMessagesView.vue.d.ts +77 -0
- package/dist/mobile-ui/chat/types.d.ts +9 -0
- package/dist/mobile-ui/index.cjs +2 -0
- package/dist/mobile-ui/index.d.ts +7 -0
- package/dist/mobile-ui/index.js +225 -0
- package/dist/mobile-ui/inputbox/Inputbox.vue.d.ts +95 -0
- package/dist/mobile-ui/style.css +1 -0
- package/dist/parser/answer.d.ts +51 -0
- package/dist/parser/answerCom/iframePage/parseIframePage.d.ts +49 -0
- package/dist/parser/answerCom/iframePage/types.d.ts +11 -0
- package/dist/parser/answerCom/knowledgeStream/parseKnowledgeStream.d.ts +54 -0
- package/dist/parser/answerCom/knowledgeStream/types.d.ts +27 -0
- package/dist/parser/answerCom/outputFile/parseOutputFile.d.ts +43 -0
- package/dist/parser/answerCom/outputFile/types.d.ts +17 -0
- package/dist/parser/answerCom/recordset/parseRecordset.d.ts +48 -0
- package/dist/parser/answerCom/recordset/types.d.ts +36 -0
- package/dist/parser/attach/attachActions.d.ts +43 -0
- package/dist/parser/attach/index.d.ts +9 -0
- package/dist/parser/attach/parseAttach.d.ts +27 -0
- package/dist/parser/attach/types.d.ts +48 -0
- package/dist/parser/deepThinking/parseDeepThinking.d.ts +30 -0
- package/dist/parser/deepThinking/types.d.ts +14 -0
- package/dist/parser/history/history.d.ts +54 -0
- package/dist/parser/history/index.d.ts +7 -0
- package/dist/parser/index.cjs +3 -0
- package/dist/parser/index.d.ts +45 -0
- package/dist/parser/index.js +479 -0
- package/dist/parser/message.d.ts +60 -0
- package/dist/parser/registry.d.ts +81 -0
- package/dist/parser/sse.d.ts +34 -0
- package/dist/parser/stream.d.ts +8 -0
- package/dist/renderers/aiAnswer/AiAnswerBubble.vue.d.ts +58 -0
- package/dist/renderers/aiAnswer/contentMap.d.ts +13 -0
- package/dist/renderers/deepThinking/DeepThinkingSteps.vue.d.ts +21 -0
- package/dist/renderers/iframePage/IframePage.vue.d.ts +19 -0
- package/dist/renderers/iframePage/useIframePage.d.ts +64 -0
- package/dist/renderers/index.cjs +2 -0
- package/dist/renderers/index.d.ts +12 -0
- package/dist/renderers/index.js +609 -0
- package/dist/renderers/knowledgeStream/KnowledgeStreamResult.vue.d.ts +19 -0
- package/dist/renderers/outputFile/OutputFile.vue.d.ts +19 -0
- package/dist/renderers/outputFile/useOutputFile.d.ts +85 -0
- package/dist/renderers/style.css +1 -0
- package/dist/request/api.d.ts +132 -0
- package/dist/request/client.d.ts +30 -0
- package/dist/request/index.cjs +4 -0
- package/dist/request/index.d.ts +18 -0
- package/dist/request/index.js +264 -0
- package/dist/request/login.d.ts +37 -0
- package/dist/request/ws.d.ts +91 -0
- package/dist/style.css +24 -0
- package/dist/styles/github.css +2 -0
- package/dist/styles/katex.css +2 -0
- package/dist/theme/index.cjs +3 -0
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/index.js +37 -0
- package/dist/theme/theme.d.ts +40 -0
- package/dist/tools/attachDownload.d.ts +20 -0
- package/dist/tools/index.cjs +17 -0
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.js +251 -0
- package/dist/tools/markdown/MarkdownContent.vue.d.ts +36 -0
- package/dist/tools/markdown/imagePreview.d.ts +15 -0
- package/dist/tools/markdown/index.d.ts +5 -0
- package/dist/tools/markdown/renderMarkdown.d.ts +22 -0
- package/dist/tools/markdown/tableDownload.d.ts +14 -0
- package/dist/tools/stream.d.ts +9 -0
- package/dist/tools/style.css +1 -0
- package/dist/tools/useAutoScroll.d.ts +31 -0
- package/dist/web-ui/attach/AttachmentCard.vue.d.ts +91 -0
- package/dist/web-ui/attach/AttachmentList.vue.d.ts +94 -0
- package/dist/web-ui/attach/types.d.ts +5 -0
- package/dist/web-ui/chat/ChatContainer.vue.d.ts +165 -0
- package/dist/web-ui/chat/ChatMessagesView.vue.d.ts +88 -0
- package/dist/web-ui/chat/types.d.ts +24 -0
- package/dist/web-ui/envswitch/EnvSwitch.vue.d.ts +67 -0
- package/dist/web-ui/envswitch/types.d.ts +22 -0
- package/dist/web-ui/index.cjs +2 -0
- package/dist/web-ui/index.d.ts +14 -0
- package/dist/web-ui/index.js +1048 -0
- package/dist/web-ui/inputbox/Inputbox.vue.d.ts +215 -0
- package/dist/web-ui/recordset/RecordsetTable.vue.d.ts +37 -0
- package/dist/web-ui/recordset/webAnswerContentMap.d.ts +9 -0
- package/dist/web-ui/style.css +1 -0
- package/package.json +124 -4
- package/styles/github.css +2 -0
- package/styles/katex.css +2 -0
- package/README.md +0 -3
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { AnswerParser, BeforeKnowledgeRender, ChatAttachment, StreamChunk } from 'wi-chat/parser';
|
|
2
|
+
import { ChatApi, LoginParams, RequestClient } from 'wi-chat/request';
|
|
3
|
+
|
|
4
|
+
export interface UseChatOptions {
|
|
5
|
+
/** 后端基础地址(不含结尾斜杠);当提供 `api` 时可不填 */
|
|
6
|
+
baseURL?: string;
|
|
7
|
+
/**
|
|
8
|
+
* 自动登录账号(可含 client / system_name 及任意额外登录参数,平铺展开透传);
|
|
9
|
+
* 自建 request 且启用 autoLogin 时需提供(不提供则跳过自动登录,可自行设置 session)
|
|
10
|
+
*/
|
|
11
|
+
login?: LoginParams;
|
|
12
|
+
/** 是否启动时自动登录,默认 true(提供 `api` 时跳过) */
|
|
13
|
+
autoLogin?: boolean;
|
|
14
|
+
/** 无分组时新建分组的默认标题 */
|
|
15
|
+
defaultGroupTitle?: string;
|
|
16
|
+
/** 按分组加载历史时的拉取条数,默认 10 */
|
|
17
|
+
lastCount?: number;
|
|
18
|
+
/**
|
|
19
|
+
* 提问是否携带之前对话上下文(后端 inc_prev_question 参数):
|
|
20
|
+
* 'Y' 不忽略(默认)、'N' 忽略。作为返回的 incPrevQuestion 初始值,可在外部随时修改。
|
|
21
|
+
*/
|
|
22
|
+
incPrevQuestion?: 'Y' | 'N';
|
|
23
|
+
/**
|
|
24
|
+
* 每次提问携带的扩展参数(后端 ext_args 的原始对象),submitQuestion 时 JSON.stringify 后放入 ext_args 发送。
|
|
25
|
+
* 单次提问可用 SubmitQuestionOptions.extArgs 覆盖;构造与单次都缺省时序列化为 `{}`。
|
|
26
|
+
*/
|
|
27
|
+
extArgs?: Record<string, unknown>;
|
|
28
|
+
/**
|
|
29
|
+
* 提问提交后立即触发的回调(在 user 消息与 assistant 占位消息 push 进 messages 后触发)。
|
|
30
|
+
* 常用于通知外层 UI 立即强制滚动到底部。
|
|
31
|
+
* @param question 当前提交的提问文本
|
|
32
|
+
*/
|
|
33
|
+
onSubmitQuestion?: (question: string) => void;
|
|
34
|
+
/**
|
|
35
|
+
* 当在某个会话分组提出第一个问题时,是否自动将提问文本作为 history_group 的 title。
|
|
36
|
+
* 默认 true;若显式传 false 则不自动更新分组标题。
|
|
37
|
+
*/
|
|
38
|
+
autoSetGroupTitleOnFirstQuestion?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* 当在某个会话分组提出第一个问题时的回调。
|
|
41
|
+
* 若提供此回调,会由该回调全权负责首问联动(例如调用 useHistory.renameGroup 同步远端及分组列表);
|
|
42
|
+
* 若未提供此回调且 autoSetGroupTitleOnFirstQuestion 为 true,则内部直接调用 api.setHistoryGroupTitle。
|
|
43
|
+
* @param payload 包含提问标题文本与分组 ID
|
|
44
|
+
*/
|
|
45
|
+
onFirstQuestion?: (payload: {
|
|
46
|
+
question: string;
|
|
47
|
+
groupId: string;
|
|
48
|
+
}) => void;
|
|
49
|
+
/** 流式过程中每个 chunk 被应用后回调(可用于 UI 联动,如自动滚动) */
|
|
50
|
+
onChunk?: (chunk: StreamChunk) => void;
|
|
51
|
+
/**
|
|
52
|
+
* 流式回答正常结束后触发(主动停止或请求失败不触发)。
|
|
53
|
+
* @returns 无返回值;回调异常会按原始 Promise 语义向外抛出
|
|
54
|
+
*/
|
|
55
|
+
onFinish?: () => void;
|
|
56
|
+
/**
|
|
57
|
+
* 知识流文本写入前的处理(实时累积与 loadGroup / loadOlder 历史加载统一应用),
|
|
58
|
+
* 如把 `{{MAIN_URL}}` 占位替换成实际后端地址。解析层保留未处理原文并对其整体应用,
|
|
59
|
+
* 跨 chunk 分裂的占位符会在后续 chunk 上补全,无需幂等。缺省不处理。
|
|
60
|
+
*/
|
|
61
|
+
beforeKnowledgeRender?: BeforeKnowledgeRender;
|
|
62
|
+
/**
|
|
63
|
+
* 自定义回答类型解析器(实例注入):注入后实时流(submitQuestion)与历史加载
|
|
64
|
+
* (loadGroup / loadOlder)两条链路都会分发——chunk 按内置在前、自定义在后遍历,
|
|
65
|
+
* 历史归一化按 answer_type 查表(冲突时自定义优先);内置类型始终生效、无需注入。
|
|
66
|
+
* 配套 renderers-ui 的 contentMap 按 answerType 注册渲染组件即闭环,
|
|
67
|
+
* 见 wi-chat-parser 的 registry(AnswerParser)。
|
|
68
|
+
*/
|
|
69
|
+
parsers?: AnswerParser[];
|
|
70
|
+
/** 已构造的业务 API(供测试注入或外部已配置 auth 的场景);未提供则内部用 createRequest+createChatApi 自建 */
|
|
71
|
+
api?: ChatApi;
|
|
72
|
+
}
|
|
73
|
+
/** 提交问题入参选项 */
|
|
74
|
+
export interface SubmitQuestionOptions {
|
|
75
|
+
/** 覆盖当前提问文本,未提供则读取 question.value */
|
|
76
|
+
text?: string;
|
|
77
|
+
/** 指定调用的智能体 ID */
|
|
78
|
+
entryId?: string;
|
|
79
|
+
/** 附件文件列表 */
|
|
80
|
+
files?: File[];
|
|
81
|
+
/** 自定义附件列表(如已预构造好的附件项) */
|
|
82
|
+
attachments?: ChatAttachment[];
|
|
83
|
+
/**
|
|
84
|
+
* 本次提问的扩展参数(后端 ext_args 的原始对象),覆盖 useChat 构造的 extArgs;
|
|
85
|
+
* 两者都缺省时序列化为 `{}`。
|
|
86
|
+
*/
|
|
87
|
+
extArgs?: Record<string, unknown>;
|
|
88
|
+
/**
|
|
89
|
+
* 其余任意字段会原样透传到 questionStream 首包(如 raw_mode / tables / metrics / group_type 等后端扩展参数);
|
|
90
|
+
* 已知字段(text / entryId / files / attachments / extArgs)不会透传,同名时以已知字段为准。
|
|
91
|
+
*/
|
|
92
|
+
[key: string]: unknown;
|
|
93
|
+
}
|
|
94
|
+
export declare const useChat: (options: UseChatOptions) => {
|
|
95
|
+
/** 当前分组的消息列表(user / assistant 交错;loadGroup / loadOlder / submitQuestion 会更新) */
|
|
96
|
+
messages: import('vue').Ref<({
|
|
97
|
+
id: string;
|
|
98
|
+
historyId?: string;
|
|
99
|
+
role: "user";
|
|
100
|
+
content: string;
|
|
101
|
+
attachments?: {
|
|
102
|
+
[x: string]: any;
|
|
103
|
+
type?: string;
|
|
104
|
+
name: string;
|
|
105
|
+
description?: string;
|
|
106
|
+
attachContent?: any;
|
|
107
|
+
}[];
|
|
108
|
+
} | {
|
|
109
|
+
id: string;
|
|
110
|
+
historyId?: string;
|
|
111
|
+
role: "assistant";
|
|
112
|
+
answer: {
|
|
113
|
+
[x: string]: any;
|
|
114
|
+
id?: string;
|
|
115
|
+
question?: string;
|
|
116
|
+
answer?: {
|
|
117
|
+
[x: string]: string | {
|
|
118
|
+
[x: string]: any;
|
|
119
|
+
answer_type?: string;
|
|
120
|
+
values?: any;
|
|
121
|
+
exec_process?: {
|
|
122
|
+
mode?: string;
|
|
123
|
+
type?: string;
|
|
124
|
+
value?: any;
|
|
125
|
+
}[];
|
|
126
|
+
}[];
|
|
127
|
+
reports?: {
|
|
128
|
+
[x: string]: any;
|
|
129
|
+
answer_type?: string;
|
|
130
|
+
values?: any;
|
|
131
|
+
exec_process?: {
|
|
132
|
+
mode?: string;
|
|
133
|
+
type?: string;
|
|
134
|
+
value?: any;
|
|
135
|
+
}[];
|
|
136
|
+
}[];
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
error: boolean;
|
|
140
|
+
stopped: boolean;
|
|
141
|
+
thinking: {
|
|
142
|
+
steps: string[];
|
|
143
|
+
expanded: boolean;
|
|
144
|
+
};
|
|
145
|
+
})[]>;
|
|
146
|
+
/** 输入框内容(v-model 绑定;submitQuestion 成功后清空) */
|
|
147
|
+
question: import('vue').Ref<string>;
|
|
148
|
+
/**
|
|
149
|
+
* 提问是否携带之前对话上下文(inc_prev_question:'Y' 不忽略 / 'N' 忽略,默认 'Y')。
|
|
150
|
+
* submitQuestion 提交时读取当前值发送;可在外部随时修改(如绑定输入框组件的勾选开关)。
|
|
151
|
+
*/
|
|
152
|
+
incPrevQuestion: import('vue').Ref<"Y" | "N">;
|
|
153
|
+
/** 会话发送 / 流式回答进行中(true 时 submitQuestion 不再受理新提问) */
|
|
154
|
+
talking: import('vue').Ref<boolean>;
|
|
155
|
+
/** 历史加载中(首屏 loadGroup 及并发加载全部完成后结束) */
|
|
156
|
+
loading: import('vue').Ref<boolean>;
|
|
157
|
+
/** 当前会话 token(自动登录写入;未自动登录时可自行赋值) */
|
|
158
|
+
session: import('vue').Ref<string>;
|
|
159
|
+
/** 自动登录流程已结束(成功 / 失败 / 跳过均置 true;UI 可等待它再渲染登录状态) */
|
|
160
|
+
autoLoginDone: import('vue').Ref<boolean>;
|
|
161
|
+
/** 最近一次自动登录的错误信息(UI 可据此提示重试) */
|
|
162
|
+
autoLoginError: import('vue').Ref<string>;
|
|
163
|
+
/** 自动登录完成时机(无论成败都会 resolve;宿主用它编排"登录后才能发"的请求,如加载历史分组) */
|
|
164
|
+
loginDone: Promise<void>;
|
|
165
|
+
/** 当前会话所在的历史分组 id */
|
|
166
|
+
historyGroupId: import('vue').Ref<string>;
|
|
167
|
+
/** 内部自建的 request 客户端(注入 api 时为 null,无使用价值) */
|
|
168
|
+
selfRequest: RequestClient;
|
|
169
|
+
/** 实际使用的业务 API(外部注入的实例或内部自建) */
|
|
170
|
+
api: ChatApi;
|
|
171
|
+
/** 手动触发一次自动登录(成功返回登录结果;失败抛错并记录到 autoLoginError) */
|
|
172
|
+
doAutoLogin: () => Promise<import('wi-chat/request').LoginResult>;
|
|
173
|
+
/** 按分组加载消息(插空式渐进渲染;并发调用时仅最新一次生效) */
|
|
174
|
+
loadGroup: (groupId: string) => Promise<void>;
|
|
175
|
+
/** 加载更早一页历史(向上翻页),前插到消息列表顶部 */
|
|
176
|
+
loadOlder: () => Promise<void>;
|
|
177
|
+
/** 是否仍可能有更早历史(向上翻页) */
|
|
178
|
+
hasMore: import('vue').Ref<boolean>;
|
|
179
|
+
/** 向上翻页加载中(触顶防重) */
|
|
180
|
+
loadMoreLoading: import('vue').Ref<boolean>;
|
|
181
|
+
/** 新建历史分组并选中(返回分组 id) */
|
|
182
|
+
createGroup: (title?: string) => Promise<string>;
|
|
183
|
+
/** 提交问题并走 SSE 流式问答(支持传参 entryId、files 与文本;无文本 / 发送中 / 无分组时不发送) */
|
|
184
|
+
submitQuestion: (customOptions?: string | SubmitQuestionOptions) => Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* 向当前提问的 WebSocket 连接追发自定义消息(B/M/E 分帧):
|
|
187
|
+
* 连接就绪立即发出、未就绪入队待连接建立后按序补发;仅在 talking 期间受理,
|
|
188
|
+
* 无在途会话返回 false。见 sendWsMessage 的 JSDoc。
|
|
189
|
+
*/
|
|
190
|
+
sendWsMessage: (message: unknown, chunkSize?: number) => boolean;
|
|
191
|
+
/** 停止在途会话:中断流、把当前回答标记为 stopped,并复位 talking */
|
|
192
|
+
stopQuestion: () => void;
|
|
193
|
+
};
|
|
194
|
+
/** useChat 返回值类型(成员说明见 useChat 返回对象的逐项 JSDoc) */
|
|
195
|
+
export type UseChatReturn = ReturnType<typeof useChat>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { AnswerParser } from 'wi-chat/parser';
|
|
2
|
+
import { UseAgentOptions, UseAgentReturn } from './useAgent';
|
|
3
|
+
import { SubmitQuestionOptions, UseChatOptions, UseChatReturn } from './useChat';
|
|
4
|
+
import { UseHistoryOptions, UseHistoryReturn } from './useHistory';
|
|
5
|
+
|
|
6
|
+
/** useChatSession 允许透传给 useChat 的配置(API、parser 与首问逻辑由本层接管) */
|
|
7
|
+
export type UseChatSessionChatOptions = Omit<UseChatOptions, 'api' | 'parsers' | 'onFirstQuestion' | 'autoSetGroupTitleOnFirstQuestion'>;
|
|
8
|
+
/** useChatSession 允许透传给 useHistory 的配置(API、消息加载与 parser 由本层接管) */
|
|
9
|
+
export type UseChatSessionHistoryOptions = Omit<UseHistoryOptions, 'api' | 'autoLoadMessages' | 'parsers'>;
|
|
10
|
+
/** useChatSession 允许透传给 useAgent 的配置(API 与自动加载由本层接管) */
|
|
11
|
+
export type UseChatSessionAgentOptions = Omit<UseAgentOptions, 'api' | 'autoLoad'>;
|
|
12
|
+
/** useChatSession 异步流程出错的位置 */
|
|
13
|
+
export type UseChatSessionErrorScope = 'groups' | 'messages' | 'agents';
|
|
14
|
+
/** useChatSession 入参配置 */
|
|
15
|
+
export interface UseChatSessionOptions {
|
|
16
|
+
/** useChat 配置;api、parsers、首问改名由本层统一接管 */
|
|
17
|
+
chat?: UseChatSessionChatOptions;
|
|
18
|
+
/** useHistory 配置;api、消息加载与 parsers 由本层统一接管 */
|
|
19
|
+
history?: UseChatSessionHistoryOptions;
|
|
20
|
+
/** useAgent 配置;api 与自动加载由本层统一接管 */
|
|
21
|
+
agent?: UseChatSessionAgentOptions;
|
|
22
|
+
/** 自定义回答类型解析器;同一份 parser 会注入实时流与历史加载两条链路 */
|
|
23
|
+
parsers?: AnswerParser[];
|
|
24
|
+
/** 内部异步流程失败回调;不提供时错误被捕获以避免 unhandled rejection */
|
|
25
|
+
onError?: (error: unknown, scope: UseChatSessionErrorScope) => void;
|
|
26
|
+
}
|
|
27
|
+
/** useChatSession 返回对象接口 */
|
|
28
|
+
export interface UseChatSessionReturn {
|
|
29
|
+
/** 底层对话状态机(需要更细粒度能力时可直接使用) */
|
|
30
|
+
chat: UseChatReturn;
|
|
31
|
+
/** 底层历史分组管理器(侧栏的新建、改名、删除可直接调用) */
|
|
32
|
+
history: UseHistoryReturn;
|
|
33
|
+
/** 底层智能体管理器 */
|
|
34
|
+
agent: UseAgentReturn;
|
|
35
|
+
/** 注入实时流与历史加载的自定义 parser 列表 */
|
|
36
|
+
parsers: AnswerParser[];
|
|
37
|
+
/** 当前分组消息列表 */
|
|
38
|
+
messages: UseChatReturn['messages'];
|
|
39
|
+
/** 输入框文本 */
|
|
40
|
+
question: UseChatReturn['question'];
|
|
41
|
+
/** 提问是否携带之前对话上下文 */
|
|
42
|
+
incPrevQuestion: UseChatReturn['incPrevQuestion'];
|
|
43
|
+
/** 流式回答是否进行中 */
|
|
44
|
+
talking: UseChatReturn['talking'];
|
|
45
|
+
/** 消息历史是否加载中 */
|
|
46
|
+
loading: UseChatReturn['loading'];
|
|
47
|
+
/** 当前会话 token;登录成功后由 useChat 写入 */
|
|
48
|
+
session: UseChatReturn['session'];
|
|
49
|
+
/** 历史分组列表 */
|
|
50
|
+
groups: UseHistoryReturn['groups'];
|
|
51
|
+
/** 当前选中的历史分组 id */
|
|
52
|
+
activeGroupId: UseHistoryReturn['activeGroupId'];
|
|
53
|
+
/** 历史分组列表是否加载中 */
|
|
54
|
+
historyLoading: UseHistoryReturn['loading'];
|
|
55
|
+
/** 智能体列表 */
|
|
56
|
+
agentList: UseAgentReturn['agentList'];
|
|
57
|
+
/** 当前选中的智能体 */
|
|
58
|
+
currentAgent: UseAgentReturn['currentAgent'];
|
|
59
|
+
/** 智能体列表是否加载中 */
|
|
60
|
+
agentLoading: UseAgentReturn['loading'];
|
|
61
|
+
/** 是否还有更早历史可加载 */
|
|
62
|
+
hasMore: UseChatReturn['hasMore'];
|
|
63
|
+
/** 向上翻页是否加载中 */
|
|
64
|
+
loadMoreLoading: UseChatReturn['loadMoreLoading'];
|
|
65
|
+
/** 按分组加载消息 */
|
|
66
|
+
loadGroup: (groupId: string) => Promise<void>;
|
|
67
|
+
/** 加载更早一页历史 */
|
|
68
|
+
loadOlder: UseChatReturn['loadOlder'];
|
|
69
|
+
/** 刷新历史分组列表 */
|
|
70
|
+
refreshGroups: () => Promise<void>;
|
|
71
|
+
/** 刷新智能体列表 */
|
|
72
|
+
loadAgents: UseAgentReturn['loadAgents'];
|
|
73
|
+
/** 切换当前智能体 */
|
|
74
|
+
selectAgent: UseAgentReturn['selectAgent'];
|
|
75
|
+
/** 获取文件访问完整 URL */
|
|
76
|
+
getFileUrl: UseAgentReturn['getFileUrl'];
|
|
77
|
+
/** 提交问题;未显式传 entryId 时使用当前智能体,等待首问改名落盘后刷新分组 */
|
|
78
|
+
submitQuestion: (customOptions?: string | SubmitQuestionOptions) => Promise<void>;
|
|
79
|
+
/** 向当前提问的 WebSocket 连接追发自定义消息(仅 talking 期间受理,无在途会话返回 false) */
|
|
80
|
+
sendWsMessage: UseChatReturn['sendWsMessage'];
|
|
81
|
+
/** 停止当前流式回答 */
|
|
82
|
+
stopQuestion: UseChatReturn['stopQuestion'];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* 创建聚合对话会话:统一编排对话状态、历史分组与智能体选择。
|
|
86
|
+
* @param options 会话配置,见 UseChatSessionOptions
|
|
87
|
+
* @returns 状态与方法集合,见 UseChatSessionReturn
|
|
88
|
+
*/
|
|
89
|
+
export declare const useChatSession: (options?: UseChatSessionOptions) => UseChatSessionReturn;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { AnswerParser, BeforeKnowledgeRender, Message } from 'wi-chat/parser';
|
|
3
|
+
import { ChatApi, HistoryGroup } from 'wi-chat/request';
|
|
4
|
+
|
|
5
|
+
export interface UseHistoryOptions {
|
|
6
|
+
/** 业务 API(与 useChat 共用可传同一实例) */
|
|
7
|
+
api: ChatApi;
|
|
8
|
+
/** 新建分组的默认标题(自动建组时也用它,由外层自定义) */
|
|
9
|
+
defaultGroupTitle?: string;
|
|
10
|
+
/** 每组加载的会话条数,默认 10 */
|
|
11
|
+
lastCount?: number;
|
|
12
|
+
/** 拉取后列表为空时自动创建一个分组,默认 true */
|
|
13
|
+
ensureGroup?: boolean;
|
|
14
|
+
/** 拉取后无选中分组时自动选中第一个,默认 true */
|
|
15
|
+
autoSelectFirst?: boolean;
|
|
16
|
+
/** 选中分组时是否加载会话消息到本 composable 的 messages;与 useChat 配用(消息由 useChat 加载)时可关闭以避免重复请求,默认 true */
|
|
17
|
+
autoLoadMessages?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* 知识流文本写入前的处理(仅 autoLoadMessages 开启时的消息加载路径生效;
|
|
20
|
+
* 与 useChat 配用时建议关闭本开关、由 useChat 的 beforeKnowledgeRender 统一处理,避免双重处理)。
|
|
21
|
+
* 见 wi-chat-parser 的 BeforeKnowledgeRender。
|
|
22
|
+
*/
|
|
23
|
+
beforeKnowledgeRender?: BeforeKnowledgeRender;
|
|
24
|
+
/**
|
|
25
|
+
* 自定义回答类型解析器(实例注入,仅 autoLoadMessages 开启时的消息加载路径生效,
|
|
26
|
+
* 历史归一化按 answer_type 分发到内置 + 自定义 parser);
|
|
27
|
+
* 与 useChat 配用时建议关闭本开关、由 useChat 的 parsers 统一注入,
|
|
28
|
+
* 避免同一份历史跑两遍归一化。见 wi-chat-parser 的 registry(AnswerParser)。
|
|
29
|
+
*/
|
|
30
|
+
parsers?: AnswerParser[];
|
|
31
|
+
/**
|
|
32
|
+
* 是否把分组列表持久化到 localStorage,默认 false。
|
|
33
|
+
* 开启后:loadGroups = 远端 ∩ 本地,交集回写本地;新建 / 改名 / 删除同步本地;
|
|
34
|
+
* 首次(localStorage 无记录)即空集(存量分组不显示,空列表走 ensureGroup 自动建组);
|
|
35
|
+
* Storage 不可用(如隐私模式)时本次自动降级为关闭(用远端全量、不读写)。
|
|
36
|
+
*/
|
|
37
|
+
persistGroups?: boolean;
|
|
38
|
+
/** 分组持久化的 localStorage key(仅 persistGroups 开启时生效),默认 'wi-chat-history-groups' */
|
|
39
|
+
storageKey?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface UseHistoryReturn {
|
|
42
|
+
/** 历史分组列表(按 create_time 降序;persistGroups 开启时为远端 ∩ 本地) */
|
|
43
|
+
groups: Ref<HistoryGroup[]>;
|
|
44
|
+
/** 当前选中的分组 id(可双向绑定控制选中) */
|
|
45
|
+
activeGroupId: Ref<string>;
|
|
46
|
+
/** 当前选中分组的会话消息(autoLoadMessages 关闭时始终为空,由 useChat 加载) */
|
|
47
|
+
messages: Ref<Message[]>;
|
|
48
|
+
/** 分组列表 / 会话消息加载中 */
|
|
49
|
+
loading: Ref<boolean>;
|
|
50
|
+
/** 拉取历史分组列表;空列表自动建组(ensureGroup),无选中时自动选第一个(autoSelectFirst) */
|
|
51
|
+
loadGroups: () => Promise<void>;
|
|
52
|
+
/** 新建分组(返回分组 id,刷新列表并选中新组) */
|
|
53
|
+
createGroup: (title?: string) => Promise<string>;
|
|
54
|
+
/** 修改分组标题 */
|
|
55
|
+
renameGroup: (groupId: string, title: string) => Promise<void>;
|
|
56
|
+
/** 删除分组;若删除的是当前分组则自动选中相邻分组(列表空时按 ensureGroup 自动新建) */
|
|
57
|
+
deleteGroup: (groupId: string) => Promise<void>;
|
|
58
|
+
/** 选中分组并加载会话消息(autoLoadMessages 为 false 时仅选中) */
|
|
59
|
+
selectGroup: (groupId: string) => Promise<void>;
|
|
60
|
+
/** 刷新当前分组会话(重新拉取) */
|
|
61
|
+
loadMessages: (groupId: string, lastCount?: number) => Promise<void>;
|
|
62
|
+
}
|
|
63
|
+
export declare const useHistory: (options: UseHistoryOptions) => UseHistoryReturn;
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("wi-chat/style.css");const r=require("wi-chat/request"),e=require("wi-chat/parser"),a=require("wi-chat/theme"),n=require("wi-chat/core"),t=require("wi-chat/tools");Object.defineProperty(exports,"AuthExpiredError",{enumerable:!0,get:()=>r.AuthExpiredError});Object.defineProperty(exports,"buildChatWsUrl",{enumerable:!0,get:()=>r.buildChatWsUrl});Object.defineProperty(exports,"createChatApi",{enumerable:!0,get:()=>r.createChatApi});Object.defineProperty(exports,"createRequest",{enumerable:!0,get:()=>r.createRequest});Object.defineProperty(exports,"fileToBase64",{enumerable:!0,get:()=>r.fileToBase64});Object.defineProperty(exports,"formDataToJson",{enumerable:!0,get:()=>r.formDataToJson});Object.defineProperty(exports,"isCancelError",{enumerable:!0,get:()=>r.isCancelError});Object.defineProperty(exports,"login",{enumerable:!0,get:()=>r.login});Object.defineProperty(exports,"openChatWebSocketStream",{enumerable:!0,get:()=>r.openChatWebSocketStream});Object.defineProperty(exports,"pwdEncrypt",{enumerable:!0,get:()=>r.pwdEncrypt});Object.defineProperty(exports,"resolveMessageData",{enumerable:!0,get:()=>r.resolveMessageData});Object.defineProperty(exports,"sendPayloadInChunks",{enumerable:!0,get:()=>r.sendPayloadInChunks});Object.defineProperty(exports,"IFRAME_RESIZER_CHILD_SCRIPT",{enumerable:!0,get:()=>e.IFRAME_RESIZER_CHILD_SCRIPT});Object.defineProperty(exports,"IMAGE_EXTENSIONS",{enumerable:!0,get:()=>e.IMAGE_EXTENSIONS});Object.defineProperty(exports,"OUTPUT_FILE_ANSWER_TYPE",{enumerable:!0,get:()=>e.OUTPUT_FILE_ANSWER_TYPE});Object.defineProperty(exports,"RECORDSET_ANSWER_TYPE",{enumerable:!0,get:()=>e.RECORDSET_ANSWER_TYPE});Object.defineProperty(exports,"RoleEnum",{enumerable:!0,get:()=>e.RoleEnum});Object.defineProperty(exports,"applyAnswerChunk",{enumerable:!0,get:()=>e.applyAnswerChunk});Object.defineProperty(exports,"applyDeepThinkingChunk",{enumerable:!0,get:()=>e.applyDeepThinkingChunk});Object.defineProperty(exports,"applyIframePageChunk",{enumerable:!0,get:()=>e.applyIframePageChunk});Object.defineProperty(exports,"applyKnowledgeStreamChunk",{enumerable:!0,get:()=>e.applyKnowledgeStreamChunk});Object.defineProperty(exports,"applyOutputFileChunk",{enumerable:!0,get:()=>e.applyOutputFileChunk});Object.defineProperty(exports,"applyRecordsetChunk",{enumerable:!0,get:()=>e.applyRecordsetChunk});Object.defineProperty(exports,"collectDeepThinkingSteps",{enumerable:!0,get:()=>e.collectDeepThinkingSteps});Object.defineProperty(exports,"collectThinkingSteps",{enumerable:!0,get:()=>e.collectThinkingSteps});Object.defineProperty(exports,"consumeStream",{enumerable:!0,get:()=>e.consumeStream});Object.defineProperty(exports,"createEmptyAnswerValues",{enumerable:!0,get:()=>e.createEmptyAnswerValues});Object.defineProperty(exports,"createHistoryGroup",{enumerable:!0,get:()=>e.createHistoryGroup});Object.defineProperty(exports,"createLineSplitter",{enumerable:!0,get:()=>e.createLineSplitter});Object.defineProperty(exports,"deepThinkingParser",{enumerable:!0,get:()=>e.deepThinkingParser});Object.defineProperty(exports,"deleteHistoryGroup",{enumerable:!0,get:()=>e.deleteHistoryGroup});Object.defineProperty(exports,"extractAttachmentsFromHistory",{enumerable:!0,get:()=>e.extractAttachmentsFromHistory});Object.defineProperty(exports,"extractHistoryAttachments",{enumerable:!0,get:()=>e.extractHistoryAttachments});Object.defineProperty(exports,"formatFileSize",{enumerable:!0,get:()=>e.formatFileSize});Object.defineProperty(exports,"getHistoryGroups",{enumerable:!0,get:()=>e.getHistoryGroups});Object.defineProperty(exports,"iframePageParser",{enumerable:!0,get:()=>e.iframePageParser});Object.defineProperty(exports,"injectIframeResizerScript",{enumerable:!0,get:()=>e.injectIframeResizerScript});Object.defineProperty(exports,"isImageAttachment",{enumerable:!0,get:()=>e.isImageAttachment});Object.defineProperty(exports,"knowledgeStreamParser",{enumerable:!0,get:()=>e.knowledgeStreamParser});Object.defineProperty(exports,"loadGroupMessages",{enumerable:!0,get:()=>e.loadGroupMessages});Object.defineProperty(exports,"loadGroupMessagesByStep",{enumerable:!0,get:()=>e.loadGroupMessagesByStep});Object.defineProperty(exports,"nextLocalMessageId",{enumerable:!0,get:()=>e.nextLocalMessageId});Object.defineProperty(exports,"normalizeAnswer",{enumerable:!0,get:()=>e.normalizeAnswer});Object.defineProperty(exports,"normalizeAnswerReport",{enumerable:!0,get:()=>e.normalizeAnswerReport});Object.defineProperty(exports,"normalizeAttachment",{enumerable:!0,get:()=>e.normalizeAttachment});Object.defineProperty(exports,"normalizeIframePageReport",{enumerable:!0,get:()=>e.normalizeIframePageReport});Object.defineProperty(exports,"normalizeKnowledgeStreamReport",{enumerable:!0,get:()=>e.normalizeKnowledgeStreamReport});Object.defineProperty(exports,"normalizeOutputFileReport",{enumerable:!0,get:()=>e.normalizeOutputFileReport});Object.defineProperty(exports,"normalizeRecordsetReport",{enumerable:!0,get:()=>e.normalizeRecordsetReport});Object.defineProperty(exports,"outputFileParser",{enumerable:!0,get:()=>e.outputFileParser});Object.defineProperty(exports,"parseHistoryAttachment",{enumerable:!0,get:()=>e.parseHistoryAttachment});Object.defineProperty(exports,"parseRealtimeAttachment",{enumerable:!0,get:()=>e.parseRealtimeAttachment});Object.defineProperty(exports,"parseSseLine",{enumerable:!0,get:()=>e.parseSseLine});Object.defineProperty(exports,"readOutputFilePayload",{enumerable:!0,get:()=>e.readOutputFilePayload});Object.defineProperty(exports,"readRecordsetPayload",{enumerable:!0,get:()=>e.readRecordsetPayload});Object.defineProperty(exports,"recordsetParser",{enumerable:!0,get:()=>e.recordsetParser});Object.defineProperty(exports,"resolveAttachDownloadUrl",{enumerable:!0,get:()=>e.resolveAttachDownloadUrl});Object.defineProperty(exports,"resolveAttachPreviewUrl",{enumerable:!0,get:()=>e.resolveAttachPreviewUrl});Object.defineProperty(exports,"resolveRemoteFileUrl",{enumerable:!0,get:()=>e.resolveRemoteFileUrl});Object.defineProperty(exports,"setHistoryGroupTitle",{enumerable:!0,get:()=>e.setHistoryGroupTitle});Object.defineProperty(exports,"DEFAULT_PRIMARY",{enumerable:!0,get:()=>a.DEFAULT_PRIMARY});Object.defineProperty(exports,"applyTheme",{enumerable:!0,get:()=>a.applyTheme});Object.defineProperty(exports,"createChatTheme",{enumerable:!0,get:()=>a.createChatTheme});Object.defineProperty(exports,"useAgent",{enumerable:!0,get:()=>n.useAgent});Object.defineProperty(exports,"useChat",{enumerable:!0,get:()=>n.useChat});Object.defineProperty(exports,"useChatSession",{enumerable:!0,get:()=>n.useChatSession});Object.defineProperty(exports,"useHistory",{enumerable:!0,get:()=>n.useHistory});Object.defineProperty(exports,"closeImagePreview",{enumerable:!0,get:()=>t.closeImagePreview});Object.defineProperty(exports,"downloadAttachment",{enumerable:!0,get:()=>t.downloadAttachment});Object.defineProperty(exports,"openImagePreview",{enumerable:!0,get:()=>t.openImagePreview});Object.defineProperty(exports,"renderMarkdown",{enumerable:!0,get:()=>t.renderMarkdown});Object.defineProperty(exports,"useAutoScroll",{enumerable:!0,get:()=>t.useAutoScroll});
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
export { AuthExpiredError, isCancelError, createRequest, pwdEncrypt, login, createChatApi, fileToBase64, formDataToJson, buildChatWsUrl, resolveMessageData, sendPayloadInChunks, openChatWebSocketStream } from 'wi-chat/request';
|
|
3
|
+
export type { RequestOptions, RequestClient, LoginParams, LoginResult, HistoryGroup, HistoryGroupsResult, HistoryDetailItem, AgentEntryItem, ChatApi, FileJsonValue, ChatWsStreamOptions, WsChunkSender } from 'wi-chat/request';
|
|
4
|
+
export { normalizeAnswer, applyAnswerChunk, normalizeAnswerReport, RoleEnum, nextLocalMessageId, parseSseLine, createLineSplitter, consumeStream, IMAGE_EXTENSIONS, formatFileSize, isImageAttachment, resolveRemoteFileUrl, resolveAttachDownloadUrl, resolveAttachPreviewUrl, parseRealtimeAttachment, parseHistoryAttachment, extractHistoryAttachments, normalizeAttachment, createEmptyAnswerValues, applyKnowledgeStreamChunk, normalizeKnowledgeStreamReport, knowledgeStreamParser, IFRAME_RESIZER_CHILD_SCRIPT, injectIframeResizerScript, applyIframePageChunk, normalizeIframePageReport, iframePageParser, RECORDSET_ANSWER_TYPE, readRecordsetPayload, applyRecordsetChunk, normalizeRecordsetReport, recordsetParser, OUTPUT_FILE_ANSWER_TYPE, readOutputFilePayload, applyOutputFileChunk, normalizeOutputFileReport, outputFileParser, applyDeepThinkingChunk, collectDeepThinkingSteps, collectThinkingSteps, deepThinkingParser, extractAttachmentsFromHistory, getHistoryGroups, createHistoryGroup, deleteHistoryGroup, setHistoryGroupTitle, loadGroupMessages, loadGroupMessagesByStep } from 'wi-chat/parser';
|
|
5
|
+
export type { AiAnswerReport, AiAnswerValues, AnswerParser, AnswerParseOptions, Role, UserMessage, AssistantMessage, Message, StreamChunk, LineSplitter, ChatAttachment, FileAttachContent, AttachmentType, KnowledgeStreamValue, BeforeKnowledgeRender, KnowledgeRenderOptions, IframePageValue, RecordsetColumn, RecordsetValue, OutputFileValue, ExecProcessItem, GroupMessagesProgress } from 'wi-chat/parser';
|
|
6
|
+
export { DEFAULT_PRIMARY, createChatTheme, applyTheme } from 'wi-chat/theme';
|
|
7
|
+
export type { ChatThemeOptions, ChatThemeTokens } from 'wi-chat/theme';
|
|
8
|
+
export { useChat, useHistory, useAgent, useChatSession } from 'wi-chat/core';
|
|
9
|
+
export type { SubmitQuestionOptions, UseChatOptions, UseChatReturn, UseHistoryOptions, UseHistoryReturn, UseAgentOptions, UseAgentReturn, UseChatSessionAgentOptions, UseChatSessionChatOptions, UseChatSessionErrorScope, UseChatSessionHistoryOptions, UseChatSessionOptions, UseChatSessionReturn } from 'wi-chat/core';
|
|
10
|
+
export { renderMarkdown, openImagePreview, closeImagePreview, downloadAttachment, useAutoScroll } from 'wi-chat/tools';
|
|
11
|
+
export type { MarkdownRenderOptions, DownloadAttachmentOptions, OnReachTopOptions, UseAutoScrollReturn } from 'wi-chat/tools';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import "wi-chat/style.css";
|
|
2
|
+
import { AuthExpiredError as a, buildChatWsUrl as o, createChatApi as s, createRequest as l, fileToBase64 as n, formDataToJson as p, isCancelError as i, login as m, openChatWebSocketStream as c, pwdEncrypt as u, resolveMessageData as h, sendPayloadInChunks as d } from "wi-chat/request";
|
|
3
|
+
import { IFRAME_RESIZER_CHILD_SCRIPT as R, IMAGE_EXTENSIONS as S, OUTPUT_FILE_ANSWER_TYPE as y, RECORDSET_ANSWER_TYPE as g, RoleEnum as E, applyAnswerChunk as P, applyDeepThinkingChunk as C, applyIframePageChunk as T, applyKnowledgeStreamChunk as I, applyOutputFileChunk as k, applyRecordsetChunk as w, collectDeepThinkingSteps as f, collectThinkingSteps as F, consumeStream as _, createEmptyAnswerValues as x, createHistoryGroup as z, createLineSplitter as H, deepThinkingParser as D, deleteHistoryGroup as M, extractAttachmentsFromHistory as v, extractHistoryAttachments as G, formatFileSize as U, getHistoryGroups as L, iframePageParser as O, injectIframeResizerScript as N, isImageAttachment as W, knowledgeStreamParser as Y, loadGroupMessages as b, loadGroupMessagesByStep as B, nextLocalMessageId as K, normalizeAnswer as j, normalizeAnswerReport as q, normalizeAttachment as J, normalizeIframePageReport as V, normalizeKnowledgeStreamReport as X, normalizeOutputFileReport as Z, normalizeRecordsetReport as Q, outputFileParser as $, parseHistoryAttachment as ee, parseRealtimeAttachment as re, parseSseLine as te, readOutputFilePayload as ae, readRecordsetPayload as oe, recordsetParser as se, resolveAttachDownloadUrl as le, resolveAttachPreviewUrl as ne, resolveRemoteFileUrl as pe, setHistoryGroupTitle as ie } from "wi-chat/parser";
|
|
4
|
+
import { DEFAULT_PRIMARY as ce, applyTheme as ue, createChatTheme as he } from "wi-chat/theme";
|
|
5
|
+
import { useAgent as Ae, useChat as Re, useChatSession as Se, useHistory as ye } from "wi-chat/core";
|
|
6
|
+
import { closeImagePreview as Ee, downloadAttachment as Pe, openImagePreview as Ce, renderMarkdown as Te, useAutoScroll as Ie } from "wi-chat/tools";
|
|
7
|
+
export {
|
|
8
|
+
a as AuthExpiredError,
|
|
9
|
+
ce as DEFAULT_PRIMARY,
|
|
10
|
+
R as IFRAME_RESIZER_CHILD_SCRIPT,
|
|
11
|
+
S as IMAGE_EXTENSIONS,
|
|
12
|
+
y as OUTPUT_FILE_ANSWER_TYPE,
|
|
13
|
+
g as RECORDSET_ANSWER_TYPE,
|
|
14
|
+
E as RoleEnum,
|
|
15
|
+
P as applyAnswerChunk,
|
|
16
|
+
C as applyDeepThinkingChunk,
|
|
17
|
+
T as applyIframePageChunk,
|
|
18
|
+
I as applyKnowledgeStreamChunk,
|
|
19
|
+
k as applyOutputFileChunk,
|
|
20
|
+
w as applyRecordsetChunk,
|
|
21
|
+
ue as applyTheme,
|
|
22
|
+
o as buildChatWsUrl,
|
|
23
|
+
Ee as closeImagePreview,
|
|
24
|
+
f as collectDeepThinkingSteps,
|
|
25
|
+
F as collectThinkingSteps,
|
|
26
|
+
_ as consumeStream,
|
|
27
|
+
s as createChatApi,
|
|
28
|
+
he as createChatTheme,
|
|
29
|
+
x as createEmptyAnswerValues,
|
|
30
|
+
z as createHistoryGroup,
|
|
31
|
+
H as createLineSplitter,
|
|
32
|
+
l as createRequest,
|
|
33
|
+
D as deepThinkingParser,
|
|
34
|
+
M as deleteHistoryGroup,
|
|
35
|
+
Pe as downloadAttachment,
|
|
36
|
+
v as extractAttachmentsFromHistory,
|
|
37
|
+
G as extractHistoryAttachments,
|
|
38
|
+
n as fileToBase64,
|
|
39
|
+
p as formDataToJson,
|
|
40
|
+
U as formatFileSize,
|
|
41
|
+
L as getHistoryGroups,
|
|
42
|
+
O as iframePageParser,
|
|
43
|
+
N as injectIframeResizerScript,
|
|
44
|
+
i as isCancelError,
|
|
45
|
+
W as isImageAttachment,
|
|
46
|
+
Y as knowledgeStreamParser,
|
|
47
|
+
b as loadGroupMessages,
|
|
48
|
+
B as loadGroupMessagesByStep,
|
|
49
|
+
m as login,
|
|
50
|
+
K as nextLocalMessageId,
|
|
51
|
+
j as normalizeAnswer,
|
|
52
|
+
q as normalizeAnswerReport,
|
|
53
|
+
J as normalizeAttachment,
|
|
54
|
+
V as normalizeIframePageReport,
|
|
55
|
+
X as normalizeKnowledgeStreamReport,
|
|
56
|
+
Z as normalizeOutputFileReport,
|
|
57
|
+
Q as normalizeRecordsetReport,
|
|
58
|
+
c as openChatWebSocketStream,
|
|
59
|
+
Ce as openImagePreview,
|
|
60
|
+
$ as outputFileParser,
|
|
61
|
+
ee as parseHistoryAttachment,
|
|
62
|
+
re as parseRealtimeAttachment,
|
|
63
|
+
te as parseSseLine,
|
|
64
|
+
u as pwdEncrypt,
|
|
65
|
+
ae as readOutputFilePayload,
|
|
66
|
+
oe as readRecordsetPayload,
|
|
67
|
+
se as recordsetParser,
|
|
68
|
+
Te as renderMarkdown,
|
|
69
|
+
le as resolveAttachDownloadUrl,
|
|
70
|
+
ne as resolveAttachPreviewUrl,
|
|
71
|
+
h as resolveMessageData,
|
|
72
|
+
pe as resolveRemoteFileUrl,
|
|
73
|
+
d as sendPayloadInChunks,
|
|
74
|
+
ie as setHistoryGroupTitle,
|
|
75
|
+
Ae as useAgent,
|
|
76
|
+
Ie as useAutoScroll,
|
|
77
|
+
Re as useChat,
|
|
78
|
+
Se as useChatSession,
|
|
79
|
+
ye as useHistory
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { AnswerParser, AssistantMessage, Message } from 'wi-chat/parser';
|
|
2
|
+
import { OutputFileConfig } from 'wi-chat/renderers';
|
|
3
|
+
import { ChatSubmitPayload } from './types';
|
|
4
|
+
|
|
5
|
+
declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
6
|
+
/** 当前分组消息列表 */
|
|
7
|
+
messages: Message[];
|
|
8
|
+
/** 自定义回答类型 parser */
|
|
9
|
+
parsers?: AnswerParser<any>[];
|
|
10
|
+
/** output_file 文件加载 / 预览配置 */
|
|
11
|
+
outputFileConfig?: OutputFileConfig;
|
|
12
|
+
/** 历史消息是否加载中 */
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
/** 流式回答是否进行中 */
|
|
15
|
+
talking?: boolean;
|
|
16
|
+
/** 会话 token;为空时禁用输入 */
|
|
17
|
+
session?: string;
|
|
18
|
+
/** 输入框文本 */
|
|
19
|
+
question?: string;
|
|
20
|
+
/** 输入框占位文案 */
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
/** 是否还有更早历史可加载 */
|
|
23
|
+
hasMore?: boolean;
|
|
24
|
+
/** 空态主标题 */
|
|
25
|
+
emptyTitle?: string;
|
|
26
|
+
/** 空态描述文案 */
|
|
27
|
+
emptyDescription?: string;
|
|
28
|
+
/** 是否禁用输入区 */
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
}>, {
|
|
31
|
+
messages: () => any[];
|
|
32
|
+
parsers: () => any[];
|
|
33
|
+
loading: boolean;
|
|
34
|
+
talking: boolean;
|
|
35
|
+
session: string;
|
|
36
|
+
question: string;
|
|
37
|
+
placeholder: string;
|
|
38
|
+
hasMore: boolean;
|
|
39
|
+
emptyTitle: string;
|
|
40
|
+
emptyDescription: string;
|
|
41
|
+
disabled: boolean;
|
|
42
|
+
}>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
43
|
+
"update:question": (value: string) => void;
|
|
44
|
+
submit: (payload: ChatSubmitPayload) => void;
|
|
45
|
+
stop: () => void;
|
|
46
|
+
loadOlder: () => void;
|
|
47
|
+
updateThinkingExpanded: (message: AssistantMessage, expanded: boolean) => void;
|
|
48
|
+
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
49
|
+
/** 当前分组消息列表 */
|
|
50
|
+
messages: Message[];
|
|
51
|
+
/** 自定义回答类型 parser */
|
|
52
|
+
parsers?: AnswerParser<any>[];
|
|
53
|
+
/** output_file 文件加载 / 预览配置 */
|
|
54
|
+
outputFileConfig?: OutputFileConfig;
|
|
55
|
+
/** 历史消息是否加载中 */
|
|
56
|
+
loading?: boolean;
|
|
57
|
+
/** 流式回答是否进行中 */
|
|
58
|
+
talking?: boolean;
|
|
59
|
+
/** 会话 token;为空时禁用输入 */
|
|
60
|
+
session?: string;
|
|
61
|
+
/** 输入框文本 */
|
|
62
|
+
question?: string;
|
|
63
|
+
/** 输入框占位文案 */
|
|
64
|
+
placeholder?: string;
|
|
65
|
+
/** 是否还有更早历史可加载 */
|
|
66
|
+
hasMore?: boolean;
|
|
67
|
+
/** 空态主标题 */
|
|
68
|
+
emptyTitle?: string;
|
|
69
|
+
/** 空态描述文案 */
|
|
70
|
+
emptyDescription?: string;
|
|
71
|
+
/** 是否禁用输入区 */
|
|
72
|
+
disabled?: boolean;
|
|
73
|
+
}>, {
|
|
74
|
+
messages: () => any[];
|
|
75
|
+
parsers: () => any[];
|
|
76
|
+
loading: boolean;
|
|
77
|
+
talking: boolean;
|
|
78
|
+
session: string;
|
|
79
|
+
question: string;
|
|
80
|
+
placeholder: string;
|
|
81
|
+
hasMore: boolean;
|
|
82
|
+
emptyTitle: string;
|
|
83
|
+
emptyDescription: string;
|
|
84
|
+
disabled: boolean;
|
|
85
|
+
}>>> & {
|
|
86
|
+
onSubmit?: (payload: ChatSubmitPayload) => any;
|
|
87
|
+
onLoadOlder?: () => any;
|
|
88
|
+
onUpdateThinkingExpanded?: (message: AssistantMessage, expanded: boolean) => any;
|
|
89
|
+
onStop?: () => any;
|
|
90
|
+
"onUpdate:question"?: (value: string) => any;
|
|
91
|
+
}, {
|
|
92
|
+
parsers: AnswerParser<any>[];
|
|
93
|
+
question: string;
|
|
94
|
+
loading: boolean;
|
|
95
|
+
messages: Message[];
|
|
96
|
+
emptyTitle: string;
|
|
97
|
+
emptyDescription: string;
|
|
98
|
+
placeholder: string;
|
|
99
|
+
disabled: boolean;
|
|
100
|
+
talking: boolean;
|
|
101
|
+
session: string;
|
|
102
|
+
hasMore: boolean;
|
|
103
|
+
}, {}>, {
|
|
104
|
+
messages?(_: {}): any;
|
|
105
|
+
"above-input"?(_: {}): any;
|
|
106
|
+
}>;
|
|
107
|
+
export default _default;
|
|
108
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
109
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
110
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
111
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
112
|
+
} : {
|
|
113
|
+
type: import('vue').PropType<T[K]>;
|
|
114
|
+
required: true;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
type __VLS_WithDefaults<P, D> = {
|
|
118
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
119
|
+
default: D[K];
|
|
120
|
+
}> : P[K];
|
|
121
|
+
};
|
|
122
|
+
type __VLS_Prettify<T> = {
|
|
123
|
+
[K in keyof T]: T[K];
|
|
124
|
+
} & {};
|
|
125
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
126
|
+
new (): {
|
|
127
|
+
$slots: S;
|
|
128
|
+
};
|
|
129
|
+
};
|