mirror of
https://gitee.com/270580156/weiyu.git
synced 2026-05-16 12:18:10 +00:00
1 line
14 KiB
JavaScript
1 line
14 KiB
JavaScript
"use strict";(self.webpackChunkadmin=self.webpackChunkadmin||[]).push([[1463],{41282: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),l=t(89933),s=t.n(l),u=t(5488),c=t(14870);function d(e){return p.apply(this,arguments)}function p(){return(p=s()(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=s()(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=s()(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=s()(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)}},52202:function(e,n,t){t.d(n,{G9:function(){return k},J$:function(){return S},N6:function(){return w},VM:function(){return d},c8:function(){return m},gF:function(){return v},rg:function(){return h},sF:function(){return g}});var r=t(90819),a=t.n(r),i=t(73193),o=t.n(i),l=t(89933),s=t.n(l),u=t(5488),c=t(14870);function d(e){return p.apply(this,arguments)}function p(){return(p=s()(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/ollama4j/ping",{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=s()(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/ollama4j/local-models",{method:"GET",params: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=s()(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/ollama4j/models",{method:"GET",params: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=s()(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/ollama4j/library/models/details",{method:"GET",params:o()(o()({},n),{},{channel:u.XtJ})}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function g(e){return b.apply(this,arguments)}function b(){return(b=s()(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/ollama4j/models/details",{method:"GET",params:o()(o()({},n),{},{channel:u.XtJ})}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function w(e){return j.apply(this,arguments)}function j(){return(j=s()(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/ollama4j/models/pull",{method:"POST",data:o()(o()({},n),{},{channel:u.XtJ})}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function k(e){return M.apply(this,arguments)}function M(){return(M=s()(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/ollama4j/models/delete",{method:"POST",data:o()(o()({},n),{},{channel:u.XtJ})}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function S(e){return C.apply(this,arguments)}function C(){return(C=s()(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)("/springai/ollama/embedding-model/exists",{method:"GET",params:o()(o()({},n),{},{channel:u.XtJ})}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}},21463:function(e,n,t){var r=t(10154),a=t.n(r),i=t(73193),o=t.n(i),l=t(90819),s=t.n(l),u=t(89933),c=t.n(u),d=t(45332),p=t.n(d),m=t(5025),f=t(41282),h=t(52202),y=t(18751),v=t(5488),x=t(13775),g=t(85817),b=t(79401),w=t(31261),j=t(49616),k=t(93892),M=t(5780),S=t(68724),C=t(37963),T=t(14870),P=t(44194),Z=t(24522),L=t(31549),q=g.Z.Text,J=P.memo((function(e){var n,t=e.visible,r=e.onCancel,i=e.onOk,l=e.initialProvider,u=e.initialModel,d=e.initialModelLabel,J=e.providers,O=e.currentOrgUid,N=e.existingProviderModels,X=void 0===N?{}:N,E=e.onModelsLoaded,F=e.allowedModelTypes,G=void 0===F?[]:F,I=(0,T.useIntl)(),z=(0,Z.Z)().isDarkMode,B=(0,y.Z)().translateString,U=(0,P.useState)(l||""),R=p()(U,2),A=R[0],D=R[1],H=(0,P.useState)(X),V=p()(H,2),K=V[0],Q=V[1],W=(0,P.useState)(l||""),$=p()(W,2),Y=$[0],_=$[1],ee=(0,P.useState)(u||""),ne=p()(ee,2),te=ne[0],re=ne[1],ae=(0,P.useState)(d||""),ie=p()(ae,2),oe=ie[0],le=ie[1],se=(0,P.useState)(!1),ue=p()(se,2),ce=ue[0],de=ue[1],pe=(0,P.useState)(!1),me=p()(pe,2),fe=me[0],he=me[1];(0,P.useEffect)((function(){_(l),re(u),le(d),D(l),he(!1)}),[l,u,d,t]),(0,P.useEffect)((function(){if(t&&A&&!K[A]&&!ce){de(!0),m.yw.loading({content:I.formatMessage({id:"loading"}),key:"modelLoading"});var e=J.find((function(e){return e.name===A}));e&&(e.name===v.j9I?be(e):je(e))}}),[t,A,J]);var ye=(0,P.useCallback)((function(){Y&&te&&i(Y,te,oe)}),[Y,te,oe,i]),ve=(0,P.useCallback)((function(){r(),T.history.push("/ai/model")}),[r]),xe=(0,P.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())}))}),[]),ge=(0,P.useCallback)((function(e){return e?e.filter((function(e){return!xe(e.value)&&(!G||0===G.length||(!e.type||G.includes(e.type)))})):[]}),[G,xe]),be=function(){var e=c()(s()().mark((function e(n){var t,r;return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t={baseUrl:null==n?void 0:n.baseUrl},e.next=4,(0,h.VM)(t);case 4:r=e.sent,console.log("getOllamaServerStatus:",r,t),200===r.code&&r.data?(he(!0),we(n)):(he(!1),m.yw.destroy("modelLoading"),de(!1)),e.next=15;break;case 9:e.prev=9,e.t0=e.catch(0),console.error("Failed to check Ollama status:",e.t0),he(!1),m.yw.destroy("modelLoading"),de(!1);case 15:case"end":return e.stop()}}),e,null,[[0,9]])})));return function(n){return e.apply(this,arguments)}}(),we=function(){var e=c()(s()().mark((function e(n){var t,r,a,i;return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t={baseUrl:null==n?void 0:n.baseUrl},e.next=4,(0,h.c8)(t);case 4:r=e.sent,console.log("getOllamaLocalModels:",r.data,t),200===r.code?(a=r.data.map((function(e){return{value:e.name,label:e.name,providerName:"ollama"}})),i=ge(a),Q((function(e){return o()(o()({},e),{},{ollama:i})})),E&&E("ollama",i)):m.yw.error(r.message),e.next=13;break;case 9:e.prev=9,e.t0=e.catch(0),console.error("Failed to fetch local models:",e.t0),m.yw.error(I.formatMessage({id:"error"}));case 13:return e.prev=13,m.yw.destroy("modelLoading"),de(!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)}}(),je=function(){var e=c()(s()().mark((function e(n){var t,r,i,l;return s()().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:O,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}})),l=ge(i),Q((function(e){return o()(o()({},e),{},a()({},n.name,l))})),E&&E(n.name,l)):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(I.formatMessage({id:"error"}));case 13:return e.prev=13,m.yw.destroy("modelLoading"),de(!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)}}(),ke=(0,P.useCallback)((function(e,n){_(e),re(n.value),le(n.label)}),[]),Me=(0,P.useCallback)((function(e){if(D(e),!K[e]&&!ce){de(!0),m.yw.loading({content:I.formatMessage({id:"loading"}),key:"modelLoading"});var n=J.find((function(n){return n.name===e}));n&&("ollama"===n.name?be(n):je(n))}}),[J,K,ce]),Se=P.memo((function(e){var n=e.model,t=e.providerName;return(0,L.jsxs)(b.Z,{hoverable:!0,style:{cursor:"pointer",border:te===n.value&&Y===t?"2px solid #1890ff":"1px solid #e8e8e8"},onClick:function(){return ke(t,n)},children:[(0,L.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[(0,L.jsx)(g.Z.Title,{level:5,style:{margin:0},children:n.label}),(0,L.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end"},children:[n.type&&(0,L.jsx)("div",{style:{marginBottom:8},children:(0,x.Rb)(n.type)}),te===n.value&&Y===t&&(0,L.jsx)(w.Z,{status:"processing",text:I.formatMessage({id:"ai.modelSelection.selected"})})]})]}),n.description&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(g.Z.Text,{type:"secondary",children:null==n?void 0:n.value}),(0,L.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&&(te===e.model.value&&Y===e.providerName)===(te===n.model.value&&Y===n.providerName)})),Ce=(0,P.useMemo)((function(){return J.filter((function(e){return!v.juN.includes(e.name)})).map((function(e){var n,t;return{key:e.name,label:B(e.nickname),children:(0,L.jsx)("div",{style:{minHeight:"400px",width:"100%"},children:(0,L.jsxs)(j.Z,{direction:"vertical",style:{width:"100%"},children:["ollama"===e.name&&!fe&&(0,L.jsx)(k.Z,{message:I.formatMessage({id:"ai.ollama.notRunning"}),type:"error",showIcon:!0,style:{marginBottom:"16px"}}),ce&&A===e.name&&!K[e.name]?(0,L.jsx)("div",{style:{textAlign:"center",padding:"20px"},children:(0,L.jsx)(q,{type:"secondary",children:I.formatMessage({id:"ai.modelSelection.loading"})})}):K[e.name]&&0!==(null===(n=K[e.name])||void 0===n?void 0:n.length)?null:(0,L.jsxs)("div",{style:{textAlign:"center",padding:"20px"},children:[(0,L.jsx)(q,{type:"secondary",style:{display:"block",marginBottom:"16px"},children:I.formatMessage({id:"ai.modelSelection.noModels"})}),(0,L.jsx)(M.ZP,{type:"link",onClick:ve,style:{padding:0,height:"auto",fontSize:"14px",color:"#1890ff"},children:I.formatMessage({id:"ai.modelSelection.addModelTip"})})]}),(0,L.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"16px"},children:null===(t=K[e.name])||void 0===t?void 0:t.map((function(n){return(0,L.jsx)(Se,{model:n,providerName:e.name},n.value)}))})]})})}}))}),[J,K,A,ce,te,Y,B,fe]);return(0,L.jsx)(S.Z,{title:I.formatMessage({id:"ai.modelSelection.title"}),open:t,onClose:r,width:700,destroyOnHidden:!1,footer:(0,L.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%"},children:[(0,L.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,L.jsx)(q,{type:"secondary",style:{fontSize:"14px",marginRight:"8px"},children:I.formatMessage({id:"ai.modelSelection.cannotFindModel"})}),(0,L.jsx)(M.ZP,{type:"link",onClick:ve,style:{padding:0,height:"auto",fontSize:"14px"},children:I.formatMessage({id:"ai.modelSelection.addNewModel"})})]}),(0,L.jsxs)("div",{children:[(0,L.jsx)(M.ZP,{onClick:r,style:{marginRight:8},children:I.formatMessage({id:"ai.modelSelection.cancel"})}),(0,L.jsx)(M.ZP,{onClick:ye,type:"primary",children:I.formatMessage({id:"ai.modelSelection.confirm"})})]})]}),children:J.length>0?(0,L.jsx)(C.Z,{activeKey:A||(null===(n=J.filter((function(e){return!v.juN.includes(e.name)}))[0])||void 0===n?void 0:n.name),onChange:Me,items:Ce,destroyOnHidden:!1}):(0,L.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"400px",textAlign:"center"},children:[(0,L.jsx)(q,{type:"secondary",style:{fontSize:"16px",marginBottom:"16px"},children:I.formatMessage({id:"ai.modelSelection.noProviders"})}),(0,L.jsx)(q,{type:"secondary",style:{fontSize:"14px",marginBottom:"24px"},children:I.formatMessage({id:"ai.modelSelection.noProvidersTip"})}),(0,L.jsx)(M.ZP,{type:"primary",onClick:ve,style:{fontSize:"14px"},children:I.formatMessage({id:"ai.modelSelection.goToProviders"})})]})})}),(function(e,n){return e.visible===n.visible&&e.initialProvider===n.initialProvider&&e.initialModel===n.initialModel&&e.initialModelLabel===n.initialModelLabel}));n.Z=J}}]); |