@blueking/ai-ui-sdk 0.0.7-beta.2 → 0.0.7-beta.4
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/75c2c9345bc27655039f.js +1 -0
- package/dist/common/chart-helper.d.ts +1 -1
- package/dist/common/type-transform.d.ts +1 -1
- package/dist/hooks/use-chat.d.ts +6 -7
- package/dist/hooks/use-reference-doc.d.ts +1 -1
- package/dist/hooks/use-style.d.ts +1 -0
- package/dist/hooks/use-summary.d.ts +1 -1
- package/dist/main.js +248 -0
- package/dist/svg/iconcool.99d41d1a.svg +53 -0
- package/package.json +15 -4
- package/dist/main.es.js +0 -1086
- package/dist/main.es.js.map +0 -1
- package/dist/main.umd.js +0 -2
- package/dist/main.umd.js.map +0 -1
package/dist/main.es.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"main.es.js","sources":["../src/types/enum.ts","../src/common/type-transform.ts","../src/common/util.ts","../src/hooks/use-click-proxy.ts","../src/hooks/use-reference-doc.ts","../src/hooks/use-think.ts","../src/common/chart-helper.ts","../src/hooks/use-chat.ts","../src/hooks/use-summary.ts","../src/hooks/use-style.ts"],"sourcesContent":["// 传给 ai 的类型\nexport enum SessionPromptRole {\n System = 'system',\n Assistant = 'assistant',\n User = 'user',\n Guide = 'guide',\n Pause = 'pause',\n UserImage = 'user-image',\n Hidden = 'hidden',\n HiddenUser = 'hidden-user',\n HiddenAssistant = 'hidden-assistant',\n HiddenSystem = 'hidden-system',\n HiddenGuide = 'hidden-guide',\n TemplateUser = 'template-user',\n TemplateAssistant = 'template-assistant',\n TemplateSystem = 'template-system',\n TemplateGuide = 'template-guide',\n TemplateHidden = 'template-hidden',\n}\n\nexport enum SessionContentStatus {\n Fail = 'fail',\n Loading = 'loading',\n Success = 'success',\n}\n\nexport enum SessionContentRole {\n Ai = 'ai',\n User = 'user',\n Time = 'time',\n System = 'system',\n Role = 'role',\n Hidden = 'hidden',\n Guide = 'guide',\n Pause = 'pause',\n TokenExpired = 'token-expired',\n UserImage = 'user-image',\n HiddenUser = 'hidden-user',\n HiddenAi = 'hidden-ai',\n HiddenRole = 'hidden-role',\n HiddenGuide = 'hidden-guide',\n TemplateUser = 'template-user',\n TemplateAi = 'template-ai',\n TemplateRole = 'template-role',\n TemplateGuide = 'template-guide',\n TemplateHidden = 'template-hidden',\n ImageNotSupported = 'image-not-supported'\n}\n\nexport enum HttpErrorCode {\n TokenExpired = '80003',\n ImageNotSupported = '82003',\n UnAuthorizedPreviewFile = '80401',\n TagRepeat = '1513405',\n Aborted = 20,\n UnLogin = 401,\n IamNoPermission = 'IAM_NO_PERMISSION'\n}\n","import {\n SessionContentRole,\n SessionPromptRole,\n} from '../types/enum';\nimport type {\n ISessionContent,\n ISessionPrompt,\n} from '../types/type';\n\n/**\n * 将 sessionContent 转换为 sessionPrompt\n * @param sessionContent sessionContent\n * @returns sessionPrompt\n */\nexport const transferSessionContent2SessionPrompt = (sessionContent: ISessionContent): ISessionPrompt => {\n const sessionRoleMap = {\n [SessionContentRole.Ai]: SessionPromptRole.Assistant,\n [SessionContentRole.User]: SessionPromptRole.User,\n [SessionContentRole.System]: SessionPromptRole.System,\n [SessionContentRole.Hidden]: SessionPromptRole.Hidden,\n [SessionContentRole.Guide]: SessionPromptRole.Guide,\n [SessionContentRole.Time]: SessionPromptRole.System,\n [SessionContentRole.Role]: SessionPromptRole.System,\n [SessionContentRole.HiddenAi]: SessionPromptRole.HiddenAssistant,\n [SessionContentRole.HiddenGuide]: SessionPromptRole.HiddenGuide,\n [SessionContentRole.HiddenRole]: SessionPromptRole.HiddenSystem,\n [SessionContentRole.HiddenUser]: SessionPromptRole.HiddenUser,\n [SessionContentRole.TemplateAi]: SessionPromptRole.TemplateAssistant,\n [SessionContentRole.TemplateGuide]: SessionPromptRole.TemplateGuide,\n [SessionContentRole.TemplateRole]: SessionPromptRole.TemplateSystem,\n [SessionContentRole.TemplateUser]: SessionPromptRole.TemplateUser,\n [SessionContentRole.TemplateHidden]: SessionPromptRole.TemplateHidden,\n [SessionContentRole.Pause]: SessionPromptRole.Pause,\n [SessionContentRole.TokenExpired]: SessionPromptRole.Pause,\n [SessionContentRole.ImageNotSupported]: SessionPromptRole.Pause,\n [SessionContentRole.UserImage]: SessionPromptRole.UserImage,\n };\n return {\n content: sessionContent.content,\n role: sessionRoleMap[sessionContent.role],\n };\n};\n","import {\n Message,\n} from 'bkui-vue';\n\n/**\n * 判断是否是 JSON 字符串\n * @param str 字符串\n * @returns 是否是 JSON 字符串\n */\nexport const isJSON = (str: string) => {\n try {\n JSON.parse(str);\n return true;\n } catch (e) {\n return false;\n }\n};\n\n/**\n * 响应时间格式化\n * @param val 待格式化时间,xxms\n * @returns 格式化后的时间,xx小时xx分钟xx秒\n */\nexport function durationFormatter(val: number) {\n const hours = Math.floor(val / 3600000);\n const minutes = Math.floor((val % 3600000) / 60000);\n const seconds = Math.floor((val % 60000) / 1000);\n const milliseconds = val % 1000;\n\n const parts: string[] = [];\n if (hours > 0) {\n parts.push(`${hours}h`);\n }\n if (minutes > 0) {\n parts.push(`${minutes}min`);\n }\n if (seconds > 0) {\n parts.push(`${seconds}s`);\n }\n if (milliseconds > 0) {\n parts.push(`${milliseconds.toFixed(2)}ms`);\n }\n\n return parts.join(' ');\n}\n\n/**\n * 前端下载文件\n * @param {*} source 文件内容\n * @param {*} filename 文件名\n */\nexport function handleDownLoad(source: string, filename = 'ai.txt') {\n const downloadEl = document.createElement('a');\n const blob = new Blob([source]);\n downloadEl.download = filename;\n downloadEl.href = URL.createObjectURL(blob);\n downloadEl.style.display = 'none';\n document.body.appendChild(downloadEl);\n downloadEl.click();\n document.body.removeChild(downloadEl);\n}\n\nexport const handleCopy = (text: string) => {\n const textarea = document.createElement('textarea');\n textarea.value = text;\n document.body.appendChild(textarea);\n textarea.select();\n document.execCommand('copy');\n Message({\n theme: 'success',\n message: '复制成功',\n });\n document.body.removeChild(textarea);\n};\n\n/**\n * 处理提示词模板,替换模板中的变量\n * @param prompt 提示词模板\n * @param selectedText 选中的文本\n * @returns 处理后的提示词\n */\nexport const processPromptTemplate = (prompt: string, selectedText: string) => {\n return prompt.replace(/\\{\\{\\s*SELECTED_TEXT\\s*\\}\\}/g, selectedText || '');\n};","import {\n onBeforeMount,\n onBeforeUnmount,\n} from 'vue';\n\nimport {\n handleCopy,\n handleDownLoad,\n} from '../common/util';\n\ntype FullScreenWrap = HTMLElement & {\n _originalParent: Node;\n _originalNextSibling: Node;\n};\n\n// 全局点击代理事件\nexport const useClickProxy = () => {\n const clickProxy = (e: MouseEvent) => {\n const target = e.target as HTMLElement;\n // 聊天窗里面的引用资料和思考内容\n if (target?.classList.contains('bkaidev-angle-up')) {\n const parent = target?.parentElement;\n if (parent?.classList.contains('closed')) {\n parent?.classList.remove('closed');\n } else {\n parent?.classList.add('closed');\n }\n }\n if (target?.classList.contains('click-close')) {\n if (target?.classList.contains('closed')) {\n target?.classList.remove('closed');\n } else {\n target?.classList.add('closed');\n }\n }\n // 会话里面代码块的全屏\n if (target?.classList.contains('click-full-screen')) {\n // 获取全屏的父元素\n const fullScreenWrap = target?.parentElement?.parentElement?.parentElement as FullScreenWrap;\n // 添加 class\n fullScreenWrap?.classList.add('full-screen');\n // 元素移动到body\n if (!fullScreenWrap._originalParent) {\n fullScreenWrap._originalParent = fullScreenWrap.parentNode as Node;\n fullScreenWrap._originalNextSibling = fullScreenWrap.nextSibling as Node;\n }\n document.body.appendChild(fullScreenWrap);\n }\n // 会话里面代码块的取消全屏\n if (target?.classList.contains('click-un-full-screen')) {\n // 获取全屏的父元素\n const fullScreenWrap = target?.parentElement?.parentElement?.parentElement as FullScreenWrap;\n // 移除 class\n fullScreenWrap?.classList.remove('full-screen');\n // 移回原位\n if (fullScreenWrap._originalNextSibling) {\n fullScreenWrap._originalParent.insertBefore(fullScreenWrap, fullScreenWrap._originalNextSibling);\n } else {\n fullScreenWrap._originalParent.appendChild(fullScreenWrap);\n }\n }\n // 复制\n if (target?.classList.contains('click-copy')) {\n const text = target?.getAttribute('data-clipboard-text');\n if (text) {\n handleCopy(decodeURIComponent(text));\n }\n }\n // 下载\n if (target?.classList.contains('click-download')) {\n const text = target?.getAttribute('data-clipboard-text');\n const fileName = target?.getAttribute('data-file-name');\n if (text && fileName) {\n handleDownLoad(decodeURIComponent(text), fileName);\n }\n }\n };\n\n const addClickProxy = () => {\n window.addEventListener('click', clickProxy);\n };\n\n const removeClickProxy = () => {\n window.removeEventListener('click', clickProxy);\n };\n\n onBeforeMount(() => {\n addClickProxy();\n });\n\n onBeforeUnmount(() => {\n removeClickProxy();\n });\n};\n","import {\n onBeforeMount,\n onBeforeUnmount,\n} from 'vue';\n\nimport type {\n Document,\n} from '../types/type';\n\n/**\n * 获取引用资料的 HTML 内容\n * @param documents\n * @returns\n */\nexport const getHtmlContentFromDocuments = (documents: Document[]) => {\n let htmlContent = `<section class=\"knowledge-head click-close\">\n <svg\n class=\"ai-ui-sdk-wenzhang\"\n >\n <use href=\"#ai-ui-sdk-wenzhang\"></use>\n </svg>\n 找到 ${documents.length} 篇资料参考\n <i class=\"ai-ui-sdk-icon ai-ui-sdk-angle-up\"></i>\n </section>\n <ul class=\"knowledge-body\">`;\n documents.forEach((document) => {\n const { path, file_path: filePath, display_name: displayName, preview_path: previewPath } = document.metadata;\n const title = displayName || filePath.split('/').pop();\n htmlContent += `<li\n class=\"knowledge-item\"\n >\n <i class=\"ai-ui-sdk-icon ai-ui-sdk-zhishiku\"></i>\n <a href=\"${previewPath}\" title=\"${title} (${previewPath})\" target=\"_blank\" class=\"knowledge-link g-flex-truncate\">\n ${title}\n </a>\n <a href=\"${path}\" title=\"预览原文\" target=\"_blank\" class=\"knowledge-link hover-show\">\n <i class=\"ai-ui-sdk-icon ai-ui-sdk-yanjing-kejian\"></i>\n </a>\n </li>`;\n });\n htmlContent += '</ul>';\n return htmlContent;\n};\n\n/**\n * 移除引用资料的 HTML 内容\n * @param content\n * @returns\n */\nexport const removeReferenceDoc = (content: string) => {\n return content\n .replace(/<section class=\"knowledge-head click-close\">[\\s\\S]*?<\\/section>/, '')\n .replace(/<ul class=\"knowledge-body\">[\\s\\S]*?<\\/ul>/, '')\n .replace(/<section class=\"knowledge-tips\">[\\s\\S]*?<\\/section>/, '');\n};\n\nexport const useReferenceDoc = () => {\n let styleEle: HTMLStyleElement | null = null;\n\n const addReferenceDocStyle = () => {\n // 旧版知识样式\n const oldStyle = `.knowledge-tips {\n position: relative;\n padding: 6px 8px;\n margin-bottom: 14px;\n line-height: 22px;\n background: #f5f7fa;\n border-radius: 4px;\n\n &.closed {\n .bkaidev-angle-up {\n transform: rotate(180deg);\n }\n\n .knowledge-summary {\n margin-bottom: 0;\n }\n\n .knowledge-link {\n display: none;\n }\n }\n\n .bkaidev-angle-up {\n position: absolute;\n top: 4px;\n right: 0px;\n font-size: 22px;\n color: #979ba5;\n cursor: pointer;\n }\n\n .bkaidev-help-document {\n margin-right: 4px;\n font-size: 19px;\n color: #3a84ff;\n }\n\n .knowledge-summary {\n display: block;\n margin-bottom: 4px;\n color: #313238;\n }\n\n .knowledge-link {\n display: block;\n color: #3a84ff;\n text-decoration: none;\n cursor: pointer;\n\n .bkaidev-cc-jump-link {\n font-size: 14px;\n }\n\n &:last-child {\n margin-bottom: 2px;\n }\n }\n }`;\n // 新版知识样式\n const newStyle = `.knowledge-head {\n display: flex;\n align-items: center;\n padding: 0 8px 0 6px;\n margin-bottom: 8px;\n line-height: 28px;\n background: #F0F1F5;\n border-radius: 4px;\n font-size: 12px;\n color: #313238;\n cursor: pointer;\n width: fit-content;\n\n .ai-ui-sdk-wenzhang {\n width: 14px;\n height: 14px;\n margin-right: 6px;\n }\n\n .ai-ui-sdk-angle-up {\n font-size: 22px;\n color: #4D4F56;\n margin-left: 4px;\n }\n\n &.closed {\n margin-bottom: 16px;\n\n .ai-ui-sdk-angle-up {\n transform: rotate(180deg);\n }\n\n &~ .knowledge-body {\n display: none;\n }\n }\n\n &:hover {\n background: #EAEBF0;\n }\n }\n .knowledge-body {\n background: #F5F7FA;\n padding: 16px 0 !important;\n .knowledge-item {\n padding-left: 10px;\n display: flex;\n align-items: center;\n line-height: 28px;\n .hover-show {\n display: none;\n }\n a {\n margin-right: 10px;\n &:has(i) {\n padding: 0 10px;\n margin-right: 0;\n text-decoration: none !important;\n }\n }\n .ai-ui-sdk-zhishiku {\n color: #D66F6B;\n font-size: 14px;\n margin-right: 6px;\n }\n &:hover {\n background: #EAEBF0;\n .hover-show {\n display: inline;\n }\n }\n }\n }`;\n styleEle = document.createElement('style');\n styleEle.textContent = oldStyle + newStyle;\n document.head.appendChild(styleEle);\n };\n\n const removeReferenceDocStyle = () => {\n if (styleEle) {\n styleEle.remove();\n styleEle = null;\n }\n };\n\n onBeforeMount(() => {\n addReferenceDocStyle();\n });\n\n onBeforeUnmount(() => {\n removeReferenceDocStyle();\n });\n};\n","import {\n onBeforeMount,\n onBeforeUnmount,\n} from 'vue';\n\nimport {\n durationFormatter,\n} from '../common/util';\n\n/**\n * 获取思考的 HTML 内容\n * @param chatContent 聊天内容\n * @param content 思考内容\n * @param elapsedTime 思考时间\n * @returns 完整的 chatContent\n */\nexport const getHtmlContentFromThink = (chatContent: string, content: string, cover?: boolean, elapsedTime?: number) => {\n let htmlContent = (chatContent === '内容正在生成中...' || cover) ? '' : chatContent;\n // 思考开始\n if (!htmlContent.includes('<section class=\"think-head click-close\">')) {\n htmlContent += `<section class=\"think-head click-close\">\n <i class=\"ai-ui-sdk-icon ai-ui-sdk-sikao\"></i>思考中...<i class=\"ai-ui-sdk-icon ai-ui-sdk-angle-up\"></i>\n </section>\n <section class=\"think-body\">\n ${content}\n</section>`;\n } else {\n // 补充思考内容\n const thinkBodyMatch = htmlContent.match(/<section class=\"think-body\">([\\s\\S]*?)<\\/section>/);\n if (thinkBodyMatch) {\n // 原有思考内容\n const thinkContent = thinkBodyMatch[1];\n // 在最后的换行符前面添加新的思考内容\n const newThinkContent = thinkContent.replace(/\\n$/g, `${content}\\n`);\n htmlContent = htmlContent.replace(\n thinkContent,\n newThinkContent,\n );\n }\n }\n // 思考结束\n if (elapsedTime) {\n htmlContent = htmlContent.replace('思考中...', `已完成思考 (耗时:${durationFormatter(elapsedTime)})`);\n }\n return htmlContent;\n};\n\n/**\n * 移除思考的 HTML 内容\n * @param content\n * @returns\n */\nexport const removeThink = (content: string) => {\n // 移除思考头部\n const afterRemoveThinkHead = content.replace(/<section class=\"think-head click-close\">[\\s\\S]*<\\/section>/, '');\n // 移除思考内容\n let afterRemoveThinkBody = afterRemoveThinkHead.replace(/<section class=\"think-body\">[\\s\\S]*<\\/section>/, '');\n // 如果内容只有思考,那就给ai传递思考内容\n if (afterRemoveThinkBody.trim() === '') {\n const thinkBodyMatch = content.match(/<section class=\"think-body\">([\\s\\S]*?)<\\/section>/);\n if (thinkBodyMatch) {\n [, afterRemoveThinkBody] = thinkBodyMatch;\n }\n }\n return afterRemoveThinkBody;\n};\n\n/**\n * 判断是否是思考中\n * @param content\n * @returns\n */\nexport const isThinking = (content: string) => {\n // 是否开始思考\n const isStartThinking = content === '正在思考...';\n // 判断是否空思考\n const thinkBodyMatch = content.match(/<section class=\"think-body\">([\\s\\S]*?)<\\/section>$/);\n const isEmptyThinking = thinkBodyMatch && thinkBodyMatch[1].trim() === '';\n\n return isStartThinking || isEmptyThinking;\n};\n\n// 思考\nexport const useThink = () => {\n let styleEle: HTMLStyleElement | null = null;\n\n const addThinkStyle = () => {\n const style = `.think-head {\n display: flex;\n align-items: center;\n padding: 0 8px 0 6px;\n margin-bottom: 8px;\n line-height: 28px;\n background: #F0F1F5;\n border-radius: 4px;\n font-size: 12px;\n color: #313238;\n cursor: pointer;\n width: fit-content;\n .ai-ui-sdk-sikao {\n font-size: 14px;\n color: #979ba5;\n margin-right: 4px;\n }\n\n .ai-ui-sdk-angle-up {\n font-size: 22px;\n color: #4D4F56;\n margin-left: 4px;\n }\n\n &.closed {\n margin-bottom: 16px;\n\n .ai-ui-sdk-angle-up {\n transform: rotate(180deg);\n }\n\n &~ .think-body {\n display: none;\n }\n }\n\n &:hover {\n background: #EAEBF0;\n }\n }\n .think-body {\n background: #F5F7FA;\n color: #979BA5;\n padding: 16px;\n margin-bottom: 16px;\n &~ .knowledge-head {\n margin-bottom: 8px;\n }\n }`;\n styleEle = document.createElement('style');\n styleEle.textContent = style;\n document.head.appendChild(styleEle);\n };\n\n const removeThinkStyle = () => {\n if (styleEle) {\n styleEle.remove();\n styleEle = null;\n }\n };\n\n onBeforeMount(() => {\n addThinkStyle();\n });\n\n onBeforeUnmount(() => {\n removeThinkStyle();\n });\n};\n","import {\n isJSON,\n} from './util';\n\nimport type {\n Document,\n} from '../types/type';\n\ntype HandleStart = (sessionCode: string) => any;\ntype HandleText = (sessionCode: string, message: string, cover?: boolean) => void;\ntype HandleReferenceDoc = (sessionCode: string, documents: Document[], cover?: boolean) => void;\ntype HandleThink = (sessionCode: string, content: string, cover?: boolean, elapsed_time?: number) => void;\ntype HandleEnd = (sessionCode: string, message?: string) => void;\ntype HandleError = (sessionCode: string, message: string, code: string) => any;\n\nexport class ChatHelper {\n handleStart: HandleStart;\n handleText: HandleText;\n handleReferenceDoc?: HandleReferenceDoc;\n handleThink?: HandleThink;\n handleEnd: HandleEnd;\n handleError: HandleError;\n controllerMap: Record<string, AbortController>;\n\n constructor({\n handleStart,\n handleText,\n handleReferenceDoc,\n handleThink,\n handleEnd,\n handleError,\n }: {\n handleStart: HandleStart;\n handleText: HandleText;\n handleReferenceDoc?: HandleReferenceDoc;\n handleThink?: HandleThink;\n handleEnd: HandleEnd;\n handleError: HandleError;\n }) {\n this.handleStart = handleStart;\n this.handleText = handleText;\n this.handleReferenceDoc = handleReferenceDoc;\n this.handleThink = handleThink;\n this.handleEnd = handleEnd;\n this.handleError = handleError;\n this.controllerMap = {};\n }\n\n async stream({\n sessionCode,\n url,\n headers,\n data,\n }: {\n sessionCode: string;\n url: string;\n headers?: Record<string, string>;\n data?: Record<string, any>;\n }) {\n // 开始\n await this.handleStart?.(sessionCode);\n // 记录 controller\n const controller = new AbortController();\n this.controllerMap[sessionCode] = controller;\n // 发送请求\n fetch(url, {\n method: 'post',\n signal: controller.signal,\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n },\n mode: 'cors',\n credentials: 'include',\n body: JSON.stringify(data),\n })\n .then(async (response: any) => {\n const reader = response.body\n .pipeThrough(new window.TextDecoderStream())\n .getReader();\n\n // 临时存储数据\n let temp = '';\n\n while (true) {\n try {\n const { value, done } = await reader.read();\n\n // 接口异常处理\n if (!response.ok) {\n this.handleError(sessionCode, value || response.statusText, response.status);\n break;\n }\n // 接口完成\n if (done) {\n this.handleEnd(sessionCode);\n break;\n }\n\n const values = (temp + value.toString()).split('\\n');\n values.forEach((value) => {\n const item = value.replace('data:', '').trim();\n if (isJSON(item)) {\n const {\n event,\n content,\n cover,\n documents,\n result,\n code,\n elapsed_time,\n message,\n } = JSON.parse(item);\n // 业务错误处理\n if (result === false || response.status !== 200) {\n this.handleError(sessionCode, message || '模型调用失败', code);\n return;\n }\n\n switch (event) {\n case 'text':\n this.handleText(sessionCode, content, cover);\n break;\n case 'reference_doc':\n this.handleReferenceDoc?.(sessionCode, documents, cover);\n break;\n case 'think':\n this.handleThink?.(sessionCode, content, cover, elapsed_time);\n break;\n case 'done':\n this.handleEnd(sessionCode, cover ? content : '');\n break;\n case 'error':\n this.handleError(sessionCode, message || '模型调用失败', code);\n break;\n }\n temp = '';\n } else if (item) {\n temp = item;\n }\n });\n } catch (error: any) {\n if (error?.code !== 20) {\n this.handleError(sessionCode, `模型调用失败:${error.message}`, error.code);\n }\n break;\n }\n }\n });\n }\n\n stop(sessionCode: string) {\n this.controllerMap[sessionCode]?.abort?.();\n return this.handleEnd(sessionCode);\n }\n}\n","import {\n ref,\n computed,\n} from 'vue';\nimport type {\n Document,\n ISessionContent,\n ISession,\n ISessionPrompt,\n ChatCallbacks,\n BasicChatContent,\n ShortcutChatContent,\n} from '../types/type.ts';\nimport { processPromptTemplate } from '../common/util';\nimport {\n HttpErrorCode,\n SessionContentRole,\n SessionContentStatus,\n} from '../types/enum';\nimport {\n getHtmlContentFromDocuments,\n removeReferenceDoc,\n} from '../hooks/use-reference-doc';\nimport {\n getHtmlContentFromThink,\n isThinking,\n removeThink,\n} from '../hooks/use-think';\nimport {\n ChatHelper,\n} from '../common/chart-helper';\nimport {\n transferSessionContent2SessionPrompt,\n} from '../common/type-transform';\n\ntype SessionContentsMap = {\n [key: string]: ISessionContent[]\n};\n\ntype SessionLoadingMap = {\n [key: string]: boolean\n};\n\n// ai 聊天\nexport const useChat = <T extends ISession = ISession>({\n handleStart,\n handleText,\n handleReferenceDoc,\n handleThink,\n handleEnd,\n handleError,\n requestOptions,\n}: ChatCallbacks = {}) => {\n const startMessage = '内容正在生成中...';\n // 聊天上下文\n const currentSession = ref<T>();\n const sessionLoadingMap = ref<SessionLoadingMap>({});\n const sessionContents = ref<ISessionContent[]>([]);\n const sessionContentsMap: SessionContentsMap = {};\n\n // 通过计算得到的会话列表\n const calculatedSessionContents = computed<ISessionContent[]>(() => {\n const calculatedSessionContents: ISessionContent[] = [];\n for (let index = sessionContents.value.length - 1; index >= 0; index--) {\n const sessionContent = sessionContents.value[index];\n // 向下找到下一个ai回复\n let nextAiSessionContentIndex = index + 1;\n let nextAiSessionContent = sessionContents.value[nextAiSessionContentIndex];\n while (nextAiSessionContent && ![\n SessionContentRole.Ai,\n SessionContentRole.TokenExpired,\n SessionContentRole.ImageNotSupported,\n SessionContentRole.Pause,\n SessionContentRole.Guide,\n ].includes(nextAiSessionContent.role)\n ) {\n nextAiSessionContentIndex += 1;\n nextAiSessionContent = sessionContents.value[nextAiSessionContentIndex];\n }\n\n // 系统消息,退出\n if (sessionContent.role === SessionContentRole.System) {\n break;\n }\n\n // 倒叙添加当前聊天上下文 排除异常答复、异常问题 & 系统消息和时间消息\n if (sessionContent.status !== SessionContentStatus.Fail\n && !(nextAiSessionContent?.status === SessionContentStatus.Fail\n && [SessionContentRole.User, SessionContentRole.UserImage].includes(sessionContent.role)\n )\n && ![SessionContentRole.Time, SessionContentRole.System].includes(sessionContent.role)\n ) {\n calculatedSessionContents.unshift(sessionContent);\n }\n }\n\n return calculatedSessionContents;\n });\n\n // 当前会话是否正在加载\n const currentSessionLoading = computed(() => {\n const sessionCode = currentSession.value?.sessionCode;\n return sessionCode ? sessionLoadingMap.value[sessionCode] : false;\n });\n\n // 计算当前的 prompt\n const prompts = computed<ISessionPrompt[]>(() => {\n const rolePrompts: ISessionPrompt[] = [];\n const userPrompts: ISessionPrompt[] = [];\n const prompts: ISessionPrompt[] = [];\n\n // build rolePrompts\n const latestMatchIndex = sessionContents.value.findLastIndex(sessionContent => (\n sessionContent.role === SessionContentRole.System && ['已启用角色', '已启用模型'].some(key => sessionContent.content.includes(key))\n ));\n let index = 0;\n currentSession.value?.roleInfo?.content?.forEach((roleContent) => {\n const sessionContent = sessionContents.value[latestMatchIndex + 1 + index];\n let nextSessionContent = sessionContents.value[latestMatchIndex + 2 + index];\n if (sessionContent?.content === roleContent.content && sessionContent.role !== SessionContentRole.System) {\n rolePrompts.push(transferSessionContent2SessionPrompt(sessionContent));\n index += 1;\n if (sessionContent?.role === SessionContentRole.Pause) {\n while (nextSessionContent && nextSessionContent.role === SessionContentRole.System) {\n index += 1;\n nextSessionContent = sessionContents.value[latestMatchIndex + 1 + index];\n }\n while (nextSessionContent\n && [SessionContentRole.User, SessionContentRole.UserImage].includes(nextSessionContent.role)\n ) {\n rolePrompts.push(transferSessionContent2SessionPrompt(nextSessionContent));\n index += 1;\n nextSessionContent = sessionContents.value[latestMatchIndex + 1 + index];\n }\n }\n }\n });\n\n // build userPrompts\n userPrompts.push(...calculatedSessionContents.value.map(transferSessionContent2SessionPrompt));\n\n const isSameContent = (startIndex: number) => {\n let isSame = true;\n for (let index = startIndex; index < rolePrompts.length; index++) {\n const rolePrompt = rolePrompts[index];\n if (rolePrompt.content !== userPrompts[index - startIndex]?.content) {\n isSame = false;\n }\n }\n\n return isSame;\n };\n\n // 排除在一个系统消息里面,重复的情况\n for (let index = 0; index < rolePrompts.length; index++) {\n const rolePrompt = rolePrompts[index];\n if (isSameContent(index)) {\n break;\n } else {\n prompts.push(rolePrompt);\n }\n }\n\n prompts.push(...userPrompts);\n\n // 删除引用资料\n prompts.forEach(prompt => {\n prompt.content = removeThink(prompt.content);\n prompt.content = removeReferenceDoc(prompt.content);\n });\n\n return prompts;\n });\n\n const chatHelper = new ChatHelper({\n handleStart: handleStartChat,\n handleText: handleTextChat,\n handleReferenceDoc: handleReferenceDocChat,\n handleThink: handleThinkChat,\n handleEnd: handleEndChat,\n handleError: handleErrorChat,\n });\n\n // 设置 currentSession\n function setCurrentSession(session?: T) {\n currentSession.value = session;\n // 空session,不处理\n if (!session?.sessionCode) return;\n\n if (!sessionContentsMap[session.sessionCode]) {\n sessionContentsMap[session.sessionCode] = [];\n }\n sessionContents.value = sessionContentsMap[session.sessionCode];\n }\n\n // 设置 sessionContents\n function setSessionContents(data: ISessionContent[]) {\n if (!currentSession.value) return;\n sessionContentsMap[currentSession.value.sessionCode] = data;\n sessionContents.value = data;\n }\n\n\n // 获取 SessionContent 通过 id\n function getSessionContentById(id: number, sessionCode: string) {\n const sessionContents = getSessionContentsBySessionCode(sessionCode);\n return sessionContents.find(item => item.id === id);\n }\n\n // 获取执行中的 SessionContent(最后一个)\n function getLastSessionContentBySessionCode(sessionCode: string) {\n if (currentSession.value?.sessionCode === sessionCode) {\n return sessionContents.value.at(-1) as ISessionContent;\n }\n return sessionContentsMap[sessionCode]?.at(-1) as ISessionContent;\n }\n\n // 获取 SessionContents\n function getSessionContentsBySessionCode(sessionCode: string) {\n if (currentSession.value?.sessionCode === sessionCode) {\n return sessionContents.value;\n }\n return sessionContentsMap[sessionCode];\n }\n\n // 新增 sessionContent\n function plusSessionContent(sessionCode: string, sessionContent: ISessionContent) {\n const sessionContents = getSessionContentsBySessionCode(sessionCode);\n sessionContents.push(sessionContent);\n }\n\n // 更新 chatContent\n function updateSessionContent(sessionContent: ISessionContent) {\n const currentSessionContents = currentSession.value?.sessionCode === sessionContent.sessionCode\n ? sessionContents.value\n : sessionContentsMap[sessionContent.sessionCode];\n\n const currentSessionContent = currentSessionContents.find(item => +(item.id || 0) === +(sessionContent.id || 0));\n if (currentSessionContent) {\n Object.assign(currentSessionContent, sessionContent);\n }\n }\n\n // 获取待删除的会话id,并从会话列表中删除\n function getDeleteSessionContents(sessionCode: string, sessionContentIds: number[], relatedDelete: boolean) {\n const currentSessionContents = currentSession.value?.sessionCode === sessionCode\n ? sessionContents.value\n : sessionContentsMap[sessionCode];\n const deleteSessionContentIds: number[] = [];\n\n sessionContentIds.forEach((sessionContentId) => {\n const index = currentSessionContents.findIndex(sessionContent => sessionContent.id === sessionContentId);\n if (index > -1) {\n const preSessionContent = currentSessionContents[index - 1];\n const nextSessionContent = currentSessionContents[index + 1];\n const nextNextSessionContent = currentSessionContents[index + 2];\n // 删除当前会话\n currentSessionContents.splice(index, 1);\n deleteSessionContentIds.push(sessionContentId);\n // 如果前一个是 hidden 也需要删除\n if ([SessionContentRole.Hidden].includes(preSessionContent?.role)) {\n const hiddenIndex = currentSessionContents\n .findIndex(sessionContent => sessionContent.id === preSessionContent.id);\n currentSessionContents.splice(hiddenIndex, 1);\n deleteSessionContentIds.push(preSessionContent.id as number);\n }\n // 如果下一个是ai回复,也需要删掉\n if (nextSessionContent?.role === SessionContentRole.Ai\n || (relatedDelete && [\n SessionContentRole.Ai,\n SessionContentRole.Guide,\n SessionContentRole.TokenExpired,\n SessionContentRole.ImageNotSupported,\n SessionContentRole.Pause,\n ].includes(nextSessionContent?.role))\n ) {\n const nextIndex = currentSessionContents\n .findIndex(sessionContent => sessionContent.id === nextSessionContent.id);\n currentSessionContents.splice(nextIndex, 1);\n deleteSessionContentIds.push(nextSessionContent.id as number);\n }\n // 如果下下个是 guide,需要删除\n if ([SessionContentRole.Guide].includes(nextNextSessionContent?.role) && relatedDelete) {\n const nextNextIndex = currentSessionContents\n .findIndex(sessionContent => sessionContent.id === nextNextSessionContent.id);\n currentSessionContents.splice(nextNextIndex, 1);\n deleteSessionContentIds.push(nextNextSessionContent.id as number);\n }\n }\n });\n\n return deleteSessionContentIds;\n }\n\n // 删除聊天内容\n function deleteSessionContent(sessionCode: string, contentId: number) {\n const deleteSessionContentIds = getDeleteSessionContents(sessionCode, [contentId], true);\n return deleteSessionContentIds;\n }\n\n // 批量删除\n function deleteSessionContents(sessionCode: string, contentIds: number[]) {\n const deleteSessionContentIds = getDeleteSessionContents(sessionCode, contentIds, false);\n return deleteSessionContentIds;\n }\n\n // 聊天开始\n function handleStartChat(sessionCode: string) {\n sessionLoadingMap.value[sessionCode] = true;\n const sessionContent: ISessionContent = {\n sessionCode,\n role: SessionContentRole.Ai,\n status: SessionContentStatus.Loading,\n content: startMessage,\n };\n // 画布新增\n plusSessionContent(sessionCode, sessionContent);\n // 调用cb\n return handleStart?.(sessionCode, sessionContent);\n }\n\n // 引用资料\n function handleReferenceDocChat(sessionCode: string, documents: Document[], cover?: boolean) {\n const sessionContent = getLastSessionContentBySessionCode(sessionCode);\n const content = getHtmlContentFromDocuments(documents);\n sessionContent.content = cover ? content : sessionContent.content + content;\n return handleReferenceDoc?.(sessionCode, sessionContent);\n }\n\n // 思考\n function handleThinkChat(sessionCode: string, content: string, cover?: boolean, elapsedTime?: number) {\n const sessionContent = getLastSessionContentBySessionCode(sessionCode);\n // 获取思考的html\n sessionContent.content = getHtmlContentFromThink(sessionContent.content, content, cover, elapsedTime);\n // 调用cb\n return handleThink?.(sessionCode, sessionContent);\n }\n\n // 文本\n function handleTextChat(sessionCode: string, message: string, cover?: boolean) {\n const sessionContent = getLastSessionContentBySessionCode(sessionCode);\n if (sessionContent.content === startMessage) {\n sessionContent.content = message;\n } else if (sessionContent.status === SessionContentStatus.Loading) {\n sessionContent.content = cover\n ? message\n : sessionContent.content + message;\n } else {\n return;\n }\n // 调用cb\n return handleText?.(sessionCode, sessionContent);\n }\n\n // 聊天结束\n function handleEndChat(sessionCode: string, message?: string) {\n const sessionContent = getLastSessionContentBySessionCode(sessionCode);\n // 防止 error 的情况下异步触发 end 更新了数据\n if (sessionContent.status === SessionContentStatus.Loading) {\n sessionLoadingMap.value[sessionCode] = false;\n // end 的时候,如果 message 有值,则更新 content\n if (message) {\n sessionContent.content = message;\n }\n // 更新状态\n sessionContent.status = SessionContentStatus.Success;\n // 调用cb\n return handleEnd?.(sessionCode, sessionContent);\n }\n // 内容正在生成中或者正在思考中\n if (sessionContent.content === startMessage || isThinking(sessionContent.content)) {\n handleErrorChat(sessionCode, '聊天内容已中断');\n }\n }\n\n // 聊天异常\n function handleErrorChat(sessionCode: string, message: string, code?: string) {\n const sessionContent = getLastSessionContentBySessionCode(sessionCode);\n sessionContent.status = SessionContentStatus.Fail;\n sessionContent.content = message;\n sessionLoadingMap.value[sessionCode] = false;\n // token 超了,提示 token 不足\n if (code === HttpErrorCode.TokenExpired) {\n sessionContent.content = '抱歉,您的剩余 Token 不足,无法返回回答内容,请先清空当前会话(上下文仍会作为历史记录保留))';\n sessionContent.role = SessionContentRole.TokenExpired;\n }\n if (code === HttpErrorCode.ImageNotSupported) {\n sessionContent.content = '抱歉,当前模型不支持图片内容解析';\n sessionContent.role = SessionContentRole.ImageNotSupported;\n }\n // 调用cb\n return handleError?.(sessionCode, sessionContent, code);\n }\n\n // 重新生成对话 仅支持重新生成 ai 的回复\n function reGenerateChat(chatIndex: number) {\n const chat = sessionContents.value[chatIndex];\n if (chat.role !== SessionContentRole.Ai) {\n return;\n }\n\n const message = sessionContents.value[chatIndex - 1].content;\n const cite = sessionContents.value[chatIndex - 1].cite;\n sessionContents.value.splice(chatIndex - 1, 2);\n sendChat({message, cite});\n }\n\n // 聊天\n function chat({\n sessionCode,\n data,\n url,\n headers,\n }: {\n sessionCode: string;\n data?: Record<string, any>;\n url: string;\n headers?: Record<string, string>;\n }) {\n // 发送请求\n chatHelper.stream({\n sessionCode,\n url: url,\n data,\n headers: headers || requestOptions?.headers,\n });\n }\n\n // 重新发送聊天, 需要将当前聊天内容以及下方的所有内容删除\n function reSendChat(index: number, {message, cite}: {message: string, cite?: string}, callback?: () => void) {\n const chat = sessionContents.value[index];\n if (chat.role !== SessionContentRole.User) {\n return;\n }\n\n sessionContents.value.splice(index, sessionContents.value.length - index);\n sendChat({message, cite}, callback);\n }\n\n // 发送聊天\n function sendChat(content: BasicChatContent | ShortcutChatContent, callback?: () => void) {\n if (!currentSession.value?.sessionCode || !requestOptions?.url || currentSessionLoading.value) {\n return;\n }\n\n const {message, cite, shortcut} = content;\n\n let input = '';\n\n if (shortcut) {\n input = processPromptTemplate(shortcut.prompt, cite);\n } else {\n input = cite ? `${message}: \"${cite}\"` : message;\n }\n\n\n sessionContents.value.push({\n sessionCode: currentSession.value?.sessionCode,\n content: message,\n role: SessionContentRole.User,\n status: SessionContentStatus.Success,\n cite,\n });\n\n // 发送请求\n chatHelper.stream({\n sessionCode: currentSession.value?.sessionCode,\n url: requestOptions.url,\n headers: requestOptions?.headers,\n data: {\n inputs: {\n chat_history: prompts.value.slice(0, prompts.value.length - 1),\n input,\n },\n }\n });\n\n callback?.();\n }\n\n /**\n * 删除聊天内容\n * @param index 要删除的聊天内容索引\n * @description \n * - 如果删除的是用户消息,则同时删除该消息及其对应的AI回复(共2条)\n * - 如果删除的是其他类型消息(如AI回复),则只删除该条消息\n */\n function deleteChat(index: number) {\n const chat = sessionContents.value[index];\n if (chat.role === SessionContentRole.User) {\n sessionContents.value.splice(index, 2);\n return;\n }\n\n sessionContents.value.splice(index-1, 2);\n }\n\n // 停止聊天\n function stopChat(sessionCode: string) {\n chatHelper.stop(sessionCode);\n }\n\n return {\n currentSession,\n sessionContents,\n sessionContentsMap,\n sessionLoadingMap,\n prompts,\n currentSessionLoading,\n chat,\n sendChat,\n stopChat,\n plusSessionContent,\n updateSessionContent,\n getSessionContentById,\n getLastSessionContentBySessionCode,\n getSessionContentsBySessionCode,\n setCurrentSession,\n setSessionContents,\n deleteSessionContent,\n deleteSessionContents,\n handleStartChat,\n handleErrorChat,\n reGenerateChat,\n reSendChat,\n deleteChat,\n };\n};","import type {\n SummaryCallbacks,\n} from '../types/type.ts';\nimport {\n SessionPromptRole,\n} from '../types/enum';\nimport {\n removeReferenceDoc,\n} from '../hooks/use-reference-doc';\nimport {\n removeThink,\n} from '../hooks/use-think';\nimport {\n ChatHelper,\n} from '../common/chart-helper';\n\n// ai 总结\nexport const useSummary = ({\n handleStart,\n handleEnd,\n handleError,\n}: SummaryCallbacks = {}) => {\n let summaryText = '';\n\n const handleStartChat = () => {\n summaryText = '';\n return handleStart?.();\n };\n\n const handleTextChat = (sessionCode: string, message: string, cover?: boolean) => {\n if (cover || summaryText === '正在思考...') {\n summaryText = message;\n } else {\n summaryText += message;\n }\n };\n\n const handleEndChat = () => {\n if (summaryText === '无话可说') {\n summaryText = '';\n }\n return handleEnd?.(summaryText);\n };\n\n const handleErrorChat = (sessionCode: string, message: string, code?: string) => {\n return handleError?.(message, code);\n };\n\n const chatHelper = new ChatHelper({\n handleStart: handleStartChat,\n handleText: handleTextChat,\n handleEnd: handleEndChat,\n handleError: handleErrorChat,\n });\n\n const summary = ({\n content,\n url,\n headers,\n model,\n }: {\n content: string;\n url: string;\n headers?: Record<string, string>;\n model?: string;\n }) => {\n const filterContent = removeThink(removeReferenceDoc(content));\n const prompts = [\n {\n role: SessionPromptRole.User,\n content: `你是一个总结大师,请帮助我对下面这段话进行总结。要求总结精炼,不超过 15 个字!且末尾没有标点符号!请注意:如果你无法总结,请回复“无话可说”!\\n文字如下:\\n${filterContent}`,\n },\n ];\n \n chatHelper.stream({\n sessionCode: 'summary',\n url,\n data: {\n prompts,\n model,\n },\n headers,\n });\n };\n\n return {\n summary,\n };\n}","import {\n useReferenceDoc,\n} from \"./use-reference-doc\";\nimport {\n useThink,\n} from \"./use-think\";\n\n// ai 样式。注意:全局引入一次即可\nexport const useStyle = () => {\n // 引入样式\n require('../css/style.css');\n require('../css/iconcool.js');\n // 引用资料\n useReferenceDoc();\n // 思考\n useThink();\n};\n"],"names":["SessionPromptRole","SessionContentStatus","SessionContentRole","HttpErrorCode","document","value","_a","calculatedSessionContents","prompts","index","sessionContents","chat"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACY,IAAA,sCAAAA,uBAAL;AACLA,qBAAA,QAAS,IAAA;AACTA,qBAAA,WAAY,IAAA;AACZA,qBAAA,MAAO,IAAA;AACPA,qBAAA,OAAQ,IAAA;AACRA,qBAAA,OAAQ,IAAA;AACRA,qBAAA,WAAY,IAAA;AACZA,qBAAA,QAAS,IAAA;AACTA,qBAAA,YAAa,IAAA;AACbA,qBAAA,iBAAkB,IAAA;AAClBA,qBAAA,cAAe,IAAA;AACfA,qBAAA,aAAc,IAAA;AACdA,qBAAA,cAAe,IAAA;AACfA,qBAAA,mBAAoB,IAAA;AACpBA,qBAAA,gBAAiB,IAAA;AACjBA,qBAAA,eAAgB,IAAA;AAChBA,qBAAA,gBAAiB,IAAA;AAhBPA,SAAAA;AAAA,GAAA,qBAAA,CAAA,CAAA;AAmBA,IAAA,yCAAAC,0BAAL;AACLA,wBAAA,MAAO,IAAA;AACPA,wBAAA,SAAU,IAAA;AACVA,wBAAA,SAAU,IAAA;AAHAA,SAAAA;AAAA,GAAA,wBAAA,CAAA,CAAA;AAMA,IAAA,uCAAAC,wBAAL;AACLA,sBAAA,IAAK,IAAA;AACLA,sBAAA,MAAO,IAAA;AACPA,sBAAA,MAAO,IAAA;AACPA,sBAAA,QAAS,IAAA;AACTA,sBAAA,MAAO,IAAA;AACPA,sBAAA,QAAS,IAAA;AACTA,sBAAA,OAAQ,IAAA;AACRA,sBAAA,OAAQ,IAAA;AACRA,sBAAA,cAAe,IAAA;AACfA,sBAAA,WAAY,IAAA;AACZA,sBAAA,YAAa,IAAA;AACbA,sBAAA,UAAW,IAAA;AACXA,sBAAA,YAAa,IAAA;AACbA,sBAAA,aAAc,IAAA;AACdA,sBAAA,cAAe,IAAA;AACfA,sBAAA,YAAa,IAAA;AACbA,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MACF;AAAA,MACA;AAAA,IAAA,CACD;AAAA,EACH;AAEO,SAAA;AAAA,IACL;AAAA,EACF;AACF;AChFO,MAAM,WAAW,MAAM;AAE5B,UAAQ,kBAAkB;AAC1B,UAAQ,oBAAoB;AAEZ,kBAAA;AAEP,WAAA;AACX;"}
|
package/dist/main.umd.js
DELETED
@@ -1,2 +0,0 @@
|
|
1
|
-
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vue"),require("bkui-vue")):"function"==typeof define&&define.amd?define(["exports","vue","bkui-vue"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self)["ai-ui-sdk"]={},e.Vue,e["bkui-vue"])}(this,(function(e,n,t){"use strict";var o=Object.defineProperty,s=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,a=(e,n,t)=>n in e?o(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,d=(e,n)=>{for(var t in n||(n={}))i.call(n,t)&&a(e,t,n[t]);if(s)for(var t of s(n))l.call(n,t)&&a(e,t,n[t]);return e},r=(e,n,t)=>a(e,"symbol"!=typeof n?n+"":n,t),c=(e,n,t)=>new Promise(((o,s)=>{var i=e=>{try{a(t.next(e))}catch(n){s(n)}},l=e=>{try{a(t.throw(e))}catch(n){s(n)}},a=e=>e.done?o(e.value):Promise.resolve(e.value).then(i,l);a((t=t.apply(e,n)).next())})),u=(e=>(e.System="system",e.Assistant="assistant",e.User="user",e.Guide="guide",e.Pause="pause",e.UserImage="user-image",e.Hidden="hidden",e.HiddenUser="hidden-user",e.HiddenAssistant="hidden-assistant",e.HiddenSystem="hidden-system",e.HiddenGuide="hidden-guide",e.TemplateUser="template-user",e.TemplateAssistant="template-assistant",e.TemplateSystem="template-system",e.TemplateGuide="template-guide",e.TemplateHidden="template-hidden",e))(u||{}),p=(e=>(e.Fail="fail",e.Loading="loading",e.Success="success",e))(p||{}),h=(e=>(e.Ai="ai",e.User="user",e.Time="time",e.System="system",e.Role="role",e.Hidden="hidden",e.Guide="guide",e.Pause="pause",e.TokenExpired="token-expired",e.UserImage="user-image",e.HiddenUser="hidden-user",e.HiddenAi="hidden-ai",e.HiddenRole="hidden-role",e.HiddenGuide="hidden-guide",e.TemplateUser="template-user",e.TemplateAi="template-ai",e.TemplateRole="template-role",e.TemplateGuide="template-guide",e.TemplateHidden="template-hidden",e.ImageNotSupported="image-not-supported",e))(h||{}),m=(e=>(e.TokenExpired="80003",e.ImageNotSupported="82003",e.UnAuthorizedPreviewFile="80401",e.TagRepeat="1513405",e[e.Aborted=20]="Aborted",e[e.UnLogin=401]="UnLogin",e.IamNoPermission="IAM_NO_PERMISSION",e))(m||{});const g=e=>{const n={[h.Ai]:u.Assistant,[h.User]:u.User,[h.System]:u.System,[h.Hidden]:u.Hidden,[h.Guide]:u.Guide,[h.Time]:u.System,[h.Role]:u.System,[h.HiddenAi]:u.HiddenAssistant,[h.HiddenGuide]:u.HiddenGuide,[h.HiddenRole]:u.HiddenSystem,[h.HiddenUser]:u.HiddenUser,[h.TemplateAi]:u.TemplateAssistant,[h.TemplateGuide]:u.TemplateGuide,[h.TemplateRole]:u.TemplateSystem,[h.TemplateUser]:u.TemplateUser,[h.TemplateHidden]:u.TemplateHidden,[h.Pause]:u.Pause,[h.TokenExpired]:u.Pause,[h.ImageNotSupported]:u.Pause,[h.UserImage]:u.UserImage};return{content:e.content,role:n[e.role]}},v=e=>{try{return JSON.parse(e),!0}catch(n){return!1}};const f=e=>e.replace(/<section class="knowledge-head click-close">[\s\S]*?<\/section>/,"").replace(/<ul class="knowledge-body">[\s\S]*?<\/ul>/,"").replace(/<section class="knowledge-tips">[\s\S]*?<\/section>/,""),k=()=>{let e=null;n.onBeforeMount((()=>{e=document.createElement("style"),e.textContent=".knowledge-tips {\n position: relative;\n padding: 6px 8px;\n margin-bottom: 14px;\n line-height: 22px;\n background: #f5f7fa;\n border-radius: 4px;\n\n &.closed {\n .bkaidev-angle-up {\n transform: rotate(180deg);\n }\n\n .knowledge-summary {\n margin-bottom: 0;\n }\n\n .knowledge-link {\n display: none;\n }\n }\n\n .bkaidev-angle-up {\n position: absolute;\n top: 4px;\n right: 0px;\n font-size: 22px;\n color: #979ba5;\n cursor: pointer;\n }\n\n .bkaidev-help-document {\n margin-right: 4px;\n font-size: 19px;\n color: #3a84ff;\n }\n\n .knowledge-summary {\n display: block;\n margin-bottom: 4px;\n color: #313238;\n }\n\n .knowledge-link {\n display: block;\n color: #3a84ff;\n text-decoration: none;\n cursor: pointer;\n\n .bkaidev-cc-jump-link {\n font-size: 14px;\n }\n\n &:last-child {\n margin-bottom: 2px;\n }\n }\n }.knowledge-head {\n display: flex;\n align-items: center;\n padding: 0 8px 0 6px;\n margin-bottom: 8px;\n line-height: 28px;\n background: #F0F1F5;\n border-radius: 4px;\n font-size: 12px;\n color: #313238;\n cursor: pointer;\n width: fit-content;\n\n .ai-ui-sdk-wenzhang {\n width: 14px;\n height: 14px;\n margin-right: 6px;\n }\n\n .ai-ui-sdk-angle-up {\n font-size: 22px;\n color: #4D4F56;\n margin-left: 4px;\n }\n\n &.closed {\n margin-bottom: 16px;\n\n .ai-ui-sdk-angle-up {\n transform: rotate(180deg);\n }\n\n &~ .knowledge-body {\n display: none;\n }\n }\n\n &:hover {\n background: #EAEBF0;\n }\n }\n .knowledge-body {\n background: #F5F7FA;\n padding: 16px 0 !important;\n .knowledge-item {\n padding-left: 10px;\n display: flex;\n align-items: center;\n line-height: 28px;\n .hover-show {\n display: none;\n }\n a {\n margin-right: 10px;\n &:has(i) {\n padding: 0 10px;\n margin-right: 0;\n text-decoration: none !important;\n }\n }\n .ai-ui-sdk-zhishiku {\n color: #D66F6B;\n font-size: 14px;\n margin-right: 6px;\n }\n &:hover {\n background: #EAEBF0;\n .hover-show {\n display: inline;\n }\n }\n }\n }",document.head.appendChild(e)})),n.onBeforeUnmount((()=>{e&&(e.remove(),e=null)}))},b=(e,n,t,o)=>{let s="内容正在生成中..."===e||t?"":e;if(s.includes('<section class="think-head click-close">')){const e=s.match(/<section class="think-body">([\s\S]*?)<\/section>/);if(e){const t=e[1],o=t.replace(/\n$/g,`${n}\n`);s=s.replace(t,o)}}else s+=`<section class="think-head click-close">\n <i class="ai-ui-sdk-icon ai-ui-sdk-sikao"></i>思考中...<i class="ai-ui-sdk-icon ai-ui-sdk-angle-up"></i>\n </section>\n <section class="think-body">\n ${n}\n</section>`;return o&&(s=s.replace("思考中...",`已完成思考 (耗时:${function(e){const n=Math.floor(e/36e5),t=Math.floor(e%36e5/6e4),o=Math.floor(e%6e4/1e3),s=e%1e3,i=[];return n>0&&i.push(`${n}h`),t>0&&i.push(`${t}min`),o>0&&i.push(`${o}s`),s>0&&i.push(`${s.toFixed(2)}ms`),i.join(" ")}(o)})`)),s},x=e=>{let n=e.replace(/<section class="think-head click-close">[\s\S]*<\/section>/,"").replace(/<section class="think-body">[\s\S]*<\/section>/,"");if(""===n.trim()){const t=e.match(/<section class="think-body">([\s\S]*?)<\/section>/);t&&([,n]=t)}return n},y=()=>{let e=null;n.onBeforeMount((()=>{e=document.createElement("style"),e.textContent=".think-head {\n display: flex;\n align-items: center;\n padding: 0 8px 0 6px;\n margin-bottom: 8px;\n line-height: 28px;\n background: #F0F1F5;\n border-radius: 4px;\n font-size: 12px;\n color: #313238;\n cursor: pointer;\n width: fit-content;\n .ai-ui-sdk-sikao {\n font-size: 14px;\n color: #979ba5;\n margin-right: 4px;\n }\n\n .ai-ui-sdk-angle-up {\n font-size: 22px;\n color: #4D4F56;\n margin-left: 4px;\n }\n\n &.closed {\n margin-bottom: 16px;\n\n .ai-ui-sdk-angle-up {\n transform: rotate(180deg);\n }\n\n &~ .think-body {\n display: none;\n }\n }\n\n &:hover {\n background: #EAEBF0;\n }\n }\n .think-body {\n background: #F5F7FA;\n color: #979BA5;\n padding: 16px;\n margin-bottom: 16px;\n &~ .knowledge-head {\n margin-bottom: 8px;\n }\n }",document.head.appendChild(e)})),n.onBeforeUnmount((()=>{e&&(e.remove(),e=null)}))};class S{constructor({handleStart:e,handleText:n,handleReferenceDoc:t,handleThink:o,handleEnd:s,handleError:i}){r(this,"handleStart"),r(this,"handleText"),r(this,"handleReferenceDoc"),r(this,"handleThink"),r(this,"handleEnd"),r(this,"handleError"),r(this,"controllerMap"),this.handleStart=e,this.handleText=n,this.handleReferenceDoc=t,this.handleThink=o,this.handleEnd=s,this.handleError=i,this.controllerMap={}}stream(e){return c(this,arguments,(function*({sessionCode:e,url:n,headers:t,data:o}){var s;yield null==(s=this.handleStart)?void 0:s.call(this,e);const i=new AbortController;this.controllerMap[e]=i,fetch(n,{method:"post",signal:i.signal,headers:d({"Content-Type":"application/json"},t),mode:"cors",credentials:"include",body:JSON.stringify(o)}).then((n=>c(this,null,(function*(){const t=n.body.pipeThrough(new window.TextDecoderStream).getReader();let o="";for(;;)try{const{value:s,done:i}=yield t.read();if(!n.ok){this.handleError(e,s||n.statusText,n.status);break}if(i){this.handleEnd(e);break}(o+s.toString()).split("\n").forEach((t=>{var s,i;const l=t.replace("data:","").trim();if(v(l)){const{event:t,content:a,cover:d,documents:r,result:c,code:u,elapsed_time:p,message:h}=JSON.parse(l);if(!1===c||200!==n.status)return void this.handleError(e,h||"模型调用失败",u);switch(t){case"text":this.handleText(e,a,d);break;case"reference_doc":null==(s=this.handleReferenceDoc)||s.call(this,e,r,d);break;case"think":null==(i=this.handleThink)||i.call(this,e,a,d,p);break;case"done":this.handleEnd(e,d?a:"");break;case"error":this.handleError(e,h||"模型调用失败",u)}o=""}else l&&(o=l)}))}catch(s){20!==(null==s?void 0:s.code)&&this.handleError(e,`模型调用失败:${s.message}`,s.code);break}}))))}))}stop(e){var n,t;return null==(t=null==(n=this.controllerMap[e])?void 0:n.abort)||t.call(n),this.handleEnd(e)}}e.HttpErrorCode=m,e.SessionContentRole=h,e.SessionContentStatus=p,e.SessionPromptRole=u,e.transferSessionContent2SessionPrompt=g,e.useChat=({handleStart:e,handleText:t,handleReferenceDoc:o,handleThink:s,handleEnd:i,handleError:l,requestOptions:a}={})=>{const d="内容正在生成中...",r=n.ref(),c=n.ref({}),u=n.ref([]),v={},k=n.computed((()=>{const e=[];for(let n=u.value.length-1;n>=0;n--){const t=u.value[n];let o=n+1,s=u.value[o];for(;s&&![h.Ai,h.TokenExpired,h.ImageNotSupported,h.Pause,h.Guide].includes(s.role);)o+=1,s=u.value[o];if(t.role===h.System)break;t.status===p.Fail||(null==s?void 0:s.status)===p.Fail&&[h.User,h.UserImage].includes(t.role)||[h.Time,h.System].includes(t.role)||e.unshift(t)}return e})),y=n.computed((()=>{var e;const n=null==(e=r.value)?void 0:e.sessionCode;return!!n&&c.value[n]})),C=n.computed((()=>{var e,n,t;const o=[],s=[],i=[],l=u.value.findLastIndex((e=>e.role===h.System&&["已启用角色","已启用模型"].some((n=>e.content.includes(n)))));let a=0;null==(t=null==(n=null==(e=r.value)?void 0:e.roleInfo)?void 0:n.content)||t.forEach((e=>{const n=u.value[l+1+a];let t=u.value[l+2+a];if((null==n?void 0:n.content)===e.content&&n.role!==h.System&&(o.push(g(n)),a+=1,(null==n?void 0:n.role)===h.Pause)){for(;t&&t.role===h.System;)a+=1,t=u.value[l+1+a];for(;t&&[h.User,h.UserImage].includes(t.role);)o.push(g(t)),a+=1,t=u.value[l+1+a]}})),s.push(...k.value.map(g));const d=e=>{var n;let t=!0;for(let i=e;i<o.length;i++){o[i].content!==(null==(n=s[i-e])?void 0:n.content)&&(t=!1)}return t};for(let r=0;r<o.length;r++){const e=o[r];if(d(r))break;i.push(e)}return i.push(...s),i.forEach((e=>{e.content=x(e.content),e.content=f(e.content)})),i})),E=new S({handleStart:L,handleText:function(e,n,o){const s=T(e);if(s.content===d)s.content=n;else{if(s.status!==p.Loading)return;s.content=o?n:s.content+n}return null==t?void 0:t(e,s)},handleReferenceDoc:function(e,n,t){const s=T(e),i=(e=>{let n=`<section class="knowledge-head click-close">\n <svg\n class="ai-ui-sdk-wenzhang"\n >\n <use href="#ai-ui-sdk-wenzhang"></use>\n </svg>\n 找到 ${e.length} 篇资料参考\n <i class="ai-ui-sdk-icon ai-ui-sdk-angle-up"></i>\n </section>\n <ul class="knowledge-body">`;return e.forEach((e=>{const{path:t,file_path:o,display_name:s,preview_path:i}=e.metadata,l=s||o.split("/").pop();n+=`<li\n class="knowledge-item"\n >\n <i class="ai-ui-sdk-icon ai-ui-sdk-zhishiku"></i>\n <a href="${i}" title="${l} (${i})" target="_blank" class="knowledge-link g-flex-truncate">\n ${l}\n </a>\n <a href="${t}" title="预览原文" target="_blank" class="knowledge-link hover-show">\n <i class="ai-ui-sdk-icon ai-ui-sdk-yanjing-kejian"></i>\n </a>\n </li>`})),n+="</ul>",n})(n);return s.content=t?i:s.content+i,null==o?void 0:o(e,s)},handleThink:function(e,n,t,o){const i=T(e);return i.content=b(i.content,n,t,o),null==s?void 0:s(e,i)},handleEnd:function(e,n){const t=T(e);if(t.status===p.Loading)return c.value[e]=!1,n&&(t.content=n),t.status=p.Success,null==i?void 0:i(e,t);(t.content===d||(e=>{const n="正在思考..."===e,t=e.match(/<section class="think-body">([\s\S]*?)<\/section>$/),o=t&&""===t[1].trim();return n||o})(t.content))&&I(e,"聊天内容已中断")},handleError:I});function T(e){var n,t;return(null==(n=r.value)?void 0:n.sessionCode)===e?u.value.at(-1):null==(t=v[e])?void 0:t.at(-1)}function w(e){var n;return(null==(n=r.value)?void 0:n.sessionCode)===e?u.value:v[e]}function U(e,n){w(e).push(n)}function A(e,n,t){var o;const s=(null==(o=r.value)?void 0:o.sessionCode)===e?u.value:v[e],i=[];return n.forEach((e=>{const n=s.findIndex((n=>n.id===e));if(n>-1){const o=s[n-1],l=s[n+1],a=s[n+2];if(s.splice(n,1),i.push(e),[h.Hidden].includes(null==o?void 0:o.role)){const e=s.findIndex((e=>e.id===o.id));s.splice(e,1),i.push(o.id)}if((null==l?void 0:l.role)===h.Ai||t&&[h.Ai,h.Guide,h.TokenExpired,h.ImageNotSupported,h.Pause].includes(null==l?void 0:l.role)){const e=s.findIndex((e=>e.id===l.id));s.splice(e,1),i.push(l.id)}if([h.Guide].includes(null==a?void 0:a.role)&&t){const e=s.findIndex((e=>e.id===a.id));s.splice(e,1),i.push(a.id)}}})),i}function L(n){c.value[n]=!0;const t={sessionCode:n,role:h.Ai,status:p.Loading,content:d};return U(n,t),null==e?void 0:e(n,t)}function I(e,n,t){const o=T(e);return o.status=p.Fail,o.content=n,c.value[e]=!1,t===m.TokenExpired&&(o.content="抱歉,您的剩余 Token 不足,无法返回回答内容,请先清空当前会话(上下文仍会作为历史记录保留))",o.role=h.TokenExpired),t===m.ImageNotSupported&&(o.content="抱歉,当前模型不支持图片内容解析",o.role=h.ImageNotSupported),null==l?void 0:l(e,o,t)}function H(e,n){var t,o,s;if(!(null==(t=r.value)?void 0:t.sessionCode)||!(null==a?void 0:a.url)||y.value)return;const{message:i,cite:l,shortcut:d}=e;let c="";var m,g;d?(m=d.prompt,g=l,c=m.replace(/\{\{\s*SELECTED_TEXT\s*\}\}/g,g||"")):c=l?`${i}: "${l}"`:i,u.value.push({sessionCode:null==(o=r.value)?void 0:o.sessionCode,content:i,role:h.User,status:p.Success,cite:l}),E.stream({sessionCode:null==(s=r.value)?void 0:s.sessionCode,url:a.url,headers:null==a?void 0:a.headers,data:{inputs:{chat_history:C.value.slice(0,C.value.length-1),input:c}}}),null==n||n()}return{currentSession:r,sessionContents:u,sessionContentsMap:v,sessionLoadingMap:c,prompts:C,currentSessionLoading:y,chat:function({sessionCode:e,data:n,url:t,headers:o}){E.stream({sessionCode:e,url:t,data:n,headers:o||(null==a?void 0:a.headers)})},sendChat:H,stopChat:function(e){E.stop(e)},plusSessionContent:U,updateSessionContent:function(e){var n;const t=((null==(n=r.value)?void 0:n.sessionCode)===e.sessionCode?u.value:v[e.sessionCode]).find((n=>+(n.id||0)==+(e.id||0)));t&&Object.assign(t,e)},getSessionContentById:function(e,n){return w(n).find((n=>n.id===e))},getLastSessionContentBySessionCode:T,getSessionContentsBySessionCode:w,setCurrentSession:function(e){r.value=e,(null==e?void 0:e.sessionCode)&&(v[e.sessionCode]||(v[e.sessionCode]=[]),u.value=v[e.sessionCode])},setSessionContents:function(e){r.value&&(v[r.value.sessionCode]=e,u.value=e)},deleteSessionContent:function(e,n){return A(e,[n],!0)},deleteSessionContents:function(e,n){return A(e,n,!1)},handleStartChat:L,handleErrorChat:I,reGenerateChat:function(e){if(u.value[e].role!==h.Ai)return;const n=u.value[e-1].content,t=u.value[e-1].cite;u.value.splice(e-1,2),H({message:n,cite:t})},reSendChat:function(e,{message:n,cite:t},o){u.value[e].role===h.User&&(u.value.splice(e,u.value.length-e),H({message:n,cite:t},o))},deleteChat:function(e){u.value[e].role!==h.User?u.value.splice(e-1,2):u.value.splice(e,2)}}},e.useClickProxy=()=>{const e=e=>{var n,o,s,i;const l=e.target;if(null==l?void 0:l.classList.contains("bkaidev-angle-up")){const e=null==l?void 0:l.parentElement;(null==e?void 0:e.classList.contains("closed"))?null==e||e.classList.remove("closed"):null==e||e.classList.add("closed")}if((null==l?void 0:l.classList.contains("click-close"))&&((null==l?void 0:l.classList.contains("closed"))?null==l||l.classList.remove("closed"):null==l||l.classList.add("closed")),null==l?void 0:l.classList.contains("click-full-screen")){const e=null==(o=null==(n=null==l?void 0:l.parentElement)?void 0:n.parentElement)?void 0:o.parentElement;null==e||e.classList.add("full-screen"),e._originalParent||(e._originalParent=e.parentNode,e._originalNextSibling=e.nextSibling),document.body.appendChild(e)}if(null==l?void 0:l.classList.contains("click-un-full-screen")){const e=null==(i=null==(s=null==l?void 0:l.parentElement)?void 0:s.parentElement)?void 0:i.parentElement;null==e||e.classList.remove("full-screen"),e._originalNextSibling?e._originalParent.insertBefore(e,e._originalNextSibling):e._originalParent.appendChild(e)}if(null==l?void 0:l.classList.contains("click-copy")){const e=null==l?void 0:l.getAttribute("data-clipboard-text");e&&(e=>{const n=document.createElement("textarea");n.value=e,document.body.appendChild(n),n.select(),document.execCommand("copy"),t.Message({theme:"success",message:"复制成功"}),document.body.removeChild(n)})(decodeURIComponent(e))}if(null==l?void 0:l.classList.contains("click-download")){const e=null==l?void 0:l.getAttribute("data-clipboard-text"),n=null==l?void 0:l.getAttribute("data-file-name");e&&n&&function(e,n="ai.txt"){const t=document.createElement("a"),o=new Blob([e]);t.download=n,t.href=URL.createObjectURL(o),t.style.display="none",document.body.appendChild(t),t.click(),document.body.removeChild(t)}(decodeURIComponent(e),n)}};n.onBeforeMount((()=>{window.addEventListener("click",e)})),n.onBeforeUnmount((()=>{window.removeEventListener("click",e)}))},e.useStyle=()=>{require("../css/style.css"),require("../css/iconcool.js"),k(),y()},e.useSummary=({handleStart:e,handleEnd:n,handleError:t}={})=>{let o="";const s=new S({handleStart:()=>(o="",null==e?void 0:e()),handleText:(e,n,t)=>{t||"正在思考..."===o?o=n:o+=n},handleEnd:()=>("无话可说"===o&&(o=""),null==n?void 0:n(o)),handleError:(e,n,o)=>null==t?void 0:t(n,o)});return{summary:({content:e,url:n,headers:t,model:o})=>{const i=x(f(e)),l=[{role:u.User,content:`你是一个总结大师,请帮助我对下面这段话进行总结。要求总结精炼,不超过 15 个字!且末尾没有标点符号!请注意:如果你无法总结,请回复“无话可说”!\n文字如下:\n${i}`}];s.stream({sessionCode:"summary",url:n,data:{prompts:l,model:o},headers:t})}}},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
|
2
|
-
//# sourceMappingURL=main.umd.js.map
|
package/dist/main.umd.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"main.umd.js","sources":["../src/types/enum.ts","../src/common/type-transform.ts","../src/common/util.ts","../src/hooks/use-reference-doc.ts","../src/hooks/use-think.ts","../src/common/chart-helper.ts","../src/hooks/use-chat.ts","../src/hooks/use-click-proxy.ts","../src/hooks/use-style.ts","../src/hooks/use-summary.ts"],"sourcesContent":["// 传给 ai 的类型\nexport enum SessionPromptRole {\n System = 'system',\n Assistant = 'assistant',\n User = 'user',\n Guide = 'guide',\n Pause = 'pause',\n UserImage = 'user-image',\n Hidden = 'hidden',\n HiddenUser = 'hidden-user',\n HiddenAssistant = 'hidden-assistant',\n HiddenSystem = 'hidden-system',\n HiddenGuide = 'hidden-guide',\n TemplateUser = 'template-user',\n TemplateAssistant = 'template-assistant',\n TemplateSystem = 'template-system',\n TemplateGuide = 'template-guide',\n TemplateHidden = 'template-hidden',\n}\n\nexport enum SessionContentStatus {\n Fail = 'fail',\n Loading = 'loading',\n Success = 'success',\n}\n\nexport enum SessionContentRole {\n Ai = 'ai',\n User = 'user',\n Time = 'time',\n System = 'system',\n Role = 'role',\n Hidden = 'hidden',\n Guide = 'guide',\n Pause = 'pause',\n TokenExpired = 'token-expired',\n UserImage = 'user-image',\n HiddenUser = 'hidden-user',\n HiddenAi = 'hidden-ai',\n HiddenRole = 'hidden-role',\n HiddenGuide = 'hidden-guide',\n TemplateUser = 'template-user',\n TemplateAi = 'template-ai',\n TemplateRole = 'template-role',\n TemplateGuide = 'template-guide',\n TemplateHidden = 'template-hidden',\n ImageNotSupported = 'image-not-supported'\n}\n\nexport enum HttpErrorCode {\n TokenExpired = '80003',\n ImageNotSupported = '82003',\n UnAuthorizedPreviewFile = '80401',\n TagRepeat = '1513405',\n Aborted = 20,\n UnLogin = 401,\n IamNoPermission = 'IAM_NO_PERMISSION'\n}\n","import {\n SessionContentRole,\n SessionPromptRole,\n} from '../types/enum';\nimport type {\n ISessionContent,\n ISessionPrompt,\n} from '../types/type';\n\n/**\n * 将 sessionContent 转换为 sessionPrompt\n * @param sessionContent sessionContent\n * @returns sessionPrompt\n */\nexport const transferSessionContent2SessionPrompt = (sessionContent: ISessionContent): ISessionPrompt => {\n const sessionRoleMap = {\n [SessionContentRole.Ai]: SessionPromptRole.Assistant,\n [SessionContentRole.User]: SessionPromptRole.User,\n [SessionContentRole.System]: SessionPromptRole.System,\n [SessionContentRole.Hidden]: SessionPromptRole.Hidden,\n [SessionContentRole.Guide]: SessionPromptRole.Guide,\n [SessionContentRole.Time]: SessionPromptRole.System,\n [SessionContentRole.Role]: SessionPromptRole.System,\n [SessionContentRole.HiddenAi]: SessionPromptRole.HiddenAssistant,\n [SessionContentRole.HiddenGuide]: SessionPromptRole.HiddenGuide,\n [SessionContentRole.HiddenRole]: SessionPromptRole.HiddenSystem,\n [SessionContentRole.HiddenUser]: SessionPromptRole.HiddenUser,\n [SessionContentRole.TemplateAi]: SessionPromptRole.TemplateAssistant,\n [SessionContentRole.TemplateGuide]: SessionPromptRole.TemplateGuide,\n [SessionContentRole.TemplateRole]: SessionPromptRole.TemplateSystem,\n [SessionContentRole.TemplateUser]: SessionPromptRole.TemplateUser,\n [SessionContentRole.TemplateHidden]: SessionPromptRole.TemplateHidden,\n [SessionContentRole.Pause]: SessionPromptRole.Pause,\n [SessionContentRole.TokenExpired]: SessionPromptRole.Pause,\n [SessionContentRole.ImageNotSupported]: SessionPromptRole.Pause,\n [SessionContentRole.UserImage]: SessionPromptRole.UserImage,\n };\n return {\n content: sessionContent.content,\n role: sessionRoleMap[sessionContent.role],\n };\n};\n","import {\n Message,\n} from 'bkui-vue';\n\n/**\n * 判断是否是 JSON 字符串\n * @param str 字符串\n * @returns 是否是 JSON 字符串\n */\nexport const isJSON = (str: string) => {\n try {\n JSON.parse(str);\n return true;\n } catch (e) {\n return false;\n }\n};\n\n/**\n * 响应时间格式化\n * @param val 待格式化时间,xxms\n * @returns 格式化后的时间,xx小时xx分钟xx秒\n */\nexport function durationFormatter(val: number) {\n const hours = Math.floor(val / 3600000);\n const minutes = Math.floor((val % 3600000) / 60000);\n const seconds = Math.floor((val % 60000) / 1000);\n const milliseconds = val % 1000;\n\n const parts: string[] = [];\n if (hours > 0) {\n parts.push(`${hours}h`);\n }\n if (minutes > 0) {\n parts.push(`${minutes}min`);\n }\n if (seconds > 0) {\n parts.push(`${seconds}s`);\n }\n if (milliseconds > 0) {\n parts.push(`${milliseconds.toFixed(2)}ms`);\n }\n\n return parts.join(' ');\n}\n\n/**\n * 前端下载文件\n * @param {*} source 文件内容\n * @param {*} filename 文件名\n */\nexport function handleDownLoad(source: string, filename = 'ai.txt') {\n const downloadEl = document.createElement('a');\n const blob = new Blob([source]);\n downloadEl.download = filename;\n downloadEl.href = URL.createObjectURL(blob);\n downloadEl.style.display = 'none';\n document.body.appendChild(downloadEl);\n downloadEl.click();\n document.body.removeChild(downloadEl);\n}\n\nexport const handleCopy = (text: string) => {\n const textarea = document.createElement('textarea');\n textarea.value = text;\n document.body.appendChild(textarea);\n textarea.select();\n document.execCommand('copy');\n Message({\n theme: 'success',\n message: '复制成功',\n });\n document.body.removeChild(textarea);\n};\n\n/**\n * 处理提示词模板,替换模板中的变量\n * @param prompt 提示词模板\n * @param selectedText 选中的文本\n * @returns 处理后的提示词\n */\nexport const processPromptTemplate = (prompt: string, selectedText: string) => {\n return prompt.replace(/\\{\\{\\s*SELECTED_TEXT\\s*\\}\\}/g, selectedText || '');\n};","import {\n onBeforeMount,\n onBeforeUnmount,\n} from 'vue';\n\nimport type {\n Document,\n} from '../types/type';\n\n/**\n * 获取引用资料的 HTML 内容\n * @param documents\n * @returns\n */\nexport const getHtmlContentFromDocuments = (documents: Document[]) => {\n let htmlContent = `<section class=\"knowledge-head click-close\">\n <svg\n class=\"ai-ui-sdk-wenzhang\"\n >\n <use href=\"#ai-ui-sdk-wenzhang\"></use>\n </svg>\n 找到 ${documents.length} 篇资料参考\n <i class=\"ai-ui-sdk-icon ai-ui-sdk-angle-up\"></i>\n </section>\n <ul class=\"knowledge-body\">`;\n documents.forEach((document) => {\n const { path, file_path: filePath, display_name: displayName, preview_path: previewPath } = document.metadata;\n const title = displayName || filePath.split('/').pop();\n htmlContent += `<li\n class=\"knowledge-item\"\n >\n <i class=\"ai-ui-sdk-icon ai-ui-sdk-zhishiku\"></i>\n <a href=\"${previewPath}\" title=\"${title} (${previewPath})\" target=\"_blank\" class=\"knowledge-link g-flex-truncate\">\n ${title}\n </a>\n <a href=\"${path}\" title=\"预览原文\" target=\"_blank\" class=\"knowledge-link hover-show\">\n <i class=\"ai-ui-sdk-icon ai-ui-sdk-yanjing-kejian\"></i>\n </a>\n </li>`;\n });\n htmlContent += '</ul>';\n return htmlContent;\n};\n\n/**\n * 移除引用资料的 HTML 内容\n * @param content\n * @returns\n */\nexport const removeReferenceDoc = (content: string) => {\n return content\n .replace(/<section class=\"knowledge-head click-close\">[\\s\\S]*?<\\/section>/, '')\n .replace(/<ul class=\"knowledge-body\">[\\s\\S]*?<\\/ul>/, '')\n .replace(/<section class=\"knowledge-tips\">[\\s\\S]*?<\\/section>/, '');\n};\n\nexport const useReferenceDoc = () => {\n let styleEle: HTMLStyleElement | null = null;\n\n const addReferenceDocStyle = () => {\n // 旧版知识样式\n const oldStyle = `.knowledge-tips {\n position: relative;\n padding: 6px 8px;\n margin-bottom: 14px;\n line-height: 22px;\n background: #f5f7fa;\n border-radius: 4px;\n\n &.closed {\n .bkaidev-angle-up {\n transform: rotate(180deg);\n }\n\n .knowledge-summary {\n margin-bottom: 0;\n }\n\n .knowledge-link {\n display: none;\n }\n }\n\n .bkaidev-angle-up {\n position: absolute;\n top: 4px;\n right: 0px;\n font-size: 22px;\n color: #979ba5;\n cursor: pointer;\n }\n\n .bkaidev-help-document {\n margin-right: 4px;\n font-size: 19px;\n color: #3a84ff;\n }\n\n .knowledge-summary {\n display: block;\n margin-bottom: 4px;\n color: #313238;\n }\n\n .knowledge-link {\n display: block;\n color: #3a84ff;\n text-decoration: none;\n cursor: pointer;\n\n .bkaidev-cc-jump-link {\n font-size: 14px;\n }\n\n &:last-child {\n margin-bottom: 2px;\n }\n }\n }`;\n // 新版知识样式\n const newStyle = `.knowledge-head {\n display: flex;\n align-items: center;\n padding: 0 8px 0 6px;\n margin-bottom: 8px;\n line-height: 28px;\n background: #F0F1F5;\n border-radius: 4px;\n font-size: 12px;\n color: #313238;\n cursor: pointer;\n width: fit-content;\n\n .ai-ui-sdk-wenzhang {\n width: 14px;\n height: 14px;\n margin-right: 6px;\n }\n\n .ai-ui-sdk-angle-up {\n font-size: 22px;\n color: #4D4F56;\n margin-left: 4px;\n }\n\n &.closed {\n margin-bottom: 16px;\n\n .ai-ui-sdk-angle-up {\n transform: rotate(180deg);\n }\n\n &~ .knowledge-body {\n display: none;\n }\n }\n\n &:hover {\n background: #EAEBF0;\n }\n }\n .knowledge-body {\n background: #F5F7FA;\n padding: 16px 0 !important;\n .knowledge-item {\n padding-left: 10px;\n display: flex;\n align-items: center;\n line-height: 28px;\n .hover-show {\n display: none;\n }\n a {\n margin-right: 10px;\n &:has(i) {\n padding: 0 10px;\n margin-right: 0;\n text-decoration: none !important;\n }\n }\n .ai-ui-sdk-zhishiku {\n color: #D66F6B;\n font-size: 14px;\n margin-right: 6px;\n }\n &:hover {\n background: #EAEBF0;\n .hover-show {\n display: inline;\n }\n }\n }\n }`;\n styleEle = document.createElement('style');\n styleEle.textContent = oldStyle + newStyle;\n document.head.appendChild(styleEle);\n };\n\n const removeReferenceDocStyle = () => {\n if (styleEle) {\n styleEle.remove();\n styleEle = null;\n }\n };\n\n onBeforeMount(() => {\n addReferenceDocStyle();\n });\n\n onBeforeUnmount(() => {\n removeReferenceDocStyle();\n });\n};\n","import {\n onBeforeMount,\n onBeforeUnmount,\n} from 'vue';\n\nimport {\n durationFormatter,\n} from '../common/util';\n\n/**\n * 获取思考的 HTML 内容\n * @param chatContent 聊天内容\n * @param content 思考内容\n * @param elapsedTime 思考时间\n * @returns 完整的 chatContent\n */\nexport const getHtmlContentFromThink = (chatContent: string, content: string, cover?: boolean, elapsedTime?: number) => {\n let htmlContent = (chatContent === '内容正在生成中...' || cover) ? '' : chatContent;\n // 思考开始\n if (!htmlContent.includes('<section class=\"think-head click-close\">')) {\n htmlContent += `<section class=\"think-head click-close\">\n <i class=\"ai-ui-sdk-icon ai-ui-sdk-sikao\"></i>思考中...<i class=\"ai-ui-sdk-icon ai-ui-sdk-angle-up\"></i>\n </section>\n <section class=\"think-body\">\n ${content}\n</section>`;\n } else {\n // 补充思考内容\n const thinkBodyMatch = htmlContent.match(/<section class=\"think-body\">([\\s\\S]*?)<\\/section>/);\n if (thinkBodyMatch) {\n // 原有思考内容\n const thinkContent = thinkBodyMatch[1];\n // 在最后的换行符前面添加新的思考内容\n const newThinkContent = thinkContent.replace(/\\n$/g, `${content}\\n`);\n htmlContent = htmlContent.replace(\n thinkContent,\n newThinkContent,\n );\n }\n }\n // 思考结束\n if (elapsedTime) {\n htmlContent = htmlContent.replace('思考中...', `已完成思考 (耗时:${durationFormatter(elapsedTime)})`);\n }\n return htmlContent;\n};\n\n/**\n * 移除思考的 HTML 内容\n * @param content\n * @returns\n */\nexport const removeThink = (content: string) => {\n // 移除思考头部\n const afterRemoveThinkHead = content.replace(/<section class=\"think-head click-close\">[\\s\\S]*<\\/section>/, '');\n // 移除思考内容\n let afterRemoveThinkBody = afterRemoveThinkHead.replace(/<section class=\"think-body\">[\\s\\S]*<\\/section>/, '');\n // 如果内容只有思考,那就给ai传递思考内容\n if (afterRemoveThinkBody.trim() === '') {\n const thinkBodyMatch = content.match(/<section class=\"think-body\">([\\s\\S]*?)<\\/section>/);\n if (thinkBodyMatch) {\n [, afterRemoveThinkBody] = thinkBodyMatch;\n }\n }\n return afterRemoveThinkBody;\n};\n\n/**\n * 判断是否是思考中\n * @param content\n * @returns\n */\nexport const isThinking = (content: string) => {\n // 是否开始思考\n const isStartThinking = content === '正在思考...';\n // 判断是否空思考\n const thinkBodyMatch = content.match(/<section class=\"think-body\">([\\s\\S]*?)<\\/section>$/);\n const isEmptyThinking = thinkBodyMatch && thinkBodyMatch[1].trim() === '';\n\n return isStartThinking || isEmptyThinking;\n};\n\n// 思考\nexport const useThink = () => {\n let styleEle: HTMLStyleElement | null = null;\n\n const addThinkStyle = () => {\n const style = `.think-head {\n display: flex;\n align-items: center;\n padding: 0 8px 0 6px;\n margin-bottom: 8px;\n line-height: 28px;\n background: #F0F1F5;\n border-radius: 4px;\n font-size: 12px;\n color: #313238;\n cursor: pointer;\n width: fit-content;\n .ai-ui-sdk-sikao {\n font-size: 14px;\n color: #979ba5;\n margin-right: 4px;\n }\n\n .ai-ui-sdk-angle-up {\n font-size: 22px;\n color: #4D4F56;\n margin-left: 4px;\n }\n\n &.closed {\n margin-bottom: 16px;\n\n .ai-ui-sdk-angle-up {\n transform: rotate(180deg);\n }\n\n &~ .think-body {\n display: none;\n }\n }\n\n &:hover {\n background: #EAEBF0;\n }\n }\n .think-body {\n background: #F5F7FA;\n color: #979BA5;\n padding: 16px;\n margin-bottom: 16px;\n &~ .knowledge-head {\n margin-bottom: 8px;\n }\n }`;\n styleEle = document.createElement('style');\n styleEle.textContent = style;\n document.head.appendChild(styleEle);\n };\n\n const removeThinkStyle = () => {\n if (styleEle) {\n styleEle.remove();\n styleEle = null;\n }\n };\n\n onBeforeMount(() => {\n addThinkStyle();\n });\n\n onBeforeUnmount(() => {\n removeThinkStyle();\n });\n};\n","import {\n isJSON,\n} from './util';\n\nimport type {\n Document,\n} from '../types/type';\n\ntype HandleStart = (sessionCode: string) => any;\ntype HandleText = (sessionCode: string, message: string, cover?: boolean) => void;\ntype HandleReferenceDoc = (sessionCode: string, documents: Document[], cover?: boolean) => void;\ntype HandleThink = (sessionCode: string, content: string, cover?: boolean, elapsed_time?: number) => void;\ntype HandleEnd = (sessionCode: string, message?: string) => void;\ntype HandleError = (sessionCode: string, message: string, code: string) => any;\n\nexport class ChatHelper {\n handleStart: HandleStart;\n handleText: HandleText;\n handleReferenceDoc?: HandleReferenceDoc;\n handleThink?: HandleThink;\n handleEnd: HandleEnd;\n handleError: HandleError;\n controllerMap: Record<string, AbortController>;\n\n constructor({\n handleStart,\n handleText,\n handleReferenceDoc,\n handleThink,\n handleEnd,\n handleError,\n }: {\n handleStart: HandleStart;\n handleText: HandleText;\n handleReferenceDoc?: HandleReferenceDoc;\n handleThink?: HandleThink;\n handleEnd: HandleEnd;\n handleError: HandleError;\n }) {\n this.handleStart = handleStart;\n this.handleText = handleText;\n this.handleReferenceDoc = handleReferenceDoc;\n this.handleThink = handleThink;\n this.handleEnd = handleEnd;\n this.handleError = handleError;\n this.controllerMap = {};\n }\n\n async stream({\n sessionCode,\n url,\n headers,\n data,\n }: {\n sessionCode: string;\n url: string;\n headers?: Record<string, string>;\n data?: Record<string, any>;\n }) {\n // 开始\n await this.handleStart?.(sessionCode);\n // 记录 controller\n const controller = new AbortController();\n this.controllerMap[sessionCode] = controller;\n // 发送请求\n fetch(url, {\n method: 'post',\n signal: controller.signal,\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n },\n mode: 'cors',\n credentials: 'include',\n body: JSON.stringify(data),\n })\n .then(async (response: any) => {\n const reader = response.body\n .pipeThrough(new window.TextDecoderStream())\n .getReader();\n\n // 临时存储数据\n let temp = '';\n\n while (true) {\n try {\n const { value, done } = await reader.read();\n\n // 接口异常处理\n if (!response.ok) {\n this.handleError(sessionCode, value || response.statusText, response.status);\n break;\n }\n // 接口完成\n if (done) {\n this.handleEnd(sessionCode);\n break;\n }\n\n const values = (temp + value.toString()).split('\\n');\n values.forEach((value) => {\n const item = value.replace('data:', '').trim();\n if (isJSON(item)) {\n const {\n event,\n content,\n cover,\n documents,\n result,\n code,\n elapsed_time,\n message,\n } = JSON.parse(item);\n // 业务错误处理\n if (result === false || response.status !== 200) {\n this.handleError(sessionCode, message || '模型调用失败', code);\n return;\n }\n\n switch (event) {\n case 'text':\n this.handleText(sessionCode, content, cover);\n break;\n case 'reference_doc':\n this.handleReferenceDoc?.(sessionCode, documents, cover);\n break;\n case 'think':\n this.handleThink?.(sessionCode, content, cover, elapsed_time);\n break;\n case 'done':\n this.handleEnd(sessionCode, cover ? content : '');\n break;\n case 'error':\n this.handleError(sessionCode, message || '模型调用失败', code);\n break;\n }\n temp = '';\n } else if (item) {\n temp = item;\n }\n });\n } catch (error: any) {\n if (error?.code !== 20) {\n this.handleError(sessionCode, `模型调用失败:${error.message}`, error.code);\n }\n break;\n }\n }\n });\n }\n\n stop(sessionCode: string) {\n this.controllerMap[sessionCode]?.abort?.();\n return this.handleEnd(sessionCode);\n }\n}\n","import {\n ref,\n computed,\n} from 'vue';\nimport type {\n Document,\n ISessionContent,\n ISession,\n ISessionPrompt,\n ChatCallbacks,\n BasicChatContent,\n ShortcutChatContent,\n} from '../types/type.ts';\nimport { processPromptTemplate } from '../common/util';\nimport {\n HttpErrorCode,\n SessionContentRole,\n SessionContentStatus,\n} from '../types/enum';\nimport {\n getHtmlContentFromDocuments,\n removeReferenceDoc,\n} from '../hooks/use-reference-doc';\nimport {\n getHtmlContentFromThink,\n isThinking,\n removeThink,\n} from '../hooks/use-think';\nimport {\n ChatHelper,\n} from '../common/chart-helper';\nimport {\n transferSessionContent2SessionPrompt,\n} from '../common/type-transform';\n\ntype SessionContentsMap = {\n [key: string]: ISessionContent[]\n};\n\ntype SessionLoadingMap = {\n [key: string]: boolean\n};\n\n// ai 聊天\nexport const useChat = <T extends ISession = ISession>({\n handleStart,\n handleText,\n handleReferenceDoc,\n handleThink,\n handleEnd,\n handleError,\n requestOptions,\n}: ChatCallbacks = {}) => {\n const startMessage = '内容正在生成中...';\n // 聊天上下文\n const currentSession = ref<T>();\n const sessionLoadingMap = ref<SessionLoadingMap>({});\n const sessionContents = ref<ISessionContent[]>([]);\n const sessionContentsMap: SessionContentsMap = {};\n\n // 通过计算得到的会话列表\n const calculatedSessionContents = computed<ISessionContent[]>(() => {\n const calculatedSessionContents: ISessionContent[] = [];\n for (let index = sessionContents.value.length - 1; index >= 0; index--) {\n const sessionContent = sessionContents.value[index];\n // 向下找到下一个ai回复\n let nextAiSessionContentIndex = index + 1;\n let nextAiSessionContent = sessionContents.value[nextAiSessionContentIndex];\n while (nextAiSessionContent && ![\n SessionContentRole.Ai,\n SessionContentRole.TokenExpired,\n SessionContentRole.ImageNotSupported,\n SessionContentRole.Pause,\n SessionContentRole.Guide,\n ].includes(nextAiSessionContent.role)\n ) {\n nextAiSessionContentIndex += 1;\n nextAiSessionContent = sessionContents.value[nextAiSessionContentIndex];\n }\n\n // 系统消息,退出\n if (sessionContent.role === SessionContentRole.System) {\n break;\n }\n\n // 倒叙添加当前聊天上下文 排除异常答复、异常问题 & 系统消息和时间消息\n if (sessionContent.status !== SessionContentStatus.Fail\n && !(nextAiSessionContent?.status === SessionContentStatus.Fail\n && [SessionContentRole.User, SessionContentRole.UserImage].includes(sessionContent.role)\n )\n && ![SessionContentRole.Time, SessionContentRole.System].includes(sessionContent.role)\n ) {\n calculatedSessionContents.unshift(sessionContent);\n }\n }\n\n return calculatedSessionContents;\n });\n\n // 当前会话是否正在加载\n const currentSessionLoading = computed(() => {\n const sessionCode = currentSession.value?.sessionCode;\n return sessionCode ? sessionLoadingMap.value[sessionCode] : false;\n });\n\n // 计算当前的 prompt\n const prompts = computed<ISessionPrompt[]>(() => {\n const rolePrompts: ISessionPrompt[] = [];\n const userPrompts: ISessionPrompt[] = [];\n const prompts: ISessionPrompt[] = [];\n\n // build rolePrompts\n const latestMatchIndex = sessionContents.value.findLastIndex(sessionContent => (\n sessionContent.role === SessionContentRole.System && ['已启用角色', '已启用模型'].some(key => sessionContent.content.includes(key))\n ));\n let index = 0;\n currentSession.value?.roleInfo?.content?.forEach((roleContent) => {\n const sessionContent = sessionContents.value[latestMatchIndex + 1 + index];\n let nextSessionContent = sessionContents.value[latestMatchIndex + 2 + index];\n if (sessionContent?.content === roleContent.content && sessionContent.role !== SessionContentRole.System) {\n rolePrompts.push(transferSessionContent2SessionPrompt(sessionContent));\n index += 1;\n if (sessionContent?.role === SessionContentRole.Pause) {\n while (nextSessionContent && nextSessionContent.role === SessionContentRole.System) {\n index += 1;\n nextSessionContent = sessionContents.value[latestMatchIndex + 1 + index];\n }\n while (nextSessionContent\n && [SessionContentRole.User, SessionContentRole.UserImage].includes(nextSessionContent.role)\n ) {\n rolePrompts.push(transferSessionContent2SessionPrompt(nextSessionContent));\n index += 1;\n nextSessionContent = sessionContents.value[latestMatchIndex + 1 + index];\n }\n }\n }\n });\n\n // build userPrompts\n userPrompts.push(...calculatedSessionContents.value.map(transferSessionContent2SessionPrompt));\n\n const isSameContent = (startIndex: number) => {\n let isSame = true;\n for (let index = startIndex; index < rolePrompts.length; index++) {\n const rolePrompt = rolePrompts[index];\n if (rolePrompt.content !== userPrompts[index - startIndex]?.content) {\n isSame = false;\n }\n }\n\n return isSame;\n };\n\n // 排除在一个系统消息里面,重复的情况\n for (let index = 0; index < rolePrompts.length; index++) {\n const rolePrompt = rolePrompts[index];\n if (isSameContent(index)) {\n break;\n } else {\n prompts.push(rolePrompt);\n }\n }\n\n prompts.push(...userPrompts);\n\n // 删除引用资料\n prompts.forEach(prompt => {\n prompt.content = removeThink(prompt.content);\n prompt.content = removeReferenceDoc(prompt.content);\n });\n\n return prompts;\n });\n\n const chatHelper = new ChatHelper({\n handleStart: handleStartChat,\n handleText: handleTextChat,\n handleReferenceDoc: handleReferenceDocChat,\n handleThink: handleThinkChat,\n handleEnd: handleEndChat,\n handleError: handleErrorChat,\n });\n\n // 设置 currentSession\n function setCurrentSession(session?: T) {\n currentSession.value = session;\n // 空session,不处理\n if (!session?.sessionCode) return;\n\n if (!sessionContentsMap[session.sessionCode]) {\n sessionContentsMap[session.sessionCode] = [];\n }\n sessionContents.value = sessionContentsMap[session.sessionCode];\n }\n\n // 设置 sessionContents\n function setSessionContents(data: ISessionContent[]) {\n if (!currentSession.value) return;\n sessionContentsMap[currentSession.value.sessionCode] = data;\n sessionContents.value = data;\n }\n\n\n // 获取 SessionContent 通过 id\n function getSessionContentById(id: number, sessionCode: string) {\n const sessionContents = getSessionContentsBySessionCode(sessionCode);\n return sessionContents.find(item => item.id === id);\n }\n\n // 获取执行中的 SessionContent(最后一个)\n function getLastSessionContentBySessionCode(sessionCode: string) {\n if (currentSession.value?.sessionCode === sessionCode) {\n return sessionContents.value.at(-1) as ISessionContent;\n }\n return sessionContentsMap[sessionCode]?.at(-1) as ISessionContent;\n }\n\n // 获取 SessionContents\n function getSessionContentsBySessionCode(sessionCode: string) {\n if (currentSession.value?.sessionCode === sessionCode) {\n return sessionContents.value;\n }\n return sessionContentsMap[sessionCode];\n }\n\n // 新增 sessionContent\n function plusSessionContent(sessionCode: string, sessionContent: ISessionContent) {\n const sessionContents = getSessionContentsBySessionCode(sessionCode);\n sessionContents.push(sessionContent);\n }\n\n // 更新 chatContent\n function updateSessionContent(sessionContent: ISessionContent) {\n const currentSessionContents = currentSession.value?.sessionCode === sessionContent.sessionCode\n ? sessionContents.value\n : sessionContentsMap[sessionContent.sessionCode];\n\n const currentSessionContent = currentSessionContents.find(item => +(item.id || 0) === +(sessionContent.id || 0));\n if (currentSessionContent) {\n Object.assign(currentSessionContent, sessionContent);\n }\n }\n\n // 获取待删除的会话id,并从会话列表中删除\n function getDeleteSessionContents(sessionCode: string, sessionContentIds: number[], relatedDelete: boolean) {\n const currentSessionContents = currentSession.value?.sessionCode === sessionCode\n ? sessionContents.value\n : sessionContentsMap[sessionCode];\n const deleteSessionContentIds: number[] = [];\n\n sessionContentIds.forEach((sessionContentId) => {\n const index = currentSessionContents.findIndex(sessionContent => sessionContent.id === sessionContentId);\n if (index > -1) {\n const preSessionContent = currentSessionContents[index - 1];\n const nextSessionContent = currentSessionContents[index + 1];\n const nextNextSessionContent = currentSessionContents[index + 2];\n // 删除当前会话\n currentSessionContents.splice(index, 1);\n deleteSessionContentIds.push(sessionContentId);\n // 如果前一个是 hidden 也需要删除\n if ([SessionContentRole.Hidden].includes(preSessionContent?.role)) {\n const hiddenIndex = currentSessionContents\n .findIndex(sessionContent => sessionContent.id === preSessionContent.id);\n currentSessionContents.splice(hiddenIndex, 1);\n deleteSessionContentIds.push(preSessionContent.id as number);\n }\n // 如果下一个是ai回复,也需要删掉\n if (nextSessionContent?.role === SessionContentRole.Ai\n || (relatedDelete && [\n SessionContentRole.Ai,\n SessionContentRole.Guide,\n SessionContentRole.TokenExpired,\n SessionContentRole.ImageNotSupported,\n SessionContentRole.Pause,\n ].includes(nextSessionContent?.role))\n ) {\n const nextIndex = currentSessionContents\n .findIndex(sessionContent => sessionContent.id === nextSessionContent.id);\n currentSessionContents.splice(nextIndex, 1);\n deleteSessionContentIds.push(nextSessionContent.id as number);\n }\n // 如果下下个是 guide,需要删除\n if ([SessionContentRole.Guide].includes(nextNextSessionContent?.role) && relatedDelete) {\n const nextNextIndex = currentSessionContents\n .findIndex(sessionContent => sessionContent.id === nextNextSessionContent.id);\n currentSessionContents.splice(nextNextIndex, 1);\n deleteSessionContentIds.push(nextNextSessionContent.id as number);\n }\n }\n });\n\n return deleteSessionContentIds;\n }\n\n // 删除聊天内容\n function deleteSessionContent(sessionCode: string, contentId: number) {\n const deleteSessionContentIds = getDeleteSessionContents(sessionCode, [contentId], true);\n return deleteSessionContentIds;\n }\n\n // 批量删除\n function deleteSessionContents(sessionCode: string, contentIds: number[]) {\n const deleteSessionContentIds = getDeleteSessionContents(sessionCode, contentIds, false);\n return deleteSessionContentIds;\n }\n\n // 聊天开始\n function handleStartChat(sessionCode: string) {\n sessionLoadingMap.value[sessionCode] = true;\n const sessionContent: ISessionContent = {\n sessionCode,\n role: SessionContentRole.Ai,\n status: SessionContentStatus.Loading,\n content: startMessage,\n };\n // 画布新增\n plusSessionContent(sessionCode, sessionContent);\n // 调用cb\n return handleStart?.(sessionCode, sessionContent);\n }\n\n // 引用资料\n function handleReferenceDocChat(sessionCode: string, documents: Document[], cover?: boolean) {\n const sessionContent = getLastSessionContentBySessionCode(sessionCode);\n const content = getHtmlContentFromDocuments(documents);\n sessionContent.content = cover ? content : sessionContent.content + content;\n return handleReferenceDoc?.(sessionCode, sessionContent);\n }\n\n // 思考\n function handleThinkChat(sessionCode: string, content: string, cover?: boolean, elapsedTime?: number) {\n const sessionContent = getLastSessionContentBySessionCode(sessionCode);\n // 获取思考的html\n sessionContent.content = getHtmlContentFromThink(sessionContent.content, content, cover, elapsedTime);\n // 调用cb\n return handleThink?.(sessionCode, sessionContent);\n }\n\n // 文本\n function handleTextChat(sessionCode: string, message: string, cover?: boolean) {\n const sessionContent = getLastSessionContentBySessionCode(sessionCode);\n if (sessionContent.content === startMessage) {\n sessionContent.content = message;\n } else if (sessionContent.status === SessionContentStatus.Loading) {\n sessionContent.content = cover\n ? message\n : sessionContent.content + message;\n } else {\n return;\n }\n // 调用cb\n return handleText?.(sessionCode, sessionContent);\n }\n\n // 聊天结束\n function handleEndChat(sessionCode: string, message?: string) {\n const sessionContent = getLastSessionContentBySessionCode(sessionCode);\n // 防止 error 的情况下异步触发 end 更新了数据\n if (sessionContent.status === SessionContentStatus.Loading) {\n sessionLoadingMap.value[sessionCode] = false;\n // end 的时候,如果 message 有值,则更新 content\n if (message) {\n sessionContent.content = message;\n }\n // 更新状态\n sessionContent.status = SessionContentStatus.Success;\n // 调用cb\n return handleEnd?.(sessionCode, sessionContent);\n }\n // 内容正在生成中或者正在思考中\n if (sessionContent.content === startMessage || isThinking(sessionContent.content)) {\n handleErrorChat(sessionCode, '聊天内容已中断');\n }\n }\n\n // 聊天异常\n function handleErrorChat(sessionCode: string, message: string, code?: string) {\n const sessionContent = getLastSessionContentBySessionCode(sessionCode);\n sessionContent.status = SessionContentStatus.Fail;\n sessionContent.content = message;\n sessionLoadingMap.value[sessionCode] = false;\n // token 超了,提示 token 不足\n if (code === HttpErrorCode.TokenExpired) {\n sessionContent.content = '抱歉,您的剩余 Token 不足,无法返回回答内容,请先清空当前会话(上下文仍会作为历史记录保留))';\n sessionContent.role = SessionContentRole.TokenExpired;\n }\n if (code === HttpErrorCode.ImageNotSupported) {\n sessionContent.content = '抱歉,当前模型不支持图片内容解析';\n sessionContent.role = SessionContentRole.ImageNotSupported;\n }\n // 调用cb\n return handleError?.(sessionCode, sessionContent, code);\n }\n\n // 重新生成对话 仅支持重新生成 ai 的回复\n function reGenerateChat(chatIndex: number) {\n const chat = sessionContents.value[chatIndex];\n if (chat.role !== SessionContentRole.Ai) {\n return;\n }\n\n const message = sessionContents.value[chatIndex - 1].content;\n const cite = sessionContents.value[chatIndex - 1].cite;\n sessionContents.value.splice(chatIndex - 1, 2);\n sendChat({message, cite});\n }\n\n // 聊天\n function chat({\n sessionCode,\n data,\n url,\n headers,\n }: {\n sessionCode: string;\n data?: Record<string, any>;\n url: string;\n headers?: Record<string, string>;\n }) {\n // 发送请求\n chatHelper.stream({\n sessionCode,\n url: url,\n data,\n headers: headers || requestOptions?.headers,\n });\n }\n\n // 重新发送聊天, 需要将当前聊天内容以及下方的所有内容删除\n function reSendChat(index: number, {message, cite}: {message: string, cite?: string}, callback?: () => void) {\n const chat = sessionContents.value[index];\n if (chat.role !== SessionContentRole.User) {\n return;\n }\n\n sessionContents.value.splice(index, sessionContents.value.length - index);\n sendChat({message, cite}, callback);\n }\n\n // 发送聊天\n function sendChat(content: BasicChatContent | ShortcutChatContent, callback?: () => void) {\n if (!currentSession.value?.sessionCode || !requestOptions?.url || currentSessionLoading.value) {\n return;\n }\n\n const {message, cite, shortcut} = content;\n\n let input = '';\n\n if (shortcut) {\n input = processPromptTemplate(shortcut.prompt, cite);\n } else {\n input = cite ? `${message}: \"${cite}\"` : message;\n }\n\n\n sessionContents.value.push({\n sessionCode: currentSession.value?.sessionCode,\n content: message,\n role: SessionContentRole.User,\n status: SessionContentStatus.Success,\n cite,\n });\n\n // 发送请求\n chatHelper.stream({\n sessionCode: currentSession.value?.sessionCode,\n url: requestOptions.url,\n headers: requestOptions?.headers,\n data: {\n inputs: {\n chat_history: prompts.value.slice(0, prompts.value.length - 1),\n input,\n },\n }\n });\n\n callback?.();\n }\n\n /**\n * 删除聊天内容\n * @param index 要删除的聊天内容索引\n * @description \n * - 如果删除的是用户消息,则同时删除该消息及其对应的AI回复(共2条)\n * - 如果删除的是其他类型消息(如AI回复),则只删除该条消息\n */\n function deleteChat(index: number) {\n const chat = sessionContents.value[index];\n if (chat.role === SessionContentRole.User) {\n sessionContents.value.splice(index, 2);\n return;\n }\n\n sessionContents.value.splice(index-1, 2);\n }\n\n // 停止聊天\n function stopChat(sessionCode: string) {\n chatHelper.stop(sessionCode);\n }\n\n return {\n currentSession,\n sessionContents,\n sessionContentsMap,\n sessionLoadingMap,\n prompts,\n currentSessionLoading,\n chat,\n sendChat,\n stopChat,\n plusSessionContent,\n updateSessionContent,\n getSessionContentById,\n getLastSessionContentBySessionCode,\n getSessionContentsBySessionCode,\n setCurrentSession,\n setSessionContents,\n deleteSessionContent,\n deleteSessionContents,\n handleStartChat,\n handleErrorChat,\n reGenerateChat,\n reSendChat,\n deleteChat,\n };\n};","import {\n onBeforeMount,\n onBeforeUnmount,\n} from 'vue';\n\nimport {\n handleCopy,\n handleDownLoad,\n} from '../common/util';\n\ntype FullScreenWrap = HTMLElement & {\n _originalParent: Node;\n _originalNextSibling: Node;\n};\n\n// 全局点击代理事件\nexport const useClickProxy = () => {\n const clickProxy = (e: MouseEvent) => {\n const target = e.target as HTMLElement;\n // 聊天窗里面的引用资料和思考内容\n if (target?.classList.contains('bkaidev-angle-up')) {\n const parent = target?.parentElement;\n if (parent?.classList.contains('closed')) {\n parent?.classList.remove('closed');\n } else {\n parent?.classList.add('closed');\n }\n }\n if (target?.classList.contains('click-close')) {\n if (target?.classList.contains('closed')) {\n target?.classList.remove('closed');\n } else {\n target?.classList.add('closed');\n }\n }\n // 会话里面代码块的全屏\n if (target?.classList.contains('click-full-screen')) {\n // 获取全屏的父元素\n const fullScreenWrap = target?.parentElement?.parentElement?.parentElement as FullScreenWrap;\n // 添加 class\n fullScreenWrap?.classList.add('full-screen');\n // 元素移动到body\n if (!fullScreenWrap._originalParent) {\n fullScreenWrap._originalParent = fullScreenWrap.parentNode as Node;\n fullScreenWrap._originalNextSibling = fullScreenWrap.nextSibling as Node;\n }\n document.body.appendChild(fullScreenWrap);\n }\n // 会话里面代码块的取消全屏\n if (target?.classList.contains('click-un-full-screen')) {\n // 获取全屏的父元素\n const fullScreenWrap = target?.parentElement?.parentElement?.parentElement as FullScreenWrap;\n // 移除 class\n fullScreenWrap?.classList.remove('full-screen');\n // 移回原位\n if (fullScreenWrap._originalNextSibling) {\n fullScreenWrap._originalParent.insertBefore(fullScreenWrap, fullScreenWrap._originalNextSibling);\n } else {\n fullScreenWrap._originalParent.appendChild(fullScreenWrap);\n }\n }\n // 复制\n if (target?.classList.contains('click-copy')) {\n const text = target?.getAttribute('data-clipboard-text');\n if (text) {\n handleCopy(decodeURIComponent(text));\n }\n }\n // 下载\n if (target?.classList.contains('click-download')) {\n const text = target?.getAttribute('data-clipboard-text');\n const fileName = target?.getAttribute('data-file-name');\n if (text && fileName) {\n handleDownLoad(decodeURIComponent(text), fileName);\n }\n }\n };\n\n const addClickProxy = () => {\n window.addEventListener('click', clickProxy);\n };\n\n const removeClickProxy = () => {\n window.removeEventListener('click', clickProxy);\n };\n\n onBeforeMount(() => {\n addClickProxy();\n });\n\n onBeforeUnmount(() => {\n removeClickProxy();\n });\n};\n","import {\n useReferenceDoc,\n} from \"./use-reference-doc\";\nimport {\n useThink,\n} from \"./use-think\";\n\n// ai 样式。注意:全局引入一次即可\nexport const useStyle = () => {\n // 引入样式\n require('../css/style.css');\n require('../css/iconcool.js');\n // 引用资料\n useReferenceDoc();\n // 思考\n useThink();\n};\n","import type {\n SummaryCallbacks,\n} from '../types/type.ts';\nimport {\n SessionPromptRole,\n} from '../types/enum';\nimport {\n removeReferenceDoc,\n} from '../hooks/use-reference-doc';\nimport {\n removeThink,\n} from '../hooks/use-think';\nimport {\n ChatHelper,\n} from '../common/chart-helper';\n\n// ai 总结\nexport const useSummary = ({\n handleStart,\n handleEnd,\n handleError,\n}: SummaryCallbacks = {}) => {\n let summaryText = '';\n\n const handleStartChat = () => {\n summaryText = '';\n return handleStart?.();\n };\n\n const handleTextChat = (sessionCode: string, message: string, cover?: boolean) => {\n if (cover || summaryText === '正在思考...') {\n summaryText = message;\n } else {\n summaryText += message;\n }\n };\n\n const handleEndChat = () => {\n if (summaryText === '无话可说') {\n summaryText = '';\n }\n return handleEnd?.(summaryText);\n };\n\n const handleErrorChat = (sessionCode: string, message: string, code?: string) => {\n return handleError?.(message, code);\n };\n\n const chatHelper = new ChatHelper({\n handleStart: handleStartChat,\n handleText: handleTextChat,\n handleEnd: handleEndChat,\n handleError: handleErrorChat,\n });\n\n const summary = ({\n content,\n url,\n headers,\n model,\n }: {\n content: string;\n url: string;\n headers?: Record<string, string>;\n model?: string;\n }) => {\n const filterContent = removeThink(removeReferenceDoc(content));\n const prompts = [\n {\n role: SessionPromptRole.User,\n content: `你是一个总结大师,请帮助我对下面这段话进行总结。要求总结精炼,不超过 15 个字!且末尾没有标点符号!请注意:如果你无法总结,请回复“无话可说”!\\n文字如下:\\n${filterContent}`,\n },\n ];\n \n chatHelper.stream({\n sessionCode: 'summary',\n url,\n data: {\n prompts,\n model,\n },\n headers,\n });\n };\n\n return {\n summary,\n };\n}"],"names":["SessionPromptRole","SessionContentStatus","SessionContentRole","HttpErrorCode","transferSessionContent2SessionPrompt","sessionContent","sessionRoleMap","Ai","Assistant","User","System","Hidden","Guide","Time","Role","HiddenAi","HiddenAssistant","HiddenGuide","HiddenRole","HiddenSystem","HiddenUser","TemplateAi","TemplateAssistant","TemplateGuide","TemplateRole","TemplateSystem","TemplateUser","TemplateHidden","Pause","TokenExpired","ImageNotSupported","UserImage","content","role","isJSON","str","JSON","parse","e","removeReferenceDoc","replace","useReferenceDoc","styleEle","onBeforeMount","document","createElement","textContent","oldStyle","head","appendChild","onBeforeUnmount","remove","getHtmlContentFromThink","chatContent","cover","elapsedTime","htmlContent","includes","thinkBodyMatch","match","thinkContent","newThinkContent","val","hours","Math","floor","minutes","seconds","milliseconds","parts","push","toFixed","join","durationFormatter","removeThink","afterRemoveThinkBody","trim","useThink","ChatHelper","constructor","handleStart","handleText","handleReferenceDoc","handleThink","handleEnd","handleError","__publicField","this","controllerMap","stream","_0","__async","arguments","sessionCode","url","headers","data","_a","call","controller","AbortController","fetch","method","signal","__spreadValues","mode","credentials","body","stringify","then","response","reader","pipeThrough","window","TextDecoderStream","getReader","temp","value","done","read","ok","statusText","status","toString","split","forEach","item","event","documents","result","code","elapsed_time","message","_b","error","stop","abort","requestOptions","startMessage","currentSession","ref","sessionLoadingMap","sessionContents","sessionContentsMap","calculatedSessionContents","computed","index","length","nextAiSessionContentIndex","nextAiSessionContent","Fail","unshift","currentSessionLoading","prompts","rolePrompts","userPrompts","latestMatchIndex","findLastIndex","some","key","_c","roleInfo","roleContent","nextSessionContent","map","isSameContent","startIndex","isSame","rolePrompt","prompts2","prompt","chatHelper","handleStartChat","getLastSessionContentBySessionCode","Loading","path","file_path","filePath","display_name","displayName","preview_path","previewPath","metadata","title","pop","getHtmlContentFromDocuments","Success","isStartThinking","isEmptyThinking","isThinking","handleErrorChat","at","getSessionContentsBySessionCode","plusSessionContent","getDeleteSessionContents","sessionContentIds","relatedDelete","currentSessionContents","deleteSessionContentIds","sessionContentId","findIndex","id","preSessionContent","nextNextSessionContent","splice","hiddenIndex","nextIndex","nextNextIndex","sendChat","callback","cite","shortcut","input","selectedText","inputs","chat_history","slice","chat","stopChat","updateSessionContent","currentSessionContent","find","Object","assign","getSessionContentById","setCurrentSession","session","setSessionContents","deleteSessionContent","contentId","deleteSessionContents","contentIds","reGenerateChat","chatIndex","reSendChat","deleteChat","clickProxy","target","classList","contains","parent","parentElement","add","fullScreenWrap","_originalParent","parentNode","_originalNextSibling","nextSibling","_d","insertBefore","text","getAttribute","textarea","select","execCommand","Message","theme","removeChild","handleCopy","decodeURIComponent","fileName","source","filename","downloadEl","blob","Blob","download","href","URL","createObjectURL","style","display","click","handleDownLoad","addEventListener","removeEventListener","require","summaryText","summary","model","filterContent"],"mappings":"o4BACYA,GAAAA,IACVA,EAAS,OAAA,SACTA,EAAY,UAAA,YACZA,EAAO,KAAA,OACPA,EAAQ,MAAA,QACRA,EAAQ,MAAA,QACRA,EAAY,UAAA,aACZA,EAAS,OAAA,SACTA,EAAa,WAAA,cACbA,EAAkB,gBAAA,mBAClBA,EAAe,aAAA,gBACfA,EAAc,YAAA,eACdA,EAAe,aAAA,gBACfA,EAAoB,kBAAA,qBACpBA,EAAiB,eAAA,kBACjBA,EAAgB,cAAA,iBAChBA,EAAiB,eAAA,kBAhBPA,IAAAA,GAAA,CAAA,GAmBAC,GAAAA,IACVA,EAAO,KAAA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