@blueking/ai-ui-sdk 0.0.1-beta.2 → 0.0.1-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/common/chart-helper.d.ts +2 -2
- package/dist/common/type-transform.d.ts +7 -0
- package/dist/main.d.ts +13 -8
- package/dist/main.js +7 -13
- package/dist/types/enum.d.ts +35 -0
- package/dist/types/type.d.ts +175 -1
- package/package.json +1 -1
@@ -21,11 +21,11 @@ export declare class ChatHelper {
|
|
21
21
|
handleEnd: HandleEnd;
|
22
22
|
handleError: HandleError;
|
23
23
|
});
|
24
|
-
stream({ sessionCode, url, headers,
|
24
|
+
stream({ sessionCode, url, headers, data, }: {
|
25
25
|
sessionCode: string;
|
26
26
|
url: string;
|
27
27
|
headers?: Record<string, string>;
|
28
|
-
|
28
|
+
data?: Record<string, any>;
|
29
29
|
}): Promise<void>;
|
30
30
|
stop(sessionCode: string): void;
|
31
31
|
}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import type { ISessionContent, ISessionPrompt } from '../types/type';
|
2
|
+
/**
|
3
|
+
* 将 sessionContent 转换为 sessionPrompt
|
4
|
+
* @param sessionContent sessionContent
|
5
|
+
* @returns sessionPrompt
|
6
|
+
*/
|
7
|
+
export declare const transferSessionContent2SessionPrompt: (sessionContent: ISessionContent) => ISessionPrompt;
|
package/dist/main.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { ISessionContent } from './types/type.ts';
|
1
|
+
import type { ISessionContent, ISession, ISessionPrompt } from './types/type.ts';
|
2
2
|
import { SessionContentRole, SessionContentStatus } from './types/enum';
|
3
3
|
type SessionContentsMap = {
|
4
4
|
[key: string]: ISessionContent[];
|
@@ -6,17 +6,19 @@ type SessionContentsMap = {
|
|
6
6
|
type SessionLoadingMap = {
|
7
7
|
[key: string]: boolean;
|
8
8
|
};
|
9
|
-
export type
|
10
|
-
export
|
9
|
+
export type * from './types/type';
|
10
|
+
export * from './types/enum';
|
11
|
+
export * from './common/type-transform';
|
11
12
|
export interface AICallbacks {
|
12
13
|
handleStart?: (sessionCode: string, sessionContent: ISessionContent) => void;
|
13
14
|
handleText?: (sessionCode: string, sessionContent: ISessionContent) => void;
|
14
15
|
handleReferenceDoc?: (sessionCode: string, sessionContent: ISessionContent) => void;
|
15
16
|
handleThink?: (sessionCode: string, sessionContent: ISessionContent) => void;
|
16
17
|
handleEnd?: (sessionCode: string, sessionContent: ISessionContent) => void;
|
17
|
-
handleError?: (sessionCode: string, code: string | undefined
|
18
|
+
handleError?: (sessionCode: string, sessionContent: ISessionContent, code: string | undefined) => void;
|
18
19
|
}
|
19
|
-
export declare const useAI: ({ handleStart, handleText, handleReferenceDoc, handleThink, handleEnd, handleError, }
|
20
|
+
export declare const useAI: ({ handleStart, handleText, handleReferenceDoc, handleThink, handleEnd, handleError, }?: AICallbacks) => {
|
21
|
+
currentSession: import("vue").Ref<ISession | undefined, ISession | undefined>;
|
20
22
|
sessionContents: import("vue").Ref<{
|
21
23
|
id?: number | undefined;
|
22
24
|
createdAt?: string | undefined;
|
@@ -46,14 +48,17 @@ export declare const useAI: ({ handleStart, handleText, handleReferenceDoc, hand
|
|
46
48
|
}[]>;
|
47
49
|
sessionContentsMap: SessionContentsMap;
|
48
50
|
sessionLoadingMap: import("vue").Ref<SessionLoadingMap, SessionLoadingMap>;
|
49
|
-
|
51
|
+
prompts: import("vue").ComputedRef<ISessionPrompt[]>;
|
52
|
+
chat: ({ sessionCode, data, url, headers, }: {
|
50
53
|
sessionCode: string;
|
51
|
-
|
54
|
+
data?: Record<string, any>;
|
52
55
|
url: string;
|
53
56
|
headers?: Record<string, string>;
|
54
57
|
}) => void;
|
58
|
+
stopChat: (sessionCode: string) => void;
|
55
59
|
getSessionContentBySessionCode: (sessionCode: string) => ISessionContent;
|
56
60
|
getSessionContentsBySessionCode: (sessionCode: string) => ISessionContent[];
|
57
|
-
|
61
|
+
setCurrentSession: (session: ISession) => void;
|
58
62
|
setSessionContents: (data: ISessionContent[]) => void;
|
59
63
|
};
|
64
|
+
export declare const useStyle: () => void;
|
package/dist/main.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("vue")):"function"==typeof define&&define.amd?define(["vue"],t):"object"==typeof exports?exports["ai-ui-sdk"]=t(require("vue")):e["ai-ui-sdk"]=t(e.vue)}("undefined"!=typeof self?self:this,e=>(()=>{"use strict";var t,n,o,i,r={380:t=>{t.exports=e}},
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("vue")):"function"==typeof define&&define.amd?define(["vue"],t):"object"==typeof exports?exports["ai-ui-sdk"]=t(require("vue")):e["ai-ui-sdk"]=t(e.vue)}("undefined"!=typeof self?self:this,e=>(()=>{"use strict";var t,n,o,i,r,l,a,d,s,u,c={380:t=>{t.exports=e}},p={};function h(e){var t=p[e];if(void 0!==t)return t.exports;var n=p[e]={exports:{}};return c[e](n,n.exports,h),n.exports}h.d=(e,t)=>{for(var n in t)h.o(t,n)&&!h.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},h.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),h.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},h.p="/";var m={};h.r(m),h.d(m,{ApiValueType:()=>a,EnumCharacter:()=>d,FileLinkType:()=>r,FileStatus:()=>l,HttpErrorCode:()=>i,KnowledgePathType:()=>s,KnowledgeType:()=>u,SessionContentRole:()=>o,SessionContentStatus:()=>n,SessionPromptRole:()=>t,default:()=>P,transferSessionContent2SessionPrompt:()=>F,useAI:()=>U,useStyle:()=>H});var f={};h.r(f),h.d(f,{Cy:()=>a,hb:()=>d,rs:()=>r,BM:()=>l,eo:()=>i,sh:()=>s,zW:()=>u,In:()=>o,c_:()=>n,bJ:()=>t,DA:()=>F,OD:()=>U,X3:()=>H});var g=h(380);!function(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"}(t||(t={})),function(e){e.Fail="fail",e.Loading="loading",e.Success="success"}(n||(n={})),function(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"}(o||(o={})),function(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"}(i||(i={})),function(e){e.External="external",e.BkRepo="bk_repo"}(r||(r={})),function(e){e.Init="init",e.Uploading="uploading",e.Uploaded="uploaded",e.Deleting="deleting",e.Deleted="deleted",e.Failed="failed"}(l||(l={})),function(e){e.String="string",e.Number="number",e.Boolean="boolean",e.Array="array",e.Object="object"}(a||(a={})),function(e){e.All="all",e.System="system",e.User="user",e.Public="public",e.Space="space"}(d||(d={})),function(e){e.File="file",e.Folder="folder"}(s||(s={})),function(e){e.File="file",e.Manual="manual",e.Link="link"}(u||(u={}));let v=e=>{let t=`<section class="knowledge-head click-close">
|
2
2
|
<svg
|
3
3
|
class="bkaidev-wenzhang"
|
4
4
|
>
|
@@ -9,14 +9,13 @@
|
|
9
9
|
</section>
|
10
10
|
<ul class="knowledge-body">`;return e.forEach(e=>{let{file_path:n,preview_path:o}=e.metadata,i=n.split("/").pop();t+=`<li
|
11
11
|
class="knowledge-item"
|
12
|
-
title="${i} (${o})"
|
12
|
+
title="${i} (${o||n})"
|
13
13
|
>
|
14
14
|
<i class="bkaidev-icon bkaidev-zhishiku"></i>
|
15
|
-
<a href="${o}" target="_blank" class="knowledge-link g-flex-truncate">
|
15
|
+
<a href="${o||n}" target="_blank" class="knowledge-link g-flex-truncate">
|
16
16
|
${i}
|
17
17
|
</a>
|
18
|
-
|
19
|
-
</li>`}),t+="</ul>"},p=()=>{let e=null,t=()=>{let t=`.knowledge-tips {
|
18
|
+
</li>`}),t+="</ul>"},b=()=>{let e=null,t=()=>{let t=`.knowledge-tips {
|
20
19
|
position: relative;
|
21
20
|
padding: 6px 8px;
|
22
21
|
margin-bottom: 14px;
|
@@ -129,22 +128,17 @@
|
|
129
128
|
font-size: 14px;
|
130
129
|
margin-right: 6px;
|
131
130
|
}
|
132
|
-
.knowledge-path {
|
133
|
-
margin-left: auto;
|
134
|
-
color: #979BA5;
|
135
|
-
text-align: right;
|
136
|
-
}
|
137
131
|
&:hover {
|
138
132
|
background: #EAEBF0;
|
139
133
|
}
|
140
134
|
}
|
141
|
-
}`;(e=document.createElement("style")).textContent=t+n,document.head.appendChild(e)},n=()=>{e&&(e.remove(),e=null)};(0,
|
135
|
+
}`;(e=document.createElement("style")).textContent=t+n,document.head.appendChild(e)},n=()=>{e&&(e.remove(),e=null)};(0,g.onBeforeMount)(()=>{t()}),(0,g.onBeforeUnmount)(()=>{n()})},k=e=>{try{return JSON.parse(e),!0}catch(e){return!1}},y=(e,t,n,o)=>{let i="内容正在生成中..."===e||n?"":e;if(i.includes('<section class="think-head click-close">')){let e=i.match(/<section class="think-body">([\s\S]*?)<\/section>/);if(e){let n=e[1],o=n.replace(/\n$/g,`${t}
|
142
136
|
`);i=i.replace(n,o)}}else i+=`<section class="think-head click-close">
|
143
137
|
<i class="bkaidev-icon bkaidev-sikao"></i>思考中...<i class="bkaidev-icon bkaidev-angle-up"></i>
|
144
138
|
</section>
|
145
139
|
<section class="think-body">
|
146
140
|
${t}
|
147
|
-
</section>`;return o&&(i=i.replace("思考中...",`已完成思考 (耗时:${function(e){let t=Math.floor(e/36e5),n=Math.floor(e%36e5/6e4),o=Math.floor(e%6e4/1e3),i=e%1e3,r=[];return t>0&&r.push(`${t}h`),n>0&&r.push(`${n}min`),o>0&&r.push(`${o}s`),i>0&&r.push(`${i.toFixed(2)}ms`),r.join(" ")}(o)})`)),i},
|
141
|
+
</section>`;return o&&(i=i.replace("思考中...",`已完成思考 (耗时:${function(e){let t=Math.floor(e/36e5),n=Math.floor(e%36e5/6e4),o=Math.floor(e%6e4/1e3),i=e%1e3,r=[];return t>0&&r.push(`${t}h`),n>0&&r.push(`${n}min`),o>0&&r.push(`${o}s`),i>0&&r.push(`${i.toFixed(2)}ms`),r.join(" ")}(o)})`)),i},x=e=>{let t="正在思考..."===e,n=e.match(/<section class="think-body">([\s\S]*?)<\/section>$/),o=n&&""===n[1].trim();return t||o},S=()=>{let e=null,t=()=>{let t=`.think-head {
|
148
142
|
display: flex;
|
149
143
|
align-items: center;
|
150
144
|
padding: 0 8px 0 6px;
|
@@ -192,4 +186,4 @@
|
|
192
186
|
&~ .knowledge-head {
|
193
187
|
margin-bottom: 8px;
|
194
188
|
}
|
195
|
-
}`;(e=document.createElement("style")).textContent=t,document.head.appendChild(e)},n=()=>{e&&(e.remove(),e=null)};(0,
|
189
|
+
}`;(e=document.createElement("style")).textContent=t,document.head.appendChild(e)},n=()=>{e&&(e.remove(),e=null)};(0,g.onBeforeMount)(()=>{t()}),(0,g.onBeforeUnmount)(()=>{n()})};function T(e,t,n,o,i,r,l){try{var a=e[r](l),d=a.value}catch(e){n(e);return}a.done?t(d):Promise.resolve(d).then(o,i)}function w(e){return function(){var t=this,n=arguments;return new Promise(function(o,i){var r=e.apply(t,n);function l(e){T(r,o,i,l,a,"next",e)}function a(e){T(r,o,i,l,a,"throw",e)}l(void 0)})}}function E(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class A{stream({sessionCode:e,url:t,headers:n,data:o}){var i=this;return w(function*(){var r,l;yield null===(r=i.handleStart)||void 0===r?void 0:r.call(i,e);let a=new AbortController;i.controllerMap[e]=a,fetch(t,{method:"post",signal:a.signal,headers:function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){E(e,t,n[t])})}return e}({"Content-Type":"application/json"},n),mode:"cors",credentials:"include",body:JSON.stringify(o)}).then((l=w(function*(t){let n=t.body.pipeThrough(new window.TextDecoderStream).getReader(),o="";for(;;)try{let{value:r,done:l}=yield n.read();if(!t.ok){i.handleError(e,r||t.statusText,t.status);break}if(l){i.handleEnd(e);break}(o+r.toString()).split("\n").forEach(n=>{let r=n.replace("data:","").trim();if(k(r)){var l,a;let{event:n,content:d,cover:s,documents:u,result:c,code:p,elapsed_time:h,message:m}=JSON.parse(r);if(!1===c||200!==t.status){i.handleError(e,m||"模型调用失败",p);return}switch(n){case"text":i.handleText(e,d,s);break;case"reference_doc":null===(l=i.handleReferenceDoc)||void 0===l||l.call(i,e,u,s);break;case"think":null===(a=i.handleThink)||void 0===a||a.call(i,e,d,s,h);break;case"done":i.handleEnd(e,s?d:"");break;case"error":i.handleError(e,m||"模型调用失败",p)}o=""}else r&&(o=r)})}catch(t){(null==t?void 0:t.code)!==20&&i.handleError(e,`模型调用失败:${t.message}`,t.code);break}}),function(e){return l.apply(this,arguments)}))})()}stop(e){var t,n;return null===(n=this.controllerMap[e])||void 0===n||null===(t=n.abort)||void 0===t||t.call(n),this.handleEnd(e)}constructor({handleStart:e,handleText:t,handleReferenceDoc:n,handleThink:o,handleEnd:i,handleError:r}){E(this,"handleStart",void 0),E(this,"handleText",void 0),E(this,"handleReferenceDoc",void 0),E(this,"handleThink",void 0),E(this,"handleEnd",void 0),E(this,"handleError",void 0),E(this,"controllerMap",void 0),this.handleStart=e,this.handleText=t,this.handleReferenceDoc=n,this.handleThink=o,this.handleEnd=i,this.handleError=r,this.controllerMap={}}}let F=e=>{let n={[o.Ai]:t.Assistant,[o.User]:t.User,[o.System]:t.System,[o.Hidden]:t.Hidden,[o.Guide]:t.Guide,[o.Time]:t.System,[o.Role]:t.System,[o.HiddenAi]:t.HiddenAssistant,[o.HiddenGuide]:t.HiddenGuide,[o.HiddenRole]:t.HiddenSystem,[o.HiddenUser]:t.HiddenUser,[o.TemplateAi]:t.TemplateAssistant,[o.TemplateGuide]:t.TemplateGuide,[o.TemplateRole]:t.TemplateSystem,[o.TemplateUser]:t.TemplateUser,[o.TemplateHidden]:t.TemplateHidden,[o.Pause]:t.Pause,[o.TokenExpired]:t.Pause,[o.ImageNotSupported]:t.Pause,[o.UserImage]:t.UserImage};return{content:e.content,role:n[e.role]}},U=({handleStart:e,handleText:t,handleReferenceDoc:r,handleThink:l,handleEnd:a,handleError:d}={})=>{let s="内容正在生成中...",u=(0,g.ref)(),c=(0,g.ref)({}),p=(0,g.ref)([]),h={},m=(0,g.computed)(()=>{let e=[];for(let t=p.value.length-1;t>=0;t--){let i=p.value[t],r=t+1,l=p.value[r];for(;l&&![o.Ai,o.TokenExpired,o.ImageNotSupported,o.Pause,o.Guide].includes(l.role);)r+=1,l=p.value[r];if(i.role===o.System)break;i.status===n.Fail||(null==l?void 0:l.status)===n.Fail&&[o.User,o.UserImage].includes(i.role)||[o.Time,o.System].includes(i.role)||e.unshift(i)}return e}),f=(0,g.computed)(()=>{var e,t,n;let i=[],r=[],l=[],a=p.value.findLastIndex(e=>e.role===o.System&&["已启用角色","已启用模型"].some(t=>e.content.includes(t))),d=0;null===(n=u.value)||void 0===n||null===(t=n.roleInfo)||void 0===t||null===(e=t.content)||void 0===e||e.forEach(e=>{let t=p.value[a+1+d],n=p.value[a+2+d];if((null==t?void 0:t.content)===e.content&&t.role!==o.System&&(i.push(F(t)),d+=1,(null==t?void 0:t.role)===o.Pause)){for(;n&&n.role===o.System;)d+=1,n=p.value[a+1+d];for(;n&&[o.User,o.UserImage].includes(n.role);)i.push(F(n)),d+=1,n=p.value[a+1+d]}}),r.push(...m.value.map(F));let s=e=>{let t=!0;for(let o=e;o<i.length;o++){var n;i[o].content!==(null===(n=r[o-e])||void 0===n?void 0:n.content)&&(t=!1)}return t};for(let e=0;e<i.length;e++){let t=i[e];if(s(e))break;l.push(t)}return l.push(...r),l}),b=new A({handleStart:function(t){c.value[t]=!0;let i={sessionCode:t,role:o.Ai,status:n.Loading,content:s};return!function(e,t){S(e).push(t)}(t,i),null==e?void 0:e(t,i)},handleText:function(e,o,i){let r=k(e);if(r.content===s)r.content=o;else{if(r.status!==n.Loading)return;r.content=i?o:r.content+o}return null==t?void 0:t(e,r)},handleReferenceDoc:function(e,t,n){let o=k(e),i=v(t);return o.content=n?i:o.content+i,null==r?void 0:r(e,o)},handleThink:function(e,t,n,o){let i=k(e);return i.content=y(i.content,t,n,o),null==l?void 0:l(e,i)},handleEnd:function(e,t){let o=k(e);if(o.status===n.Loading)return c.value[e]=!1,t&&(o.content=t),o.status=n.Success,null==a?void 0:a(e,o);(o.content===s||x(o.content))&&T(e,"聊天内容已中断")},handleError:T});function k(e){var t,n;return(null===(t=u.value)||void 0===t?void 0:t.sessionCode)===e?p.value.at(-1):null===(n=h[e])||void 0===n?void 0:n.at(-1)}function S(e){var t;return(null===(t=u.value)||void 0===t?void 0:t.sessionCode)===e?p.value:h[e]}function T(e,t,r){let l=k(e);return l.status=n.Fail,l.content=t,c.value[e]=!1,r===i.TokenExpired&&(l.content="抱歉,您的剩余 Token 不足,无法返回回答内容,请先清空当前会话(上下文仍会作为历史记录保留))",l.role=o.TokenExpired),r===i.ImageNotSupported&&(l.content="抱歉,当前模型不支持图片内容解析",l.role=o.ImageNotSupported),null==d?void 0:d(e,l,r)}return{currentSession:u,sessionContents:p,sessionContentsMap:h,sessionLoadingMap:c,prompts:f,chat:function({sessionCode:e,data:t,url:n,headers:o}){b.stream({sessionCode:e,url:n,data:t,headers:o})},stopChat:function(e){b.stop(e)},getSessionContentBySessionCode:k,getSessionContentsBySessionCode:S,setCurrentSession:function(e){u.value=e,h[e.sessionCode]||(h[e.sessionCode]=[]),p.value=h[e.sessionCode]},setSessionContents:function(e){u.value&&(h[u.value.sessionCode]=e,p.value=e)}}},H=()=>{b(),S()},P=f.default;if("undefined"!=typeof window){let{currentScript:e}=window.document,t=e&&e.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);t&&(h.p=t[1])}return m})());
|
package/dist/types/enum.d.ts
CHANGED
@@ -52,3 +52,38 @@ export declare enum HttpErrorCode {
|
|
52
52
|
UnLogin = 401,
|
53
53
|
IamNoPermission = "IAM_NO_PERMISSION"
|
54
54
|
}
|
55
|
+
export declare enum FileLinkType {
|
56
|
+
External = "external",
|
57
|
+
BkRepo = "bk_repo"
|
58
|
+
}
|
59
|
+
export declare enum FileStatus {
|
60
|
+
Init = "init",
|
61
|
+
Uploading = "uploading",
|
62
|
+
Uploaded = "uploaded",
|
63
|
+
Deleting = "deleting",
|
64
|
+
Deleted = "deleted",
|
65
|
+
Failed = "failed"
|
66
|
+
}
|
67
|
+
export declare enum ApiValueType {
|
68
|
+
String = "string",
|
69
|
+
Number = "number",
|
70
|
+
Boolean = "boolean",
|
71
|
+
Array = "array",
|
72
|
+
Object = "object"
|
73
|
+
}
|
74
|
+
export declare enum EnumCharacter {
|
75
|
+
All = "all",
|
76
|
+
System = "system",
|
77
|
+
User = "user",
|
78
|
+
Public = "public",
|
79
|
+
Space = "space"
|
80
|
+
}
|
81
|
+
export declare enum KnowledgePathType {
|
82
|
+
File = "file",
|
83
|
+
Folder = "folder"
|
84
|
+
}
|
85
|
+
export declare enum KnowledgeType {
|
86
|
+
File = "file",
|
87
|
+
Manual = "manual",
|
88
|
+
Link = "link"
|
89
|
+
}
|
package/dist/types/type.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { SessionContentRole, SessionPromptRole, SessionContentStatus } from './enum
|
1
|
+
import { SessionContentRole, SessionPromptRole, SessionContentStatus, FileLinkType, FileStatus, ApiValueType, EnumCharacter, KnowledgePathType, KnowledgeType } from './enum';
|
2
2
|
export type Document = {
|
3
3
|
metadata: {
|
4
4
|
file_path: string;
|
@@ -6,6 +6,180 @@ export type Document = {
|
|
6
6
|
preview_path: string;
|
7
7
|
};
|
8
8
|
};
|
9
|
+
export interface IContent {
|
10
|
+
role: SessionPromptRole;
|
11
|
+
content: string;
|
12
|
+
}
|
13
|
+
export interface IVariable {
|
14
|
+
name: string;
|
15
|
+
value: string;
|
16
|
+
}
|
17
|
+
export interface IToolRule {
|
18
|
+
func: string;
|
19
|
+
message: string;
|
20
|
+
value: string;
|
21
|
+
}
|
22
|
+
export interface IToolParam {
|
23
|
+
name: string;
|
24
|
+
required: boolean;
|
25
|
+
type: ApiValueType;
|
26
|
+
default: string | number | boolean;
|
27
|
+
description: string;
|
28
|
+
validate: {
|
29
|
+
enable: boolean;
|
30
|
+
rules: IToolRule[];
|
31
|
+
};
|
32
|
+
}
|
33
|
+
export interface IResourcePermission {
|
34
|
+
accessModel?: boolean;
|
35
|
+
accessModelStrategy?: boolean;
|
36
|
+
viewSpace?: boolean;
|
37
|
+
manageSpace?: boolean;
|
38
|
+
viewAgent?: boolean;
|
39
|
+
createAgent?: boolean;
|
40
|
+
manageAgent?: boolean;
|
41
|
+
viewPrompt?: boolean;
|
42
|
+
createPrompt?: boolean;
|
43
|
+
managePrompt?: boolean;
|
44
|
+
viewCollection?: boolean;
|
45
|
+
createCollection?: boolean;
|
46
|
+
manageCollection?: boolean;
|
47
|
+
viewTool?: boolean;
|
48
|
+
createTool?: boolean;
|
49
|
+
manageTool?: boolean;
|
50
|
+
viewKnowledgebase?: boolean;
|
51
|
+
createKnowledgebase?: boolean;
|
52
|
+
manageKnowledgebase?: boolean;
|
53
|
+
viewQueryTemplate?: boolean;
|
54
|
+
createQueryTemplate?: boolean;
|
55
|
+
manageQueryTemplate?: boolean;
|
56
|
+
}
|
57
|
+
export interface ITool {
|
58
|
+
spaceId?: string;
|
59
|
+
header: IToolParam[];
|
60
|
+
query?: IToolParam[];
|
61
|
+
body?: IToolParam[];
|
62
|
+
creator: string;
|
63
|
+
createTime: string;
|
64
|
+
updateTime: string;
|
65
|
+
toolCode: string;
|
66
|
+
toolName: string;
|
67
|
+
icon: string;
|
68
|
+
description: string;
|
69
|
+
method: string;
|
70
|
+
url: string;
|
71
|
+
generateType: EnumCharacter;
|
72
|
+
id?: number;
|
73
|
+
status?: string;
|
74
|
+
isSensitive?: boolean;
|
75
|
+
permission?: IResourcePermission;
|
76
|
+
}
|
77
|
+
export interface ILinkFile {
|
78
|
+
url: string;
|
79
|
+
fileName: string;
|
80
|
+
fileSize: number;
|
81
|
+
fileType: string;
|
82
|
+
linkType: FileLinkType;
|
83
|
+
fileNumber?: number;
|
84
|
+
id?: string;
|
85
|
+
files?: File[];
|
86
|
+
loadingPercentage?: number;
|
87
|
+
headers?: Record<string, string>;
|
88
|
+
}
|
89
|
+
export interface IKnowledgeLinkFile extends ILinkFile {
|
90
|
+
name: string;
|
91
|
+
handleType: string[];
|
92
|
+
splitter: string;
|
93
|
+
pathType: KnowledgePathType;
|
94
|
+
indexConfig?: IKnowledgeIndexConfig;
|
95
|
+
}
|
96
|
+
export interface IKnowledgeIndexApi {
|
97
|
+
index_name: string;
|
98
|
+
index_type: string;
|
99
|
+
status?: 'normal' | 'init' | 'deleting';
|
100
|
+
index_config: {
|
101
|
+
type?: 'user' | 'system';
|
102
|
+
data_type?: string;
|
103
|
+
columns: string[];
|
104
|
+
};
|
105
|
+
}
|
106
|
+
export interface IKnowledgeIndexConfig {
|
107
|
+
vector_indexes: IKnowledgeIndexApi[];
|
108
|
+
scalar_indexes: IKnowledgeIndexApi[];
|
109
|
+
full_text_indexes: IKnowledgeIndexApi[];
|
110
|
+
}
|
111
|
+
export interface IKnowledge {
|
112
|
+
id?: number;
|
113
|
+
spaceId?: string;
|
114
|
+
url: string;
|
115
|
+
content: string;
|
116
|
+
tagNames: string[];
|
117
|
+
splitter: string;
|
118
|
+
handleType: string[];
|
119
|
+
updateFrequency?: number;
|
120
|
+
headers?: Record<string, string>;
|
121
|
+
name: string;
|
122
|
+
fileName: string;
|
123
|
+
fileSize: number;
|
124
|
+
fileType: string;
|
125
|
+
filePath: string;
|
126
|
+
pathType: KnowledgePathType;
|
127
|
+
createdType: KnowledgeType;
|
128
|
+
status?: FileStatus;
|
129
|
+
knowledgebaseId: number;
|
130
|
+
knowledgebaseName: string;
|
131
|
+
parentAnchorPath?: string;
|
132
|
+
permission?: IResourcePermission;
|
133
|
+
anchorPath?: string;
|
134
|
+
linkFiles?: IKnowledgeLinkFile[];
|
135
|
+
updatedAt?: string;
|
136
|
+
updatedBy?: string;
|
137
|
+
errorMessage?: string;
|
138
|
+
indexConfig?: IKnowledgeIndexConfig;
|
139
|
+
}
|
140
|
+
export interface IKnowledgebase {
|
141
|
+
id?: number;
|
142
|
+
spaceId?: string;
|
143
|
+
anchorPath?: string;
|
144
|
+
parentAnchorPath?: string;
|
145
|
+
filePath: string;
|
146
|
+
fileName?: string;
|
147
|
+
fileType?: string;
|
148
|
+
handleType: string[];
|
149
|
+
updateFrequency?: number;
|
150
|
+
name: string;
|
151
|
+
generateType?: EnumCharacter;
|
152
|
+
pathType?: KnowledgePathType;
|
153
|
+
createdType?: KnowledgeType;
|
154
|
+
number: number;
|
155
|
+
folderNumber?: number;
|
156
|
+
url?: string;
|
157
|
+
updatedBy?: string;
|
158
|
+
indexConfig?: IKnowledgeIndexConfig;
|
159
|
+
permission?: IResourcePermission;
|
160
|
+
children?: Array<IKnowledgebase>;
|
161
|
+
}
|
162
|
+
export interface ISession {
|
163
|
+
sessionCode: string;
|
164
|
+
sessionName: string;
|
165
|
+
model: string;
|
166
|
+
roleInfo?: {
|
167
|
+
collectionId: number;
|
168
|
+
collectionName: string;
|
169
|
+
content: IContent[];
|
170
|
+
variables: IVariable[];
|
171
|
+
};
|
172
|
+
sessionProperty?: {
|
173
|
+
isAutoClear?: boolean;
|
174
|
+
isAutoCalcPrompt?: boolean;
|
175
|
+
};
|
176
|
+
tools?: ITool[];
|
177
|
+
anchorPathResources?: {
|
178
|
+
knowledges: IKnowledge[];
|
179
|
+
knowledgebases: IKnowledgebase[];
|
180
|
+
knowledgeFolders: IKnowledgebase[];
|
181
|
+
};
|
182
|
+
}
|
9
183
|
export interface ISessionContent {
|
10
184
|
id?: number;
|
11
185
|
createdAt?: string;
|