wi-chat 0.0.0-stage → 0.3.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 +76 -0
- package/dist/mobile-ui/chat/ChatContainer.vue.d.ts +124 -0
- package/dist/mobile-ui/chat/ChatMessagesView.vue.d.ts +72 -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 +218 -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/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 +42 -0
- package/dist/parser/index.js +439 -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 +9 -0
- package/dist/renderers/index.js +243 -0
- package/dist/renderers/knowledgeStream/KnowledgeStreamResult.vue.d.ts +19 -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 +160 -0
- package/dist/web-ui/chat/ChatMessagesView.vue.d.ts +83 -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 +1034 -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,58 @@
|
|
|
1
|
+
import { AiAnswerValues } from 'wi-chat/parser';
|
|
2
|
+
import { AnswerContentMap } from './contentMap';
|
|
3
|
+
|
|
4
|
+
declare const _default: import('vue').DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
5
|
+
/** 回答内容(结构见 wi-chat-parser 的 AiAnswerValues;知识流文本已在解析层处理完毕) */
|
|
6
|
+
answer: AiAnswerValues;
|
|
7
|
+
/** 是否回答出错(显示错误文案) */
|
|
8
|
+
error?: boolean;
|
|
9
|
+
/** 是否已被用户停止(显示停止文案) */
|
|
10
|
+
stopped?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* answer_type → 内容渲染组件;缺省走 `createAnswerContentMap()` 内置装配(懒加载)。
|
|
13
|
+
* 外层可传 `createAnswerContentMap([自定义 parser])` 追加自定义类型 / 覆盖内置。
|
|
14
|
+
*/
|
|
15
|
+
contentMap?: AnswerContentMap;
|
|
16
|
+
}>, {
|
|
17
|
+
error: boolean;
|
|
18
|
+
stopped: boolean;
|
|
19
|
+
contentMap: () => AnswerContentMap;
|
|
20
|
+
}>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
21
|
+
/** 回答内容(结构见 wi-chat-parser 的 AiAnswerValues;知识流文本已在解析层处理完毕) */
|
|
22
|
+
answer: AiAnswerValues;
|
|
23
|
+
/** 是否回答出错(显示错误文案) */
|
|
24
|
+
error?: boolean;
|
|
25
|
+
/** 是否已被用户停止(显示停止文案) */
|
|
26
|
+
stopped?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* answer_type → 内容渲染组件;缺省走 `createAnswerContentMap()` 内置装配(懒加载)。
|
|
29
|
+
* 外层可传 `createAnswerContentMap([自定义 parser])` 追加自定义类型 / 覆盖内置。
|
|
30
|
+
*/
|
|
31
|
+
contentMap?: AnswerContentMap;
|
|
32
|
+
}>, {
|
|
33
|
+
error: boolean;
|
|
34
|
+
stopped: boolean;
|
|
35
|
+
contentMap: () => AnswerContentMap;
|
|
36
|
+
}>>>, {
|
|
37
|
+
error: boolean;
|
|
38
|
+
stopped: boolean;
|
|
39
|
+
contentMap: AnswerContentMap;
|
|
40
|
+
}, {}>;
|
|
41
|
+
export default _default;
|
|
42
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
43
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
44
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
45
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
46
|
+
} : {
|
|
47
|
+
type: import('vue').PropType<T[K]>;
|
|
48
|
+
required: true;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
type __VLS_WithDefaults<P, D> = {
|
|
52
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
53
|
+
default: D[K];
|
|
54
|
+
}> : P[K];
|
|
55
|
+
};
|
|
56
|
+
type __VLS_Prettify<T> = {
|
|
57
|
+
[K in keyof T]: T[K];
|
|
58
|
+
} & {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
import { AnswerParser } from 'wi-chat/parser';
|
|
3
|
+
|
|
4
|
+
/** answer_type → 渲染组件(可为普通组件或 defineAsyncComponent 懒加载组件) */
|
|
5
|
+
export type AnswerContentMap = Record<string, Component>;
|
|
6
|
+
/**
|
|
7
|
+
* 按带 `component` 字段的 parser 列表构建回答内容渲染器注册表。
|
|
8
|
+
* 内置装配在前、自定义在后,同 answerType 时自定义覆盖内置(自定义优先);
|
|
9
|
+
* answerType 或 component 缺失的 parser 被忽略,不影响其余条目注册。
|
|
10
|
+
* @param parsers 自定义 parser 列表(component 携带渲染组件;内置类型无需重复传入)
|
|
11
|
+
* @returns answer_type → 渲染组件 的注册表,供 AiAnswerBubble 的 contentMap prop 使用
|
|
12
|
+
*/
|
|
13
|
+
export declare const createAnswerContentMap: (parsers?: AnswerParser[]) => AnswerContentMap;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare const _default: import('vue').DefineComponent<__VLS_TypePropsToRuntimeProps<{
|
|
2
|
+
steps: string[];
|
|
3
|
+
expanded: boolean;
|
|
4
|
+
}>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
5
|
+
"update:expanded": (value: boolean) => void;
|
|
6
|
+
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
7
|
+
steps: string[];
|
|
8
|
+
expanded: boolean;
|
|
9
|
+
}>>> & {
|
|
10
|
+
"onUpdate:expanded"?: (value: boolean) => any;
|
|
11
|
+
}, {}, {}>;
|
|
12
|
+
export default _default;
|
|
13
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
14
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
15
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
16
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
17
|
+
} : {
|
|
18
|
+
type: import('vue').PropType<T[K]>;
|
|
19
|
+
required: true;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AiAnswerReport, IframePageValue } from 'wi-chat/parser';
|
|
2
|
+
|
|
3
|
+
declare const _default: import('vue').DefineComponent<__VLS_TypePropsToRuntimeProps<{
|
|
4
|
+
/** iframe 页面报告(values.url / values.srcdoc 已在解析层处理好) */
|
|
5
|
+
report: AiAnswerReport<IframePageValue>;
|
|
6
|
+
}>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
7
|
+
/** iframe 页面报告(values.url / values.srcdoc 已在解析层处理好) */
|
|
8
|
+
report: AiAnswerReport<IframePageValue>;
|
|
9
|
+
}>>>, {}, {}>;
|
|
10
|
+
export default _default;
|
|
11
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
12
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
13
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
14
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
15
|
+
} : {
|
|
16
|
+
type: import('vue').PropType<T[K]>;
|
|
17
|
+
required: true;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ComputedRef, MaybeRefOrGetter } from 'vue';
|
|
2
|
+
import { AiAnswerReport, IframePageValue } from 'wi-chat/parser';
|
|
3
|
+
|
|
4
|
+
/** 宿主注入的 iframePage 配置(provide/inject 通道,见 provideIframePageConfig) */
|
|
5
|
+
export interface IframePageConfig {
|
|
6
|
+
/**
|
|
7
|
+
* {{MAIN_URL}} 占位符的替换值(字符串或取值函数,渲染时实时求值)。
|
|
8
|
+
* 缺省从 window.globalConfig.WebApiUrl.MainUrl 读取(WI 宿主约定)。
|
|
9
|
+
*/
|
|
10
|
+
mainUrl?: string | (() => string);
|
|
11
|
+
/**
|
|
12
|
+
* {{token}} 占位符的替换值(字符串或取值函数,渲染时实时求值,登录态变化自动生效)。
|
|
13
|
+
* 缺省按 WI 约定从 localStorage 扫描 *access-session 会话键读取
|
|
14
|
+
* (优先当前路径前缀精确命中,跳过后台管理端会话与刷新令牌,见 readGlobalToken)。
|
|
15
|
+
*/
|
|
16
|
+
token?: string | (() => string);
|
|
17
|
+
/**
|
|
18
|
+
* 完整自定义 url 解析:提供后整体接管占位符解析(内置的 {{MAIN_URL}} / {{SERVE_URL}} /
|
|
19
|
+
* {{token}} 替换与 mainUrl / token 均不再应用),适合非 WI 宿主或需要额外占位符的场景。
|
|
20
|
+
*/
|
|
21
|
+
resolveUrl?: (url: string) => string;
|
|
22
|
+
}
|
|
23
|
+
/** useIframePage 返回值:纯 UI 组件渲染 iframe 所需的最终取值 */
|
|
24
|
+
export interface UseIframePageReturn {
|
|
25
|
+
/** 外部页面地址(无 url 时为空串;已应用占位符解析) */
|
|
26
|
+
url: ComputedRef<string>;
|
|
27
|
+
/** 内嵌 HTML 源文档(解析层已注入 iframe-resizer child 自适应脚本;无 srcdoc 时为空串) */
|
|
28
|
+
srcdoc: ComputedRef<string>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 宿主注入 iframePage 配置:在组件 setup 内调用一次,其组件树内的 IframePage
|
|
32
|
+
* (含懒加载渲染器)即可通过 useIframePage 读到;不调用时内置占位符解析默认生效。
|
|
33
|
+
* @param config 宿主配置(mainUrl / token 覆盖缺省取值,resolveUrl 整体接管)
|
|
34
|
+
*/
|
|
35
|
+
export declare const provideIframePageConfig: (config: IframePageConfig) => void;
|
|
36
|
+
/**
|
|
37
|
+
* 内置 url 占位符解析(对齐旧 HTMLCom 语义):把 `{{MAIN_URL}}` / `{{SERVE_URL}}` /
|
|
38
|
+
* `{{token}}` 替换成实际值——取值优先用宿主注入的 config(mainUrl / token,支持函数
|
|
39
|
+
* 实时求值),缺省从浏览器环境推导;环境读不到的占位符替换成空串(不残留原文)。
|
|
40
|
+
* @param url 含占位符的原始地址
|
|
41
|
+
* @param config 宿主注入的配置(mainUrl / token 覆盖缺省取值;resolveUrl 不在此应用)
|
|
42
|
+
* @returns 替换完成后的地址
|
|
43
|
+
*/
|
|
44
|
+
export declare const resolveIframePlaceholders: (url: string, config?: IframePageConfig) => string;
|
|
45
|
+
/**
|
|
46
|
+
* iframePage 操作逻辑:从 report 算出渲染所需的 url / srcdoc。
|
|
47
|
+
* url 取 `report.values.url`(解析层归一形态),顶层 `report.url` 兜底(防御未经
|
|
48
|
+
* 新解析器处理的旧数据);非空 url 做占位符解析(内置默认,宿主提供 resolveUrl
|
|
49
|
+
* 时整体接管),token 等取值在渲染时实时进行,登录态变化无需重新解析历史。
|
|
50
|
+
* @param report iframe 页面报告(支持 ref / getter / 直接对象,流式更新时自动重算)
|
|
51
|
+
* @returns 只读的 url / srcdoc(均为空串时组件不渲染任何节点)
|
|
52
|
+
*/
|
|
53
|
+
export declare const useIframePage: (report: MaybeRefOrGetter<AiAnswerReport<IframePageValue> | undefined>) => UseIframePageReturn;
|
|
54
|
+
/**
|
|
55
|
+
* 向同源 iframe 的已加载文档补注入 iframe-resizer child 脚本(url 分支高度自适应通道):
|
|
56
|
+
* srcdoc 分支的 child 脚本由解析层内联进 HTML,而 src 外部页改不了 HTML,只能在 load 后
|
|
57
|
+
* 经 contentDocument 注入。跨域 iframe 的 contentDocument 不可读(null 或抛 SecurityError),
|
|
58
|
+
* 静默跳过——此类页面若自带 child 脚本仍可经 postMessage 通道自适应,皆无时退回组件
|
|
59
|
+
* 兜底高度(见 IframePage 的 `--wi-chat-iframe-url-height`)。注入后 child 会主动向父页
|
|
60
|
+
* 发 Ready 握手,iframe-resizer 父端收到即下发配置并接管高度,无需额外接线。
|
|
61
|
+
* @param iframe 目标 iframe 元素(url 分支 load 事件的 target)
|
|
62
|
+
* @returns 是否完成注入(元素缺省、跨域、文档未就绪、页面已自带 / 已补注入过 child 脚本时均为 false)
|
|
63
|
+
*/
|
|
64
|
+
export declare const injectIframeResizerChild: (iframe: HTMLIFrameElement | null | undefined) => boolean;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("wi-chat/style.css");const e=require("vue"),f=require("wi-chat/parser"),g=require("wi-chat/tools"),h=require("@iframe-resizer/vue/iframe-resizer.vue"),E=[{...f.knowledgeStreamParser,component:e.defineAsyncComponent(()=>Promise.resolve().then(()=>Y))},{...f.iframePageParser,component:e.defineAsyncComponent(()=>Promise.resolve().then(()=>oe))}],w=o=>{const n=a=>{const r={};for(const t of a)!t.answerType||!t.component||(r[t.answerType]=t.component);return r};return{...n(E),...n(o??[])}},C=o=>(e.pushScopeId("data-v-efad55c8"),o=o(),e.popScopeId(),o),P={class:"flex justify-start"},V={class:"ai-answer-bubble"},M={key:0,class:"ai-answer-bubble__error"},N={class:"ai-answer-bubble__body"},T={key:0,class:"ai-answer-bubble__status"},D={key:2,class:"ai-answer-bubble__status"},R={key:3,class:"ai-answer-bubble__loading"},$=C(()=>e.createElementVNode("span",{class:"ai-answer-bubble__pulse"},null,-1)),A=e.defineComponent({__name:"AiAnswerBubble",props:{answer:{},error:{type:Boolean,default:!1},stopped:{type:Boolean,default:!1},contentMap:{default:()=>w()}},setup(o){const n=o,a=e.computed(()=>{var t,s;return((s=(t=n.answer)==null?void 0:t.answer)==null?void 0:s.reports)??[]}),r=e.computed(()=>a.value.filter(t=>n.contentMap[t.answer_type]));return(t,s)=>(e.openBlock(),e.createElementBlock("div",P,[e.createElementVNode("div",V,[t.error?(e.openBlock(),e.createElementBlock("div",M,"回答加载失败")):r.value.length?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",N,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(d,c)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.contentMap[d.answer_type]),{key:c,report:d},null,8,["report"]))),128))]),t.stopped?(e.openBlock(),e.createElementBlock("div",T,"回答已停止")):e.createCommentVNode("",!0)],64)):t.stopped?(e.openBlock(),e.createElementBlock("div",D,"回答已停止")):a.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",R,[$,e.createTextVNode("正在思考...")]))])]))}}),m=(o,n)=>{const a=o.__vccOpts||o;for(const[r,t]of n)a[r]=t;return a},L=m(A,[["__scopeId","data-v-efad55c8"]]),U=o=>(e.pushScopeId("data-v-c6f5cb64"),o=o(),e.popScopeId(),o),x={key:0,class:"deep-thinking"},O=["aria-expanded"],F=U(()=>e.createElementVNode("span",{class:"deep-thinking__title"},"深度思考",-1)),j={class:"deep-thinking__count"},z={class:"deep-thinking__list"},H={class:"deep-thinking__index"},q=["innerHTML"],G=e.defineComponent({__name:"DeepThinkingSteps",props:{steps:{},expanded:{type:Boolean}},emits:["update:expanded"],setup(o,{emit:n}){const a=o,r=n,t={imageDownload:!1,tableDownload:!1},s=new Map,d=l=>{let i=s.get(l);return i===void 0&&(s.size>500&&s.clear(),i=g.renderMarkdown(l,t),s.set(l,i)),i},c=e.computed(()=>a.steps.map(d));return(l,i)=>c.value.length?(e.openBlock(),e.createElementBlock("div",x,[e.createElementVNode("button",{type:"button",class:"deep-thinking__header","aria-expanded":l.expanded,onClick:i[0]||(i[0]=p=>r("update:expanded",!l.expanded))},[F,e.createElementVNode("span",j,e.toDisplayString(c.value.length),1),e.createElementVNode("span",null,e.toDisplayString(l.expanded?"收起":"展开"),1)],8,O),e.withDirectives(e.createElementVNode("div",z,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,(p,u)=>(e.openBlock(),e.createElementBlock("div",{key:u,class:"deep-thinking__item"},[e.createElementVNode("span",H,e.toDisplayString(u+1),1),e.createElementVNode("div",{class:"markdown-it",innerHTML:p},null,8,q)]))),128))],512),[[e.vShow,l.expanded]])])):e.createCommentVNode("",!0)}}),K=m(G,[["__scopeId","data-v-c6f5cb64"]]),W=["innerHTML"],J=e.defineComponent({__name:"KnowledgeStreamResult",props:{report:{}},setup(o){const n=o,a={imageDownload:!1,tableDownload:!0},r=c=>{var u;const i=c.target.closest(".wi-md-table-download");if(!i)return;c.preventDefault(),c.stopPropagation();const p=(u=i.closest(".wi-md-table-wrap"))==null?void 0:u.querySelector("table");p&&g.downloadTableAsExcel(p)},t=new Map,s=c=>{let l=t.get(c);return l===void 0&&(t.size>300&&t.clear(),l=g.renderMarkdown(c,a),t.set(c,l)),l},d=e.computed(()=>(n.report.values||[]).map(c=>s(c.answer||"")));return(c,l)=>(e.openBlock(),e.createElementBlock("div",{class:"knowledge-result",onClick:r},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(i,p)=>(e.openBlock(),e.createElementBlock("div",{key:p,class:"markdown-it",innerHTML:i},null,8,W))),128))]))}}),b=m(J,[["__scopeId","data-v-1827e802"]]),Y=Object.freeze(Object.defineProperty({__proto__:null,default:b},Symbol.toStringTag,{value:"Module"})),X=()=>{var n,a;const o=(a=(n=window==null?void 0:window.globalConfig)==null?void 0:n.WebApiUrl)==null?void 0:a.MainUrl;return typeof o=="string"?o:""},Z=()=>window.location.origin+window.location.pathname,_="access-session",Q=()=>{const o=window.location.pathname.split("/").filter(n=>!!n).join("-");return o?`${o}-`:""},ee=()=>{const o=`${Q()}${_}`,n=[];for(let r=0;r<localStorage.length;r++){const t=localStorage.key(r);!t||!t.endsWith(_)||t.slice(0,t.lastIndexOf(":"))!=="wi admin"&&(t.endsWith(`x-${_}`)||n.push(t))}const a=n.find(r=>r.endsWith(o))??n[0];if(!a)return"";try{const r=localStorage.getItem(a);if(!r||r==="undefined")return"";const t=JSON.parse(r);return t==null?"":String(t)}catch{return""}},v=Symbol("wi-chat-iframe-page-config"),te=o=>{e.provide(v,o)},S=(o,n)=>{const a=(n==null?void 0:n.mainUrl)!==void 0?String(e.toValue(n.mainUrl)):X(),r=(n==null?void 0:n.token)!==void 0?String(e.toValue(n.token)):ee();return o.replace(/\{\{\s*MAIN_URL\s*\}\}/g,a).replace(/\{\{\s*SERVE_URL\s*\}\}/g,Z()).replace(/\{\{\s*token\s*\}\}/g,r)},y=o=>{const n=e.getCurrentInstance()?e.inject(v,{}):{},a=e.computed(()=>{var d;const t=e.toValue(o),s=((d=t==null?void 0:t.values)==null?void 0:d.url)??(t==null?void 0:t.url)??"";return s?n.resolveUrl?n.resolveUrl(s):S(s,n):""}),r=e.computed(()=>{var s;const t=e.toValue(o);return((s=t==null?void 0:t.values)==null?void 0:s.srcdoc)??(t==null?void 0:t.srcdoc)??""});return{url:a,srcdoc:r}},k="data-wi-iframe-resizer-child",I=o=>{if(!o)return!1;let n=null;try{n=o.contentDocument}catch{return!1}if(!n)return!1;const a=n.head||n.documentElement;if(!a)return!1;const r=n.defaultView;if(r!=null&&r.parentIframe||r!=null&&r.parentIFrame||n.querySelector(`script[${k}]`))return!1;const t=n.createElement("script");return t.textContent=f.IFRAME_RESIZER_CHILD_SCRIPT,t.setAttribute(k,""),a.appendChild(t),!0},ne=e.defineComponent({__name:"IframePage",props:{report:{}},setup(o){const n=o,{url:a,srcdoc:r}=y(()=>n.report),t=s=>{I(s.target)};return(s,d)=>e.unref(a)?(e.openBlock(),e.createBlock(h,{key:0,class:"iframe-page__frame iframe-page__frame--url",license:"GPLv3",src:e.unref(a),width:"100%","warning-timeout":0,onLoad:t},null,8,["src"])):e.unref(r)?(e.openBlock(),e.createBlock(h,{key:1,class:"iframe-page iframe-page--srcdoc",license:"GPLv3",srcdoc:e.unref(r),width:"100%",frameborder:"no",border:"0",marginwidth:"0",marginheight:"0",scrolling:"no"},null,8,["srcdoc"])):e.createCommentVNode("",!0)}}),B=m(ne,[["__scopeId","data-v-f4c94a4e"]]),oe=Object.freeze(Object.defineProperty({__proto__:null,default:B},Symbol.toStringTag,{value:"Module"}));exports.AiAnswerBubble=L;exports.DeepThinkingSteps=K;exports.IframePage=B;exports.KnowledgeStreamResult=b;exports.createAnswerContentMap=w;exports.injectIframeResizerChild=I;exports.provideIframePageConfig=te;exports.resolveIframePlaceholders=S;exports.useIframePage=y;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
|
|
2
|
+
export { default as AiAnswerBubble } from './aiAnswer/AiAnswerBubble.vue';
|
|
3
|
+
export { createAnswerContentMap } from './aiAnswer/contentMap';
|
|
4
|
+
export type { AnswerContentMap } from './aiAnswer/contentMap';
|
|
5
|
+
export { default as DeepThinkingSteps } from './deepThinking/DeepThinkingSteps.vue';
|
|
6
|
+
export { default as KnowledgeStreamResult } from './knowledgeStream/KnowledgeStreamResult.vue';
|
|
7
|
+
export { default as IframePage } from './iframePage/IframePage.vue';
|
|
8
|
+
export { injectIframeResizerChild, provideIframePageConfig, resolveIframePlaceholders, useIframePage } from './iframePage/useIframePage';
|
|
9
|
+
export type { IframePageConfig, UseIframePageReturn } from './iframePage/useIframePage';
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import "wi-chat/style.css";
|
|
2
|
+
import { defineAsyncComponent as P, defineComponent as v, computed as m, openBlock as l, createElementBlock as i, createElementVNode as u, Fragment as g, renderList as C, createBlock as I, resolveDynamicComponent as x, createCommentVNode as w, createTextVNode as A, pushScopeId as E, popScopeId as T, toDisplayString as S, withDirectives as U, vShow as L, getCurrentInstance as O, inject as B, toValue as b, provide as N, unref as h } from "vue";
|
|
3
|
+
import { knowledgeStreamParser as V, iframePageParser as j, IFRAME_RESIZER_CHILD_SCRIPT as F } from "wi-chat/parser";
|
|
4
|
+
import { renderMarkdown as R, downloadTableAsExcel as H } from "wi-chat/tools";
|
|
5
|
+
import M from "@iframe-resizer/vue/iframe-resizer.vue";
|
|
6
|
+
const z = [
|
|
7
|
+
{ ...V, component: P(() => Promise.resolve().then(() => me)) },
|
|
8
|
+
{ ...j, component: P(() => Promise.resolve().then(() => Ie)) }
|
|
9
|
+
], G = (n) => {
|
|
10
|
+
const t = (o) => {
|
|
11
|
+
const r = {};
|
|
12
|
+
for (const e of o)
|
|
13
|
+
!e.answerType || !e.component || (r[e.answerType] = e.component);
|
|
14
|
+
return r;
|
|
15
|
+
};
|
|
16
|
+
return { ...t(z), ...t(n ?? []) };
|
|
17
|
+
}, K = (n) => (E("data-v-efad55c8"), n = n(), T(), n), W = { class: "flex justify-start" }, q = { class: "ai-answer-bubble" }, J = {
|
|
18
|
+
key: 0,
|
|
19
|
+
class: "ai-answer-bubble__error"
|
|
20
|
+
}, Y = { class: "ai-answer-bubble__body" }, X = {
|
|
21
|
+
key: 0,
|
|
22
|
+
class: "ai-answer-bubble__status"
|
|
23
|
+
}, Z = {
|
|
24
|
+
key: 2,
|
|
25
|
+
class: "ai-answer-bubble__status"
|
|
26
|
+
}, Q = {
|
|
27
|
+
key: 3,
|
|
28
|
+
class: "ai-answer-bubble__loading"
|
|
29
|
+
}, ee = /* @__PURE__ */ K(() => /* @__PURE__ */ u("span", { class: "ai-answer-bubble__pulse" }, null, -1)), te = /* @__PURE__ */ v({
|
|
30
|
+
__name: "AiAnswerBubble",
|
|
31
|
+
props: {
|
|
32
|
+
answer: {},
|
|
33
|
+
error: { type: Boolean, default: !1 },
|
|
34
|
+
stopped: { type: Boolean, default: !1 },
|
|
35
|
+
contentMap: { default: () => G() }
|
|
36
|
+
},
|
|
37
|
+
setup(n) {
|
|
38
|
+
const t = n, o = m(() => {
|
|
39
|
+
var e, s;
|
|
40
|
+
return ((s = (e = t.answer) == null ? void 0 : e.answer) == null ? void 0 : s.reports) ?? [];
|
|
41
|
+
}), r = m(() => o.value.filter((e) => t.contentMap[e.answer_type]));
|
|
42
|
+
return (e, s) => (l(), i("div", W, [
|
|
43
|
+
u("div", q, [
|
|
44
|
+
e.error ? (l(), i("div", J, "回答加载失败")) : r.value.length ? (l(), i(g, { key: 1 }, [
|
|
45
|
+
u("div", Y, [
|
|
46
|
+
(l(!0), i(g, null, C(r.value, (p, a) => (l(), I(x(e.contentMap[p.answer_type]), {
|
|
47
|
+
key: a,
|
|
48
|
+
report: p
|
|
49
|
+
}, null, 8, ["report"]))), 128))
|
|
50
|
+
]),
|
|
51
|
+
e.stopped ? (l(), i("div", X, "回答已停止")) : w("", !0)
|
|
52
|
+
], 64)) : e.stopped ? (l(), i("div", Z, "回答已停止")) : o.value.length ? w("", !0) : (l(), i("div", Q, [
|
|
53
|
+
ee,
|
|
54
|
+
A("正在思考...")
|
|
55
|
+
]))
|
|
56
|
+
])
|
|
57
|
+
]));
|
|
58
|
+
}
|
|
59
|
+
}), k = (n, t) => {
|
|
60
|
+
const o = n.__vccOpts || n;
|
|
61
|
+
for (const [r, e] of t)
|
|
62
|
+
o[r] = e;
|
|
63
|
+
return o;
|
|
64
|
+
}, Te = /* @__PURE__ */ k(te, [["__scopeId", "data-v-efad55c8"]]), ne = (n) => (E("data-v-c6f5cb64"), n = n(), T(), n), re = {
|
|
65
|
+
key: 0,
|
|
66
|
+
class: "deep-thinking"
|
|
67
|
+
}, oe = ["aria-expanded"], se = /* @__PURE__ */ ne(() => /* @__PURE__ */ u("span", { class: "deep-thinking__title" }, "深度思考", -1)), ae = { class: "deep-thinking__count" }, le = { class: "deep-thinking__list" }, ce = { class: "deep-thinking__index" }, ie = ["innerHTML"], de = /* @__PURE__ */ v({
|
|
68
|
+
__name: "DeepThinkingSteps",
|
|
69
|
+
props: {
|
|
70
|
+
steps: {},
|
|
71
|
+
expanded: { type: Boolean }
|
|
72
|
+
},
|
|
73
|
+
emits: ["update:expanded"],
|
|
74
|
+
setup(n, { emit: t }) {
|
|
75
|
+
const o = n, r = t, e = { imageDownload: !1, tableDownload: !1 }, s = /* @__PURE__ */ new Map(), p = (c) => {
|
|
76
|
+
let d = s.get(c);
|
|
77
|
+
return d === void 0 && (s.size > 500 && s.clear(), d = R(c, e), s.set(c, d)), d;
|
|
78
|
+
}, a = m(() => o.steps.map(p));
|
|
79
|
+
return (c, d) => a.value.length ? (l(), i("div", re, [
|
|
80
|
+
u("button", {
|
|
81
|
+
type: "button",
|
|
82
|
+
class: "deep-thinking__header",
|
|
83
|
+
"aria-expanded": c.expanded,
|
|
84
|
+
onClick: d[0] || (d[0] = (_) => r("update:expanded", !c.expanded))
|
|
85
|
+
}, [
|
|
86
|
+
se,
|
|
87
|
+
u("span", ae, S(a.value.length), 1),
|
|
88
|
+
u("span", null, S(c.expanded ? "收起" : "展开"), 1)
|
|
89
|
+
], 8, oe),
|
|
90
|
+
U(u("div", le, [
|
|
91
|
+
(l(!0), i(g, null, C(a.value, (_, f) => (l(), i("div", {
|
|
92
|
+
key: f,
|
|
93
|
+
class: "deep-thinking__item"
|
|
94
|
+
}, [
|
|
95
|
+
u("span", ce, S(f + 1), 1),
|
|
96
|
+
u("div", {
|
|
97
|
+
class: "markdown-it",
|
|
98
|
+
innerHTML: _
|
|
99
|
+
}, null, 8, ie)
|
|
100
|
+
]))), 128))
|
|
101
|
+
], 512), [
|
|
102
|
+
[L, c.expanded]
|
|
103
|
+
])
|
|
104
|
+
])) : w("", !0);
|
|
105
|
+
}
|
|
106
|
+
}), Re = /* @__PURE__ */ k(de, [["__scopeId", "data-v-c6f5cb64"]]), pe = ["innerHTML"], ue = /* @__PURE__ */ v({
|
|
107
|
+
__name: "KnowledgeStreamResult",
|
|
108
|
+
props: {
|
|
109
|
+
report: {}
|
|
110
|
+
},
|
|
111
|
+
setup(n) {
|
|
112
|
+
const t = n, o = { imageDownload: !1, tableDownload: !0 }, r = (a) => {
|
|
113
|
+
var f;
|
|
114
|
+
const d = a.target.closest(".wi-md-table-download");
|
|
115
|
+
if (!d)
|
|
116
|
+
return;
|
|
117
|
+
a.preventDefault(), a.stopPropagation();
|
|
118
|
+
const _ = (f = d.closest(".wi-md-table-wrap")) == null ? void 0 : f.querySelector("table");
|
|
119
|
+
_ && H(_);
|
|
120
|
+
}, e = /* @__PURE__ */ new Map(), s = (a) => {
|
|
121
|
+
let c = e.get(a);
|
|
122
|
+
return c === void 0 && (e.size > 300 && e.clear(), c = R(a, o), e.set(a, c)), c;
|
|
123
|
+
}, p = m(() => (t.report.values || []).map((a) => s(a.answer || "")));
|
|
124
|
+
return (a, c) => (l(), i("div", {
|
|
125
|
+
class: "knowledge-result",
|
|
126
|
+
onClick: r
|
|
127
|
+
}, [
|
|
128
|
+
(l(!0), i(g, null, C(p.value, (d, _) => (l(), i("div", {
|
|
129
|
+
key: _,
|
|
130
|
+
class: "markdown-it",
|
|
131
|
+
innerHTML: d
|
|
132
|
+
}, null, 8, pe))), 128))
|
|
133
|
+
]));
|
|
134
|
+
}
|
|
135
|
+
}), _e = /* @__PURE__ */ k(ue, [["__scopeId", "data-v-1827e802"]]), me = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
136
|
+
__proto__: null,
|
|
137
|
+
default: _e
|
|
138
|
+
}, Symbol.toStringTag, { value: "Module" })), fe = () => {
|
|
139
|
+
var t, o;
|
|
140
|
+
const n = (o = (t = window == null ? void 0 : window.globalConfig) == null ? void 0 : t.WebApiUrl) == null ? void 0 : o.MainUrl;
|
|
141
|
+
return typeof n == "string" ? n : "";
|
|
142
|
+
}, he = () => window.location.origin + window.location.pathname, y = "access-session", ge = () => {
|
|
143
|
+
const n = window.location.pathname.split("/").filter((t) => !!t).join("-");
|
|
144
|
+
return n ? `${n}-` : "";
|
|
145
|
+
}, we = () => {
|
|
146
|
+
const n = `${ge()}${y}`, t = [];
|
|
147
|
+
for (let r = 0; r < localStorage.length; r++) {
|
|
148
|
+
const e = localStorage.key(r);
|
|
149
|
+
!e || !e.endsWith(y) || e.slice(0, e.lastIndexOf(":")) !== "wi admin" && (e.endsWith(`x-${y}`) || t.push(e));
|
|
150
|
+
}
|
|
151
|
+
const o = t.find((r) => r.endsWith(n)) ?? t[0];
|
|
152
|
+
if (!o)
|
|
153
|
+
return "";
|
|
154
|
+
try {
|
|
155
|
+
const r = localStorage.getItem(o);
|
|
156
|
+
if (!r || r === "undefined")
|
|
157
|
+
return "";
|
|
158
|
+
const e = JSON.parse(r);
|
|
159
|
+
return e == null ? "" : String(e);
|
|
160
|
+
} catch {
|
|
161
|
+
return "";
|
|
162
|
+
}
|
|
163
|
+
}, D = Symbol("wi-chat-iframe-page-config"), De = (n) => {
|
|
164
|
+
N(D, n);
|
|
165
|
+
}, be = (n, t) => {
|
|
166
|
+
const o = (t == null ? void 0 : t.mainUrl) !== void 0 ? String(b(t.mainUrl)) : fe(), r = (t == null ? void 0 : t.token) !== void 0 ? String(b(t.token)) : we();
|
|
167
|
+
return n.replace(/\{\{\s*MAIN_URL\s*\}\}/g, o).replace(/\{\{\s*SERVE_URL\s*\}\}/g, he()).replace(/\{\{\s*token\s*\}\}/g, r);
|
|
168
|
+
}, ve = (n) => {
|
|
169
|
+
const t = O() ? B(D, {}) : {}, o = m(() => {
|
|
170
|
+
var p;
|
|
171
|
+
const e = b(n), s = ((p = e == null ? void 0 : e.values) == null ? void 0 : p.url) ?? (e == null ? void 0 : e.url) ?? "";
|
|
172
|
+
return s ? t.resolveUrl ? t.resolveUrl(s) : be(s, t) : "";
|
|
173
|
+
}), r = m(() => {
|
|
174
|
+
var s;
|
|
175
|
+
const e = b(n);
|
|
176
|
+
return ((s = e == null ? void 0 : e.values) == null ? void 0 : s.srcdoc) ?? (e == null ? void 0 : e.srcdoc) ?? "";
|
|
177
|
+
});
|
|
178
|
+
return { url: o, srcdoc: r };
|
|
179
|
+
}, $ = "data-wi-iframe-resizer-child", ke = (n) => {
|
|
180
|
+
if (!n)
|
|
181
|
+
return !1;
|
|
182
|
+
let t = null;
|
|
183
|
+
try {
|
|
184
|
+
t = n.contentDocument;
|
|
185
|
+
} catch {
|
|
186
|
+
return !1;
|
|
187
|
+
}
|
|
188
|
+
if (!t)
|
|
189
|
+
return !1;
|
|
190
|
+
const o = t.head || t.documentElement;
|
|
191
|
+
if (!o)
|
|
192
|
+
return !1;
|
|
193
|
+
const r = t.defaultView;
|
|
194
|
+
if (r != null && r.parentIframe || r != null && r.parentIFrame || t.querySelector(`script[${$}]`))
|
|
195
|
+
return !1;
|
|
196
|
+
const e = t.createElement("script");
|
|
197
|
+
return e.textContent = F, e.setAttribute($, ""), o.appendChild(e), !0;
|
|
198
|
+
}, Se = /* @__PURE__ */ v({
|
|
199
|
+
__name: "IframePage",
|
|
200
|
+
props: {
|
|
201
|
+
report: {}
|
|
202
|
+
},
|
|
203
|
+
setup(n) {
|
|
204
|
+
const t = n, { url: o, srcdoc: r } = ve(() => t.report), e = (s) => {
|
|
205
|
+
ke(s.target);
|
|
206
|
+
};
|
|
207
|
+
return (s, p) => h(o) ? (l(), I(M, {
|
|
208
|
+
key: 0,
|
|
209
|
+
class: "iframe-page__frame iframe-page__frame--url",
|
|
210
|
+
license: "GPLv3",
|
|
211
|
+
src: h(o),
|
|
212
|
+
width: "100%",
|
|
213
|
+
"warning-timeout": 0,
|
|
214
|
+
onLoad: e
|
|
215
|
+
}, null, 8, ["src"])) : h(r) ? (l(), I(M, {
|
|
216
|
+
key: 1,
|
|
217
|
+
class: "iframe-page iframe-page--srcdoc",
|
|
218
|
+
license: "GPLv3",
|
|
219
|
+
srcdoc: h(r),
|
|
220
|
+
width: "100%",
|
|
221
|
+
frameborder: "no",
|
|
222
|
+
border: "0",
|
|
223
|
+
marginwidth: "0",
|
|
224
|
+
marginheight: "0",
|
|
225
|
+
scrolling: "no"
|
|
226
|
+
}, null, 8, ["srcdoc"])) : w("", !0);
|
|
227
|
+
}
|
|
228
|
+
}), ye = /* @__PURE__ */ k(Se, [["__scopeId", "data-v-f4c94a4e"]]), Ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
229
|
+
__proto__: null,
|
|
230
|
+
default: ye
|
|
231
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
232
|
+
export {
|
|
233
|
+
Te as AiAnswerBubble,
|
|
234
|
+
Re as DeepThinkingSteps,
|
|
235
|
+
ye as IframePage,
|
|
236
|
+
_e as KnowledgeStreamResult,
|
|
237
|
+
G as createAnswerContentMap,
|
|
238
|
+
ke as injectIframeResizerChild,
|
|
239
|
+
De as provideIframePageConfig,
|
|
240
|
+
be as resolveIframePlaceholders,
|
|
241
|
+
ve as useIframePage
|
|
242
|
+
};
|
|
243
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AiAnswerReport, KnowledgeStreamValue } from 'wi-chat/parser';
|
|
2
|
+
|
|
3
|
+
declare const _default: import('vue').DefineComponent<__VLS_TypePropsToRuntimeProps<{
|
|
4
|
+
/** 知识流报告(values 为已处理好的文本段) */
|
|
5
|
+
report: AiAnswerReport<KnowledgeStreamValue[]>;
|
|
6
|
+
}>, {}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
7
|
+
/** 知识流报告(values 为已处理好的文本段) */
|
|
8
|
+
report: AiAnswerReport<KnowledgeStreamValue[]>;
|
|
9
|
+
}>>>, {}, {}>;
|
|
10
|
+
export default _default;
|
|
11
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
12
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
13
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
14
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
15
|
+
} : {
|
|
16
|
+
type: import('vue').PropType<T[K]>;
|
|
17
|
+
required: true;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@charset "UTF-8";.flex[data-v-efad55c8]{display:flex}.justify-start[data-v-efad55c8]{justify-content:flex-start}.ai-answer-bubble[data-v-efad55c8]{width:100%;min-width:0;color:#27344d;font-size:14px;line-height:1.75;word-break:break-word}.ai-answer-bubble__error[data-v-efad55c8]{color:#f56c6c}.ai-answer-bubble__status[data-v-efad55c8]{margin-top:4px;color:#8a93a6;font-size:12px}.ai-answer-bubble__loading[data-v-efad55c8]{display:flex;align-items:center;gap:8px;color:#76819a}.ai-answer-bubble__pulse[data-v-efad55c8]{width:7px;height:7px;border-radius:50%;background:var(--wi-chat-primary);box-shadow:0 0 #5b7fff4d;animation:wi-answer-pulse-efad55c8 1.6s ease-out infinite}@keyframes wi-answer-pulse-efad55c8{70%{box-shadow:0 0 0 6px #5b7fff00}to{box-shadow:0 0 #5b7fff00}}.deep-thinking[data-v-c6f5cb64]{margin-bottom:12px;overflow:hidden;border:1px solid color-mix(in srgb,var(--wi-chat-primary) 20%,transparent);border-radius:9px;background:color-mix(in srgb,var(--wi-chat-primary) 6%,#fff)}.deep-thinking__header[data-v-c6f5cb64]{display:flex;align-items:center;gap:8px;width:100%;padding:9px 11px;border:0;background:transparent;color:#53617c;cursor:pointer;transition:background-color .2s ease,color .2s ease}.deep-thinking__header[data-v-c6f5cb64]:hover{background:color-mix(in srgb,var(--wi-chat-primary) 8%,transparent);color:var(--wi-chat-primary)}.deep-thinking__title[data-v-c6f5cb64]{display:flex;flex:1;align-items:center;gap:8px;text-align:left;font-weight:600}.deep-thinking__title[data-v-c6f5cb64]:before{width:6px;height:6px;border-radius:50%;background:var(--wi-chat-primary);content:""}.deep-thinking__count[data-v-c6f5cb64],.deep-thinking__index[data-v-c6f5cb64]{display:inline-flex;align-items:center;justify-content:center;min-width:20px;height:20px;border-radius:50%;font-size:12px}.deep-thinking__count[data-v-c6f5cb64]{background:color-mix(in srgb,var(--wi-chat-primary) 10%,transparent);color:var(--wi-chat-primary);font-weight:600}.deep-thinking__list[data-v-c6f5cb64]{display:flex;flex-direction:column;gap:9px;padding:10px 11px 11px;border-top:1px solid #e8ecf8;background:#ffffffb8;color:#5f6d87}.deep-thinking__item[data-v-c6f5cb64]{display:grid;grid-template-columns:20px minmax(0,1fr);gap:8px;font-size:13px;line-height:20px}.deep-thinking__index[data-v-c6f5cb64]{border:1px solid #dce3f3;background:#fff;color:#687597}.deep-thinking__item[data-v-c6f5cb64] p{margin:0}.knowledge-result>div+div[data-v-1827e802]{margin-top:12px}.knowledge-result[data-v-1827e802] .markdown-it{overflow-wrap:break-word}.knowledge-result[data-v-1827e802] .wi-md-table-wrap{position:relative}.knowledge-result[data-v-1827e802] .wi-md-table-download{position:absolute;top:4px;right:4px;display:inline-flex;align-items:center;justify-content:center;padding:4px;border:1px solid var(--wi-chat-border, #e1e4e8);border-radius:4px;background:var(--wi-chat-bg, #fff);color:var(--wi-chat-text-secondary, #8a93a6);cursor:pointer;opacity:0;transition:opacity .2s ease;z-index:10}.knowledge-result[data-v-1827e802] .wi-md-table-wrap:hover .wi-md-table-download{opacity:1}.knowledge-result[data-v-1827e802] .wi-md-table-download:hover{color:var(--wi-chat-primary, #5b7fff);border-color:var(--wi-chat-primary, #5b7fff)}.iframe-page__frame[data-v-f4c94a4e]{width:100%;border:0}.iframe-page__frame--url[data-v-f4c94a4e]{height:var(--wi-chat-iframe-url-height, 70vh)}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { WsChunkSender } from './ws';
|
|
2
|
+
|
|
3
|
+
/** 历史分组项 */
|
|
4
|
+
export interface HistoryGroup {
|
|
5
|
+
/** 分组 id */
|
|
6
|
+
group_id: string;
|
|
7
|
+
/** 分组标题 */
|
|
8
|
+
group_title?: string;
|
|
9
|
+
/** 分组内会话条数 */
|
|
10
|
+
chat_count?: string | number;
|
|
11
|
+
/** 创建时间(排序键,缺失视为最旧) */
|
|
12
|
+
create_time?: string;
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
}
|
|
15
|
+
/** 历史分组列表响应 */
|
|
16
|
+
export interface HistoryGroupsResult {
|
|
17
|
+
/** 业务成功标记(false 时 client 层已抛错,正常不会见到 false) */
|
|
18
|
+
json_ok?: boolean;
|
|
19
|
+
/** 分组列表(后端原序,未排序) */
|
|
20
|
+
groups?: HistoryGroup[];
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}
|
|
23
|
+
/** 会话明细记录 */
|
|
24
|
+
export interface HistoryDetailItem {
|
|
25
|
+
/** 明细 id(用于拉取对应单条回答) */
|
|
26
|
+
history_id?: string;
|
|
27
|
+
/** 用户提问文本 */
|
|
28
|
+
question?: string;
|
|
29
|
+
/** 提问时间 */
|
|
30
|
+
create_time?: string;
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
}
|
|
33
|
+
/** 智能体条目 */
|
|
34
|
+
export interface AgentEntryItem {
|
|
35
|
+
/** 智能体入口 ID */
|
|
36
|
+
entry_id: string;
|
|
37
|
+
/** 智能体名称/标题 */
|
|
38
|
+
entry_title?: string;
|
|
39
|
+
/** 智能体图标/图片 ID */
|
|
40
|
+
image_id?: string;
|
|
41
|
+
/** 是否启用 */
|
|
42
|
+
entry_enable?: boolean;
|
|
43
|
+
/** 分组名称 */
|
|
44
|
+
entry_group?: string;
|
|
45
|
+
[key: string]: any;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* 对话 + 历史业务端点聚合(由 createChatApi 基于 request 客户端构造)
|
|
49
|
+
*/
|
|
50
|
+
export interface ChatApi {
|
|
51
|
+
/** 拉取历史分组列表(返回后端原序,按 create_time 排序由上层处理) */
|
|
52
|
+
getHistoryGroups(): Promise<HistoryGroupsResult>;
|
|
53
|
+
/** 创建历史分组(groupTitle 为新组标题),返回含 group_id 的响应 */
|
|
54
|
+
createHistoryGroup(groupTitle: string): Promise<{
|
|
55
|
+
group_id?: string;
|
|
56
|
+
[key: string]: any;
|
|
57
|
+
}>;
|
|
58
|
+
/** 删除历史分组(groupId 为目标分组 id) */
|
|
59
|
+
deleteHistoryGroup(groupId: string): Promise<any>;
|
|
60
|
+
/** 修改历史分组标题(groupId 为目标分组 id,title 为新标题) */
|
|
61
|
+
setHistoryGroupTitle(groupId: string, title: string): Promise<any>;
|
|
62
|
+
/**
|
|
63
|
+
* 拉取某分组下的会话明细(仅用户提问记录,回答需按 history_id 另行拉取)。
|
|
64
|
+
* lastEnd 为起始明细序号(默认 0 = 从最近一条往回取),lastCount 为拉取条数(默认 10)。
|
|
65
|
+
*/
|
|
66
|
+
getHistoryDetail(groupId: string, lastEnd?: number, lastCount?: number): Promise<HistoryDetailItem[]>;
|
|
67
|
+
/** 拉取单条明细(historyId)对应的完整回答(reports 等原始结构) */
|
|
68
|
+
getHistoryAnswer(historyId: string): Promise<any>;
|
|
69
|
+
/**
|
|
70
|
+
* 获取系统默认智能体 ID
|
|
71
|
+
*/
|
|
72
|
+
getDefaultLlmId(): Promise<{
|
|
73
|
+
default_entry_id?: string;
|
|
74
|
+
[key: string]: any;
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* 按分组/角色拉取智能体列表
|
|
78
|
+
* @param params entry_group 默认 '智能助手'
|
|
79
|
+
*/
|
|
80
|
+
getLlmEntryListByRole(params?: {
|
|
81
|
+
entry_group?: string;
|
|
82
|
+
}): Promise<{
|
|
83
|
+
values?: AgentEntryItem[];
|
|
84
|
+
[key: string]: any;
|
|
85
|
+
}>;
|
|
86
|
+
/**
|
|
87
|
+
* 获取文件访问完整 URL(针对 algorithm/get_file_data)
|
|
88
|
+
* @param fileId 文件/图片 ID
|
|
89
|
+
*/
|
|
90
|
+
getFileUrl?(fileId: string): string;
|
|
91
|
+
/**
|
|
92
|
+
* WebSocket 流式提问:底层通过 WebSocket 连接 /chat/ws 端点交互,
|
|
93
|
+
* 并封装返回符合 SSE 规范的可读字节流(`ReadableStream<Uint8Array>`),
|
|
94
|
+
* 供上层 `consumeStream` 与 `useChat` 无缝消费。
|
|
95
|
+
* params.question 为提问文本,params.historyGroupId 为目标分组 id,
|
|
96
|
+
* params.entryId 为可选入口 id;params.files 为可选附件文件列表;
|
|
97
|
+
* params.incPrevQuestion 为是否携带之前对话(inc_prev_question:'Y' 不忽略(默认)/ 'N' 忽略);
|
|
98
|
+
* params.onOpen 为连接建立且首包发完后的回调(传输层选项,不会混入发给后端的载荷),
|
|
99
|
+
* 入参为绑定当前连接的分片发送器,可在流结束前向同一条连接追发任意载荷;
|
|
100
|
+
* signal 用于中断(stopQuestion)。
|
|
101
|
+
*/
|
|
102
|
+
questionStream(params: {
|
|
103
|
+
/** 提问文本 */
|
|
104
|
+
question: string;
|
|
105
|
+
/** 目标历史分组 id */
|
|
106
|
+
historyGroupId: string;
|
|
107
|
+
/** 入口(智能体)id */
|
|
108
|
+
entryId?: string;
|
|
109
|
+
/** 附件文件列表(自动序列化为 Base64 结构) */
|
|
110
|
+
files?: File[];
|
|
111
|
+
/** 是否携带之前对话(映射为 inc_prev_question),缺省 'Y' 不忽略 */
|
|
112
|
+
incPrevQuestion?: 'Y' | 'N';
|
|
113
|
+
/**
|
|
114
|
+
* 连接建立且首包载荷发送完毕后的回调:入参为绑定当前连接的分片发送器
|
|
115
|
+
* (B/M/E 分帧追发;连接关闭或流结束后调用静默丢弃)。不透传到后端载荷。
|
|
116
|
+
*/
|
|
117
|
+
onOpen?: (sendInChunks: WsChunkSender) => void;
|
|
118
|
+
/** 其余字段原样透传到首包 payload:如 ext_args 扩展参数(JSON 字符串)、raw_mode / tables / metrics / group_type 等 */
|
|
119
|
+
[key: string]: unknown;
|
|
120
|
+
}, signal?: AbortSignal): Promise<ReadableStream<Uint8Array>>;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* 基于 request 客户端聚合业务 API。
|
|
124
|
+
* @param client 请求客户端(createRequest 的产物,或测试注入的 stub),需提供 post / stream 两个方法
|
|
125
|
+
* @returns 对话 + 历史业务端点集合(见 ChatApi)
|
|
126
|
+
*/
|
|
127
|
+
export declare const createChatApi: (client: {
|
|
128
|
+
baseURL?: string;
|
|
129
|
+
getSession?: () => string | null | undefined;
|
|
130
|
+
post: <T = any>(url: string, data?: Record<string, unknown> | FormData) => Promise<T>;
|
|
131
|
+
stream: (url: string, data?: Record<string, unknown> | FormData, signal?: AbortSignal) => Promise<ReadableStream<Uint8Array>>;
|
|
132
|
+
}) => ChatApi;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** wisession 过期需重新认证标记错误 */
|
|
2
|
+
export declare class AuthExpiredError extends Error {
|
|
3
|
+
constructor(message?: string);
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* 判断错误是否为主动取消(AbortController 触发)。
|
|
7
|
+
* axios(含 fetch 适配器)取消抛 CanceledError(code ERR_CANCELED),
|
|
8
|
+
* 原生 fetch abort 抛 name 为 AbortError 的 DOMException,两种都算。
|
|
9
|
+
*/
|
|
10
|
+
export declare const isCancelError: (error: unknown) => boolean;
|
|
11
|
+
export interface RequestOptions {
|
|
12
|
+
/** 后端基础地址(不含结尾斜杠) */
|
|
13
|
+
baseURL: string;
|
|
14
|
+
/** 提供 wisession 请求头(登录后返回) */
|
|
15
|
+
getWisession?: () => string;
|
|
16
|
+
/** 别名:获取当前登录态 session(若有) */
|
|
17
|
+
getSession?: () => string | null | undefined;
|
|
18
|
+
}
|
|
19
|
+
export interface RequestClient {
|
|
20
|
+
/** 后端基础地址(不含结尾斜杠) */
|
|
21
|
+
baseURL?: string;
|
|
22
|
+
/** 获取当前登录态 session(若有) */
|
|
23
|
+
getSession?: () => string | null | undefined;
|
|
24
|
+
/** 普通业务请求(form-urlencoded),返回解析后的响应对象 */
|
|
25
|
+
post<T = any>(url: string, data?: Record<string, unknown> | FormData): Promise<T>;
|
|
26
|
+
/** SSE 流式请求(form-urlencoded 或 FormData),返回可流式消费的 ReadableStream<Uint8Array> */
|
|
27
|
+
stream(url: string, data?: Record<string, unknown> | FormData, signal?: AbortSignal): Promise<ReadableStream<Uint8Array>>;
|
|
28
|
+
}
|
|
29
|
+
/** 创建请求客户端 */
|
|
30
|
+
export declare const createRequest: (options: RequestOptions) => RequestClient;
|