bi-sdk-react 0.0.28 → 0.0.29
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/es/js/bi-sdk.es.js
CHANGED
|
@@ -417,7 +417,7 @@ import*as e from"react";import t,{css as l}from"styled-components";import{AlignC
|
|
|
417
417
|
.conversation-list li small {
|
|
418
418
|
white-space: nowrap;
|
|
419
419
|
}
|
|
420
|
-
`,tM=[],t_="bi-design",t$=e=>{let t,l,n,r,a,i,o,{agentList:s=tM,headExtra:d,style:u={},onEffect:p}=e,{pageId:x,schema:m,fetch:h,atItems:g,onRemoveAtItem:v}=(0,eE.useContext)(eT);if(!h)return null;let[j,y]=(0,eE.useState)(null),[w,C]=(0,eE.useState)([]),[S,k]=(0,eE.useState)([]),z=eE.default.useRef(null),I=()=>{setTimeout(()=>{z.current&&z.current.scrollToBottom()},100)},N=()=>{y(null),k([])},O=async e=>{q.confirm({title:"确认删除该对话吗?",okText:"确认",cancelText:"取消",onOk:async()=>{var t;await (null==(t=h.ai)?void 0:t.removeConversation(e)),C(t=>t.filter(t=>t.id!==e)),k(t=>t.filter(t=>t.conversationId!==e)),j===e&&N()}})},E=async e=>{var t;y(e),C(t=>t.map(t=>({...t,isActived:t.id===e}))),k(await (null==(t=h.ai)?void 0:t.messageList(e))||[]),I()},T=async e=>{var t;let l={id:ef(),question:e.message,createdAt:new Date().toISOString(),files:e.files||[],agents:e.agents||[],atItems:g,sending:!0};k(e=>[...e,l]),I();let n=!j,{id:r,answer:a,createdAt:i,conversation:o}=await (null==(t=h.ai)?void 0:t.chat(t_,x,j,{...e,page:JSON.stringify(m),pageItems:JSON.stringify(g||[])}));y((null==o?void 0:o.id)||""),C(e=>[n?o||{}:null,...e].filter(e=>null!==e)),Object.assign(l,{id:r,answer:a,createdAt:i,conversationId:(null==o?void 0:o.id)||"",sending:!1}),a.effect&&(null==p||p(a.effect)),k(e=>[...e]),I()},A=async e=>{var t;await (null==(t=h.ai)?void 0:t.removeMessage(e)),k(t=>t.filter(t=>t.id!==e))},D=(t=new Date,l=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),(n=new Date(t)).setDate(t.getDate()-1),r=[],a=[],i=[],o=[],w.forEach(e=>{let s=new Date(e.createdAt);if(l(s,t))r.push(e);else if(l(s,n))a.push(e);else s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()?i.push(e):o.push(e)}),[{title:"今天",items:r},{title:"昨天",items:a},{title:"本月内",items:i},{title:"很久以前",items:o}].filter(e=>e.items.length>0)),B=async()=>{try{var e,t;let l=await (null==(e=h.ai)?void 0:e.conversationList(t_,x));C(l||[]);let n=null==l?void 0:l.find(e=>e.isActived);if(n){y(n.id);let e=await (null==(t=h.ai)?void 0:t.messageList(n.id));k(e||[]),I()}}catch(e){console.error(e)}};return(0,eE.useEffect)(()=>{B()},[h]),(0,eE.useEffect)(()=>{I()},[]),(0,eO.jsxs)(tP,{style:u,children:[(0,eO.jsx)(tL,{title:"智能助理",extra:(0,eO.jsxs)(en,{children:[(0,eO.jsx)(es,{title:"新对话",placement:"topRight",children:(0,eO.jsx)("a",{onClick:N,children:(0,eO.jsx)(th,{type:"icon-chat-plus"})})}),(0,eO.jsx)(J,{trigger:["click"],styles:{root:{boxShadow:"var(--ant-box-shadow-drawer-up)",backgroundColor:"#ffffff",borderRadius:"var(--ant-border-radius)"}},popupRender:()=>(0,eO.jsx)(tH,{children:D.map(e=>(0,eO.jsxs)("div",{className:"group",children:[(0,eO.jsx)("div",{className:"group-title",children:e.title}),(0,eO.jsx)("ul",{className:"group-list",children:e.items.map(e=>(0,eO.jsxs)("li",{className:e.isActived?"actived":"",children:[(0,eO.jsx)("a",{onClick:()=>E(e.id),children:e.name}),(0,eO.jsx)("small",{children:(0,eO.jsx)("a",{onClick:()=>O(e.id),children:(0,eO.jsx)(c,{})})})]},e.id))})]},e.title))}),placement:"topRight",children:(0,eO.jsx)("a",{children:(0,eO.jsx)(f,{})})}),d]}),style:{width:"initial"}}),(0,eO.jsxs)("div",{className:"body",children:[(0,eO.jsx)("div",{style:{flex:"1 1 auto",overflowY:"auto"},children:S.length?(0,eO.jsx)(tJ,{ref:z,list:S,onDeleteMessage:A}):(0,eO.jsx)(tY,{})}),0===S.length&&w.length>0&&(0,eO.jsx)(M,{title:"历史记录",size:"small",variant:"borderless",styles:{header:{padding:0,border:"none"},body:{padding:0}},style:{padding:"12px 12px 0 12px"},children:(0,eO.jsx)("ul",{className:"conversation-list",children:w.slice(0,3).map(e=>(0,eO.jsxs)("li",{children:[(0,eO.jsxs)("a",{children:[(0,eO.jsx)(b,{}),e.name]}),(0,eO.jsx)("small",{children:tz(e.createdAt)})]},e.id))})}),(0,eO.jsx)(tB,{agentList:s,style:{padding:12},atItems:g,onUploading:null==h?void 0:h.upload,onSubmit:T,onRemoveAtItem:v})]})]})},tF=t.div`
|
|
420
|
+
`,tM=[],t_="bi-design",t$=e=>{let t,l,n,r,a,i,o,{agentList:s=tM,headExtra:d,style:u={},onEffect:p}=e,{pageId:x,schema:m,fetch:h,atItems:g,onRemoveAtItem:v}=(0,eE.useContext)(eT);if(!h)return null;let[j,y]=(0,eE.useState)(null),[w,C]=(0,eE.useState)([]),[S,k]=(0,eE.useState)([]),z=eE.default.useRef(null),I=()=>{setTimeout(()=>{z.current&&z.current.scrollToBottom()},100)},N=()=>{y(null),k([])},O=async e=>{q.confirm({title:"确认删除该对话吗?",okText:"确认",cancelText:"取消",onOk:async()=>{var t;await (null==(t=h.ai)?void 0:t.removeConversation(e)),C(t=>t.filter(t=>t.id!==e)),k(t=>t.filter(t=>t.conversationId!==e)),j===e&&N()}})},E=async e=>{var t;y(e),C(t=>t.map(t=>({...t,isActived:t.id===e}))),k(await (null==(t=h.ai)?void 0:t.messageList(e))||[]),I()},T=async e=>{var t;let l={id:ef(),question:e.message,createdAt:new Date().toISOString(),files:e.files||[],agents:e.agents||[],atItems:JSON.stringify(g),sending:!0};k(e=>[...e,l]),I();let n=!j,{id:r,answer:a,createdAt:i,conversation:o}=await (null==(t=h.ai)?void 0:t.chat(t_,x,j,{...e,page:JSON.stringify(m),pageItems:JSON.stringify(g||[])}));y((null==o?void 0:o.id)||""),C(e=>[n?o||{}:null,...e].filter(e=>null!==e)),Object.assign(l,{id:r,answer:a,createdAt:i,conversationId:(null==o?void 0:o.id)||"",sending:!1}),a.effect&&(null==p||p(a.effect)),k(e=>[...e]),I()},A=async e=>{var t;await (null==(t=h.ai)?void 0:t.removeMessage(e)),k(t=>t.filter(t=>t.id!==e))},D=(t=new Date,l=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),(n=new Date(t)).setDate(t.getDate()-1),r=[],a=[],i=[],o=[],w.forEach(e=>{let s=new Date(e.createdAt);if(l(s,t))r.push(e);else if(l(s,n))a.push(e);else s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()?i.push(e):o.push(e)}),[{title:"今天",items:r},{title:"昨天",items:a},{title:"本月内",items:i},{title:"很久以前",items:o}].filter(e=>e.items.length>0)),B=async()=>{try{var e,t;let l=await (null==(e=h.ai)?void 0:e.conversationList(t_,x));C(l||[]);let n=null==l?void 0:l.find(e=>e.isActived);if(n){y(n.id);let e=await (null==(t=h.ai)?void 0:t.messageList(n.id));k(e||[]),I()}}catch(e){console.error(e)}};return(0,eE.useEffect)(()=>{B()},[h]),(0,eE.useEffect)(()=>{I()},[]),(0,eO.jsxs)(tP,{style:u,children:[(0,eO.jsx)(tL,{title:"智能助理",extra:(0,eO.jsxs)(en,{children:[(0,eO.jsx)(es,{title:"新对话",placement:"topRight",children:(0,eO.jsx)("a",{onClick:N,children:(0,eO.jsx)(th,{type:"icon-chat-plus"})})}),(0,eO.jsx)(J,{trigger:["click"],styles:{root:{boxShadow:"var(--ant-box-shadow-drawer-up)",backgroundColor:"#ffffff",borderRadius:"var(--ant-border-radius)"}},popupRender:()=>(0,eO.jsx)(tH,{children:D.map(e=>(0,eO.jsxs)("div",{className:"group",children:[(0,eO.jsx)("div",{className:"group-title",children:e.title}),(0,eO.jsx)("ul",{className:"group-list",children:e.items.map(e=>(0,eO.jsxs)("li",{className:e.isActived?"actived":"",children:[(0,eO.jsx)("a",{onClick:()=>E(e.id),children:e.name}),(0,eO.jsx)("small",{children:(0,eO.jsx)("a",{onClick:()=>O(e.id),children:(0,eO.jsx)(c,{})})})]},e.id))})]},e.title))}),placement:"topRight",children:(0,eO.jsx)("a",{children:(0,eO.jsx)(f,{})})}),d]}),style:{width:"initial"}}),(0,eO.jsxs)("div",{className:"body",children:[(0,eO.jsx)("div",{style:{flex:"1 1 auto",overflowY:"auto"},children:S.length?(0,eO.jsx)(tJ,{ref:z,list:S,onDeleteMessage:A}):(0,eO.jsx)(tY,{})}),0===S.length&&w.length>0&&(0,eO.jsx)(M,{title:"历史记录",size:"small",variant:"borderless",styles:{header:{padding:0,border:"none"},body:{padding:0}},style:{padding:"12px 12px 0 12px"},children:(0,eO.jsx)("ul",{className:"conversation-list",children:w.slice(0,3).map(e=>(0,eO.jsxs)("li",{children:[(0,eO.jsxs)("a",{children:[(0,eO.jsx)(b,{}),e.name]}),(0,eO.jsx)("small",{children:tz(e.createdAt)})]},e.id))})}),(0,eO.jsx)(tB,{agentList:s,style:{padding:12},atItems:g,onUploading:null==h?void 0:h.upload,onSubmit:T,onRemoveAtItem:v})]})]})},tF=t.div`
|
|
421
421
|
flex: 1 1 auto;
|
|
422
422
|
display: flex;
|
|
423
423
|
align-items: center;
|
|
@@ -632,7 +632,7 @@ import*as e from"react";import t,{css as l}from"styled-components";import{AlignC
|
|
|
632
632
|
}
|
|
633
633
|
}
|
|
634
634
|
}
|
|
635
|
-
`,tJ=(0,eE.forwardRef)((e,t)=>{let{list:l,onDeleteMessage:n}=e,r=(0,eE.useRef)(null),a=()=>{setTimeout(()=>{r.current&&(r.current.scrollTop=r.current.scrollHeight)},100)};return(0,eE.useImperativeHandle)(t,()=>({scrollToBottom:a})),(0,eO.jsx)(tG,{className:"message-list beautified_scrollbar",ref:r,children:l.map(e=>{var t,l,r,a,i,o,s,d,u,p;return(0,eO.jsxs)("div",{className:"msg",children:[(0,eO.jsxs)("div",{className:"user-message",children:[(0,eO.jsx)("div",{className:"msg-header",children:(0,eO.jsx)("span",{children:tz(e.createdAt)})}),(0,eO.jsxs)("div",{className:"msg-section",children:[(0,eO.jsxs)(en,{size:4,orientation:"vertical",className:"msg-tools",children:[(0,eO.jsx)(ec.Text,{copyable:{text:e.question,tooltips:"复制"}}),(0,eO.jsx)(V,{title:"确认删除吗?",okText:"确认",cancelText:"取消",onConfirm:()=>n(e.id),children:(0,eO.jsx)(es,{title:"删除",children:(0,eO.jsx)(P,{type:"link",size:"small",icon:(0,eO.jsx)(c,{})})})})]}),(0,eO.jsx)("div",{className:"msg-content",children:e.question}),(null==(t=e.files)?void 0:t.length)||(null==(l=e.agents)?void 0:l.length)||(null==(r=e.atItems)?void 0:r.length)?(0,eO.jsxs)("div",{className:"msg-meta",children:[null==(a=e.files)?void 0:a.map(e=>(0,eO.jsxs)(ei,{color:"processing",children:[(0,eO.jsx)(th,{type:"icon-paper-clip"})," ",e.name]},e.id)),null==(i=e.agents)?void 0:i.map(e=>(0,eO.jsxs)(ei,{color:"blue",children:[(0,eO.jsx)(th,{type:"icon-at"})," ",e.name]},e.id)),(e=>{try{return JSON.parse(e||"[]")}catch(e){return[]}})(e.atItems).map(e=>(0,eO.jsxs)(ei,{color:"blue",children:[(0,eO.jsx)(th,{type:"icon-number"})," ",e.name]},e.id))]}):null]})]}),(0,eO.jsxs)("div",{className:"assistant-message",children:[(0,eO.jsx)("div",{className:"msg-header",children:(0,eO.jsxs)("span",{className:"msg-title",children:[(0,eO.jsx)(z,{})," 智能助理"]})}),(0,eO.jsx)("div",{className:"msg-section",children:e.sending?(0,eO.jsx)(el,{active:!0}):(0,eO.jsxs)(eO.Fragment,{children:[(0,eO.jsx)("div",{className:"msg-content",children:(null==(o=e.answer)?void 0:o.answer)||""}),!!(null==(d=e.answer)||null==(s=d.plans)?void 0:s.length)&&(0,eO.jsxs)("details",{className:"msg-ai-meta",open:!0,children:[(0,eO.jsx)("summary",{className:"msg-ai-meta-title",children:"PLANS:"}),(0,eO.jsx)("div",{className:"msg-ai-meta-list",children:e.answer.plans.map((e,t)=>(0,eO.jsx)(es,{title:e.description,children:(0,eO.jsx)(ei,{color:"blue",children:e.name})},t))})]}),!!(null==(p=e.answer)||null==(u=p.extra)?void 0:u.length)&&(0,eO.jsxs)("details",{className:"msg-ai-meta",open:!0,children:[(0,eO.jsx)("summary",{className:"msg-ai-meta-title",children:"ACTIONS:"}),(0,eO.jsx)("div",{className:"msg-ai-meta-list vertical",children:e.answer.extra.map((e,t)=>(0,eO.jsxs)("div",{className:"msg-ai-meta-list-item",children:[(0,eO.jsx)(ei,{color:"gold",children:e.element}),(0,eO.jsx)("span",{children:e.action})]},t))})]})]})})]})]},e.id)})})}),tK=t.div`
|
|
635
|
+
`,tJ=(0,eE.forwardRef)((e,t)=>{let{list:l,onDeleteMessage:n}=e,r=(0,eE.useRef)(null),a=()=>{setTimeout(()=>{r.current&&(r.current.scrollTop=r.current.scrollHeight)},100)};return(0,eE.useImperativeHandle)(t,()=>({scrollToBottom:a})),(0,eO.jsx)(tG,{className:"message-list beautified_scrollbar",ref:r,children:l.map(e=>{var t,l,r,a,i,o,s,d,u,p;return(0,eO.jsxs)("div",{className:"msg",children:[(0,eO.jsxs)("div",{className:"user-message",children:[(0,eO.jsx)("div",{className:"msg-header",children:(0,eO.jsx)("span",{children:tz(e.createdAt)})}),(0,eO.jsxs)("div",{className:"msg-section",children:[(0,eO.jsxs)(en,{size:4,orientation:"vertical",className:"msg-tools",children:[(0,eO.jsx)(ec.Text,{copyable:{text:e.question,tooltips:"复制"}}),(0,eO.jsx)(V,{title:"确认删除吗?",okText:"确认",cancelText:"取消",onConfirm:()=>n(e.id),children:(0,eO.jsx)(es,{title:"删除",children:(0,eO.jsx)(P,{type:"link",size:"small",icon:(0,eO.jsx)(c,{})})})})]}),(0,eO.jsx)("div",{className:"msg-content",children:e.question}),(null==(t=e.files)?void 0:t.length)||(null==(l=e.agents)?void 0:l.length)||(null==(r=e.atItems)?void 0:r.length)?(0,eO.jsxs)("div",{className:"msg-meta",children:[null==(a=e.files)?void 0:a.map(e=>(0,eO.jsxs)(ei,{color:"processing",children:[(0,eO.jsx)(th,{type:"icon-paper-clip"})," ",e.name]},e.id)),null==(i=e.agents)?void 0:i.map(e=>(0,eO.jsxs)(ei,{color:"blue",children:[(0,eO.jsx)(th,{type:"icon-at"})," ",e.name]},e.id)),(e=>{try{if(e){if("object"==typeof e)return e;else if("string"==typeof e)return JSON.parse(e||"[]")}return[]}catch(e){return[]}})(e.atItems).map(e=>(0,eO.jsxs)(ei,{color:"blue",children:[(0,eO.jsx)(th,{type:"icon-number"})," ",e.name]},e.id))]}):null]})]}),(0,eO.jsxs)("div",{className:"assistant-message",children:[(0,eO.jsx)("div",{className:"msg-header",children:(0,eO.jsxs)("span",{className:"msg-title",children:[(0,eO.jsx)(z,{})," 智能助理"]})}),(0,eO.jsx)("div",{className:"msg-section",children:e.sending?(0,eO.jsx)(el,{active:!0}):(0,eO.jsxs)(eO.Fragment,{children:[(0,eO.jsx)("div",{className:"msg-content",children:(null==(o=e.answer)?void 0:o.answer)||""}),!!(null==(d=e.answer)||null==(s=d.plans)?void 0:s.length)&&(0,eO.jsxs)("details",{className:"msg-ai-meta",open:!0,children:[(0,eO.jsx)("summary",{className:"msg-ai-meta-title",children:"PLANS:"}),(0,eO.jsx)("div",{className:"msg-ai-meta-list",children:e.answer.plans.map((e,t)=>(0,eO.jsx)(es,{title:e.description,children:(0,eO.jsx)(ei,{color:"blue",children:e.name})},t))})]}),!!(null==(p=e.answer)||null==(u=p.extra)?void 0:u.length)&&(0,eO.jsxs)("details",{className:"msg-ai-meta",open:!0,children:[(0,eO.jsx)("summary",{className:"msg-ai-meta-title",children:"ACTIONS:"}),(0,eO.jsx)("div",{className:"msg-ai-meta-list vertical",children:e.answer.extra.map((e,t)=>(0,eO.jsxs)("div",{className:"msg-ai-meta-list-item",children:[(0,eO.jsx)(ei,{color:"gold",children:e.element}),(0,eO.jsx)("span",{children:e.action})]},t))})]})]})})]})]},e.id)})})}),tK=t.div`
|
|
636
636
|
display: flex;
|
|
637
637
|
flex-direction: column;
|
|
638
638
|
height: 100%;
|
|
@@ -417,7 +417,7 @@
|
|
|
417
417
|
.conversation-list li small {
|
|
418
418
|
white-space: nowrap;
|
|
419
419
|
}
|
|
420
|
-
`,eY=[],e_="bi-design",eq=e=>{let t,l,n,r,a,i,o,{agentList:s=eY,headExtra:u,style:p={},onEffect:x}=e,{pageId:h,schema:g,fetch:v,atItems:j,onRemoveAtItem:b}=(0,c.useContext)(f);if(!v)return null;let[y,w]=(0,c.useState)(null),[C,S]=(0,c.useState)([]),[I,k]=(0,c.useState)([]),z=m().useRef(null),O=()=>{setTimeout(()=>{z.current&&z.current.scrollToBottom()},100)},N=()=>{w(null),k([])},T=async e=>{ep.Modal.confirm({title:"确认删除该对话吗?",okText:"确认",cancelText:"取消",onOk:async()=>{var t;await (null==(t=v.ai)?void 0:t.removeConversation(e)),S(t=>t.filter(t=>t.id!==e)),k(t=>t.filter(t=>t.conversationId!==e)),y===e&&N()}})},R=async e=>{var t;w(e),S(t=>t.map(t=>({...t,isActived:t.id===e}))),k(await (null==(t=v.ai)?void 0:t.messageList(e))||[]),O()},F=async e=>{var t;let l={id:eO(),question:e.message,createdAt:new Date().toISOString(),files:e.files||[],agents:e.agents||[],atItems:j,sending:!0};k(e=>[...e,l]),O();let n=!y,{id:r,answer:a,createdAt:i,conversation:o}=await (null==(t=v.ai)?void 0:t.chat(e_,h,y,{...e,page:JSON.stringify(g),pageItems:JSON.stringify(j||[])}));w((null==o?void 0:o.id)||""),S(e=>[n?o||{}:null,...e].filter(e=>null!==e)),Object.assign(l,{id:r,answer:a,createdAt:i,conversationId:(null==o?void 0:o.id)||"",sending:!1}),a.effect&&(null==x||x(a.effect)),k(e=>[...e]),O()},D=async e=>{var t;await (null==(t=v.ai)?void 0:t.removeMessage(e)),k(t=>t.filter(t=>t.id!==e))},E=(t=new Date,l=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),(n=new Date(t)).setDate(t.getDate()-1),r=[],a=[],i=[],o=[],C.forEach(e=>{let s=new Date(e.createdAt);if(l(s,t))r.push(e);else if(l(s,n))a.push(e);else s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()?i.push(e):o.push(e)}),[{title:"今天",items:r},{title:"昨天",items:a},{title:"本月内",items:i},{title:"很久以前",items:o}].filter(e=>e.items.length>0)),A=async()=>{try{var e,t;let l=await (null==(e=v.ai)?void 0:e.conversationList(e_,h));S(l||[]);let n=null==l?void 0:l.find(e=>e.isActived);if(n){w(n.id);let e=await (null==(t=v.ai)?void 0:t.messageList(n.id));k(e||[]),O()}}catch(e){console.error(e)}};return(0,c.useEffect)(()=>{A()},[v]),(0,c.useEffect)(()=>{O()},[]),(0,d.jsxs)(e$,{style:p,children:[(0,d.jsx)(eL,{title:"智能助理",extra:(0,d.jsxs)(ep.Space,{children:[(0,d.jsx)(ep.Tooltip,{title:"新对话",placement:"topRight",children:(0,d.jsx)("a",{onClick:N,children:(0,d.jsx)(eu,{type:"icon-chat-plus"})})}),(0,d.jsx)(ep.Dropdown,{trigger:["click"],styles:{root:{boxShadow:"var(--ant-box-shadow-drawer-up)",backgroundColor:"#ffffff",borderRadius:"var(--ant-border-radius)"}},popupRender:()=>(0,d.jsx)(eU,{children:E.map(e=>(0,d.jsxs)("div",{className:"group",children:[(0,d.jsx)("div",{className:"group-title",children:e.title}),(0,d.jsx)("ul",{className:"group-list",children:e.items.map(e=>(0,d.jsxs)("li",{className:e.isActived?"actived":"",children:[(0,d.jsx)("a",{onClick:()=>R(e.id),children:e.name}),(0,d.jsx)("small",{children:(0,d.jsx)("a",{onClick:()=>T(e.id),children:(0,d.jsx)(ed.DeleteOutlined,{})})})]},e.id))})]},e.title))}),placement:"topRight",children:(0,d.jsx)("a",{children:(0,d.jsx)(ed.HistoryOutlined,{})})}),u]}),style:{width:"initial"}}),(0,d.jsxs)("div",{className:"body",children:[(0,d.jsx)("div",{style:{flex:"1 1 auto",overflowY:"auto"},children:I.length?(0,d.jsx)(eK,{ref:z,list:I,onDeleteMessage:D}):(0,d.jsx)(eG,{})}),0===I.length&&C.length>0&&(0,d.jsx)(ep.Card,{title:"历史记录",size:"small",variant:"borderless",styles:{header:{padding:0,border:"none"},body:{padding:0}},style:{padding:"12px 12px 0 12px"},children:(0,d.jsx)("ul",{className:"conversation-list",children:C.slice(0,3).map(e=>(0,d.jsxs)("li",{children:[(0,d.jsxs)("a",{children:[(0,d.jsx)(ed.MessageOutlined,{}),e.name]}),(0,d.jsx)("small",{children:eN(e.createdAt)})]},e.id))})}),(0,d.jsx)(eM,{agentList:s,style:{padding:12},atItems:j,onUploading:null==v?void 0:v.upload,onSubmit:F,onRemoveAtItem:b})]})]})},eH=h().div`
|
|
420
|
+
`,eY=[],e_="bi-design",eq=e=>{let t,l,n,r,a,i,o,{agentList:s=eY,headExtra:u,style:p={},onEffect:x}=e,{pageId:h,schema:g,fetch:v,atItems:j,onRemoveAtItem:b}=(0,c.useContext)(f);if(!v)return null;let[y,w]=(0,c.useState)(null),[C,S]=(0,c.useState)([]),[I,k]=(0,c.useState)([]),z=m().useRef(null),O=()=>{setTimeout(()=>{z.current&&z.current.scrollToBottom()},100)},N=()=>{w(null),k([])},T=async e=>{ep.Modal.confirm({title:"确认删除该对话吗?",okText:"确认",cancelText:"取消",onOk:async()=>{var t;await (null==(t=v.ai)?void 0:t.removeConversation(e)),S(t=>t.filter(t=>t.id!==e)),k(t=>t.filter(t=>t.conversationId!==e)),y===e&&N()}})},R=async e=>{var t;w(e),S(t=>t.map(t=>({...t,isActived:t.id===e}))),k(await (null==(t=v.ai)?void 0:t.messageList(e))||[]),O()},F=async e=>{var t;let l={id:eO(),question:e.message,createdAt:new Date().toISOString(),files:e.files||[],agents:e.agents||[],atItems:JSON.stringify(j),sending:!0};k(e=>[...e,l]),O();let n=!y,{id:r,answer:a,createdAt:i,conversation:o}=await (null==(t=v.ai)?void 0:t.chat(e_,h,y,{...e,page:JSON.stringify(g),pageItems:JSON.stringify(j||[])}));w((null==o?void 0:o.id)||""),S(e=>[n?o||{}:null,...e].filter(e=>null!==e)),Object.assign(l,{id:r,answer:a,createdAt:i,conversationId:(null==o?void 0:o.id)||"",sending:!1}),a.effect&&(null==x||x(a.effect)),k(e=>[...e]),O()},D=async e=>{var t;await (null==(t=v.ai)?void 0:t.removeMessage(e)),k(t=>t.filter(t=>t.id!==e))},E=(t=new Date,l=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),(n=new Date(t)).setDate(t.getDate()-1),r=[],a=[],i=[],o=[],C.forEach(e=>{let s=new Date(e.createdAt);if(l(s,t))r.push(e);else if(l(s,n))a.push(e);else s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()?i.push(e):o.push(e)}),[{title:"今天",items:r},{title:"昨天",items:a},{title:"本月内",items:i},{title:"很久以前",items:o}].filter(e=>e.items.length>0)),A=async()=>{try{var e,t;let l=await (null==(e=v.ai)?void 0:e.conversationList(e_,h));S(l||[]);let n=null==l?void 0:l.find(e=>e.isActived);if(n){w(n.id);let e=await (null==(t=v.ai)?void 0:t.messageList(n.id));k(e||[]),O()}}catch(e){console.error(e)}};return(0,c.useEffect)(()=>{A()},[v]),(0,c.useEffect)(()=>{O()},[]),(0,d.jsxs)(e$,{style:p,children:[(0,d.jsx)(eL,{title:"智能助理",extra:(0,d.jsxs)(ep.Space,{children:[(0,d.jsx)(ep.Tooltip,{title:"新对话",placement:"topRight",children:(0,d.jsx)("a",{onClick:N,children:(0,d.jsx)(eu,{type:"icon-chat-plus"})})}),(0,d.jsx)(ep.Dropdown,{trigger:["click"],styles:{root:{boxShadow:"var(--ant-box-shadow-drawer-up)",backgroundColor:"#ffffff",borderRadius:"var(--ant-border-radius)"}},popupRender:()=>(0,d.jsx)(eU,{children:E.map(e=>(0,d.jsxs)("div",{className:"group",children:[(0,d.jsx)("div",{className:"group-title",children:e.title}),(0,d.jsx)("ul",{className:"group-list",children:e.items.map(e=>(0,d.jsxs)("li",{className:e.isActived?"actived":"",children:[(0,d.jsx)("a",{onClick:()=>R(e.id),children:e.name}),(0,d.jsx)("small",{children:(0,d.jsx)("a",{onClick:()=>T(e.id),children:(0,d.jsx)(ed.DeleteOutlined,{})})})]},e.id))})]},e.title))}),placement:"topRight",children:(0,d.jsx)("a",{children:(0,d.jsx)(ed.HistoryOutlined,{})})}),u]}),style:{width:"initial"}}),(0,d.jsxs)("div",{className:"body",children:[(0,d.jsx)("div",{style:{flex:"1 1 auto",overflowY:"auto"},children:I.length?(0,d.jsx)(eK,{ref:z,list:I,onDeleteMessage:D}):(0,d.jsx)(eG,{})}),0===I.length&&C.length>0&&(0,d.jsx)(ep.Card,{title:"历史记录",size:"small",variant:"borderless",styles:{header:{padding:0,border:"none"},body:{padding:0}},style:{padding:"12px 12px 0 12px"},children:(0,d.jsx)("ul",{className:"conversation-list",children:C.slice(0,3).map(e=>(0,d.jsxs)("li",{children:[(0,d.jsxs)("a",{children:[(0,d.jsx)(ed.MessageOutlined,{}),e.name]}),(0,d.jsx)("small",{children:eN(e.createdAt)})]},e.id))})}),(0,d.jsx)(eM,{agentList:s,style:{padding:12},atItems:j,onUploading:null==v?void 0:v.upload,onSubmit:F,onRemoveAtItem:b})]})]})},eH=h().div`
|
|
421
421
|
flex: 1 1 auto;
|
|
422
422
|
display: flex;
|
|
423
423
|
align-items: center;
|
|
@@ -632,7 +632,7 @@
|
|
|
632
632
|
}
|
|
633
633
|
}
|
|
634
634
|
}
|
|
635
|
-
`,eK=(0,c.forwardRef)((e,t)=>{let{list:l,onDeleteMessage:n}=e,r=(0,c.useRef)(null),a=()=>{setTimeout(()=>{r.current&&(r.current.scrollTop=r.current.scrollHeight)},100)};return(0,c.useImperativeHandle)(t,()=>({scrollToBottom:a})),(0,d.jsx)(eJ,{className:"message-list beautified_scrollbar",ref:r,children:l.map(e=>{var t,l,r,a,i,o,s,c,u,p;return(0,d.jsxs)("div",{className:"msg",children:[(0,d.jsxs)("div",{className:"user-message",children:[(0,d.jsx)("div",{className:"msg-header",children:(0,d.jsx)("span",{children:eN(e.createdAt)})}),(0,d.jsxs)("div",{className:"msg-section",children:[(0,d.jsxs)(ep.Space,{size:4,orientation:"vertical",className:"msg-tools",children:[(0,d.jsx)(ep.Typography.Text,{copyable:{text:e.question,tooltips:"复制"}}),(0,d.jsx)(ep.Popconfirm,{title:"确认删除吗?",okText:"确认",cancelText:"取消",onConfirm:()=>n(e.id),children:(0,d.jsx)(ep.Tooltip,{title:"删除",children:(0,d.jsx)(ep.Button,{type:"link",size:"small",icon:(0,d.jsx)(ed.DeleteOutlined,{})})})})]}),(0,d.jsx)("div",{className:"msg-content",children:e.question}),(null==(t=e.files)?void 0:t.length)||(null==(l=e.agents)?void 0:l.length)||(null==(r=e.atItems)?void 0:r.length)?(0,d.jsxs)("div",{className:"msg-meta",children:[null==(a=e.files)?void 0:a.map(e=>(0,d.jsxs)(ep.Tag,{color:"processing",children:[(0,d.jsx)(eu,{type:"icon-paper-clip"})," ",e.name]},e.id)),null==(i=e.agents)?void 0:i.map(e=>(0,d.jsxs)(ep.Tag,{color:"blue",children:[(0,d.jsx)(eu,{type:"icon-at"})," ",e.name]},e.id)),(e=>{try{return JSON.parse(e||"[]")}catch(e){return[]}})(e.atItems).map(e=>(0,d.jsxs)(ep.Tag,{color:"blue",children:[(0,d.jsx)(eu,{type:"icon-number"})," ",e.name]},e.id))]}):null]})]}),(0,d.jsxs)("div",{className:"assistant-message",children:[(0,d.jsx)("div",{className:"msg-header",children:(0,d.jsxs)("span",{className:"msg-title",children:[(0,d.jsx)(ed.RobotOutlined,{})," 智能助理"]})}),(0,d.jsx)("div",{className:"msg-section",children:e.sending?(0,d.jsx)(ep.Skeleton,{active:!0}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"msg-content",children:(null==(o=e.answer)?void 0:o.answer)||""}),!!(null==(c=e.answer)||null==(s=c.plans)?void 0:s.length)&&(0,d.jsxs)("details",{className:"msg-ai-meta",open:!0,children:[(0,d.jsx)("summary",{className:"msg-ai-meta-title",children:"PLANS:"}),(0,d.jsx)("div",{className:"msg-ai-meta-list",children:e.answer.plans.map((e,t)=>(0,d.jsx)(ep.Tooltip,{title:e.description,children:(0,d.jsx)(ep.Tag,{color:"blue",children:e.name})},t))})]}),!!(null==(p=e.answer)||null==(u=p.extra)?void 0:u.length)&&(0,d.jsxs)("details",{className:"msg-ai-meta",open:!0,children:[(0,d.jsx)("summary",{className:"msg-ai-meta-title",children:"ACTIONS:"}),(0,d.jsx)("div",{className:"msg-ai-meta-list vertical",children:e.answer.extra.map((e,t)=>(0,d.jsxs)("div",{className:"msg-ai-meta-list-item",children:[(0,d.jsx)(ep.Tag,{color:"gold",children:e.element}),(0,d.jsx)("span",{children:e.action})]},t))})]})]})})]})]},e.id)})})}),eW=h().div`
|
|
635
|
+
`,eK=(0,c.forwardRef)((e,t)=>{let{list:l,onDeleteMessage:n}=e,r=(0,c.useRef)(null),a=()=>{setTimeout(()=>{r.current&&(r.current.scrollTop=r.current.scrollHeight)},100)};return(0,c.useImperativeHandle)(t,()=>({scrollToBottom:a})),(0,d.jsx)(eJ,{className:"message-list beautified_scrollbar",ref:r,children:l.map(e=>{var t,l,r,a,i,o,s,c,u,p;return(0,d.jsxs)("div",{className:"msg",children:[(0,d.jsxs)("div",{className:"user-message",children:[(0,d.jsx)("div",{className:"msg-header",children:(0,d.jsx)("span",{children:eN(e.createdAt)})}),(0,d.jsxs)("div",{className:"msg-section",children:[(0,d.jsxs)(ep.Space,{size:4,orientation:"vertical",className:"msg-tools",children:[(0,d.jsx)(ep.Typography.Text,{copyable:{text:e.question,tooltips:"复制"}}),(0,d.jsx)(ep.Popconfirm,{title:"确认删除吗?",okText:"确认",cancelText:"取消",onConfirm:()=>n(e.id),children:(0,d.jsx)(ep.Tooltip,{title:"删除",children:(0,d.jsx)(ep.Button,{type:"link",size:"small",icon:(0,d.jsx)(ed.DeleteOutlined,{})})})})]}),(0,d.jsx)("div",{className:"msg-content",children:e.question}),(null==(t=e.files)?void 0:t.length)||(null==(l=e.agents)?void 0:l.length)||(null==(r=e.atItems)?void 0:r.length)?(0,d.jsxs)("div",{className:"msg-meta",children:[null==(a=e.files)?void 0:a.map(e=>(0,d.jsxs)(ep.Tag,{color:"processing",children:[(0,d.jsx)(eu,{type:"icon-paper-clip"})," ",e.name]},e.id)),null==(i=e.agents)?void 0:i.map(e=>(0,d.jsxs)(ep.Tag,{color:"blue",children:[(0,d.jsx)(eu,{type:"icon-at"})," ",e.name]},e.id)),(e=>{try{if(e){if("object"==typeof e)return e;else if("string"==typeof e)return JSON.parse(e||"[]")}return[]}catch(e){return[]}})(e.atItems).map(e=>(0,d.jsxs)(ep.Tag,{color:"blue",children:[(0,d.jsx)(eu,{type:"icon-number"})," ",e.name]},e.id))]}):null]})]}),(0,d.jsxs)("div",{className:"assistant-message",children:[(0,d.jsx)("div",{className:"msg-header",children:(0,d.jsxs)("span",{className:"msg-title",children:[(0,d.jsx)(ed.RobotOutlined,{})," 智能助理"]})}),(0,d.jsx)("div",{className:"msg-section",children:e.sending?(0,d.jsx)(ep.Skeleton,{active:!0}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)("div",{className:"msg-content",children:(null==(o=e.answer)?void 0:o.answer)||""}),!!(null==(c=e.answer)||null==(s=c.plans)?void 0:s.length)&&(0,d.jsxs)("details",{className:"msg-ai-meta",open:!0,children:[(0,d.jsx)("summary",{className:"msg-ai-meta-title",children:"PLANS:"}),(0,d.jsx)("div",{className:"msg-ai-meta-list",children:e.answer.plans.map((e,t)=>(0,d.jsx)(ep.Tooltip,{title:e.description,children:(0,d.jsx)(ep.Tag,{color:"blue",children:e.name})},t))})]}),!!(null==(p=e.answer)||null==(u=p.extra)?void 0:u.length)&&(0,d.jsxs)("details",{className:"msg-ai-meta",open:!0,children:[(0,d.jsx)("summary",{className:"msg-ai-meta-title",children:"ACTIONS:"}),(0,d.jsx)("div",{className:"msg-ai-meta-list vertical",children:e.answer.extra.map((e,t)=>(0,d.jsxs)("div",{className:"msg-ai-meta-list-item",children:[(0,d.jsx)(ep.Tag,{color:"gold",children:e.element}),(0,d.jsx)("span",{children:e.action})]},t))})]})]})})]})]},e.id)})})}),eW=h().div`
|
|
636
636
|
display: flex;
|
|
637
637
|
flex-direction: column;
|
|
638
638
|
height: 100%;
|
package/package.json
CHANGED
|
@@ -156,7 +156,7 @@ export const AiPanel: React.FC<AiPanelProps> = ({
|
|
|
156
156
|
createdAt: new Date().toISOString(),
|
|
157
157
|
files: data.files || [],
|
|
158
158
|
agents: data.agents || [],
|
|
159
|
-
atItems,
|
|
159
|
+
atItems: JSON.stringify(atItems),
|
|
160
160
|
sending: true,
|
|
161
161
|
} as ChatMessageType;
|
|
162
162
|
setMessageList((list) => [...list, questionMessage]);
|
|
@@ -635,7 +635,14 @@ const MessageList = forwardRef<
|
|
|
635
635
|
|
|
636
636
|
const parseAtItems = (atItems?: string | null) => {
|
|
637
637
|
try {
|
|
638
|
-
|
|
638
|
+
if (!atItems) {
|
|
639
|
+
return [];
|
|
640
|
+
} else if (typeof atItems === "object") {
|
|
641
|
+
return atItems;
|
|
642
|
+
} else if (typeof atItems === "string") {
|
|
643
|
+
return JSON.parse(atItems || "[]");
|
|
644
|
+
}
|
|
645
|
+
return [];
|
|
639
646
|
} catch (error) {
|
|
640
647
|
return [];
|
|
641
648
|
}
|