import{i as e,n as t,r as n,t as r}from"./client-BTeclN8X.js";function i(e){let t=e.toLowerCase();return!t.includes(`flux`)&&!t.includes(`sdxl`)&&!t.includes(`whisper`)&&!t.includes(`embedding`)&&!t.includes(`bge`)}async function a(){let e=await t(`/api/v1/admin/settings/ai`);return e.code!==0||!e.data?null:e.data}async function o(e){let t=await n(`/api/v1/admin/settings/ai`,e);return t.code!==0||!t.data?null:t.data}async function s(){let e=await t(`/api/v1/admin/ai/models`);return e.code!==0||!e.data?[]:e.data.models}var c=class extends Error{raw;model;errorDetail;firstError;constructor(e,t){super(e),this.name=`AiGenerateError`,this.raw=t?.raw,this.model=t?.model,this.errorDetail=t?.error,this.firstError=t?.firstError}};async function l(t,n,r={}){let i=await e(`/api/v1/admin/ai/generate`,{topic:t,existingTags:n,description:r.description,model:r.model,temperature:r.temperature,maxTokens:r.maxTokens});if(i.code!==0||!i.data){let e=i.data||{};throw new c(i.msg||`AI 生成失败，请稍后重试`,{raw:e.raw,model:e.model,error:e.error,firstError:e.firstError})}return i.data}async function u(t,n={}){let r=await e(`/api/v1/admin/ai/format`,{content:t,model:n.model,temperature:n.temperature,maxTokens:n.maxTokens});if(r.code!==0||!r.data)throw Error(r.msg||`AI 格式优化失败，请稍后重试`);return r.data}async function d(){let e=await t(`/api/v1/admin/ai/keys`);return e.code!==0||!e.data?[]:e.data.list}async function f(t){let n=await e(`/api/v1/admin/ai/keys`,{name:t});return n.code===0?n.data||{}:{msg:n.msg}}async function p(e){return(await r(`/api/v1/admin/ai/keys/${e}`)).code===0}async function m(){let e=await t(`/api/v1/admin/ai/custom-models`);return e.code!==0||!e.data?[]:e.data.list}async function h(t){let n=await e(`/api/v1/admin/ai/custom-models`,t);return n.code!==0||!n.data?null:n.data}async function g(e,t){let r=await n(`/api/v1/admin/ai/custom-models/${e}`,t);return r.code!==0||!r.data?null:r.data}async function _(e){return(await r(`/api/v1/admin/ai/custom-models/${e}`)).code===0}export{_ as a,s as c,l as d,i as f,p as i,a as l,o as m,f as n,d as o,g as p,h as r,m as s,c as t,u};