Files
weiyu/deploy/server/admin/1896.0aebb027.async.js
jack ning 543d82b05d update
2025-07-26 20:01:33 +08:00

1 line
46 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use strict";(self.webpackChunkadmin=self.webpackChunkadmin||[]).push([[1896],{69740:function(e,n,r){r.d(n,{Jr:function(){return p},LF:function(){return d},Oh:function(){return h},WS:function(){return v}});var t=r(90819),o=r.n(t),l=r(73193),a=r.n(l),i=r(89933),s=r.n(i),c=r(25191),u=r(75699);function d(e){return m.apply(this,arguments)}function m(){return(m=s()(o()().mark((function e(n){return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,u.request)("/api/v1/model/query/org",{method:"GET",params:a()(a()({},n),{},{channel:c.XtJ})}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function p(e){return f.apply(this,arguments)}function f(){return(f=s()(o()().mark((function e(n){return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,u.request)("/api/v1/model/create",{method:"POST",data:a()(a()({},n),{},{channel:c.XtJ})}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function v(e){return g.apply(this,arguments)}function g(){return(g=s()(o()().mark((function e(n){return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,u.request)("/api/v1/model/update",{method:"POST",data:a()(a()({},n),{},{channel:c.XtJ})}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function h(e){return x.apply(this,arguments)}function x(){return(x=s()(o()().mark((function e(n){return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,u.request)("/api/v1/model/delete",{method:"POST",data:a()(a()({},n),{},{channel:c.XtJ})}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}},48750:function(e,n,r){r.d(n,{G9:function(){return w},J$:function(){return P},N6:function(){return y},VM:function(){return c},c8:function(){return d},gF:function(){return v},rg:function(){return p},sF:function(){return h}});var t=r(90819),o=r.n(t),l=r(89933),a=r.n(l),i=r(25191),s=r(75699);function c(){return u.apply(this,arguments)}function u(){return(u=a()(o()().mark((function e(){return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,s.request)("/api/v1/ollama4j/ping",{method:"GET",params:{channel:i.XtJ}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function d(){return m.apply(this,arguments)}function m(){return(m=a()(o()().mark((function e(){return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,s.request)("/api/v1/ollama4j/local-models",{method:"GET",params:{channel:i.XtJ}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function p(){return f.apply(this,arguments)}function f(){return(f=a()(o()().mark((function e(){return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,s.request)("/api/v1/ollama4j/models",{method:"GET",params:{channel:i.XtJ}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function v(e){return g.apply(this,arguments)}function g(){return(g=a()(o()().mark((function e(n){return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,s.request)("/api/v1/ollama4j/library/models/"+n+"/details",{method:"GET",params:{channel:i.XtJ}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function h(e){return x.apply(this,arguments)}function x(){return(x=a()(o()().mark((function e(n){return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,s.request)("/api/v1/ollama4j/models/"+n+"/details",{method:"GET",params:{channel:i.XtJ}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function y(e){return j.apply(this,arguments)}function j(){return(j=a()(o()().mark((function e(n){return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,s.request)("/api/v1/ollama4j/models/pull",{method:"POST",params:{channel:i.XtJ},data:{model:n}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function w(e){return Z.apply(this,arguments)}function Z(){return(Z=a()(o()().mark((function e(n){return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,s.request)("/api/v1/ollama4j/models/delete",{method:"POST",params:{channel:i.XtJ},data:{model:n}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function P(e){return k.apply(this,arguments)}function k(){return(k=a()(o()().mark((function e(n){return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,s.request)("/api/v1/ollama4j/embedding-model/exists",{method:"GET",params:{channel:i.XtJ,model:n}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}},35151:function(e,n,r){var t=r(90819),o=r.n(t),l=r(89933),a=r.n(l),i=r(45332),s=r.n(i),c=r(44194),u=r(97153),d=r(31756),m=r(52544),p=r(30234),f=r(75699),v=r(35129),g=r(87791),h=r(77407),x=r(19193),y=r(89176),j=r(31881),w=r(25191),Z=r(83381),P=r(52312),k=r(10324),b=r(63521),M=r(31549);n.Z=function(e){var n,r,t=e.level,l=(0,m.Z)().isDarkMode,i=(0,f.useIntl)(),L=(0,p.Z)(),C=L.translateString,S=L.translateStringTranct,I=(0,j.u)((function(e){return e.currentOrg})),T=(0,c.useState)(!1),q=s()(T,2),R=q[0],O=q[1],E=(0,c.useState)(!1),F=s()(E,2),z=F[0],U=(F[1],(0,P.A)((function(e){return{llmproviderResult:e.llmproviderResult,currentLlmProvider:e.currentLlmProvider,setLlmProviderResult:e.setLlmProviderResult,insertLlmProvider:e.insertLlmProvider,setCurrentLlmProvider:e.setCurrentLlmProvider,upgradeLlmProvider:e.upgradeLlmProvider,deleteCurrentLlmProvider:e.deleteCurrentLlmProvider}}))),N=U.llmproviderResult,D=U.currentLlmProvider,K=U.setLlmProviderResult,J=U.insertLlmProvider,A=U.setCurrentLlmProvider,_=U.upgradeLlmProvider,H=U.deleteCurrentLlmProvider,X=(0,b.$)((function(e){return{llmproviderResultPlatform:e.llmproviderResultPlatform,currentLlmProviderPlatform:e.currentLlmProviderPlatform,setLlmProviderResultPlatform:e.setLlmProviderResultPlatform,insertLlmProviderPlatform:e.insertLlmProviderPlatform,setCurrentLlmProviderPlatform:e.setCurrentLlmProviderPlatform,upgradeLlmProviderPlatform:e.upgradeLlmProviderPlatform,deleteCurrentLlmProviderPlatform:e.deleteCurrentLlmProviderPlatform}})),G=X.llmproviderResultPlatform,B=X.currentLlmProviderPlatform,V=X.setLlmProviderResultPlatform,Y=X.insertLlmProviderPlatform,Q=X.setCurrentLlmProviderPlatform,W=X.upgradeLlmProviderPlatform,$=X.deleteCurrentLlmProviderPlatform,ee=(0,c.useState)(t===w.Hxq),ne=s()(ee,1)[0],re=ne?B:D,te=v.Z.useModal(),oe=s()(te,2),le=oe[0],ae=oe[1],ie=function(){var e=a()(o()().mark((function e(n){var r;return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("delete robot",n),d.yw.loading(i.formatMessage({id:"deleting",defaultMessage:"Deleting"})),e.next=4,(0,u.HH)(n);case 4:r=e.sent,console.log("delete robot response",r),200===r.code?(d.yw.destroy(),d.yw.success(i.formatMessage({id:"delete.success",defaultMessage:"Delete success"})),ne?$(n.uid):H(n.uid)):(d.yw.destroy(),d.yw.error(r.message));case 7:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),se=function(){var e=a()(o()().mark((function e(){var n,r,l,a,i,s;return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("getLlmProviders"),n={pageNumber:0,pageSize:50,sortBy:"createdAt",sortDirection:"ascend",status:t===w.Hxq?"":w.KY,orgUid:t===w.Hxq?"":null==I?void 0:I.uid,level:t},e.next=4,(0,u.mK)(n);case 4:r=e.sent,console.log("queryLlmProvidersByOrg: ",r),200===r.code?ne?(V(r),(null==r||null===(l=r.data)||void 0===l?void 0:l.content.length)>0&&Q(null==r||null===(a=r.data)||void 0===a?void 0:a.content[0])):(K(r),(null==r||null===(i=r.data)||void 0===i?void 0:i.content.length)>0&&A(null==r||null===(s=r.data)||void 0===s?void 0:s.content[0])):d.yw.error(r.message);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();(0,c.useEffect)((function(){se()}),[]);var ce=function(){var e=a()(o()().mark((function e(n){var r;return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("createLlmProvider",n),d.yw.loading(i.formatMessage({id:"creating"})),e.next=4,(0,u.T)(n);case 4:r=e.sent,console.log("createLlmProvider:",r),200===r.code?(d.yw.destroy(),d.yw.success(i.formatMessage({id:"create.success",defaultMessage:"create success"})),ne?Y(r.data):J(r.data),O(!1)):(d.yw.destroy(),d.yw.error(r.message));case 7:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),ue=function(){var e=a()(o()().mark((function e(n){var r;return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return d.yw.loading(i.formatMessage({id:"updating"})),e.next=3,(0,u.fx)(n);case 3:r=e.sent,console.log("updateLlmProvider:",n,r),200===r.code?(d.yw.destroy(),d.yw.success(i.formatMessage({id:"update.success",defaultMessage:"update success"})),ne?W(r.data):_(r.data),O(!1)):(d.yw.destroy(),d.yw.error(r.message));case 6:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}();return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)("div",{style:{margin:10},children:(0,M.jsxs)(g.Z,{gap:"small",align:"flex-start",children:[!1,(0,M.jsx)(h.ZP,{onClick:function(){return function(e){le.confirm({title:i.formatMessage({id:"deleteTip"}),icon:(0,M.jsx)(Z.Z,{}),content:"".concat(i.formatMessage({id:"deleteAffirm",defaultMessage:"Delete"}),"【").concat(C(e.nickname),"】?"),onOk:function(){ie(e)},onCancel:function(){},okText:i.formatMessage({id:"ok"}),cancelText:i.formatMessage({id:"cancel"})})}(re)},size:"small",style:{float:"right"},danger:!0,disabled:""===(null==re?void 0:re.uid),children:i.formatMessage({id:"pages.robot.delete",defaultMessage:"Delete"})})]})}),(0,M.jsx)(x.Z,{itemLayout:"horizontal",dataSource:ne?(null==G||null===(n=G.data)||void 0===n?void 0:n.content)||[]:(null==N||null===(r=N.data)||void 0===r?void 0:r.content)||[],renderItem:function(e,n){return(0,M.jsx)(x.Z.Item,{style:(null==re?void 0:re.uid)===e.uid?{backgroundColor:l?"#333333":"#dddddd",cursor:"pointer"}:{cursor:"pointer"},onClick:function(){return n=e,void(ne?Q(n):A(n));var n},children:(0,M.jsx)(x.Z.Item.Meta,{style:{marginLeft:"10px"},avatar:(0,M.jsx)(y.Z,{src:e.logo}),title:(0,M.jsx)(M.Fragment,{children:S(null==e?void 0:e.nickname)}),description:(null==e?void 0:e.status)===w.KY?"上线发布":"未上线"})})}}),R&&(0,M.jsx)(k.Z,{open:R,isEdit:z,level:t,llmProvider:re,onCancel:function(){O(!1)},onSubmit:function(e){z?ue(e):ce(e)}}),ae]})}},47400:function(e,n,r){r.d(n,{Z:function(){return he}});var t=r(76711),o=r.n(t),l=r(45332),a=r.n(l),i=r(44194),s=r(96154),c=r(73193),u=r.n(c),d=r(86222),m=r.n(d),p=r(90819),f=r.n(p),v=r(89933),g=r.n(v),h=r(31756),x=r(69740),y=r(31881),j=r(25191),w=r(47454),Z=r(35129),P=r(89176),k=r(77407),b=r(38862),M=r(38478),L=r(43413),C=r(19193),S=r(55738),I=r(6373),T=r(22766),q=r(12581),R=r(31051),O=r(24418),E=r(75699),F=r(31549),z=function(e){var n=e.isEdit,r=e.llmmodel,t=e.provider,o=e.open,l=e.level,s=e.onClose,c=e.onSubmit,u=I.A.useForm(),d=a()(u,1)[0],m=(0,E.useIntl)(),p=(0,y.u)((function(e){return e.currentOrg})),f=[{label:m.formatMessage({id:"model.type.text"}),value:j.l55},{label:m.formatMessage({id:"model.type.embedding"}),value:j.xTq},{label:m.formatMessage({id:"model.type.rerank"}),value:j.SeQ},{label:m.formatMessage({id:"model.type.vision"}),value:j.xZ8},{label:m.formatMessage({id:"model.type.code"}),value:j.rrk},{label:m.formatMessage({id:"model.type.reasoning"}),value:j.GNM},{label:m.formatMessage({id:"model.type.text2image"}),value:j.eQL},{label:m.formatMessage({id:"model.type.image2text"}),value:j.ztv},{label:m.formatMessage({id:"model.type.audio2text"}),value:j._D8},{label:m.formatMessage({id:"model.type.text2audio"}),value:j.YNO},{label:m.formatMessage({id:"model.type.text2video"}),value:j.GZK},{label:m.formatMessage({id:"model.type.video2text"}),value:j.B6M}];(0,i.useEffect)((function(){n&&r&&d?d.setFieldsValue({uid:null==r?void 0:r.uid,name:null==r?void 0:r.name,nickname:null==r?void 0:r.nickname,description:null==r?void 0:r.description,type:null==r?void 0:r.type}):(console.log("form resetFields"),d.resetFields(),d.setFieldValue("type",j.l55))}),[r]);return(0,i.useEffect)((function(){}),[r]),(0,F.jsx)("div",{children:(0,F.jsx)(O.Z,{title:n?m.formatMessage({id:"model.edit"}):m.formatMessage({id:"model.create"}),width:600,onClose:s,open:o,extra:(0,F.jsxs)(L.Z,{children:[(0,F.jsx)(k.ZP,{onClick:s,children:m.formatMessage({id:"cancel"})}),(0,F.jsx)(k.ZP,{onClick:function(){console.log("handleSubmit"),d.validateFields().then((function(e){console.log("Form values:",e);var o={uid:n?null==r?void 0:r.uid:"",name:e.name,nickname:e.nickname,description:e.description,type:e.type,providerUid:null==t?void 0:t.uid,providerName:null==t?void 0:t.name,level:l,orgUid:null==p?void 0:p.uid};console.log("llmmodelObject:",o),c(o)})).catch((function(e){console.log("Form errors:",e)}))},type:"primary",children:m.formatMessage({id:"ok"})})]}),children:(0,F.jsxs)(I.A,{form:d,name:"model",submitter:!1,children:[(0,F.jsx)(T.Z,{label:m.formatMessage({id:"model.name"}),name:"name"}),(0,F.jsx)(T.Z,{label:m.formatMessage({id:"model.nickname"}),name:"nickname"}),(0,F.jsx)(q.Z,{label:m.formatMessage({id:"model.description"}),name:"description",placeholder:m.formatMessage({id:"model.description.placeholder"}),fieldProps:{rows:3,maxLength:500,showCount:!0}}),(0,F.jsx)(R.Z,{label:m.formatMessage({id:"model.type"}),name:"type",options:f,placeholder:m.formatMessage({id:"model.type.placeholder"}),rules:[{required:!0,message:m.formatMessage({id:"model.type.required"})}]})]})})})},U=r(83381),N=r(28031),D=r(6992),K=r(17194),J=r(35911),A=r(97153),_=r(52544),H=r(30234),X=r(52312),G=r(10324),B=r(43443),V=r(3867),Y=r(68525),Q=S.Z.Text,W=function(e){var n=e.provider,r=e.open,t=(e.level,e.onClose),o=e.onSubmit,l=e.existingModels,s=void 0===l?[]:l,c=((0,E.useIntl)(),(0,i.useState)(!1)),u=a()(c,2),d=u[0],m=u[1],p=(0,i.useState)([]),v=a()(p,2),y=v[0],w=v[1],Z=(0,i.useState)([]),P=a()(Z,2),b=P[0],M=P[1],C=function(e){return s.some((function(n){return n.name===e.name}))},S=function(){var e=g()(f()().mark((function e(){var r,t,o,l;return f()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return m(!0),e.prev=1,r={pageNumber:0,pageSize:100,level:j.Hxq,providerName:n.name},e.next=5,(0,x.LF)(r);case 5:t=e.sent,console.log("获取平台模型列表:",t),200===t.code?(o=t.data.content||[],w(o),l=o.filter((function(e){return C(e)})).map((function(e){return e.uid})),M(l)):h.yw.error(t.message||"获取模型列表失败"),e.next=14;break;case 10:e.prev=10,e.t0=e.catch(1),console.error("获取平台模型异常:",e.t0),h.yw.error("获取模型列表异常");case 14:return e.prev=14,m(!1),e.finish(14);case 17:case"end":return e.stop()}}),e,null,[[1,10,14,17]])})));return function(){return e.apply(this,arguments)}}();(0,i.useEffect)((function(){r&&S()}),[r]);var I=[{title:"名称",dataIndex:"name",key:"name",render:function(e,n){return(0,F.jsxs)(L.Z,{children:[e,C(n)&&(0,F.jsx)(B.Z,{color:"green",children:"已存在"})]})}},{title:"别名",dataIndex:"nickname",key:"nickname"},{title:"描述",dataIndex:"description",key:"description",ellipsis:!0}],T={selectedRowKeys:b,onChange:function(e){M(e)}};return(0,F.jsxs)(O.Z,{title:"导入".concat(n.nickname,"模型"),width:700,open:r,onClose:t,destroyOnClose:!0,footer:(0,F.jsxs)(L.Z,{children:[(0,F.jsx)(k.ZP,{onClick:t,children:"取消"}),(0,F.jsxs)(k.ZP,{type:"primary",onClick:function(){if(0!==b.length){var e=y.filter((function(e){return b.includes(e.uid)}));o(e)}else h.yw.warning("请至少选择一个模型")},disabled:0===b.length,children:["导入已选(",b.length,")"]})]}),children:[(0,F.jsxs)(Q,{type:"secondary",children:["从平台已有的",n.nickname,"模型中选择并导入到当前组织",s.length>0&&(0,F.jsx)(Q,{type:"secondary",style:{marginLeft:8},children:"(已有标签的模型表示已导入到当前组织)"})]}),(0,F.jsx)("div",{style:{marginTop:16},children:(0,F.jsx)(V.Z,{spinning:d,children:(0,F.jsx)(Y.Z,{rowKey:"uid",columns:I,dataSource:y,pagination:{pageSize:10},rowSelection:T,size:"small"})})}),0===y.length&&!d&&(0,F.jsx)("div",{style:{textAlign:"center",margin:"20px 0"},children:(0,F.jsx)(Q,{type:"secondary",children:"没有找到可导入的平台模型"})})]})},$=function(e){var n=e.provider,r=e.level,t=(0,E.useIntl)(),o=(0,_.Z)().isDarkMode,l=(0,i.useState)(!0),s=a()(l,2),c=s[0],d=s[1],p=(0,H.Z)(),v=p.translateString,I=(p.translateStringTranct,(0,i.useState)()),T=a()(I,2),q=T[0],R=T[1],O=(0,i.useState)(!1),B=a()(O,2),V=B[0],Y=B[1],Q=(0,i.useState)(!1),$=a()(Q,2),ee=$[0],ne=$[1],re=(0,y.u)((function(e){return e.currentOrg})),te=(0,i.useState)([]),oe=a()(te,2),le=oe[0],ae=oe[1],ie=(0,X.A)((function(e){return e.upgradeLlmProvider})),se=Z.Z.useModal(),ce=a()(se,2),ue=ce[0],de=ce[1],me=(0,i.useState)(!1),pe=a()(me,2),fe=pe[0],ve=pe[1],ge=function(){var e=g()(f()().mark((function e(n){var r;return f()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("delete robot",n),h.yw.loading(t.formatMessage({id:"deleting",defaultMessage:"Deleting"})),e.next=4,(0,x.Oh)(n);case 4:r=e.sent,console.log("delete robot response",r),200===r.code?(h.yw.destroy(),h.yw.success(t.formatMessage({id:"delete.success",defaultMessage:"Delete success"})),he()):(h.yw.destroy(),h.yw.error(r.message));case 7:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),he=function(){var e=g()(f()().mark((function e(){var o,l;return f()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("requestModels"),ae([]),h.yw.loading(t.formatMessage({id:"loading",defaultMessage:"Loading"})),o={pageNumber:0,pageSize:50,providerUid:null==n?void 0:n.uid,orgUid:null==re?void 0:re.uid,level:r},e.next=6,(0,x.LF)(o);case 6:l=e.sent,console.log("queryLlmModelsByOrg: ",l,o),200===l.code?(ae(l.data.content),h.yw.destroy()):(h.yw.destroy(),h.yw.error(l.message));case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();(0,i.useEffect)((function(){he()}),[]);var xe=function(){Y(!1)},ye=function(){ne(!1)},je=function(){var e=g()(f()().mark((function e(n){var r,o;return f()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(console.log("handleSubmitDrawer:",n),!c){e.next=9;break}return e.next=4,(0,x.WS)(n);case 4:r=e.sent,console.log("updateLlmModel:",r.data),200===r.code?(h.yw.success(t.formatMessage({id:"update.success",defaultMessage:"update success"})),he(),xe()):h.yw.error(r.message),e.next=14;break;case 9:return e.next=11,(0,x.Jr)(n);case 11:o=e.sent,console.log("createLlmModel:",o.data),200===o.code?(h.yw.success(t.formatMessage({id:"create.success",defaultMessage:"create success"})),he(),xe()):h.yw.error(o.message);case 14:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),we=function(){var e=g()(f()().mark((function e(t){var o,l,a,i,s,c,u,d;return f()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(console.log("导入选中的模型:",t),t&&0!==t.length){e.next=5;break}return h.yw.warning("没有选择任何模型"),ye(),e.abrupt("return");case 5:if(o=le.map((function(e){return e.name})),l=t.filter((function(e){return!o.includes(e.name)})),0!==l.length){e.next=11;break}return h.yw.info("所选模型均已存在,无需重复导入"),ye(),e.abrupt("return");case 11:h.yw.loading("正在导入".concat(l.length,"个模型...")),e.prev=12,a=0,i=m()(l),e.prev=15,i.s();case 17:if((s=i.n()).done){e.next=27;break}return c=s.value,u={name:c.name,nickname:c.nickname,description:c.description,providerUid:n.uid,providerName:n.name,orgUid:null==re?void 0:re.uid,level:r},e.next=22,(0,x.Jr)(u);case 22:d=e.sent,console.log("createLlmModel:",d,u),200===d.code&&a++;case 25:e.next=17;break;case 27:e.next=32;break;case 29:e.prev=29,e.t0=e.catch(15),i.e(e.t0);case 32:return e.prev=32,i.f(),e.finish(32);case 35:h.yw.destroy(),a>0?(h.yw.success("成功导入".concat(a,"个模型")),he()):h.yw.warning("没有成功导入任何模型"),e.next=44;break;case 39:e.prev=39,e.t1=e.catch(12),console.error("导入模型出错:",e.t1),h.yw.destroy(),h.yw.error("导入模型失败");case 44:ye();case 45:case"end":return e.stop()}}),e,null,[[12,39],[15,29,32,35]])})));return function(n){return e.apply(this,arguments)}}(),Ze=function(){var e=g()(f()().mark((function e(r){var o,l;return f()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("handleUpdateProvider:",n),o=u()(u()({},n),{},{status:r?j.KY:j.L2A}),e.next=4,(0,A.fx)(o);case 4:l=e.sent,console.log("updateLlmProvider:",o,l),200===l.code?(h.yw.destroy(),h.yw.success(t.formatMessage({id:"update.success",defaultMessage:"update success"})),ie(l.data)):(h.yw.destroy(),h.yw.error(l.message));case 7:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),Pe=function(e,n){var r;console.log("list on delete",e),r=e,ue.confirm({title:t.formatMessage({id:"deleteTip"}),icon:(0,F.jsx)(U.Z,{}),content:"".concat(t.formatMessage({id:"deleteAffirm",defaultMessage:"Delete"}),"【").concat(v(r.nickname),"】?"),onOk:function(){ge(r)},onCancel:function(){},okText:t.formatMessage({id:"ok"}),cancelText:t.formatMessage({id:"cancel"})})},ke=function(){var e=g()(f()().mark((function e(n){var r;return f()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return h.yw.loading(t.formatMessage({id:"updating"})),e.next=3,(0,A.fx)(n);case 3:r=e.sent,console.log("updateLlmProvider:",n,r),200===r.code?(h.yw.destroy(),h.yw.success(t.formatMessage({id:"update.success",defaultMessage:"update success"})),ie(r.data),ve(!1)):(h.yw.destroy(),h.yw.error(r.message));case 6:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}();return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)("h1",{children:[(0,F.jsx)(P.Z,{src:null==n?void 0:n.logo}),null==n?void 0:n.nickname,(0,F.jsx)(k.ZP,{type:"text",icon:(0,F.jsx)(N.Z,{}),onClick:function(){window.open(null==n?void 0:n.webUrl,"_blank")}})]}),r===j.Hxq&&(0,F.jsx)(b.Z,{checkedChildren:"上线发布",unCheckedChildren:"下线调试",defaultChecked:(null==n?void 0:n.status)===j.KY,onChange:function(e){console.log("switch to ".concat(e)),Ze(e)}}),(0,F.jsx)(M.Z,{orientation:"left",children:"模型列表"}),(0,F.jsxs)(L.Z,{children:[(0,F.jsx)(k.ZP,{icon:(0,F.jsx)(D.Z,{}),type:"primary",onClick:function(){d(!1),Y(!0)},children:"添加模型"}),"ollama"!==n.name&&r===j.whQ&&(0,F.jsx)(k.ZP,{icon:(0,F.jsx)(K.Z,{}),onClick:function(){return ne(!0)},children:"导入模型"}),(0,F.jsx)(k.ZP,{icon:(0,F.jsx)(J.Z,{}),onClick:he,children:"刷新模型"})]}),(0,F.jsx)(C.Z,{itemLayout:"horizontal",style:{marginTop:10},dataSource:le,renderItem:function(e,n){return(0,F.jsx)(C.Z.Item,{style:(null==q?void 0:q.uid)===e.uid?{backgroundColor:o?"#333333":"#dddddd",cursor:"pointer"}:{cursor:"pointer"},onClick:function(){R(e)},actions:[(0,F.jsx)(k.ZP,{type:"link",onClick:function(){return n=e,console.log("list on edit",n),d(!0),void Y(!0);var n},children:t.formatMessage({id:"edit",defaultMessage:"Edit"})},"edit"),(0,F.jsx)(k.ZP,{type:"link",onClick:function(){return Pe(e)},children:t.formatMessage({id:"pages.robot.delete",defaultMessage:"Delete"})},"delete")],children:(0,F.jsx)(C.Z.Item.Meta,{style:{marginLeft:"15px"},title:(0,F.jsxs)(L.Z,{children:[(0,F.jsx)("span",{children:e.nickname}),(0,w.Rb)(e.type)]}),description:(0,F.jsxs)("div",{children:[(0,F.jsx)(S.Z.Text,{type:"secondary",children:e.name}),e.description&&(0,F.jsx)("div",{style:{marginTop:"4px"},children:(0,F.jsx)(S.Z.Text,{type:"secondary",ellipsis:{tooltip:e.description},children:e.description})})]})})})}}),V&&(0,F.jsx)(z,{isEdit:c,llmmodel:q,provider:n,open:V,level:r,onClose:xe,onSubmit:je}),ee&&(0,F.jsx)(W,{provider:n,open:ee,level:r,onClose:ye,onSubmit:we,existingModels:le}),fe&&(0,F.jsx)(G.Z,{open:fe,isEdit:c,level:r,llmProvider:n,onCancel:function(){return ve(!1)},onSubmit:ke}),de]})},ee=r(48750),ne=r(89348),re=r(34937),te=r(91768),oe=r(79640),le=r(44532),ae=r(59946),ie=r(32057),se=r(61629),ce=r(25950),ue=r(12715),de=r(16829),me=r(52382),pe=function(e){var n,r,t,o,l,s,c,u,d,m,p,f=e.visible,v=e.onClose,g=e.modelName,h=e.modelDetails,x=e.loading,y=e.onRefresh,j=e.onPull,w=e.onDelete,Z=(e.isRemoteModel,e.isLocalModel),P=e.pullingModelName,b=e.localModelNames,S=void 0===b?[]:b,I=(0,i.useState)(""),T=a()(I,2),q=T[0],R=T[1],E=h&&"model"in h&&"tags"in h,z=h&&"license"in h&&"modelfile"in h,U=S.includes(g);return(0,F.jsxs)(O.Z,{title:"模型详情 - ".concat(g),width:600,placement:"right",onClose:v,open:f,zIndex:1002,children:[x?(0,F.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"80%"},children:(0,F.jsx)(V.Z,{tip:"加载中...",spinning:!0,children:(0,F.jsx)("div",{style:{padding:"50px",backgroundColor:"rgba(0, 0, 0, 0.05)",borderRadius:"4px",minHeight:"200px"}})})}):h?(0,F.jsxs)(F.Fragment,{children:[E&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(se.Z,{bordered:!0,column:1,title:"基本信息",styles:{label:{width:"120px"}},children:[(0,F.jsx)(se.Z.Item,{label:"名称",children:(0,F.jsxs)(L.Z,{children:[(null===(n=h.model)||void 0===n?void 0:n.name)||g,U&&(0,F.jsx)(B.Z,{color:"success",children:"已安装"})]})}),(null===(r=h.model)||void 0===r?void 0:r.description)&&(0,F.jsx)(se.Z.Item,{label:"描述",children:h.model.description}),(null===(t=h.model)||void 0===t?void 0:t.lastUpdated)&&(0,F.jsx)(se.Z.Item,{label:"最后更新",children:h.model.lastUpdated}),(null===(o=h.model)||void 0===o?void 0:o.pullCount)&&(0,F.jsx)(se.Z.Item,{label:"下载次数",children:h.model.pullCount}),(null===(l=h.model)||void 0===l?void 0:l.totalTags)&&(0,F.jsx)(se.Z.Item,{label:"标签数量",children:h.model.totalTags}),(null===(s=h.model)||void 0===s?void 0:s.popularTags)&&h.model.popularTags.length>0&&(0,F.jsx)(se.Z.Item,{label:"热门标签",children:(0,F.jsx)(L.Z,{wrap:!0,children:h.model.popularTags.map((function(e,n){return(0,F.jsx)(B.Z,{color:"blue",children:e},n)}))})}),(null===(c=h.model)||void 0===c?void 0:c.modified_at)&&(0,F.jsx)(se.Z.Item,{label:"修改时间",children:(0,ie.mr)(h.model.modified_at.toString())})]}),h.tags&&h.tags.length>0&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(M.Z,{orientation:"left",children:"可用版本"}),(0,F.jsx)(ce.Z,{placeholder:"搜索版本...",prefix:(0,F.jsx)(ue.Z,{}),value:q,onChange:function(e){return R(e.target.value)},style:{marginBottom:16},allowClear:!0}),(0,F.jsx)(C.Z,{itemLayout:"horizontal",dataSource:function(){if(!E||!h.tags)return[];var e=h.tags;if(!q)return e;var n=q.toLowerCase();return e.filter((function(e){return e.tag.toLowerCase().includes(n)||e.name.toLowerCase().includes(n)}))}(),renderItem:function(e){var n=function(e,n){var r="".concat(e,":").concat(n);return S.includes(r)}(g,e.tag),r="".concat(g,":").concat(e.tag);return(0,F.jsxs)(C.Z.Item,{children:[(0,F.jsx)(C.Z.Item.Meta,{title:(0,F.jsxs)(L.Z,{children:[(0,F.jsx)("span",{children:e.name}),(0,F.jsx)(B.Z,{color:"green",children:e.tag}),e.size&&(0,F.jsx)(B.Z,{color:"orange",children:e.size}),n&&(0,F.jsx)(B.Z,{color:"success",children:"已安装"})]}),description:(0,F.jsxs)("span",{children:["最后更新: ",e.lastUpdated]})}),(0,F.jsx)(L.Z,{children:(0,F.jsx)(ae.Z,{title:n?"模型版本已安装":"点击拉取此版本",children:(0,F.jsx)(k.ZP,{type:"primary",size:"small",icon:n?(0,F.jsx)(de.Z,{}):(0,F.jsx)(me.Z,{}),loading:P===r,onClick:function(){j(r)},disabled:n,children:n?"已安装":"拉取此版本"})})})]})}})]})]}),z&&(0,F.jsxs)(se.Z,{bordered:!0,column:1,title:"模型详情",styles:{label:{width:"120px"}},children:[(null===(u=h.details)||void 0===u?void 0:u.format)&&(0,F.jsx)(se.Z.Item,{label:"模型格式",children:h.details.format}),(null===(d=h.details)||void 0===d?void 0:d.family)&&(0,F.jsx)(se.Z.Item,{label:"模型系列",children:h.details.family}),(null===(m=h.details)||void 0===m?void 0:m.parameter_size)&&(0,F.jsx)(se.Z.Item,{label:"参数大小",children:h.details.parameter_size}),(null===(p=h.details)||void 0===p?void 0:p.quantization_level)&&(0,F.jsx)(se.Z.Item,{label:"量化等级",children:h.details.quantization_level}),h.system&&(0,F.jsx)(se.Z.Item,{label:"系统信息",children:h.system}),h.template&&(0,F.jsx)(se.Z.Item,{label:"模板",children:(0,F.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word"},children:h.template})}),h.modelfile&&(0,F.jsx)(se.Z.Item,{label:"模型文件",children:(0,F.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word"},children:h.modelfile})}),(0,F.jsx)(se.Z.Item,{label:"许可证",children:h.license})]})]}):(0,F.jsx)(oe.Z,{message:"无法获取详细信息",type:"warning"}),(0,F.jsx)(M.Z,{}),(0,F.jsxs)(L.Z,{children:[!x&&(0,F.jsx)(k.ZP,{type:"primary",onClick:function(){return y(g)},icon:(0,F.jsx)(J.Z,{}),children:"刷新详情"}),Z&&(0,F.jsx)(le.Z,{title:"删除模型",description:"确定要删除模型 ".concat(g," 吗?"),onConfirm:function(){w(g),v()},okText:"确定",cancelText:"取消",children:(0,F.jsx)(k.ZP,{type:"primary",danger:!0,icon:(0,F.jsx)(te.Z,{}),children:"删除此模型"})})]})]})},fe=function(e){var n=e.visible,r=e.onClose,t=e.models,o=e.loading,l=e.onRefresh,s=e.onModelDetails,c=e.onPull,u=e.pullingModelName,d=e.localModelNames,m=void 0===d?[]:d,p=(0,i.useState)(""),f=a()(p,2),v=f[0],g=f[1],h=t.filter((function(e){var n=v.toLowerCase();return e.name.toLowerCase().includes(n)||e.description&&e.description.toLowerCase().includes(n)||e.popularTags&&e.popularTags.some((function(e){return e.toLowerCase().includes(n)}))}));return(0,F.jsxs)(O.Z,{title:"Ollama 远程模型库",width:600,placement:"right",onClose:r,open:n,zIndex:1001,children:[(0,F.jsxs)(L.Z,{direction:"vertical",style:{width:"100%",marginBottom:16},children:[(0,F.jsxs)(L.Z,{style:{width:"100%",justifyContent:"space-between"},children:[(0,F.jsx)(k.ZP,{icon:(0,F.jsx)(J.Z,{}),loading:o,onClick:l,children:"刷新远程模型"}),(0,F.jsxs)("span",{style:{color:"#999",fontSize:"14px"},children:["共 ",h.length,"/",t.length," 个模型"]})]}),(0,F.jsx)(ce.Z,{placeholder:"搜索模型名称、描述或标签",prefix:(0,F.jsx)(ue.Z,{}),onChange:function(e){return g(e.target.value)},allowClear:!0})]}),(0,F.jsx)(C.Z,{itemLayout:"vertical",loading:o,dataSource:h,renderItem:function(e){var n,r,t=(r=e.name,m.includes(r));return(0,F.jsx)(C.Z.Item,{extra:(0,F.jsxs)(L.Z,{children:[(0,F.jsx)(k.ZP,{type:"default",icon:(0,F.jsx)(re.Z,{}),onClick:function(){return s(e.name)},style:{marginRight:8},children:"详情"}),(0,F.jsx)(ae.Z,{title:t?"模型已存在于本地":"点击拉取模型",children:(0,F.jsx)(k.ZP,{type:"primary",icon:t?(0,F.jsx)(de.Z,{}):(0,F.jsx)(me.Z,{}),loading:u===e.name,onClick:function(){return c(e.name)},disabled:t,children:t?"已安装":"拉取"})})]}),children:(0,F.jsx)(C.Z.Item.Meta,{title:(0,F.jsxs)(L.Z,{children:[(0,F.jsx)("strong",{children:e.name}),t&&(0,F.jsx)(B.Z,{color:"success",children:"已安装"})]}),description:(0,F.jsxs)(L.Z,{direction:"vertical",style:{width:"100%"},children:[(0,F.jsxs)(L.Z,{children:[e.pullCount&&(0,F.jsxs)(B.Z,{color:"cyan",children:["下载: ",e.pullCount]}),e.lastUpdated&&(0,F.jsxs)(B.Z,{color:"orange",children:["更新: ",e.lastUpdated]})]}),(0,F.jsx)("div",{children:e.description||"暂无描述"}),(0,F.jsx)(L.Z,{style:{marginTop:8},children:null===(n=e.popularTags)||void 0===n?void 0:n.map((function(e,n){return(0,F.jsx)(B.Z,{color:"blue",children:e},n)}))})]})})})}})]})},ve=function(e){var n=e.provider,r=e.level,t=(0,E.useIntl)(),o=(0,_.Z)().isDarkMode,l=(0,i.useState)(!1),s=a()(l,2),c=s[0],d=s[1],m=(0,i.useState)(!1),p=a()(m,2),v=p[0],x=p[1],y=(0,i.useState)([]),j=a()(y,2),w=j[0],Z=j[1],b=(0,i.useState)(!1),S=a()(b,2),I=S[0],T=S[1],q=(0,X.A)((function(e){return e.upgradeLlmProvider})),R=(0,i.useState)(),O=a()(R,2),z=O[0],U=O[1],D=(0,i.useState)(!1),K=a()(D,2),H=K[0],V=K[1],Y=(0,i.useState)([]),Q=a()(Y,2),W=Q[0],$=Q[1],se=(0,i.useState)(!1),ce=a()(se,2),ue=ce[0],de=ce[1],me=(0,i.useState)(""),ve=a()(me,2),ge=ve[0],he=ve[1],xe=(0,i.useState)(""),ye=a()(xe,2),je=ye[0],we=ye[1],Ze=(0,i.useState)(!1),Pe=a()(Ze,2),ke=Pe[0],be=Pe[1],Me=(0,i.useState)(!1),Le=a()(Me,2),Ce=Le[0],Se=Le[1],Ie=(0,i.useState)(null),Te=a()(Ie,2),qe=Te[0],Re=Te[1],Oe=(0,i.useState)(""),Ee=a()(Oe,2),Fe=Ee[0],ze=Ee[1],Ue=function(){var e=g()(f()().mark((function e(){var n;return f()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return d(!0),console.log("pingOllama"),e.next=4,(0,ee.VM)();case 4:n=e.sent,console.log("getOllamaServerStatus: ",n),200===n.code?(x(n.data),d(!1)):(x(!1),d(!1));case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Ne=function(){var e=g()(f()().mark((function e(){var n,r;return f()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("requestLocalModels"),d(!0),e.next=4,(0,ee.c8)();case 4:n=e.sent,console.log("getOllamaLocalModels: ",n),200===n.code&&(r=n.data.map((function(e){var n=e.name.split(":"),r=n[0]||e.name,t=n.length>1?n[1]:"default";return u()(u()({},e),{},{modelName:r,modelVersion:t})})),Z(r)),d(!1);case 8:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),De=function(){var e=g()(f()().mark((function e(){var n;return f()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return de(!0),e.next=3,(0,ee.rg)();case 3:n=e.sent,console.log("getOllamaLibraryModels: ",n),200===n.code?$(n.data):h.yw.error(n.message||"获取远程模型列表失败"),de(!1);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Ke=function(){Ue(),Ne()};(0,i.useEffect)((function(){Ke()}),[]);var Je=function(){var e=g()(f()().mark((function e(n){var r;return f()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return h.yw.loading(t.formatMessage({id:"updating"})),e.next=3,(0,A.fx)(n);case 3:r=e.sent,console.log("updateLlmProvider:",n,r),200===r.code?(h.yw.destroy(),h.yw.success(t.formatMessage({id:"update.success",defaultMessage:"update success"})),q(r.data),T(!1)):(h.yw.destroy(),h.yw.error(r.message));case 6:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),Ae=function(){var e=g()(f()().mark((function e(n){var r;return f()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(v){e.next=3;break}return h.yw.error("Ollama未运行无法删除模型"),e.abrupt("return");case 3:return he(n),h.yw.loading("正在删除模型 ".concat(n,"...")),e.prev=5,e.next=8,(0,ee.G9)(n);case 8:r=e.sent,console.log("deleteOllamaModel:",r.data,n),200===r.code&&r.data?(h.yw.success("成功删除模型 ".concat(n)),Ne()):h.yw.error(r.message||"删除模型 ".concat(n," 失败")),e.next=17;break;case 13:e.prev=13,e.t0=e.catch(5),console.error("删除模型出错:",e.t0),h.yw.error("删除模型时发生错误: ".concat(e.t0));case 17:return e.prev=17,he(""),e.finish(17);case 20:case"end":return e.stop()}}),e,null,[[5,13,17,20]])})));return function(n){return e.apply(this,arguments)}}(),_e=function(){var e=g()(f()().mark((function e(n){var r;return f()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(v){e.next=3;break}return h.yw.error("Ollama未运行无法拉取模型"),e.abrupt("return");case 3:return we(n),h.yw.loading("正在拉取模型 ".concat(n,"...")),e.prev=5,e.next=8,(0,ee.N6)(n);case 8:200===(r=e.sent).code&&r.data?(h.yw.success("成功拉取模型 ".concat(n,",模型下载可能需要一些时间")),V(!1),Ne()):h.yw.error(r.message||"拉取模型 ".concat(n," 失败")),e.next=16;break;case 12:e.prev=12,e.t0=e.catch(5),console.error("拉取模型出错:",e.t0),h.yw.error("拉取模型时发生错误: ".concat(e.t0));case 16:return e.prev=16,we(""),e.finish(16);case 19:case"end":return e.stop()}}),e,null,[[5,12,16,19]])})));return function(n){return e.apply(this,arguments)}}(),He=function(){var e=g()(f()().mark((function e(n){var r,t,o;return f()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Se(!0),ze(n),be(!0),e.prev=3,r=w.some((function(e){return e.name===n})),t=W.some((function(e){return e.name===n})),!r){e.next=13;break}return e.next=9,(0,ee.sF)(n);case 9:o=e.sent,console.log("getOllamaModelDetails (local):",o),e.next=24;break;case 13:if(!t){e.next=20;break}return e.next=16,(0,ee.gF)(n);case 16:o=e.sent,console.log("getOllamaLibraryModelDetails (remote):",o),e.next=24;break;case 20:return e.next=22,(0,ee.gF)(n);case 22:o=e.sent,console.log("getOllamaLibraryModelDetails (default):",o);case 24:200===o.code?Re(o.data):(h.yw.error(o.message||"获取模型 ".concat(n," 详情失败")),Re(null)),e.next=32;break;case 27:e.prev=27,e.t0=e.catch(3),console.error("获取模型详情出错:",e.t0),h.yw.error("获取详情时发生错误: ".concat(e.t0)),Re(null);case 32:return e.prev=32,Se(!1),e.finish(32);case 35:case"end":return e.stop()}}),e,null,[[3,27,32,35]])})));return function(n){return e.apply(this,arguments)}}();return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)("h1",{children:[(0,F.jsx)(P.Z,{src:null==n?void 0:n.logo}),null==n?void 0:n.nickname,(0,F.jsx)(k.ZP,{type:"text",icon:(0,F.jsx)(N.Z,{}),onClick:function(){window.open(null==n?void 0:n.webUrl,"_blank")}})]}),(0,F.jsxs)(L.Z,{children:[(0,F.jsx)(k.ZP,{icon:(0,F.jsx)(J.Z,{}),loading:c,type:"primary",onClick:Ke,children:"刷新"}),(0,F.jsx)(k.ZP,{icon:(0,F.jsx)(ne.Z,{}),type:"primary",onClick:function(){V(!0),De()},children:"远程模型库"})]}),(0,F.jsx)("br",{}),(0,F.jsx)("br",{}),v?(0,F.jsx)(oe.Z,{message:"Ollama运行中",type:"success"}):(0,F.jsx)(oe.Z,{message:"请首先启动Ollama",type:"error"}),(0,F.jsx)(M.Z,{orientation:"left",children:"本地模型列表"}),(0,F.jsx)(C.Z,{itemLayout:"horizontal",style:{marginTop:10},loading:c,dataSource:w,renderItem:function(e,n){return(0,F.jsx)(C.Z.Item,{style:(null==z?void 0:z.name)===(null==e?void 0:e.name)?{backgroundColor:o?"#333333":"#dddddd",cursor:"pointer"}:{cursor:"pointer"},onClick:function(){U(e)},actions:[(0,F.jsx)(k.ZP,{type:"text",icon:(0,F.jsx)(re.Z,{}),onClick:function(n){n.stopPropagation(),He(null==e?void 0:e.name)},children:"详情"},"details"),(0,F.jsx)(le.Z,{title:"删除模型",description:"确定要删除模型 ".concat(null==e?void 0:e.name," 吗?"),onConfirm:function(n){null==n||n.stopPropagation(),Ae(null==e?void 0:e.modelName)},okText:"确定",cancelText:"取消",onCancel:function(e){return null==e?void 0:e.stopPropagation()},children:(0,F.jsx)(k.ZP,{type:"text",danger:!0,icon:(0,F.jsx)(te.Z,{}),loading:ge===(null==e?void 0:e.modelName),onClick:function(e){return e.stopPropagation()},children:"删除"})},"delete")],children:(0,F.jsx)(C.Z.Item.Meta,{title:(0,F.jsxs)(L.Z,{children:[(0,F.jsx)("span",{children:null==e?void 0:e.modelName}),(0,F.jsx)(B.Z,{color:"blue",children:null==e?void 0:e.modelVersion}),(null==e?void 0:e.size)&&(0,F.jsx)(B.Z,{color:"green",children:(0,ie.sS)(null==e?void 0:e.size)}),(null==e?void 0:e.parameter_size)&&(0,F.jsx)(ae.Z,{title:"参数大小",children:(0,F.jsx)(B.Z,{color:"purple",children:null==e?void 0:e.parameter_size})})]}),description:(0,F.jsxs)(L.Z,{direction:"vertical",children:[(0,F.jsxs)("div",{children:["完整名称: ",null==e?void 0:e.name]}),(0,F.jsxs)("div",{children:["digest: ",null==e?void 0:e.digest]}),(null==e?void 0:e.family)&&(0,F.jsxs)("div",{children:["系列: ",null==e?void 0:e.family]}),(null==e?void 0:e.quantization_level)&&(0,F.jsxs)("div",{children:["量化等级: ",null==e?void 0:e.quantization_level]}),(0,F.jsxs)("div",{children:["更新时间: ",(0,ie.mr)(null==e?void 0:e.modified_at.toString())]})]}),style:{marginLeft:"15px"}})})}}),(0,F.jsx)(fe,{visible:H,onClose:function(){return V(!1)},models:W,loading:ue,onRefresh:De,onModelDetails:He,onPull:_e,pullingModelName:je,localModelNames:w.map((function(e){return e.modelName}))}),(0,F.jsx)(pe,{visible:ke,onClose:function(){return be(!1)},modelName:Fe,modelDetails:qe,loading:Ce,onRefresh:He,onPull:_e,onDelete:Ae,isRemoteModel:W.some((function(e){return e.name===Fe})),isLocalModel:w.some((function(e){return e.name===Fe})),pullingModelName:je,localModelNames:w.map((function(e){return e.name}))}),I&&(0,F.jsx)(G.Z,{open:I,isEdit:!0,level:r,llmProvider:n,onCancel:function(){return T(!1)},onSubmit:Je})]})},ge=r(63521),he=function(e){var n=e.level,r=(0,i.useState)(""),t=a()(r,2),l=t[0],c=t[1],u=(0,i.useState)([]),d=a()(u,2),m=d[0],p=d[1],f=(0,X.A)((function(e){return e.currentLlmProvider})),v=(0,ge.$)((function(e){return e.currentLlmProviderPlatform})),g=(0,i.useState)(n===j.Hxq),h=a()(g,1)[0]?v:f;(0,i.useEffect)((function(){if(h&&h.name)if(console.log("llmProvider: ",h),m.find((function(e){return e.key===h.name})))c(h.name);else{var e=o()(m);"ollama"===h.name?e.push({label:h.nickname||h.name,children:(0,F.jsx)(ve,{provider:h,level:n}),key:h.name,closable:!0}):e.push({label:h.nickname||h.name,children:(0,F.jsx)($,{provider:h,level:n}),key:h.name,closable:!0}),p(e),c(h.name)}}),[h,m]);return 0===m.length?null:(0,F.jsx)(s.Z,{type:"editable-card",onChange:function(e){c(e)},activeKey:l,onEdit:function(e,n){"remove"===n&&function(e){var n=l,r=-1;m.forEach((function(n,t){n.key===e&&(r=t-1)}));var t=m.filter((function(n){return n.key!==e}));t.length&&n===e&&(n=r>=0?t[r].key:t[0].key),p(t),c(n)}(e)},items:m})}},10324:function(e,n,r){var t=r(90819),o=r.n(t),l=r(89933),a=r.n(l),i=r(45332),s=r.n(i),c=r(31756),u=r(97153),d=r(31881),m=r(25191),p=r(6373),f=r(31051),v=r(22766),g=r(34651),h=r(35129),x=r(44194),y=r(31549);n.Z=function(e){var n=e.open,r=e.isEdit,t=e.llmProvider,l=e.level,i=e.onCancel,j=e.onSubmit,w=g.Z.useForm(),Z=s()(w,1)[0],P=(0,d.u)((function(e){return e.currentOrg})),k=(0,x.useState)([]),b=s()(k,2),M=b[0],L=b[1],C=(0,x.useState)([]),S=s()(C,2),I=S[0],T=S[1],q=(0,x.useState)(),R=s()(q,2),O=R[0],E=R[1],F=function(){var e=a()(o()().mark((function e(){var n,r,t;return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return console.log("requestLlmProviders"),n={pageNumber:0,pageSize:50,status:"",level:m.Hxq},e.next=4,(0,u.mK)(n);case 4:r=e.sent,console.log("queryLlmProvidersByOrg: ",r),200===r.code?L(null==r||null===(t=r.data)||void 0===t?void 0:t.content):c.yw.error(r.message);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();(0,x.useEffect)((function(){var e=[];M.forEach((function(n){e.push({label:n.nickname,value:n.name,disabled:n.status!==m.KY})})),T(e)}),[M]),(0,x.useEffect)((function(){l===m.whQ&&F()}),[]),(0,x.useEffect)((function(){r?(E(t),Z.setFieldsValue({name:null==t?void 0:t.name,nickname:null==t?void 0:t.nickname,apiUrl:null==t?void 0:t.apiUrl,apiKey:null==t?void 0:t.apiKey})):Z.resetFields()}),[r,t]);return(0,y.jsx)("div",{children:(0,y.jsx)(h.Z,{title:"添加大模型提供商",open:n,forceRender:!0,onOk:function(){Z.validateFields().then(function(){var e=a()(o()().mark((function e(n){var l;return o()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:l={uid:r?null==t?void 0:t.uid:"",name:null==O?void 0:O.name,nickname:null==n?void 0:n.nickname,logo:null==O?void 0:O.logo,description:null==O?void 0:O.description,apiUrl:null==n?void 0:n.apiUrl,apiKey:null==n?void 0:n.apiKey,webUrl:null==O?void 0:O.webUrl,status:m.KY,level:m.whQ,orgUid:null==P?void 0:P.uid},console.log("handleSaveLlmProvider:",n,l),j(l);case 3:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}()).catch((function(e){console.log("Failed:",e),c.yw.error("创建角色失败")}))},onCancel:i,children:(0,y.jsxs)(p.A,{form:Z,name:"form",style:{maxWidth:400},submitter:{render:function(){return null}},children:[l===m.whQ&&(0,y.jsx)(f.Z,{label:"选择大模型提供商",name:"name",options:I,fieldProps:{placeholder:"选择大模型提供商(必选)",allowClear:!0,onChange:function(e){console.log("onParentSelectChange:",e);var n=M.find((function(n){return n.name===e}));E(n),console.log("selectedProvider:",n),Z.setFieldsValue({nickname:null==n?void 0:n.nickname,apiUrl:null==n?void 0:n.apiUrl,apiKey:null==n?void 0:n.apiKey})},dropdownStyle:{maxHeight:400,overflow:"auto"}}}),(0,y.jsx)(v.Z,{label:"名称",name:"nickname",rules:[{required:!0,message:"请输入名称!"}],fieldProps:{onPressEnter:function(e){}}}),(0,y.jsx)(v.Z,{label:"ApiUrl",name:"apiUrl",rules:[{required:!0,message:"请输入apiUrl!"}],fieldProps:{onPressEnter:function(e){}}}),"ollama"!==(null==O?void 0:O.name)&&(0,y.jsx)(v.Z.Password,{label:"ApiKey",name:"apiKey",fieldProps:{placeholder:"请输入apiKey",allowClear:!0,visibilityToggle:!0,onPressEnter:function(e){}}})]})})})}},53128:function(e,n,r){var t=r(52544);n.Z=function(){var e=(0,t.Z)().isDarkMode;return{leftSiderStyle:{borderRight:e?"1px solid #333":"1px solid #ccc",background:e?"#141414":"#f5f5f5",height:"100vh",overflow:"auto"},leftSiderWidth:250,headerStyle:{background:e?"#141414":"#fff"},rightSiderStyle:{borderLeft:e?"1px solid #333":"1px solid #ccc",background:e?"#141414":"#f5f5f5"},contentStyle:{minHeight:120,background:e?"#141414":"#f5f5f5",height:"100vh",overflow:"auto"}}}},63521:function(e,n,r){r.d(n,{$:function(){return d}});var t=r(73193),o=r.n(t),l=r(76711),a=r.n(l),i=r(25191),s=r(16894),c=r(45034),u=r(47401),d=(0,s.Ue)()((0,c.mW)((0,c.tJ)((0,u.n)((function(e,n){return{llmproviderResultPlatform:{data:{content:[]}},currentLlmProviderPlatform:{uid:"",nickname:""},insertLlmProviderPlatform:function(n){e((function(e){e.llmproviderResultPlatform.data.content.unshift(n)}))},upgradeLlmProviderPlatform:function(n){e((function(e){var r=e.llmproviderResultPlatform.data.content,t=r.findIndex((function(e){return e.uid===n.uid}));-1!==t?r[t]=n:console.warn("LlmProvider with uid ".concat(n.uid," not found."))}))},setLlmProviderResultPlatform:function(r){e({llmproviderResultPlatform:r});var t,o=n().currentLlmProviderPlatform;""!==o.uid&&void 0!==o||(null===(t=r.data)||void 0===t||null===(t=t.content)||void 0===t?void 0:t.length)>0&&e({currentLlmProviderPlatform:r.data.content[0]})},setCurrentLlmProviderPlatform:function(r){var t=n().llmproviderResultPlatform.data.content,l=t.findIndex((function(e){return e.uid===r.uid}));if(-1!==l){var i=[].concat(a()(t.slice(0,l)),[r],a()(t.slice(l+1))),s=o()(o()({},n().llmproviderResultPlatform),{},{data:{content:i}});e({llmproviderResultPlatform:s,currentLlmProviderPlatform:r})}else e({currentLlmProviderPlatform:r})},deleteCurrentLlmProviderPlatform:function(r){var t=n().llmproviderResultPlatform.data.content,l=t.findIndex((function(e){return e.uid===r}));-1!==l?e({llmproviderResultPlatform:o()(o()({},n().llmproviderResultPlatform),{},{data:{content:[].concat(a()(t.slice(0,l)),a()(t.slice(l+1)))}})}):console.warn("LlmProvider not found in cache:",r),n().currentLlmProviderPlatform.uid===r&&e({currentLlmProviderPlatform:{uid:""}})},deleteLlmProviderCachePlatform:function(){return e({},!0)}}})),{name:i.dNm})))}}]);