mirror of
https://gitee.com/270580156/weiyu.git
synced 2026-05-17 20:57:51 +00:00
1 line
13 KiB
JavaScript
1 line
13 KiB
JavaScript
"use strict";(self.webpackChunkadmin=self.webpackChunkadmin||[]).push([[8804],{20252:function(e,n,t){t.d(n,{Jr:function(){return m},LF:function(){return d},Oh:function(){return v},WS:function(){return h}});var r=t(90819),a=t.n(r),i=t(73193),o=t.n(i),s=t(89933),l=t.n(s),u=t(2622),c=t(59318);function d(e){return p.apply(this,arguments)}function p(){return(p=l()(a()().mark((function e(n){return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,c.request)("/api/v1/model/query/org",{method:"GET",params:o()(o()({},n),{},{channel:u.XtJ})}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function m(e){return f.apply(this,arguments)}function f(){return(f=l()(a()().mark((function e(n){return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,c.request)("/api/v1/model/create",{method:"POST",data:o()(o()({},n),{},{channel:u.XtJ})}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function h(e){return y.apply(this,arguments)}function y(){return(y=l()(a()().mark((function e(n){return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,c.request)("/api/v1/model/update",{method:"POST",data:o()(o()({},n),{},{channel:u.XtJ})}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function v(e){return x.apply(this,arguments)}function x(){return(x=l()(a()().mark((function e(n){return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,c.request)("/api/v1/model/delete",{method:"POST",data:o()(o()({},n),{},{channel:u.XtJ})}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}},44631:function(e,n,t){t.d(n,{G9:function(){return b},J$:function(){return j},N6:function(){return g},VM:function(){return u},c8:function(){return d},gF:function(){return h},rg:function(){return m},sF:function(){return v}});var r=t(90819),a=t.n(r),i=t(89933),o=t.n(i),s=t(2622),l=t(59318);function u(){return c.apply(this,arguments)}function c(){return(c=o()(a()().mark((function e(){return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,l.request)("/api/v1/ollama4j/ping",{method:"GET",params:{channel:s.XtJ}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function d(){return p.apply(this,arguments)}function p(){return(p=o()(a()().mark((function e(){return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,l.request)("/api/v1/ollama4j/local-models",{method:"GET",params:{channel:s.XtJ}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function m(){return f.apply(this,arguments)}function f(){return(f=o()(a()().mark((function e(){return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,l.request)("/api/v1/ollama4j/models",{method:"GET",params:{channel:s.XtJ}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function h(e){return y.apply(this,arguments)}function y(){return(y=o()(a()().mark((function e(n){return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,l.request)("/api/v1/ollama4j/library/models/"+n+"/details",{method:"GET",params:{channel:s.XtJ}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function v(e){return x.apply(this,arguments)}function x(){return(x=o()(a()().mark((function e(n){return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,l.request)("/api/v1/ollama4j/models/"+n+"/details",{method:"GET",params:{channel:s.XtJ}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function g(e){return w.apply(this,arguments)}function w(){return(w=o()(a()().mark((function e(n){return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,l.request)("/api/v1/ollama4j/models/pull",{method:"POST",params:{channel:s.XtJ},data:{model:n}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function b(e){return k.apply(this,arguments)}function k(){return(k=o()(a()().mark((function e(n){return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,l.request)("/api/v1/ollama4j/models/delete",{method:"POST",params:{channel:s.XtJ},data:{model:n}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function j(e){return C.apply(this,arguments)}function C(){return(C=o()(a()().mark((function e(n){return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,l.request)("/api/v1/ollama4j/embedding-model/exists",{method:"GET",params:{channel:s.XtJ,model:n}}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}},38804:function(e,n,t){var r=t(10154),a=t.n(r),i=t(73193),o=t.n(i),s=t(90819),l=t.n(s),u=t(89933),c=t.n(u),d=t(45332),p=t.n(d),m=t(78929),f=t(20252),h=t(44631),y=t(67794),v=t(2622),x=t(58889),g=t(62821),w=t(55599),b=t(27431),k=t(12722),j=t(20374),C=t(18613),S=t(43807),M=t(59318),T=t(44194),Z=t(31557),q=t(31549),L=g.Z.Text,P=T.memo((function(e){var n,t=e.visible,r=e.onCancel,i=e.onOk,s=e.initialProvider,u=e.initialModel,d=e.initialModelLabel,P=e.providers,J=e.currentOrgUid,O=e.existingProviderModels,X=void 0===O?{}:O,N=e.onModelsLoaded,E=e.allowedModelTypes,F=void 0===E?[]:E,G=(0,M.useIntl)(),z=(0,Z.Z)().isDarkMode,I=(0,y.Z)().translateString,B=(0,T.useState)(s||""),A=p()(B,2),D=A[0],R=A[1],H=(0,T.useState)(X),U=p()(H,2),V=U[0],K=U[1],Q=(0,T.useState)(s||""),W=p()(Q,2),$=W[0],Y=W[1],_=(0,T.useState)(u||""),ee=p()(_,2),ne=ee[0],te=ee[1],re=(0,T.useState)(d||""),ae=p()(re,2),ie=ae[0],oe=ae[1],se=(0,T.useState)(!1),le=p()(se,2),ue=le[0],ce=le[1];(0,T.useEffect)((function(){Y(s),te(u),oe(d),R(s)}),[s,u,d,t]),(0,T.useEffect)((function(){if(t&&D&&!V[D]&&!ue){ce(!0),m.yw.loading({content:G.formatMessage({id:"loading"}),key:"modelLoading"});var e=P.find((function(e){return e.name===D}));e&&("ollama"===e.name?he():ve(e))}}),[t,D,P]);var de=(0,T.useCallback)((function(){$&&ne&&i($,ne,ie)}),[$,ne,ie,i]),pe=(0,T.useCallback)((function(){r(),M.history.push("/ai/model")}),[r]),me=(0,T.useCallback)((function(e){return["bge","embed","m3e","vector","nomic","e5","gte","instructor","sentence-transformers","text-embedding","all-mpnet","multi-qa","paraphrase","sbert","clip","jina","onnx"].some((function(n){return e.toLowerCase().includes(n.toLowerCase())}))}),[]),fe=(0,T.useCallback)((function(e){return e?e.filter((function(e){return!me(e.value)&&(!F||0===F.length||(!e.type||F.includes(e.type)))})):[]}),[F,me]),he=function(){var e=c()(l()().mark((function e(){var n;return l()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,h.VM)();case 3:200===(n=e.sent).code&&n.data?ye():(m.yw.error(n.message),m.yw.destroy("modelLoading"),ce(!1)),e.next=13;break;case 7:e.prev=7,e.t0=e.catch(0),console.error("Failed to check Ollama status:",e.t0),m.yw.error(G.formatMessage({id:"error"})),m.yw.destroy("modelLoading"),ce(!1);case 13:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}(),ye=function(){var e=c()(l()().mark((function e(){var n,t,r;return l()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,h.c8)();case 3:200===(n=e.sent).code?(t=n.data.map((function(e){return{value:e.name,label:e.name,providerName:"ollama"}})),r=fe(t),K((function(e){return o()(o()({},e),{},{ollama:r})})),N&&N("ollama",r)):m.yw.error(n.message),e.next=11;break;case 7:e.prev=7,e.t0=e.catch(0),console.error("Failed to fetch local models:",e.t0),m.yw.error(G.formatMessage({id:"error"}));case 11:return e.prev=11,m.yw.destroy("modelLoading"),ce(!1),e.finish(11);case 15:case"end":return e.stop()}}),e,null,[[0,7,11,15]])})));return function(){return e.apply(this,arguments)}}(),ve=function(){var e=c()(l()().mark((function e(n){var t,r,i,s;return l()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t={pageNumber:0,pageSize:50,sortBy:"createdAt",sortDirection:"ascend",enabled:!0,providerUid:null==n?void 0:n.uid,orgUid:J,level:v.whQ},e.next=4,(0,f.LF)(t);case 4:r=e.sent,console.log("queryLlmModelsByOrg:",r.data,t),200===r.code?(i=r.data.content.map((function(e){return{value:e.name,label:e.nickname,description:e.description,type:e.type,providerName:n.name}})),s=fe(i),K((function(e){return o()(o()({},e),{},a()({},n.name,s))})),N&&N(n.name,s)):m.yw.error(r.message),e.next=13;break;case 9:e.prev=9,e.t0=e.catch(0),console.error("Failed to fetch models:",e.t0),m.yw.error(G.formatMessage({id:"error"}));case 13:return e.prev=13,m.yw.destroy("modelLoading"),ce(!1),e.finish(13);case 17:case"end":return e.stop()}}),e,null,[[0,9,13,17]])})));return function(n){return e.apply(this,arguments)}}(),xe=(0,T.useCallback)((function(e,n){Y(e),te(n.value),oe(n.label)}),[]),ge=(0,T.useCallback)((function(e){if(R(e),!V[e]&&!ue){ce(!0),m.yw.loading({content:G.formatMessage({id:"loading"}),key:"modelLoading"});var n=P.find((function(n){return n.name===e}));n&&("ollama"===n.name?he():ve(n))}}),[P,V,ue]),we=T.memo((function(e){var n=e.model,t=e.providerName;return(0,q.jsxs)(w.Z,{hoverable:!0,style:{cursor:"pointer",border:ne===n.value&&$===t?"2px solid #1890ff":"1px solid #e8e8e8"},onClick:function(){return xe(t,n)},children:[(0,q.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[(0,q.jsx)(g.Z.Title,{level:5,style:{margin:0},children:n.label}),(0,q.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end"},children:[n.type&&(0,q.jsx)("div",{style:{marginBottom:8},children:(0,x.Rb)(n.type)}),ne===n.value&&$===t&&(0,q.jsx)(b.Z,{status:"processing",text:"已选"})]})]}),n.description&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(g.Z.Text,{type:"secondary",children:null==n?void 0:n.value}),(0,q.jsx)(g.Z.Paragraph,{ellipsis:{rows:2},type:"secondary",style:{marginTop:8},children:n.description})]})]},n.value)}),(function(e,n){return e.model.value===n.model.value&&e.providerName===n.providerName&&(ne===e.model.value&&$===e.providerName)===(ne===n.model.value&&$===n.providerName)})),be=(0,T.useMemo)((function(){return P.map((function(e){var n,t;return{key:e.name,label:I(e.nickname),children:(0,q.jsx)("div",{style:{minHeight:"400px",width:"100%"},children:(0,q.jsxs)(k.Z,{direction:"vertical",style:{width:"100%"},children:[ue&&D===e.name&&!V[e.name]?(0,q.jsx)("div",{style:{textAlign:"center",padding:"20px"},children:(0,q.jsx)(L,{type:"secondary",children:"加载模型中..."})}):V[e.name]&&0!==(null===(n=V[e.name])||void 0===n?void 0:n.length)?null:(0,q.jsxs)("div",{style:{textAlign:"center",padding:"20px"},children:[(0,q.jsx)(L,{type:"secondary",style:{display:"block",marginBottom:"16px"},children:"暂无可用模型"}),(0,q.jsx)(j.ZP,{type:"link",onClick:pe,style:{padding:0,height:"auto",fontSize:"14px",color:"#1890ff"},children:"点击这里启用或添加新模型 →"})]}),(0,q.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"16px"},children:null===(t=V[e.name])||void 0===t?void 0:t.map((function(n){return(0,q.jsx)(we,{model:n,providerName:e.name},n.value)}))})]})})}}))}),[P,V,D,ue,ne,$,I]);return(0,q.jsx)(C.Z,{title:"选择AI模型",open:t,onClose:r,width:700,destroyOnClose:!1,footer:(0,q.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%"},children:[(0,q.jsxs)("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",backgroundColor:z?"#262626":"#f6f8fa",borderRadius:"6px",border:z?"1px solid #434343":"1px solid #e1e4e8"},children:[(0,q.jsx)(L,{type:"secondary",style:{fontSize:"14px",marginRight:"8px"},children:"找不到想要的模型?"}),(0,q.jsx)(j.ZP,{type:"link",onClick:pe,style:{padding:0,height:"auto",fontSize:"14px"},children:"点击这里添加新模型 →"})]}),(0,q.jsxs)("div",{children:[(0,q.jsx)(j.ZP,{onClick:r,style:{marginRight:8},children:"取消"}),(0,q.jsx)(j.ZP,{onClick:de,type:"primary",children:"确定"})]})]}),children:P.length>0?(0,q.jsx)(S.Z,{activeKey:D||(null===(n=P[0])||void 0===n?void 0:n.name),onChange:ge,items:be,destroyOnHidden:!1}):(0,q.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"400px",textAlign:"center"},children:[(0,q.jsx)(L,{type:"secondary",style:{fontSize:"16px",marginBottom:"16px"},children:"暂无可用的大模型提供商"}),(0,q.jsx)(L,{type:"secondary",style:{fontSize:"14px",marginBottom:"24px"},children:"请先启用/添加大模型提供商,然后添加相应的模型"}),(0,q.jsx)(j.ZP,{type:"primary",onClick:pe,style:{fontSize:"14px"},children:"前往启用/添加大模型提供商 →"})]})})}),(function(e,n){return e.visible===n.visible&&e.initialProvider===n.initialProvider&&e.initialModel===n.initialModel&&e.initialModelLabel===n.initialModelLabel}));n.Z=P}}]); |