2 lines
14 KiB
JavaScript
2 lines
14 KiB
JavaScript
import{ce as Y,aE as t,bf as x,aI as o,ay as de,b7 as ce,b8 as L,b9 as me,aB as h,aC as O,br as ue,cZ as ye,aD as r,aF as i,b$ as fe,aG as e,aH as a,bb as F,aK as M,aJ as p,bm as w,bn as V,ca as he,c4 as ge,c0 as ke,cE as be,c6 as we,bc as j,bo as $e,be as Ce,bs as pe,bW as Me,bX as Se,cg as re,dA as se,bt as ne,aA as Te,dB as xe,bg as X,bh as Q,c9 as Le,dC as Ie,dD as De}from"./chat-GAihfC9N.js";import{E as Ae,_ as Re}from"./ParamSettingDialog.vue_vue_type_script_setup_true_lang-DS97bO7P.js";import{_ as Ne}from"./AuthorizedWorkspaceDialog.vue_vue_type_script_setup_true_lang-J-SUySeB.js";import"./permission-api-CeSdPkUe.js";import"./workspace-BxQ89rPu.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=Y(Be,[["render",Ve],["__scopeId","data-v-91938551"]]),Fe=["innerHTML"],Oe={class:"flex",style:{height:"22px"}},Pe=["title"],We={key:0},He={key:1},Ue={class:"flex mb-4"},Ge={class:"ellipsis ml-16"},Xe={class:"flex"},je={class:"ellipsis-1 ml-16",style:{height:"20px",width:"70%"}},Je={key:0,class:"progress-mask"},Ke={class:"percentage-label flex-center"},Ze=de({__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(),d=L(()=>f.value?f.value:m.model),y=L(()=>d.value.meta&&d.value.meta.message?d.value.meta.message==="pull model manifest: file does not exist"?`${d.value.model_name} ${O("views.model.tip.noModel")}`:d.value.meta.message:""),v=I,g=h();let R;const P=()=>{we(`${O("views.model.delete.confirmTitle")}${m.model.name} ?`,O("views.model.delete.confirmMessage"),{confirmButtonText:O("common.confirm"),confirmButtonClass:"danger"}).then(()=>{j({type:"model",systemType:m.apiType}).deleteModel(m.model.id).then(()=>{v("change"),$e(O("common.deleteSuccess"))})}).catch(()=>{})},N=()=>{j({type:"model",systemType:m.apiType}).pauseDownload(m.model.id).then(()=>{f.value=void 0,v("change")})},B=()=>{var b;const l=m.provider_list.find(c=>c.provider===m.model.provider);l&&((b=g.value)==null||b.open(l,m.model))},T=L(()=>{var l;return(l=m.provider_list.find(b=>b.provider===m.model.provider))==null?void 0:l.icon}),C=()=>{R=setInterval(()=>{d.value.status==="DOWNLOAD"?j({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(),K=()=>{var l;(l=H.value)==null||l.open(m.model)},U=h();function G(l){U.value&&U.value.open(l,"Model")}return ue(()=>{C()}),ye(()=>{J()}),(l,b)=>{const c=r("WarningFilled"),s=r("el-icon"),u=r("el-tooltip"),$=r("el-text"),ee=r("el-tag"),Z=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(),i(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,Fe)]),title:e(()=>[o("div",Oe,[o("span",{class:"ellipsis-1 mb-4",title:n.model.name,style:{"max-width":"80%"}},p(n.model.name),9,Pe),d.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"])])):w("",!0),d.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"])])):w("",!0)])]),subTitle:e(()=>[a($,{class:"color-secondary lighter",size:"small"},{default:e(()=>[M(p(l.$t("common.creator"))+": "+p(V(be)(n.model.nick_name)),1)]),_:1})]),tag:e(()=>[n.isShared||D.value?(t(),i(ee,{key:0,type:"info",class:"info-tag"},{default:e(()=>[M(p(V(O)("views.shared.title")),1)]),_:1})):w("",!0)]),default:e(()=>[o("ul",null,[o("li",Ue,[a($,{type:"info",class:"color-secondary"},{default:e(()=>[M(p(l.$t("views.model.modelForm.model_type.label")),1)]),_:1}),o("span",Ge,p(l.$t(V(he)[n.model.model_type])),1)]),o("li",Xe,[a($,{type:"info",class:"color-secondary"},{default:e(()=>[M(p(l.$t("views.model.modelForm.base_model.label")),1)]),_:1}),o("span",je,p(n.model.model_name),1)])]),d.value.status==="DOWNLOAD"?(t(),x("div",Je,[a(ze,{class:"percentage"}),o("div",Ke,[M(p(l.$t("views.model.download.downloading"))+" ",1),b[4]||(b[4]=o("span",{class:"dotting"},null,-1)),a(Z,{link:"",type:"primary",class:"ml-16",onClick:F(N,["stop"])},{default:e(()=>[M(p(l.$t("views.model.download.cancelDownload")),1)]),_:1})])])):w("",!0),a(Ae,{ref_key:"editModelRef",ref:g,onSubmit:b[3]||(b[3]=q=>v("change"))},null,512),a(Re,{ref_key:"paramSettingRef",ref:H},null,512),D.value?(t(),i(Ne,{key:1,ref_key:"AuthorizedWorkspaceDialogRef",ref:U},null,512)):w("",!0),n.apiType==="workspace"?(t(),i(ge,{key:2,type:V(ke).MODEL,ref_key:"ResourceAuthorizationDrawerRef",ref:S},null,8,["type"])):w("",!0)]),_:2},[A(n.model.id)?{name:"mouseEnter",fn:e(()=>[n.isShared?w("",!0):(t(),i(oe,{key:0,trigger:"click"},{dropdown:e(()=>[a(le,null,{default:e(()=>[k.value.modify(n.model.id)?(t(),i(z,{key:0,text:"",onClick:F(B,["stop"])},{default:e(()=>[a(E,{iconName:"app-edit",class:"color-secondary"}),M(" "+p(l.$t("common.edit")),1)]),_:1})):w("",!0),D.value?(t(),i(z,{key:1,onClick:b[1]||(b[1]=F(q=>G(n.model),["stop"]))},{default:e(()=>[a(E,{iconName:"app-lock",class:"color-secondary"}),M(" "+p(l.$t("views.shared.authorized_workspace")),1)]),_:1})):w("",!0),(d.value.model_type==="TTS"||d.value.model_type==="STT"||d.value.model_type==="LLM"||d.value.model_type==="IMAGE"||d.value.model_type==="TTI"||d.value.model_type==="ITV"||d.value.model_type==="EMBEDDING"||d.value.model_type==="TTV")&&k.value.paramSetting(n.model.id)?(t(),i(z,{key:2,onClick:F(K,["stop"])},{default:e(()=>[a(E,{iconName:"app-setting",class:"color-secondary"}),M(" "+p(l.$t("views.model.modelForm.title.paramSetting")),1)]),_:1})):w("",!0),n.apiType==="workspace"&&k.value.auth(n.model.id)?(t(),i(z,{key:3,onClick:b[2]||(b[2]=F(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})):w("",!0),k.value.delete(n.model.id)?(t(),i(z,{key:4,divided:"",text:"",onClick:F(P,["stop"])},{default:e(()=>[a(E,{iconName:"app-delete",class:"color-secondary"}),M(" "+p(l.$t("common.delete")),1)]),_:1})):w("",!0)]),_:1})]),default:e(()=>[a(Z,{text:"",onClick:b[0]||(b[0]=F(()=>{},["stop"]))},{default:e(()=>[a(E,{iconName:"app-more"})]),_:1})]),_:1}))]),key:"0"}:void 0]),1032,["title"])}}}),qe=Y(Ze,[["__scopeId","data-v-3b599ad3"]]),Qe={class:"provider-list"},Ye={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"],dl={class:"flex align-center"},il={class:"ml-8"},rl={class:"flex align-center"},cl=["innerHTML"],ml=["title"],ul=de({__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 d=["model_ollama_provider","model_local_provider","model_xinference_provider","model_vllm_provider"];(y=f.filter(v=>v.provider))==null||y.forEach(v=>{d.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:O("views.shared.shared_model")})};return(f,d)=>{const y=r("AppIcon"),v=r("common-list"),g=r("el-collapse-item"),R=r("el-collapse"),P=r("el-scrollbar"),N=pe("loading");return t(),x("div",Qe,[a(P,null,{default:e(()=>{var B,T;return[o("div",Ye,[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)])):w("",!0),o("div",{class:re(["all-mode flex cursor",(T=n.active)!=null&&T.provider?"":"all-mode-active color-primary-1"]),onClick:d[0]||(d[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(),i(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",dl,[a(y,{iconName:"app-folder",style:{"font-size":"20px"}}),o("span",il,p(f.$t("views.model.modelType.privateModel")),1)])]),default:e(()=>[ne((t(),i(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=Y(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=de({__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(),d=h(!1),y=h(),v=h("name"),g=h({name:"",create_user:"",model_type:""}),R=h([]),P=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(),K=h(),U=c=>{var s,u;y.value=c,l(),y.value.provider===""&&((s=W.value)==null||s.clearCurrent(),(u=f.value)==null||u.clearCurrent())},G=(c,s)=>{var u,$;c&&c.provider?(u=H.value)==null||u.open(c,s):($=K.value)==null||$.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}:{};j({type:"model",isShared:T.value,systemType:k.value}).getModelList({...g.value,...c},P).then($=>{B.value=$.data}),j({type:"workspace",isShared:T.value,systemType:k.value}).getAllMemberList(D.getWorkspaceId(),d).then($=>{R.value=$.data})},b=()=>{g.value={name:"",create_user:"",model_type:""}};return ue(()=>{m.asyncGetProvider(d).then(c=>{const s=["Anthropic","Amazon Bedrock","Gemini","SILICONFLOW","Xorbits Inference","Regolo"],u=c.data.filter($=>!s.includes($.name));y.value=se,N.value=[se,...u],l()})}),(c,s)=>{const u=r("el-option"),$=r("el-select"),ee=r("el-input"),Z=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(),i(te,{showCollapse:"",class:"model-manage"},{left:e(()=>[o("h4",vl,p(c.$t("views.model.provider")),1),a(pl,{data:N.value,onClick:U,loading:d.value,showShared:A.value.is_share(),active:y.value},null,8,["data","loading","showShared","active"])]),default:e(()=>{var ie;return[ne((t(),i(oe,{header:(ie=y.value)==null?void 0:ie.name,style:{padding:"0"}},{search:e(()=>[o("div",_l,[o("div",yl,[a($,{class:"complex-search__left",modelValue:v.value,"onUpdate:modelValue":s[0]||(s[0]=_=>v.value=_),style:{width:"120px"},onChange:b},{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(),i(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(),i($,{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(),i(u,{key:_.id,value:_.id,label:_.nick_name},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])):v.value==="model_type"?(t(),i($,{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(),i(u,{key:_.value,label:_.text,value:_.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])):w("",!0)]),!T.value&&A.value.create()?(t(),i(Z,{key:0,class:"ml-16",type:"primary",onClick:s[4]||(s[4]=_=>G(y.value))},{default:e(()=>[M(p(c.$t("views.model.addModel")),1)]),_:1})):w("",!0)])]),default:e(()=>[o("div",fl,[J.value.length>0?(t(),i(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(),i(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(),i(le,{key:1,description:c.$t("common.noData")},null,8,["description"]))])]),_:1},8,["header"])),[[q,P.value]]),T.value?w("",!0):(t(),i(Ie,{key:0,ref_key:"createModelRef",ref:H,onSubmit:l,onChange:s[5]||(s[5]=_=>G(_))},null,512)),T.value?w("",!0):(t(),i(De,{key:1,ref_key:"selectProviderRef",ref:K,onChange:s[6]||(s[6]=(_,ae)=>G(_,ae))},null,512))]}),_:1})}}}),Cl=Y(hl,[["__scopeId","data-v-aba77917"]]);export{Cl as default};
|