import{E as D}from"./index-BjEW7-SA.js";import{E as L}from"./index-BDEF353-.js";import{E as A}from"./el-table-D8K5zLyz.js";import{d as S,G as $,ah as w,e as m,w as i,y as x,o as n,q as c,x as l,c as P,s as o,M as R,aa as f,A as C,v as V}from"./index-BKKvzUDD.js";import{E as J}from"./index-dNo5H1ie.js";/* empty css               */import"./el-checkbox-qGZ2-RM2.js";import{D as O}from"./DataTablePage-C-EM-7-s.js";import{u as U}from"./usePolling-C6448AR2.js";import{g as j,l as q,u as F,a as G,s as I,d as H}from"./compare-CZ4TIoIW.js";import"./el-scrollbar-ClJnvz-9.js";import"./index-GAnQrJsQ.js";import"./el-popper-D6_hxRbQ.js";import"./index-CWUnzf90.js";import"./_baseClone-B5RBzbh5.js";import"./_baseIteratee-BAilevJ_.js";import"./castArray-5uErZEc3.js";import"./debounce-ByXPNh5F.js";import"./toNumber-Dkj3QRv9.js";import"./raf-C-x62Pcl.js";import"./validator-Fn0bm4xU.js";import"./index-CQXVR1Ud.js";import"./clamp-CbbY8h6F.js";import"./index-DfyOU94W.js";import"./scroll-BkzZKETR.js";import"./index-TFUf94PZ.js";import"./index-DLzof2Fz.js";import"./omit-BTSq4AYh.js";import"./el-card-CApHJ1Gj.js";import"./el-pagination-DOPYW-qb.js";import"./el-select-Dl-FRZQd.js";import"./vnode-78qeDweP.js";import"./index-D5ryD3I5.js";import"./directive-DsZckUTJ.js";import"./el-tooltip-l0sNRNKZ.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";const K={class:"action-buttons"},Ae=S({__name:"InferenceListView",setup(Q){const E=V(),y=x(!1),h=x([]);let d=null;async function p(t=!1){t||(y.value=!0);try{h.value=await j()||[]}catch{}finally{t||(y.value=!1)}}function g(t){const e=_(t);return e.length>0&&e.some(s=>s.status==="starting")}function v(t){const e=_(t);return e.length===0?t.status==="loaded"||t.status==="ready":e.every(s=>s.status==="ready"||s.status==="running")&&!g(t)}function _(t){if(!t.load_status)return[];try{return(typeof t.load_status=="string"?JSON.parse(t.load_status):t.load_status).loaded_models||[]}catch{return[]}}function z(t){if(!t.models)return[];if(Array.isArray(t.models))return t.models.map(e=>e.model_name||e.name).filter(Boolean);try{const e=JSON.parse(t.models);if(Array.isArray(e))return e.map(s=>s.model_name||s.name).filter(Boolean)}catch{}return[]}async function B(t){await q(t.id),C.info("正在加载模型，请稍候..."),d&&clearTimeout(d),d=setTimeout(p,1e3)}async function T(t){await J.confirm("确定要停止模型服务吗？","确认停止",{type:"warning"}),await F(t.id),C.success("已停止模型服务"),p()}async function b(t){const e=await G(t.id).catch(()=>null);if(e!=null&&e.load_status){const s=_(e);for(const r of s)r.pid&&await I(r.pid).catch(()=>{})}await H(t.id),C.success("删除成功")}function M(t){E.push(`/model-inference/chat/${t.id}`)}const{start:N}=U(()=>p(!0),3e3,{immediate:!1});return $(async()=>{await p(),N()}),w(()=>{d&&clearTimeout(d)}),(t,e)=>{const s=A,r=L,u=D;return n(),m(O,{title:"模型推理",data:h.value,loading:y.value,searchable:"","search-fields":["name","model_name","description"],"create-text":"新建推理","create-to":"/model-inference/create","delete-fn":b,"row-key":"id",onRefresh:p},{columns:i(()=>[o(s,{label:"推理名称",align:"center"},{default:i(({row:a})=>[l(f(a.model_name||a.name||"-"),1)]),_:1}),o(s,{label:"描述",align:"center","show-overflow-tooltip":""},{default:i(({row:a})=>[l(f(a.description||"-"),1)]),_:1}),o(s,{label:"状态",align:"center",width:"120"},{default:i(({row:a})=>[g(a)?(n(),m(r,{key:0,type:"warning",size:"small"},{default:i(()=>[...e[0]||(e[0]=[l("启动中",-1)])]),_:1})):v(a)?(n(),m(r,{key:1,type:"success",size:"small"},{default:i(()=>[...e[1]||(e[1]=[l("已就绪",-1)])]),_:1})):(n(),m(r,{key:2,type:"info",size:"small"},{default:i(()=>[l(f(a.status||"未启动"),1)]),_:2},1024))]),_:1}),o(s,{label:"相关模型",align:"center","show-overflow-tooltip":""},{default:i(({row:a})=>[l(f(z(a).join("，")||"-"),1)]),_:1}),o(s,{label:"创建时间",align:"center",width:"180"},{default:i(({row:a})=>[l(f(a.create_time?new Date(a.create_time).toLocaleString("zh-CN"):"-"),1)]),_:1})]),actions:i(({row:a})=>[c("div",K,[g(a)?(n(),m(u,{key:0,type:"warning",link:"",size:"small",loading:!0,disabled:""},{default:i(()=>[...e[2]||(e[2]=[l(" 加载中 ",-1)])]),_:1})):v(a)?(n(),P(R,{key:1},[o(u,{type:"success",link:"",size:"small",onClick:k=>M(a)},{default:i(()=>[...e[3]||(e[3]=[c("i",{class:"fa fa-comments-o",style:{"margin-right":"4px"}},null,-1),l("对话 ",-1)])]),_:1},8,["onClick"]),o(u,{type:"warning",link:"",size:"small",onClick:k=>T(a)},{default:i(()=>[...e[4]||(e[4]=[c("i",{class:"fa fa-stop-circle-o",style:{"margin-right":"4px"}},null,-1),l("停止 ",-1)])]),_:1},8,["onClick"])],64)):(n(),m(u,{key:2,type:"primary",link:"",size:"small",onClick:k=>B(a)},{default:i(()=>[...e[5]||(e[5]=[c("i",{class:"fa fa-play-circle-o",style:{"margin-right":"4px"}},null,-1),l("加载 ",-1)])]),_:1},8,["onClick"])),o(u,{type:"danger",link:"",size:"small",onClick:k=>b(a)},{default:i(()=>[...e[6]||(e[6]=[c("i",{class:"fa fa-trash-o",style:{"margin-right":"4px"}},null,-1),l("删除 ",-1)])]),_:1},8,["onClick"])])]),_:1},8,["data","loading"])}}});export{Ae as default};
