2 lines
14 KiB
JavaScript
2 lines
14 KiB
JavaScript
import{cf as Z,aE as t,aW as x,aI as o,ay as ie,aQ as ce,aO as L,aP as me,aB as h,aC as P,b6 as ue,cY as ye,aD as r,aF as d,bV as fe,aG as e,aH as a,aS as O,aK as M,aJ as p,b1 as $,b2 as V,c4 as he,b_ as ge,bW as ke,cE as we,c0 as $e,aT as Y,b3 as be,aV as Ce,b7 as pe,bG as Me,bH as Se,ce as re,dz as se,b8 as ne,aA as Te,dA as xe,aX as X,aY as q,c3 as Le,dB as Ie,dC as De}from"./admin-DgPvPHD7.js";import{E as Ae,_ as Re}from"./ParamSettingDialog.vue_vue_type_script_setup_true_lang-BObAWV4i.js";import{_ as Ne}from"./AuthorizedWorkspaceDialog.vue_vue_type_script_setup_true_lang-BZwUYFPH.js";import"./permission-api-KeGpSf5X.js";import"./workspace-D2rVZOhW.js";const Be={},Ee={class:"loading-container loader"};function Ve(n,I){return t(),x("div",Ee,[...I[0]||(I[0]=[o("div",{class:"download-loading"},[o("div"),o("div"),o("div"),o("div"),o("div"),o("div"),o("div"),o("div")],-1)])])}const ze=Z(Be,[["render",Ve],["__scopeId","data-v-91938551"]]),Oe=["innerHTML"],Pe={class:"flex",style:{height:"22px"}},Fe=["title"],We={key:0},He={key:1},Ge={class:"flex mb-4"},Ue={class:"ellipsis ml-16"},Xe={class:"flex"},Ye={class:"ellipsis-1 ml-16",style:{height:"20px",width:"70%"}},je={key:0,class:"progress-mask"},Je={class:"percentage-label flex-center"},Ke=ie({__name:"ModelCard",props:{model:{},provider_list:{},updateModelById:{type:Function},isShared:{type:Boolean},isSystemShare:{type:Boolean},apiType:{}},emits:["change","update:model"],setup(n,{emit:I}){ce();const m=n,D=L(()=>m.apiType==="systemShare"),k=L(()=>me.model[m.apiType]),A=l=>k.value.modify(l)||k.value.delete(l)||k.value.auth(l)||D.value,S=h();function W(l){S.value.open(l.id)}const f=h(),i=L(()=>f.value?f.value:m.model),y=L(()=>i.value.meta&&i.value.meta.message?i.value.meta.message==="pull model manifest: file does not exist"?`${i.value.model_name} ${P("views.model.tip.noModel")}`:i.value.meta.message:""),v=I,g=h();let R;const F=()=>{$e(`${P("views.model.delete.confirmTitle")}${m.model.name} ?`,P("views.model.delete.confirmMessage"),{confirmButtonText:P("common.confirm"),confirmButtonClass:"danger"}).then(()=>{Y({type:"model",systemType:m.apiType}).deleteModel(m.model.id).then(()=>{v("change"),be(P("common.deleteSuccess"))})}).catch(()=>{})},N=()=>{Y({type:"model",systemType:m.apiType}).pauseDownload(m.model.id).then(()=>{f.value=void 0,v("change")})},B=()=>{var w;const l=m.provider_list.find(c=>c.provider===m.model.provider);l&&((w=g.value)==null||w.open(l,m.model))},T=L(()=>{var l;return(l=m.provider_list.find(w=>w.provider===m.model.provider))==null?void 0:l.icon}),C=()=>{R=setInterval(()=>{i.value.status==="DOWNLOAD"?Y({type:"model",systemType:m.apiType}).getModelMetaById(m.model.id).then(l=>{f.value=l.data}):f.value&&(m.updateModelById(m.model.id,f.value),f.value=void 0)},6e3)},j=()=>{R&&clearInterval(R)},H=h(),J=()=>{var l;(l=H.value)==null||l.open(m.model)},G=h();function U(l){G.value&&G.value.open(l,"Model")}return ue(()=>{C()}),ye(()=>{j()}),(l,w)=>{const c=r("WarningFilled"),s=r("el-icon"),u=r("el-tooltip"),b=r("el-text"),ee=r("el-tag"),K=r("el-button"),E=r("AppIcon"),z=r("el-dropdown-item"),le=r("el-dropdown-menu"),oe=r("el-dropdown"),te=r("card-box");return t(),d(te,{title:n.model.name,shadow:"hover",class:"model-card"},fe({icon:e(()=>[o("span",{style:{height:"32px",width:"32px"},innerHTML:T.value},null,8,Oe)]),title:e(()=>[o("div",Pe,[o("span",{class:"ellipsis-1 mb-4",title:n.model.name,style:{"max-width":"80%"}},p(n.model.name),9,Fe),i.value.status==="ERROR"?(t(),x("span",We,[a(u,{effect:"dark",content:y.value,placement:"top"},{default:e(()=>[a(s,{class:"color-danger ml-4",size:"18"},{default:e(()=>[a(c)]),_:1})]),_:1},8,["content"])])):$("",!0),i.value.status==="PAUSE_DOWNLOAD"?(t(),x("span",He,[a(u,{effect:"dark",content:`${l.$t("views.model.modelForm.base_model.label")}: ${m.model.model_name} ${l.$t("views.model.tip.downloadError")}`,placement:"top"},{default:e(()=>[a(s,{class:"color-danger ml-4",size:"18"},{default:e(()=>[a(c)]),_:1})]),_:1},8,["content"])])):$("",!0)])]),subTitle:e(()=>[a(b,{class:"color-secondary lighter",size:"small"},{default:e(()=>[M(p(l.$t("common.creator"))+": "+p(V(we)(n.model.nick_name)),1)]),_:1})]),tag:e(()=>[n.isShared||D.value?(t(),d(ee,{key:0,type:"info",class:"info-tag"},{default:e(()=>[M(p(V(P)("views.shared.title")),1)]),_:1})):$("",!0)]),default:e(()=>[o("ul",null,[o("li",Ge,[a(b,{type:"info",class:"color-secondary"},{default:e(()=>[M(p(l.$t("views.model.modelForm.model_type.label")),1)]),_:1}),o("span",Ue,p(l.$t(V(he)[n.model.model_type])),1)]),o("li",Xe,[a(b,{type:"info",class:"color-secondary"},{default:e(()=>[M(p(l.$t("views.model.modelForm.base_model.label")),1)]),_:1}),o("span",Ye,p(n.model.model_name),1)])]),i.value.status==="DOWNLOAD"?(t(),x("div",je,[a(ze,{class:"percentage"}),o("div",Je,[M(p(l.$t("views.model.download.downloading"))+" ",1),w[4]||(w[4]=o("span",{class:"dotting"},null,-1)),a(K,{link:"",type:"primary",class:"ml-16",onClick:O(N,["stop"])},{default:e(()=>[M(p(l.$t("views.model.download.cancelDownload")),1)]),_:1})])])):$("",!0),a(Ae,{ref_key:"editModelRef",ref:g,onSubmit:w[3]||(w[3]=Q=>v("change"))},null,512),a(Re,{ref_key:"paramSettingRef",ref:H},null,512),D.value?(t(),d(Ne,{key:1,ref_key:"AuthorizedWorkspaceDialogRef",ref:G},null,512)):$("",!0),n.apiType==="workspace"?(t(),d(ge,{key:2,type:V(ke).MODEL,ref_key:"ResourceAuthorizationDrawerRef",ref:S},null,8,["type"])):$("",!0)]),_:2},[A(n.model.id)?{name:"mouseEnter",fn:e(()=>[n.isShared?$("",!0):(t(),d(oe,{key:0,trigger:"click"},{dropdown:e(()=>[a(le,null,{default:e(()=>[k.value.modify(n.model.id)?(t(),d(z,{key:0,text:"",onClick:O(B,["stop"])},{default:e(()=>[a(E,{iconName:"app-edit",class:"color-secondary"}),M(" "+p(l.$t("common.edit")),1)]),_:1})):$("",!0),D.value?(t(),d(z,{key:1,onClick:w[1]||(w[1]=O(Q=>U(n.model),["stop"]))},{default:e(()=>[a(E,{iconName:"app-lock",class:"color-secondary"}),M(" "+p(l.$t("views.shared.authorized_workspace")),1)]),_:1})):$("",!0),(i.value.model_type==="TTS"||i.value.model_type==="STT"||i.value.model_type==="LLM"||i.value.model_type==="IMAGE"||i.value.model_type==="TTI"||i.value.model_type==="ITV"||i.value.model_type==="EMBEDDING"||i.value.model_type==="TTV")&&k.value.paramSetting(n.model.id)?(t(),d(z,{key:2,onClick:O(J,["stop"])},{default:e(()=>[a(E,{iconName:"app-setting",class:"color-secondary"}),M(" "+p(l.$t("views.model.modelForm.title.paramSetting")),1)]),_:1})):$("",!0),n.apiType==="workspace"&&k.value.auth(n.model.id)?(t(),d(z,{key:3,onClick:w[2]||(w[2]=O(Q=>W(n.model),["stop"]))},{default:e(()=>[a(E,{iconName:"app-resource-authorization",class:"color-secondary"}),M(" "+p(l.$t("views.system.resourceAuthorization.title")),1)]),_:1})):$("",!0),k.value.delete(n.model.id)?(t(),d(z,{key:4,divided:"",text:"",onClick:O(F,["stop"])},{default:e(()=>[a(E,{iconName:"app-delete",class:"color-secondary"}),M(" "+p(l.$t("common.delete")),1)]),_:1})):$("",!0)]),_:1})]),default:e(()=>[a(K,{text:"",onClick:w[0]||(w[0]=O(()=>{},["stop"]))},{default:e(()=>[a(E,{iconName:"app-more"})]),_:1})]),_:1}))]),key:"0"}:void 0]),1032,["title"])}}}),Qe=Z(Ke,[["__scopeId","data-v-3b599ad3"]]),qe={class:"provider-list"},Ze={class:"p-8"},el={key:0,class:"border-b mb-4"},ll={class:"ml-8"},ol={class:"flex align-center"},tl={class:"ml-8"},al={class:"flex align-center"},sl=["innerHTML"],nl=["title"],il={class:"flex align-center"},dl={class:"ml-8"},rl={class:"flex align-center"},cl=["innerHTML"],ml=["title"],ul=ie({__name:"Provider",props:{data:{},loading:{type:Boolean},showShared:{type:Boolean},active:{}},emits:["click"],setup(n,{emit:I}){const m=n,D=I,k=h([]),A=h([]);Ce(()=>m.data,f=>{var y;const i=["model_ollama_provider","model_local_provider","model_xinference_provider","model_vllm_provider"];(y=f.filter(v=>v.provider))==null||y.forEach(v=>{i.indexOf(v.provider)>-1?A.value.push(v):k.value.push(v)}),k.value.sort((v,g)=>v.provider.localeCompare(g.provider)),A.value.sort((v,g)=>v.provider.localeCompare(g.provider))},{immediate:!0});const S=f=>{D("click",f)},W=()=>{D("click",{provider:"share",name:P("views.shared.shared_model")})};return(f,i)=>{const y=r("AppIcon"),v=r("common-list"),g=r("el-collapse-item"),R=r("el-collapse"),F=r("el-scrollbar"),N=pe("loading");return t(),x("div",qe,[a(F,null,{default:e(()=>{var B,T;return[o("div",Ze,[n.showShared&&V(Me)(V(Se).IS_EE,"OR")?(t(),x("div",el,[o("div",{onClick:W,class:re(["shared-button flex cursor",((B=n.active)==null?void 0:B.provider)==="share"&&"active"])},[a(y,{iconName:"app-shared-active",style:{"font-size":"18px"},class:"color-primary"}),o("span",ll,p(f.$t("views.shared.shared_model")),1)],2)])):$("",!0),o("div",{class:re(["all-mode flex cursor",(T=n.active)!=null&&T.provider?"":"all-mode-active color-primary-1"]),onClick:i[0]||(i[0]=C=>S(V(se)))},[a(y,{class:"mr-8 color-primary",style:{height:"20px",width:"20px"},iconName:"app-all-menu-active"}),o("span",null,p(f.$t("views.model.modelType.allModel")),1)],2),a(R,{class:"model-collapse","expand-icon-position":"left"},{default:e(()=>[a(g,{title:f.$t("views.model.modelType.publicModel"),name:"1",icon:"CaretRight"},{title:e(()=>[o("div",ol,[a(y,{iconName:"app-folder",style:{"font-size":"20px"}}),o("span",tl,p(f.$t("views.model.modelType.publicModel")),1)])]),default:e(()=>[ne((t(),d(v,{data:k.value,onClick:S,"value-key":"provider","default-active":"",ref:"commonList1"},{default:e(({row:C})=>[o("div",al,[o("span",{innerHTML:C.icon,alt:"",style:{height:"20px",width:"20px"},class:"mr-8"},null,8,sl),o("span",{class:"ellipsis-1",title:C.name},p(C.name),9,nl)])]),_:1},8,["data"])),[[N,n.loading]])]),_:1},8,["title"]),a(g,{title:f.$t("views.model.modelType.privateModel"),name:"2",icon:"CaretRight"},{title:e(()=>[o("div",il,[a(y,{iconName:"app-folder",style:{"font-size":"20px"}}),o("span",dl,p(f.$t("views.model.modelType.privateModel")),1)])]),default:e(()=>[ne((t(),d(v,{data:A.value,onClick:S,"value-key":"provider","default-active":"",ref:"commonList2"},{default:e(({row:C})=>[o("div",rl,[o("span",{innerHTML:C.icon,alt:"",style:{height:"20px",width:"20px"},class:"mr-8"},null,8,cl),o("span",{class:"ellipsis-1",title:C.name},p(C.name),9,ml)])]),_:1},8,["data"])),[[N,n.loading]])]),_:1},8,["title"])]),_:1})])]}),_:1})])}}}),pl=Z(ul,[["__scopeId","data-v-0d404666"]]),vl={class:"p-12-16 pb-0 mt-12"},_l={class:"flex"},yl={class:"complex-search"},fl={class:"model-list-height"},hl=ie({__name:"index",setup(n){const I=ce(),{model:m,user:D}=Te(),k=L(()=>I.path.includes("shared")?"systemShare":I.path.includes("resource-management")?"systemManage":"workspace"),A=L(()=>me.model[k.value]),S=L(()=>k.value==="systemShare"),W=h(),f=h(),i=h(!1),y=h(),v=h("name"),g=h({name:"",create_user:"",model_type:""}),R=h([]),F=h(!1),N=h([]),B=h([]),T=L(()=>y.value&&y.value.provider==="share"),C=(c,s)=>{B.value.filter(u=>u.id==c).forEach(u=>{u.status=s.status})},j=L(()=>xe(B.value,2)),H=h(),J=h(),G=c=>{var s,u;y.value=c,l(),y.value.provider===""&&((s=W.value)==null||s.clearCurrent(),(u=f.value)==null||u.clearCurrent())},U=(c,s)=>{var u,b;c&&c.provider?(u=H.value)==null||u.open(c,s):(b=J.value)==null||b.open()},l=()=>{var s,u;const c=(s=y.value)!=null&&s.provider&&((u=y.value)==null?void 0:u.provider)!=="share"?{provider:y.value.provider}:{};Y({type:"model",isShared:T.value,systemType:k.value}).getModelList({...g.value,...c},F).then(b=>{B.value=b.data}),Y({type:"workspace",isShared:T.value,systemType:k.value}).getAllMemberList(D.getWorkspaceId(),i).then(b=>{R.value=b.data})},w=()=>{g.value={name:"",create_user:"",model_type:""}};return ue(()=>{m.asyncGetProvider(i).then(c=>{const s=["Anthropic","Amazon Bedrock","Gemini","SILICONFLOW","Xorbits Inference","Regolo"],u=c.data.filter(b=>!s.includes(b.name));y.value=se,N.value=[se,...u],l()})}),(c,s)=>{const u=r("el-option"),b=r("el-select"),ee=r("el-input"),K=r("el-button"),E=r("el-col"),z=r("el-row"),le=r("el-empty"),oe=r("ContentContainer"),te=r("LayoutContainer"),Q=pe("loading");return t(),d(te,{showCollapse:"",isCollapse:!0,class:"model-manage"},{left:e(()=>[o("h4",vl,p(c.$t("views.model.provider")),1),a(pl,{data:N.value,onClick:G,loading:i.value,showShared:A.value.is_share(),active:y.value},null,8,["data","loading","showShared","active"])]),default:e(()=>{var de;return[ne((t(),d(oe,{header:(de=y.value)==null?void 0:de.name,style:{padding:"0"}},{search:e(()=>[o("div",_l,[o("div",yl,[a(b,{class:"complex-search__left",modelValue:v.value,"onUpdate:modelValue":s[0]||(s[0]=_=>v.value=_),style:{width:"120px"},onChange:w},{default:e(()=>[a(u,{label:c.$t("common.creator"),value:"create_user"},null,8,["label"]),a(u,{label:c.$t("views.model.modelForm.model_type.label"),value:"model_type"},null,8,["label"]),a(u,{label:c.$t("views.model.modelForm.modeName.label"),value:"name"},null,8,["label"])]),_:1},8,["modelValue"]),v.value==="name"?(t(),d(ee,{key:0,modelValue:g.value.name,"onUpdate:modelValue":s[1]||(s[1]=_=>g.value.name=_),onChange:l,placeholder:c.$t("common.searchBar.placeholder"),style:{width:"220px"},clearable:""},null,8,["modelValue","placeholder"])):v.value==="create_user"?(t(),d(b,{key:1,modelValue:g.value.create_user,"onUpdate:modelValue":s[2]||(s[2]=_=>g.value.create_user=_),onChange:l,filterable:"",clearable:"",style:{width:"220px"}},{default:e(()=>[(t(!0),x(X,null,q(R.value,_=>(t(),d(u,{key:_.id,value:_.id,label:_.nick_name},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])):v.value==="model_type"?(t(),d(b,{key:2,modelValue:g.value.model_type,"onUpdate:modelValue":s[3]||(s[3]=_=>g.value.model_type=_),clearable:"",onChange:l,style:{width:"220px"}},{default:e(()=>[(t(!0),x(X,null,q(V(Le),_=>(t(),d(u,{key:_.value,label:_.text,value:_.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])):$("",!0)]),!T.value&&A.value.create()?(t(),d(K,{key:0,class:"ml-16",type:"primary",onClick:s[4]||(s[4]=_=>U(y.value))},{default:e(()=>[M(p(c.$t("views.model.addModel")),1)]),_:1})):$("",!0)])]),default:e(()=>[o("div",fl,[j.value.length>0?(t(),d(z,{key:0,gutter:15,class:"w-full"},{default:e(()=>[(t(!0),x(X,null,q(j.value,(_,ae)=>(t(),x(X,{key:ae},[(t(!0),x(X,null,q(_,(ve,_e)=>(t(),d(E,{xs:24,sm:12,md:S.value?24:12,lg:S.value?12:8,xl:S.value?12:8,class:"mb-16",key:_e},{default:e(()=>[a(Qe,{onChange:l,updateModelById:C,model:ve,provider_list:N.value,isShared:T.value,isSystemShare:S.value,apiType:k.value},null,8,["model","provider_list","isShared","isSystemShare","apiType"])]),_:2},1032,["md","lg","xl"]))),128))],64))),128))]),_:1})):(t(),d(le,{key:1,description:c.$t("common.noData")},null,8,["description"]))])]),_:1},8,["header"])),[[Q,F.value]]),T.value?$("",!0):(t(),d(Ie,{key:0,ref_key:"createModelRef",ref:H,onSubmit:l,onChange:s[5]||(s[5]=_=>U(_))},null,512)),T.value?$("",!0):(t(),d(De,{key:1,ref_key:"selectProviderRef",ref:J,onChange:s[6]||(s[6]=(_,ae)=>U(_,ae))},null,512))]}),_:1})}}}),Cl=Z(hl,[["__scopeId","data-v-40586c12"]]);export{Cl as default};
|