2 lines
14 KiB
JavaScript
2 lines
14 KiB
JavaScript
import{ce as Q,b0 as t,bc as x,b5 as o,aW as de,aX as ce,aY as L,a_ as me,aZ as h,aU as O,bp as ue,cZ as fe,a$ as r,b1 as i,b$ as ye,b2 as e,b3 as a,b6 as F,b7 as M,b8 as p,bk as w,bl as V,ca as he,c4 as ge,c0 as ke,cF as be,c6 as we,b9 as j,bm as $e,bb as Ce,bq as pe,bW as Me,bX as Se,cf as re,dA as se,br as ne,bj as Te,dB as xe,bd as X,be as K,c9 as Le,dC as Ie,dD as De}from"./chat-qPBzecKv.js";import{E as Ae,_ as Re}from"./ParamSettingDialog.vue_vue_type_script_setup_true_lang-ChWmnxX3.js";import{_ as Ne}from"./AuthorizedWorkspaceDialog.vue_vue_type_script_setup_true_lang-DH2DKlXp.js";import"./permission-api-DGZfyy6y.js";import"./workspace-CSuuUCkN.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=Q(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%"}},Ze={key:0,class:"progress-mask"},qe={class:"percentage-label flex-center"},Ye=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 y=h(),d=L(()=>y.value?y.value:m.model),f=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(()=>{y.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=>{y.value=l.data}):y.value&&(m.updateModelById(m.model.id,y.value),y.value=void 0)},6e3)},Z=()=>{R&&clearInterval(R)},H=h(),q=()=>{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()}),fe(()=>{Z()}),(l,b)=>{const c=r("WarningFilled"),s=r("el-icon"),u=r("el-tooltip"),$=r("el-text"),ee=r("el-tag"),Y=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"},ye({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:f.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",Ze,[a(ze,{class:"percentage"}),o("div",qe,[M(p(l.$t("views.model.download.downloading"))+" ",1),b[4]||(b[4]=o("span",{class:"dotting"},null,-1)),a(Y,{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]=J=>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(J=>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(q,["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(J=>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(Y,{text:"",onClick:b[0]||(b[0]=F(()=>{},["stop"]))},{default:e(()=>[a(E,{iconName:"app-more"})]),_:1})]),_:1}))]),key:"0"}:void 0]),1032,["title"])}}}),Je=Q(Ye,[["__scopeId","data-v-3b599ad3"]]),Ke={class:"provider-list"},Qe={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,y=>{var f;const d=["model_ollama_provider","model_local_provider","model_xinference_provider","model_vllm_provider"];(f=y.filter(v=>v.provider))==null||f.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=y=>{D("click",y)},W=()=>{D("click",{provider:"share",name:O("views.shared.shared_model")})};return(y,d)=>{const f=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",Ke,[a(P,null,{default:e(()=>{var B,T;return[o("div",Qe,[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(f,{iconName:"app-shared-active",style:{"font-size":"18px"},class:"color-primary"}),o("span",ll,p(y.$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(f,{class:"mr-8 color-primary",style:{height:"20px",width:"20px"},iconName:"app-all-menu-active"}),o("span",null,p(y.$t("views.model.modelType.allModel")),1)],2),a(R,{class:"model-collapse","expand-icon-position":"left"},{default:e(()=>[a(g,{title:y.$t("views.model.modelType.publicModel"),name:"1",icon:"CaretRight"},{title:e(()=>[o("div",ol,[a(f,{iconName:"app-folder",style:{"font-size":"20px"}}),o("span",tl,p(y.$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:y.$t("views.model.modelType.privateModel"),name:"2",icon:"CaretRight"},{title:e(()=>[o("div",dl,[a(f,{iconName:"app-folder",style:{"font-size":"20px"}}),o("span",il,p(y.$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=Q(ul,[["__scopeId","data-v-0d404666"]]),vl={class:"p-12-16 pb-0 mt-12"},_l={class:"flex"},fl={class:"complex-search"},yl={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(),y=h(),d=h(!1),f=h(),v=h("name"),g=h({name:"",create_user:"",model_type:""}),R=h([]),P=h(!1),N=h([]),B=h([]),T=L(()=>f.value&&f.value.provider==="share"),C=(c,s)=>{B.value.filter(u=>u.id==c).forEach(u=>{u.status=s.status})},Z=L(()=>xe(B.value,2)),H=h(),q=h(),U=c=>{var s,u;f.value=c,l(),f.value.provider===""&&((s=W.value)==null||s.clearCurrent(),(u=y.value)==null||u.clearCurrent())},G=(c,s)=>{var u,$;c&&c.provider?(u=H.value)==null||u.open(c,s):($=q.value)==null||$.open()},l=()=>{var s,u;const c=(s=f.value)!=null&&s.provider&&((u=f.value)==null?void 0:u.provider)!=="share"?{provider:f.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));f.value=se,N.value=[se,...u],l()})}),(c,s)=>{const u=r("el-option"),$=r("el-select"),ee=r("el-input"),Y=r("el-button"),E=r("el-col"),z=r("el-row"),le=r("el-empty"),oe=r("ContentContainer"),te=r("LayoutContainer"),J=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:f.value},null,8,["data","loading","showShared","active"])]),default:e(()=>{var ie;return[ne((t(),i(oe,{header:(ie=f.value)==null?void 0:ie.name,style:{padding:"0"}},{search:e(()=>[o("div",_l,[o("div",fl,[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,K(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,K(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(Y,{key:0,class:"ml-16",type:"primary",onClick:s[4]||(s[4]=_=>G(f.value))},{default:e(()=>[M(p(c.$t("views.model.addModel")),1)]),_:1})):w("",!0)])]),default:e(()=>[o("div",yl,[Z.value.length>0?(t(),i(z,{key:0,gutter:15,class:"w-full"},{default:e(()=>[(t(!0),x(X,null,K(Z.value,(_,ae)=>(t(),x(X,{key:ae},[(t(!0),x(X,null,K(_,(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(Je,{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"])),[[J,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:q,onChange:s[6]||(s[6]=(_,ae)=>G(_,ae))},null,512))]}),_:1})}}}),Cl=Q(hl,[["__scopeId","data-v-aba77917"]]);export{Cl as default};
|