@blueking/ai-ui-sdk 0.0.3 → 0.0.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.
@@ -21,6 +21,8 @@ export declare const useChat: <T extends ISession = ISession>({ handleStart, han
21
21
  rate?: number | undefined;
22
22
  status?: SessionContentStatus | undefined;
23
23
  sessionCode: string;
24
+ cite?: string | undefined;
25
+ time?: string | undefined;
24
26
  }[], ISessionContent[] | {
25
27
  id?: number | undefined;
26
28
  createdAt?: string | undefined;
@@ -34,6 +36,8 @@ export declare const useChat: <T extends ISession = ISession>({ handleStart, han
34
36
  rate?: number | undefined;
35
37
  status?: SessionContentStatus | undefined;
36
38
  sessionCode: string;
39
+ cite?: string | undefined;
40
+ time?: string | undefined;
37
41
  }[]>;
38
42
  sessionContentsMap: SessionContentsMap;
39
43
  sessionLoadingMap: import("vue").Ref<SessionLoadingMap, SessionLoadingMap>;
@@ -45,7 +49,10 @@ export declare const useChat: <T extends ISession = ISession>({ handleStart, han
45
49
  url: string;
46
50
  headers?: Record<string, string>;
47
51
  }) => void;
48
- sendChat: (message: string, callback?: () => void) => void;
52
+ sendChat: (content: {
53
+ message: string;
54
+ cite?: string;
55
+ }, callback?: () => void) => void;
49
56
  stopChat: (sessionCode: string) => void;
50
57
  plusSessionContent: (sessionCode: string, sessionContent: ISessionContent) => void;
51
58
  updateSessionContent: (sessionContent: ISessionContent) => void;
@@ -59,5 +66,9 @@ export declare const useChat: <T extends ISession = ISession>({ handleStart, han
59
66
  handleStartChat: (sessionCode: string) => void | undefined;
60
67
  handleErrorChat: (sessionCode: string, message: string, code?: string) => void | undefined;
61
68
  reGenerateChat: (chatIndex: number) => void;
69
+ reSendChat: (index: number, { message, cite }: {
70
+ message: string;
71
+ cite?: string;
72
+ }, callback?: () => void) => void;
62
73
  };
63
74
  export {};
package/dist/main.js CHANGED
@@ -160,8 +160,9 @@ url(${m}) format("embedded-opentype");
160
160
  }
161
161
  .knowledge-body {
162
162
  background: #F5F7FA;
163
- padding: 16px !important;
163
+ padding: 16px 0 !important;
164
164
  .knowledge-item {
165
+ padding-left: 10px;
165
166
  display: flex;
166
167
  align-items: center;
167
168
  line-height: 28px;
@@ -169,8 +170,9 @@ url(${m}) format("embedded-opentype");
169
170
  display: none;
170
171
  }
171
172
  a {
172
- margin-right: 20px;
173
+ margin-right: 10px;
173
174
  &:has(i) {
175
+ padding: 0 10px;
174
176
  margin-right: 0;
175
177
  text-decoration: none !important;
176
178
  }
@@ -241,6 +243,6 @@ url(${m}) format("embedded-opentype");
241
243
  &~ .knowledge-head {
242
244
  margin-bottom: 8px;
243
245
  }
244
- }`;(A=document.createElement("style")).textContent=e,document.head.appendChild(A)},t=()=>{A&&(A.remove(),A=null)};(0,a.onBeforeMount)(()=>{e()}),(0,a.onBeforeUnmount)(()=>{t()})};function f(A,e,t,n,i,o,l){try{var s=A[o](l),a=s.value}catch(A){t(A);return}s.done?e(a):Promise.resolve(a).then(n,i)}function Q(A){return function(){var e=this,t=arguments;return new Promise(function(n,i){var o=A.apply(e,t);function l(A){f(o,n,i,l,s,"next",A)}function s(A){f(o,n,i,l,s,"throw",A)}l(void 0)})}}function w(A,e,t){return e in A?Object.defineProperty(A,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):A[e]=t,A}class b{stream({sessionCode:A,url:e,headers:t,data:n}){var i=this;return Q(function*(){var o,l;yield null===(o=i.handleStart)||void 0===o?void 0:o.call(i,A);let s=new AbortController;i.controllerMap[A]=s,fetch(e,{method:"post",signal:s.signal,headers:function(A){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(A){return Object.getOwnPropertyDescriptor(t,A).enumerable}))),n.forEach(function(e){w(A,e,t[e])})}return A}({"Content-Type":"application/json"},t),mode:"cors",credentials:"include",body:JSON.stringify(n)}).then((l=Q(function*(e){let t=e.body.pipeThrough(new window.TextDecoderStream).getReader(),n="";for(;;)try{let{value:o,done:l}=yield t.read();if(!e.ok){i.handleError(A,o||e.statusText,e.status);break}if(l){i.handleEnd(A);break}(n+o.toString()).split("\n").forEach(t=>{let o=t.replace("data:","").trim();if(d(o)){var l,s;let{event:t,content:a,cover:r,documents:d,result:c,code:u,elapsed_time:B,message:g}=JSON.parse(o);if(!1===c||200!==e.status){i.handleError(A,g||"模型调用失败",u);return}switch(t){case"text":i.handleText(A,a,r);break;case"reference_doc":null===(l=i.handleReferenceDoc)||void 0===l||l.call(i,A,d,r);break;case"think":null===(s=i.handleThink)||void 0===s||s.call(i,A,a,r,B);break;case"done":i.handleEnd(A,r?a:"");break;case"error":i.handleError(A,g||"模型调用失败",u)}n=""}else o&&(n=o)})}catch(e){(null==e?void 0:e.code)!==20&&i.handleError(A,`模型调用失败:${e.message}`,e.code);break}}),function(A){return l.apply(this,arguments)}))})()}stop(A){var e,t;return null===(t=this.controllerMap[A])||void 0===t||null===(e=t.abort)||void 0===e||e.call(t),this.handleEnd(A)}constructor({handleStart:A,handleText:e,handleReferenceDoc:t,handleThink:n,handleEnd:i,handleError:o}){w(this,"handleStart",void 0),w(this,"handleText",void 0),w(this,"handleReferenceDoc",void 0),w(this,"handleThink",void 0),w(this,"handleEnd",void 0),w(this,"handleError",void 0),w(this,"controllerMap",void 0),this.handleStart=A,this.handleText=e,this.handleReferenceDoc=t,this.handleThink=n,this.handleEnd=i,this.handleError=o,this.controllerMap={}}}let k=({handleStart:A,handleText:i,handleReferenceDoc:o,handleThink:l,handleEnd:r,handleError:d,requestOptions:c}={})=>{let u="内容正在生成中...",h=(0,a.ref)(),v=(0,a.ref)({}),f=(0,a.ref)([]),Q={};null==c||c.url,null==c||c.headers;let w=(0,a.computed)(()=>{let A=[];for(let n=f.value.length-1;n>=0;n--){let i=f.value[n],o=n+1,l=f.value[o];for(;l&&![t.Ai,t.TokenExpired,t.ImageNotSupported,t.Pause,t.Guide].includes(l.role);)o+=1,l=f.value[o];if(i.role===t.System)break;i.status===e.Fail||(null==l?void 0:l.status)===e.Fail&&[t.User,t.UserImage].includes(i.role)||[t.Time,t.System].includes(i.role)||A.unshift(i)}return A}),k=(0,a.computed)(()=>{var A;let e=null===(A=h.value)||void 0===A?void 0:A.sessionCode;return!!e&&v.value[e]}),C=(0,a.computed)(()=>{var A,e,n;let i=[],o=[],l=[],a=f.value.findLastIndex(A=>A.role===t.System&&["已启用角色","已启用模型"].some(e=>A.content.includes(e))),r=0;null===(n=h.value)||void 0===n||null===(e=n.roleInfo)||void 0===e||null===(A=e.content)||void 0===A||A.forEach(A=>{let e=f.value[a+1+r],n=f.value[a+2+r];if((null==e?void 0:e.content)===A.content&&e.role!==t.System&&(i.push(s(e)),r+=1,(null==e?void 0:e.role)===t.Pause)){for(;n&&n.role===t.System;)r+=1,n=f.value[a+1+r];for(;n&&[t.User,t.UserImage].includes(n.role);)i.push(s(n)),r+=1,n=f.value[a+1+r]}}),o.push(...w.value.map(s));let d=A=>{let e=!0;for(let n=A;n<i.length;n++){var t;i[n].content!==(null===(t=o[n-A])||void 0===t?void 0:t.content)&&(e=!1)}return e};for(let A=0;A<i.length;A++){let e=i[A];if(d(A))break;l.push(e)}return l.push(...o),l.forEach(A=>{A.content=m(A.content),A.content=g(A.content)}),l}),y=new b({handleStart:R,handleText:function(A,t,n){let o=I(A);if(o.content===u)o.content=t;else{if(o.status!==e.Loading)return;o.content=n?t:o.content+t}return null==i?void 0:i(A,o)},handleReferenceDoc:function(A,e,t){let n=I(A),i=B(e);return n.content=t?i:n.content+i,null==o?void 0:o(A,n)},handleThink:function(A,e,t,n){let i=I(A);return i.content=p(i.content,e,t,n),null==l?void 0:l(A,i)},handleEnd:function(A,t){let n=I(A);if(n.status===e.Loading)return v.value[A]=!1,t&&(n.content=t),n.status=e.Success,null==r?void 0:r(A,n);(n.content===u||E(n.content))&&D(A,"聊天内容已中断")},handleError:D});function I(A){var e,t;return(null===(e=h.value)||void 0===e?void 0:e.sessionCode)===A?f.value.at(-1):null===(t=Q[A])||void 0===t?void 0:t.at(-1)}function G(A){var e;return(null===(e=h.value)||void 0===e?void 0:e.sessionCode)===A?f.value:Q[A]}function x(A,e){G(A).push(e)}function Y(A,e,n){var i;let o=(null===(i=h.value)||void 0===i?void 0:i.sessionCode)===A?f.value:Q[A],l=[];return e.forEach(A=>{let e=o.findIndex(e=>e.id===A);if(e>-1){let i=o[e-1],s=o[e+1],a=o[e+2];if(o.splice(e,1),l.push(A),[t.Hidden].includes(null==i?void 0:i.role)){let A=o.findIndex(A=>A.id===i.id);o.splice(A,1),l.push(i.id)}if((null==s?void 0:s.role)===t.Ai||n&&[t.Ai,t.Guide,t.TokenExpired,t.ImageNotSupported,t.Pause].includes(null==s?void 0:s.role)){let A=o.findIndex(A=>A.id===s.id);o.splice(A,1),l.push(s.id)}if([t.Guide].includes(null==a?void 0:a.role)&&n){let A=o.findIndex(A=>A.id===a.id);o.splice(A,1),l.push(a.id)}}}),l}function R(n){v.value[n]=!0;let i={sessionCode:n,role:t.Ai,status:e.Loading,content:u};return x(n,i),null==A?void 0:A(n,i)}function D(A,i,o){let l=I(A);return l.status=e.Fail,l.content=i,v.value[A]=!1,o===n.TokenExpired&&(l.content="抱歉,您的剩余 Token 不足,无法返回回答内容,请先清空当前会话(上下文仍会作为历史记录保留))",l.role=t.TokenExpired),o===n.ImageNotSupported&&(l.content="抱歉,当前模型不支持图片内容解析",l.role=t.ImageNotSupported),null==d?void 0:d(A,l,o)}function F(A,n){var i,o,l;(null===(i=h.value)||void 0===i?void 0:i.sessionCode)&&(null==c?void 0:c.url)&&!k.value&&(f.value.push({sessionCode:null===(o=h.value)||void 0===o?void 0:o.sessionCode,content:A,role:t.User,status:e.Success}),y.stream({sessionCode:null===(l=h.value)||void 0===l?void 0:l.sessionCode,url:c.url,headers:null==c?void 0:c.headers,data:{inputs:{chat_history:C.value.slice(0,C.value.length-1),input:A}}}),null==n||n())}return{currentSession:h,sessionContents:f,sessionContentsMap:Q,sessionLoadingMap:v,prompts:C,currentSessionLoading:k,chat:function({sessionCode:A,data:e,url:t,headers:n}){y.stream({sessionCode:A,url:t,data:e,headers:n||(null==c?void 0:c.headers)})},sendChat:F,stopChat:function(A){y.stop(A)},plusSessionContent:x,updateSessionContent:function(A){var e;let t=((null===(e=h.value)||void 0===e?void 0:e.sessionCode)===A.sessionCode?f.value:Q[A.sessionCode]).find(e=>+(e.id||0)==+(A.id||0));t&&Object.assign(t,A)},getSessionContentById:function(A,e){return G(e).find(e=>e.id===A)},getLastSessionContentBySessionCode:I,getSessionContentsBySessionCode:G,setCurrentSession:function(A){h.value=A,(null==A?void 0:A.sessionCode)&&(Q[A.sessionCode]||(Q[A.sessionCode]=[]),f.value=Q[A.sessionCode])},setSessionContents:function(A){h.value&&(Q[h.value.sessionCode]=A,f.value=A)},deleteSessionContent:function(A,e){return Y(A,[e],!0)},deleteSessionContents:function(A,e){return Y(A,e,!1)},handleStartChat:R,handleErrorChat:D,reGenerateChat:function(A){if(f.value[A].role!==t.Ai)return;let e=f.value[A-1].content;f.value.splice(A-1,2),F(e)}}},C=({handleStart:e,handleEnd:t,handleError:n}={})=>{let i="",o=new b({handleStart:()=>(i="",null==e?void 0:e()),handleText:(A,e,t)=>{t||"正在思考..."===i?i=e:i+=e},handleEnd:()=>("无话可说"===i&&(i=""),null==t?void 0:t(i)),handleError:(A,e,t)=>null==n?void 0:n(e,t)});return{summary:({content:e,url:t,headers:n,model:i})=>{let l=m(g(e)),s=[{role:A.User,content:`你是一个总结大师,请帮助我对下面这段话进行总结。要求总结精炼,不超过 15 个字!且末尾没有标点符号!请注意:如果你无法总结,请回复“无话可说”!
246
+ }`;(A=document.createElement("style")).textContent=e,document.head.appendChild(A)},t=()=>{A&&(A.remove(),A=null)};(0,a.onBeforeMount)(()=>{e()}),(0,a.onBeforeUnmount)(()=>{t()})};function f(A,e,t,n,i,o,l){try{var s=A[o](l),a=s.value}catch(A){t(A);return}s.done?e(a):Promise.resolve(a).then(n,i)}function Q(A){return function(){var e=this,t=arguments;return new Promise(function(n,i){var o=A.apply(e,t);function l(A){f(o,n,i,l,s,"next",A)}function s(A){f(o,n,i,l,s,"throw",A)}l(void 0)})}}function w(A,e,t){return e in A?Object.defineProperty(A,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):A[e]=t,A}class b{stream({sessionCode:A,url:e,headers:t,data:n}){var i=this;return Q(function*(){var o,l;yield null===(o=i.handleStart)||void 0===o?void 0:o.call(i,A);let s=new AbortController;i.controllerMap[A]=s,fetch(e,{method:"post",signal:s.signal,headers:function(A){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(A){return Object.getOwnPropertyDescriptor(t,A).enumerable}))),n.forEach(function(e){w(A,e,t[e])})}return A}({"Content-Type":"application/json"},t),mode:"cors",credentials:"include",body:JSON.stringify(n)}).then((l=Q(function*(e){let t=e.body.pipeThrough(new window.TextDecoderStream).getReader(),n="";for(;;)try{let{value:o,done:l}=yield t.read();if(!e.ok){i.handleError(A,o||e.statusText,e.status);break}if(l){i.handleEnd(A);break}(n+o.toString()).split("\n").forEach(t=>{let o=t.replace("data:","").trim();if(d(o)){var l,s;let{event:t,content:a,cover:r,documents:d,result:c,code:u,elapsed_time:B,message:g}=JSON.parse(o);if(!1===c||200!==e.status){i.handleError(A,g||"模型调用失败",u);return}switch(t){case"text":i.handleText(A,a,r);break;case"reference_doc":null===(l=i.handleReferenceDoc)||void 0===l||l.call(i,A,d,r);break;case"think":null===(s=i.handleThink)||void 0===s||s.call(i,A,a,r,B);break;case"done":i.handleEnd(A,r?a:"");break;case"error":i.handleError(A,g||"模型调用失败",u)}n=""}else o&&(n=o)})}catch(e){(null==e?void 0:e.code)!==20&&i.handleError(A,`模型调用失败:${e.message}`,e.code);break}}),function(A){return l.apply(this,arguments)}))})()}stop(A){var e,t;return null===(t=this.controllerMap[A])||void 0===t||null===(e=t.abort)||void 0===e||e.call(t),this.handleEnd(A)}constructor({handleStart:A,handleText:e,handleReferenceDoc:t,handleThink:n,handleEnd:i,handleError:o}){w(this,"handleStart",void 0),w(this,"handleText",void 0),w(this,"handleReferenceDoc",void 0),w(this,"handleThink",void 0),w(this,"handleEnd",void 0),w(this,"handleError",void 0),w(this,"controllerMap",void 0),this.handleStart=A,this.handleText=e,this.handleReferenceDoc=t,this.handleThink=n,this.handleEnd=i,this.handleError=o,this.controllerMap={}}}let k=({handleStart:A,handleText:i,handleReferenceDoc:o,handleThink:l,handleEnd:r,handleError:d,requestOptions:c}={})=>{let u="内容正在生成中...",h=(0,a.ref)(),v=(0,a.ref)({}),f=(0,a.ref)([]),Q={},w=(0,a.computed)(()=>{let A=[];for(let n=f.value.length-1;n>=0;n--){let i=f.value[n],o=n+1,l=f.value[o];for(;l&&![t.Ai,t.TokenExpired,t.ImageNotSupported,t.Pause,t.Guide].includes(l.role);)o+=1,l=f.value[o];if(i.role===t.System)break;i.status===e.Fail||(null==l?void 0:l.status)===e.Fail&&[t.User,t.UserImage].includes(i.role)||[t.Time,t.System].includes(i.role)||A.unshift(i)}return A}),k=(0,a.computed)(()=>{var A;let e=null===(A=h.value)||void 0===A?void 0:A.sessionCode;return!!e&&v.value[e]}),C=(0,a.computed)(()=>{var A,e,n;let i=[],o=[],l=[],a=f.value.findLastIndex(A=>A.role===t.System&&["已启用角色","已启用模型"].some(e=>A.content.includes(e))),r=0;null===(n=h.value)||void 0===n||null===(e=n.roleInfo)||void 0===e||null===(A=e.content)||void 0===A||A.forEach(A=>{let e=f.value[a+1+r],n=f.value[a+2+r];if((null==e?void 0:e.content)===A.content&&e.role!==t.System&&(i.push(s(e)),r+=1,(null==e?void 0:e.role)===t.Pause)){for(;n&&n.role===t.System;)r+=1,n=f.value[a+1+r];for(;n&&[t.User,t.UserImage].includes(n.role);)i.push(s(n)),r+=1,n=f.value[a+1+r]}}),o.push(...w.value.map(s));let d=A=>{let e=!0;for(let n=A;n<i.length;n++){var t;i[n].content!==(null===(t=o[n-A])||void 0===t?void 0:t.content)&&(e=!1)}return e};for(let A=0;A<i.length;A++){let e=i[A];if(d(A))break;l.push(e)}return l.push(...o),l.forEach(A=>{A.content=m(A.content),A.content=g(A.content)}),l}),y=new b({handleStart:R,handleText:function(A,t,n){let o=I(A);if(o.content===u)o.content=t;else{if(o.status!==e.Loading)return;o.content=n?t:o.content+t}return null==i?void 0:i(A,o)},handleReferenceDoc:function(A,e,t){let n=I(A),i=B(e);return n.content=t?i:n.content+i,null==o?void 0:o(A,n)},handleThink:function(A,e,t,n){let i=I(A);return i.content=p(i.content,e,t,n),null==l?void 0:l(A,i)},handleEnd:function(A,t){let n=I(A);if(n.status===e.Loading)return v.value[A]=!1,t&&(n.content=t),n.status=e.Success,null==r?void 0:r(A,n);(n.content===u||E(n.content))&&D(A,"聊天内容已中断")},handleError:D});function I(A){var e,t;return(null===(e=h.value)||void 0===e?void 0:e.sessionCode)===A?f.value.at(-1):null===(t=Q[A])||void 0===t?void 0:t.at(-1)}function G(A){var e;return(null===(e=h.value)||void 0===e?void 0:e.sessionCode)===A?f.value:Q[A]}function x(A,e){G(A).push(e)}function Y(A,e,n){var i;let o=(null===(i=h.value)||void 0===i?void 0:i.sessionCode)===A?f.value:Q[A],l=[];return e.forEach(A=>{let e=o.findIndex(e=>e.id===A);if(e>-1){let i=o[e-1],s=o[e+1],a=o[e+2];if(o.splice(e,1),l.push(A),[t.Hidden].includes(null==i?void 0:i.role)){let A=o.findIndex(A=>A.id===i.id);o.splice(A,1),l.push(i.id)}if((null==s?void 0:s.role)===t.Ai||n&&[t.Ai,t.Guide,t.TokenExpired,t.ImageNotSupported,t.Pause].includes(null==s?void 0:s.role)){let A=o.findIndex(A=>A.id===s.id);o.splice(A,1),l.push(s.id)}if([t.Guide].includes(null==a?void 0:a.role)&&n){let A=o.findIndex(A=>A.id===a.id);o.splice(A,1),l.push(a.id)}}}),l}function R(n){v.value[n]=!0;let i={sessionCode:n,role:t.Ai,status:e.Loading,content:u};return x(n,i),null==A?void 0:A(n,i)}function D(A,i,o){let l=I(A);return l.status=e.Fail,l.content=i,v.value[A]=!1,o===n.TokenExpired&&(l.content="抱歉,您的剩余 Token 不足,无法返回回答内容,请先清空当前会话(上下文仍会作为历史记录保留))",l.role=t.TokenExpired),o===n.ImageNotSupported&&(l.content="抱歉,当前模型不支持图片内容解析",l.role=t.ImageNotSupported),null==d?void 0:d(A,l,o)}function F(A,n){var i,o,l;if(!(null===(i=h.value)||void 0===i?void 0:i.sessionCode)||!(null==c?void 0:c.url)||k.value)return;let{message:s,cite:a}=A;f.value.push({sessionCode:null===(o=h.value)||void 0===o?void 0:o.sessionCode,content:s,role:t.User,status:e.Success,cite:a});let r=a?`${s}: "${a}"`:s;y.stream({sessionCode:null===(l=h.value)||void 0===l?void 0:l.sessionCode,url:c.url,headers:null==c?void 0:c.headers,data:{inputs:{chat_history:C.value.slice(0,C.value.length-1),input:r}}}),null==n||n()}return{currentSession:h,sessionContents:f,sessionContentsMap:Q,sessionLoadingMap:v,prompts:C,currentSessionLoading:k,chat:function({sessionCode:A,data:e,url:t,headers:n}){y.stream({sessionCode:A,url:t,data:e,headers:n||(null==c?void 0:c.headers)})},sendChat:F,stopChat:function(A){y.stop(A)},plusSessionContent:x,updateSessionContent:function(A){var e;let t=((null===(e=h.value)||void 0===e?void 0:e.sessionCode)===A.sessionCode?f.value:Q[A.sessionCode]).find(e=>+(e.id||0)==+(A.id||0));t&&Object.assign(t,A)},getSessionContentById:function(A,e){return G(e).find(e=>e.id===A)},getLastSessionContentBySessionCode:I,getSessionContentsBySessionCode:G,setCurrentSession:function(A){h.value=A,(null==A?void 0:A.sessionCode)&&(Q[A.sessionCode]||(Q[A.sessionCode]=[]),f.value=Q[A.sessionCode])},setSessionContents:function(A){h.value&&(Q[h.value.sessionCode]=A,f.value=A)},deleteSessionContent:function(A,e){return Y(A,[e],!0)},deleteSessionContents:function(A,e){return Y(A,e,!1)},handleStartChat:R,handleErrorChat:D,reGenerateChat:function(A){if(f.value[A].role!==t.Ai)return;let e=f.value[A-1].content,n=f.value[A-1].cite;f.value.splice(A-1,2),F({message:e,cite:n})},reSendChat:function(A,{message:e,cite:n},i){f.value[A].role===t.User&&(f.value.splice(A,f.value.length-A),F({message:e,cite:n},i))}}},C=({handleStart:e,handleEnd:t,handleError:n}={})=>{let i="",o=new b({handleStart:()=>(i="",null==e?void 0:e()),handleText:(A,e,t)=>{t||"正在思考..."===i?i=e:i+=e},handleEnd:()=>("无话可说"===i&&(i=""),null==t?void 0:t(i)),handleError:(A,e,t)=>null==n?void 0:n(e,t)});return{summary:({content:e,url:t,headers:n,model:i})=>{let l=m(g(e)),s=[{role:A.User,content:`你是一个总结大师,请帮助我对下面这段话进行总结。要求总结精炼,不超过 15 个字!且末尾没有标点符号!请注意:如果你无法总结,请回复“无话可说”!
245
247
  文字如下:
246
248
  ${l}`}];o.stream({sessionCode:"summary",url:t,data:{prompts:s,model:i},headers:n})}}},y=()=>{i(86),i(84),h(),v()},I=l.default;if("undefined"!=typeof window){let{currentScript:A}=window.document,e=A&&A.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);e&&(i.p=e[1])}})(),o})());
@@ -34,6 +34,8 @@ export interface ISessionContent {
34
34
  rate?: number;
35
35
  status?: SessionContentStatus;
36
36
  sessionCode: string;
37
+ cite?: string;
38
+ time?: string;
37
39
  }
38
40
  export interface ISessionPrompt {
39
41
  content: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueking/ai-ui-sdk",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "蓝鲸AI UI SDK",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",