Files
YG_FT/frontend/dist/assets/ModelCreateView-xWX2_niA.js

2 lines
6.3 KiB
JavaScript
Raw Normal View History

2026-07-27 09:12:47 +08:00
import{a as S,E as j}from"./index-DOmj2wT1.js";import{E as F}from"./index-DOTsJDGF.js";import{E as N}from"./index-CunlXsH6.js";import{E as G,a as T}from"./index-uEvcRnhb.js";import{E as $,b as z}from"./index-CkuccYaV.js";import{v as Y}from"./directive-DnYsEmpc.js";import{d as H,aN as J,G as Q,K as W,e as m,w as t,y as _,j as P,z as X,o as n,s as o,c as V,ad as U,f as Z,M as b,x as i,aa as ee,A as w,v as le,ac as ae}from"./index-_T_ZwAU8.js";import{P as oe}from"./PageCard-Diq1cxbk.js";import{c as te,f as re,u as ue,h as ne}from"./model-CmuYoHXd.js";import"./castArray-BlzMMKhq.js";import"./_baseClone-BuLLSdZ_.js";import"./raf-BSHx3Xj9.js";import"./index-I-t9u_Se.js";import"./index-CaL9AHzU.js";import"./index-DPr6SX3u.js";import"./vnode-BBSgohgu.js";import"./index-DrL-DdXi.js";import"./index-CnFjh-NG.js";import"./index-jXIxALr6.js";import"./index-LblaQ-sT.js";import"./scroll-xdnWlbe1.js";import"./clamp-eKDmixUu.js";import"./toNumber-B7ieOfxs.js";import"./_baseIteratee-C37ZLjhl.js";import"./omit-BNuYgpQl.js";import"./index-DcESg4sN.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";const Be=H({__name:"ModelCreateView",setup(ie){const k=ae(),E=le(),f=_(),c=_(!1),g=_(!1),y=P(()=>!!k.params.id),d=P(()=>k.params.id),v=_([]),l=X({name:"",type:"LLM",purpose:"inference",model_source:"local",description:"",path:"",api_url:"",api_key:"",online_model_name:""}),q={name:[{required:!0,message:"请输入模型名称",trigger:"blur"},{max:100,message:"不超过 100 字符",trigger:"blur"}],type:[{required:!0,message:"请选择模型类型",trigger:"change"}],purpose:[{required:!0,message:"请选择模型用途",trigger:"change"}]};function I(){return l.model_source==="local"?{path:[{required:!0,message:"请选择本地模型路径",trigger:"change"}]}:{api_url:[{required:!0,message:"请输入 API 地址",trigger:"blur"}],api_key:[{required:!0,message:"请输入 API Key",trigger:"blur"}],online_model_name:[{required:!0,message:"请输入模型名称",trigger:"blur"}]}}const A=Object.entries(J).map(([r,e])=>({value:r,label:e}));async function C(){if(d.value){c.value=!0;try{const r=await te(d.value),e=r.model_source==="online"?"api":r.model_source||"local";Object.assign(l,{name:r.name||"",type:r.type||"LLM",purpose:r.purpose||"inference",model_source:e,description:r.description||"",path:r.path||"",api_url:r.api_url||"",api_key:r.api_key||"",online_model_name:r.model_name||""})}catch{}finally{c.value=!1}}}async function R(){try{const r=await re();v.value=(r==null?void 0:r.models)||[]}catch{v.value=[]}}async function O(){f.value&&await f.value.validate(async r=>{if(r){if(l.model_source==="local"&&!l.path){w.warning("请选择本地模型路径");return}g.value=!0;try{const e={name:l.name,type:l.type,purpose:l.purpose,model_source:l.model_source,description:l.description};l.model_source==="local"?e.path=l.path:(e.api_url=l.api_url,e.api_key=l.api_key,e.online_model_name=l.online_model_name),y.value&&d.value?(await ue(d.value,e),w.success("更新成功")):(await ne(e),w.success("创建成功")),E.push("/model-manage")}catch{}finally{g.value=!1}}})}function B(){E.back()}return Q(()=>{R(),C()}),(r,e)=>{const p=F,u=S,M=T,h=G,s=z,x=$,L=N,D=j,K=Y;return W((n(),m(oe,{title:y.value?"编辑模型":"添加模型"},{default:t(()=>[o(D,{ref_key:"formRef",ref:f,model:l,rules:{...q,...I()},"label-width":"120px",style:{"max-width":"640px"}},{default:t(()=>[o(u,{label:"模型名称",prop:"name"},{default:t(()=>[o(p,{modelValue:l.name,"onUpdate:modelValue":e[0]||(e[0]=a=>l.name=a),placeholder:"请输入模型名称",maxlength:"100","show-word-limit":""},null,8,["modelValue"])]),_:1}),o(u,{label:"模型类型",prop:"type"},{default:t(()=>[o(h,{modelValue:l.type,"onUpdate:modelValue":e[1]||(e[1]=a=>l.type=a),placeholder:"请选择模型类型",style:{width:"100%"}},{default:t(()=>[(n(!0),V(b,null,U(Z(A),a=>(n(),m(M,{key:a.value,label:a.label,value:a.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1}),o(u,{label:"模型用途",prop:"purpose"},{default:t(()=>[o(x,{modelValue:l.purpose,"onUpdate:modelValue":e[2]||(e[2]=a=>l.purpose=a)},{defaul