PageSourceSearch

https://recork.org/_app/immutable/chunks/BIMfEMVU.js

js recork.org collected 2026-09-25 21:05:48 UTC 17,889 bytes, 2 lines download raw bytes

1import{_ as R}from"./C1FmrZbK.js";import{d as h,x as U}from"./DKKyCjZm.js";import{g as G}from"./CyHtxK_t.js";const J=o=>{if(typeof o=="string")return o;if(typeof o=="object"&&o!==null&&"name"in o)return o.name},L=o=>(Array.isArray(o)?o:[]).map(J).filter(t=>typeof t=="string"&&t.trim()!=="").map(t=>({name:t.trim()})),B=1e4,N=new Set(["get","put","post","delete","options","head","patch","trace"]),V=async(o="",t=null,n=!1,a=!1)=>{const e=new URLSearchParams;a&&e.append("refresh","true");let i=null;const s=await fetch(`${h}/api/models${n?"/base":""}?${e.toString()}`,{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json",...o&&{authorization:`Bearer ${o}`}}}).then(async r=>{if(!r.ok)throw await r.json();return r.json()}).catch(r=>(i=r,null));if(i)throw i;let l=(s==null?void 0:s.data)??[];if(t&&!n){let r=[];if(t){const c=t.OPENAI_API_BASE_URLS,y=t.OPENAI_API_KEYS,f=t.OPENAI_API_CONFIGS,d=[];for(const j in c){const T=c[j];if(j.toString()in f){const m=f[j.toString()]??{},S=(m==null?void 0:m.enable)??!0,P=(m==null?void 0:m.model_ids)??[];if(S)if(P.length>0){const A={object:"list",data:P.map(g=>({id:g,name:g,owned_by:"openai",openai:{id:g},urlIdx:j}))};d.push((async()=>A)())}else d.push((async()=>await G(T,y[j]).then(A=>A).catch(A=>({object:"list",data:[],urlIdx:j})))());else d.push((async()=>({object:"list",data:[],urlIdx:j}))())}}const $=await Promise.all(d);for(const j in $){const T=$[j],m=f[j.toString()]??{};let S=Array.isArray(T)?T:(T==null?void 0:T.data)??[];S=S.map(g=>({...g,openai:{id:g.id},urlIdx:j}));const P=m.prefix_id;if(P)for(const g of S)g.id=`${P}.${g.id}`;const A=L(m.tags);if(A.length>0)for(const g of S)g.tags=A;r=r.concat(S)}}l=l.concat(r.map(c=>({...c,name:(c==null?void 0:c.name)??(c==null?void 0:c.id),direct:!0})));const u={};for(const c of l){const y=u[c.id];u[c.id]=y?{...y,...c,info:y.info??c.info}:c}l=Object.values(u)}return l},F=async(o,t)=>{let n=null;const a=await fetch(`${h}/api/models/unload`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...o&&{authorization:`Bearer ${o}`}},body:JSON.stringify({model:t})}).then(async e=>{if(!e.ok)throw await e.json();return e.json()}).catch(e=>("detail"in e?n=e.detail:n=e,null));if(n)throw n;return a},H=async(o,t,n)=>{let a=null;const e=await fetch(`${h}/api/chat/actions/${t}`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...o&&{authorization:`Bearer ${o}`}},body:JSON.stringify(n)}).then(async i=>{if(!i.ok)throw await i.json();return i.json()}).catch(i=>("detail"in i?a=i.detail:a=i,null));if(a)throw a;return e},K=async(o,t)=>{let n=null;const a=await fetch(`${h}/api/tasks/stop/${t}`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...o&&{authorization:`Bearer ${o}`}}}).then(async e=>{if(!e.ok)throw await e.json();return e.json()}).catch(e=>("detail"in e?n=e.detail:n=e,null));if(n)throw n;return a},Y=async(o,t)=>{let n=null;const a=await fetch(`${h}/api/tasks/chat/${encodeURIComponent(t)}/stop`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...o&&{authorization:`Bearer ${o}`}}}).then(async e=>{if(!e.ok)throw await e.json();return e.json()}).catch(e=>("detail"in e?n=e.detail:n=e,null));if(n)throw n;return a},X=async(o,t)=>{let n=null;const a=await fetch(`${h}/api/tasks/chat/${encodeURIComponent(t)}`,{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json",...o&&{authorization:`Bearer ${o}`}}}).then(async e=>{if(!e.ok)throw await e.json();return e.json()}).catch(e=>("detail"in e?n=e.detail:n=e,null));if(n)throw n;return a},q=async(o,t)=>{let n=null;const a=await fetch(`${t}`,{signal:AbortSignal.timeout(B),method:"GET",headers:{Accept:"application/json","Content-Type":"application/json",...o&&{authorization:`Bearer ${o}`}}}).then(async e=>{if(t.toLowerCase().endsWith(".yaml")||t.toLowerCase().endsWith(".yml")){if(!e.ok)throw await e.text();const[i,{parse:s}]=await Promise.all([e.text(),R(()=>import("./B09doO8H.js"),[],import.meta.url)]);return s(i)}else{if(!e.ok)throw await e.json();return e.json()}}).catch(e=>((e==null?void 0:e.name)==="TimeoutError"?n=`Connection to ${t} timed out`:"detail"in e?n=e.detail:n=e,null));if(n)throw n;return a},Q=async o=>(await Promise.all(o.filter(t=>{var n;return(n=t==null?void 0:t.config)==null?void 0:n.enable}).map(async t=>{var l;let n=null,a=null;const e=(t==null?void 0:t.auth_type)??"bearer";e==="bearer"?a=t==null?void 0:t.key:e==="none"||e==="session"&&(
1a=localStorage.token);let i=null;const s=(t==null?void 0:t.spec_type)??"url";if(s==="url")i=await q(a,((t==null?void 0:t.path)??"").includes("://")?t==null?void 0:t.path:`${t==null?void 0:t.url}${((t==null?void 0:t.path)??"").startsWith("/")?"":"/"}${t==null?void 0:t.path}`).catch(r=>(n=r,null));else if((s==="json"&&(t==null?void 0:t.spec))??null)try{i=JSON.parse(t==null?void 0:t.spec)}catch{n="Failed to parse JSON spec"}if(i){if(!i.paths)return{error:"Invalid OpenAPI spec",url:t==null?void 0:t.url};const{openapi:r,info:u,specs:c}={openapi:i,info:i.info,specs:U(i)},y={url:t==null?void 0:t.url,openapi:r,info:u,specs:c};try{const f=((t==null?void 0:t.url)??"").replace(/\/$/,""),d=await fetch(`${f}/api/config`,{signal:AbortSignal.timeout(B)});if(d.ok){const $=await d.json();if((l=$==null?void 0:$.features)!=null&&l.system){const j={};a&&(j.Authorization=`Bearer ${a}`);const T=await fetch(`${f}/system`,{signal:AbortSignal.timeout(B),headers:j});if(T.ok){const m=await T.json();m!=null&&m.prompt&&(y.system_prompt=m.prompt)}}}}catch{}return y}else return n?{error:n,url:t==null?void 0:t.url}:null}))).filter(t=>t),Z=async(o,t,n,a,e,i)=>{var l,r;let s=null;try{const u=Object.entries(e.openapi.paths).find(([p,w])=>Object.entries(w).some(([O,b])=>N.has(O)&&b&&typeof b=="object"&&b.operationId===n));if(!u)throw new Error(`No matching route found for operationId: ${n}`);const[c,y]=u,f=Object.entries(y).find(([p,w])=>N.has(p)&&w&&typeof w=="object"&&w.operationId===n);if(!f)throw new Error(`No matching method found for operationId: ${n}`);const[d,$]=f,j=Array.isArray(y.parameters)?y.parameters:[],T=Array.isArray($.parameters)?$.parameters:[],m=new Map;for(const p of j)p!=null&&p.name&&m.set(`${p.name}:${p.in??""}`,p);for(const p of T)p!=null&&p.name&&m.set(`${p.name}:${p.in??""}`,p);const S={},P={};let A={};for(const p of m.values()){const w=p==null?void 0:p.name;if(!w)continue;const O=p==null?void 0:p.in;a.hasOwnProperty(w)&&(O==="path"?S[w]=a[w]:O==="query"&&(P[w]=a[w]))}let g=`${t}${c}`;if(Object.entries(S).forEach(([p,w])=>{g=g.replace(new RegExp(`{${p}}`,"g"),encodeURIComponent(w))}),Object.keys(P).length>0){const p=new URLSearchParams(Object.entries(P).map(([w,O])=>[w,String(O)])).toString();g+=`?${p}`}if($.requestBody&&$.requestBody.content){const p=Object.keys($.requestBody.content)[0];if(a!==void 0)A=a;else throw new Error(`Request body expected for operation '${n}' but none found.`)}const x={"Content-Type":"application/json",...o&&{authorization:`Bearer ${o}`}};i&&(x["X-Session-Id"]=i);const _={method:d.toUpperCase(),headers:x};["post","put","patch","delete"].includes(d.toLowerCase())&&$.requestBody&&(_.body=JSON.stringify(A));const E=await fetch(g,_);if(!E.ok){const p=await E.text();throw new Error(`HTTP error! Status: ${E.status}. Message: ${p}`)}const z={};E.headers.forEach((p,w)=>{z[w]=p});let C;const I=((r=(l=E.headers.get("Content-Type"))==null?void 0:l.split(";")[0])==null?void 0:r.trim())??"";try{C=await E.clone().json()}catch{if(I.startsWith("text/")||!I)C=await E.text();else{const p=await E.arrayBuffer(),w=new Uint8Array(p);let O="";for(let k=0;k<w.length;k++)O+=String.fromCharCode(w[k]);const b=btoa(O);C=`data:${I};base64,${b}`}}return[C,z]}catch(u){return s=u.message,[{error:s},null]}},v=async(o="")=>{let t=null;const n=await fetch(`${h}/api/v1/tasks/config`,{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json",...o&&{authorization:`Bearer ${o}`}}}).then(async a=>{if(!a.ok)throw await a.json();return a.json()}).catch(a=>(t=a,null));if(t)throw t;return n},tt=async(o,t)=>{let n=null;const a=await fetch(`${h}/api/v1/tasks/config/update`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...o&&{authorization:`Bearer ${o}`}},body:JSON.stringify(t)}).then(async e=>{if(!e.ok)throw await e.json();return e.json()}).catch(e=>("detail"in e?n=e.detail:n=e,null));if(n)throw n;return a},nt=async(o="",t,n,a)=>{var s,l;let e=null;const i=await fetch(`${h}/api/v1/tasks/title/completions`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({model:t,messages:n,...a})}).then(async r=>{if(!r.ok)throw await r.json();return r.json()}).catch(r=>("detail"in r&&(e=r.detail),null));if(e)throw e;try{const u=(((l=(s=i==null?void 0:i.choices[0])==null?void 0:s.message)==null?void 0:l.content)??"").replace(/['‘’`]/g,'"'),c=u.indexOf("{"),y=u.lastIndexOf("}");if(c!==-1&&y!==-1){const f=u.substring(c,y+1),d=JSON.parse(f);return d&&d.title?d.title:null}return null}catch{return null}},et=async(o="",t,n,a)=>{var s,l;let e=null;const i=await fetch(`${h}/api/v1/tasks/tags/completions`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({model:t,messages:n,...a&&{chat_id:a}})}).then(async r=>{if(!r.ok)throw await r.json();return r.json()}).catch(r=>("detail"in r&&(e=r.detail),null));if(e)throw e;try{const u=(((l=(s=i==null?void 0:i.choices[0])==null?void 0:s.message)==null?void 0:l.content)??"").replace(/['‘’`]/g,'"'),c=u.indexOf("{"),y=u.lastIndexOf("}");if(c!==-1&&y!==-1){const f=u.substring(c,y+1),d=JSON.parse(f);return d&&d.tags?Array.isArray(d.tags)?d.tags:[]:[]}return[]}catch{return[]}},at=async(o="",t,n,a)=>{var l,r,u;let e=null;const i=await fetch(`${h}/api/v1/tasks/emoji/completions`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({model:t,prompt:n,...a&&{chat_id:a}})}).then(async c=>{if(!c.ok)throw await c.json();return c.json()}).catch(c=>("detail"in c&&(e=c.detail),null));if(e)throw e;const s=((u=(r=(l=i==null?void 0:i.choices[0])==null?void 0:l.message)==null?void 0:r.content)==null?void 0:u.replace(/["']/g,""))??null;return s&&new RegExp("\\p{Extended_Pictographic}","u").test(s)?s.match(new RegExp("\\p{Extended_Pictographic}","gu"))[0]:null},ot=async(o="",t,n,a,e="search query",i)=>{var c,y;const s=new AbortController;let l=null;const r=await fetch(`${h}/api/v1/tasks/auto/completions`,{signal:s.signal,method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({model:t,prompt:n,...a&&{messages:a},type:e,stream:!1,...i})}).then(async f=>{if(!f.ok)throw await f.json();return f.json()}).catch(f=>("detail"in f&&(l=f.detail),null));if(l)throw l;const u=((y=(c=r==null?void 0:r.choices[0])==null?void 0:c.message)==null?void 0:y.content)??"";try{const f=u.indexOf("{"),d=u.lastIndexOf("}");if(f!==-1&&d!==-1){const $=u.substring(f,d+1),j=JSON.parse($);return j&&j.text?j.text:""}return u}catch{return u}},it=async(o="",t,n,a)=>{const e=new AbortController;let i=null;const s=await fetch(`${h}/api/v1/tasks/moa/completions`,{signal:e.signal,method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({model:t,prompt:n,responses:a,stream:!0})}).catch(l=>(i=l,null));if(i)throw i;return[s,e]},st=async(o="")=>{let t=null;const n=await fetch(`${h}/api/v1/pipelines/list`,{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json",...o&&{authorization:`Bearer ${o}`}}}).then(async e=>{if(!e.ok)throw await e.json();return e.json()}).catch(e=>(t=e,null));if(t)throw t;return(n==null?void 0:n.data)??[]},rt=async(o,t,n)=>{let a=null;const e=new FormData;e.append("file",t),e.append("urlIdx",n);const i=await fetch(`${h}/api/v1/pipelines/upload`,{method:"POST",headers:{...o&&{authorization:`Bearer ${o}`}},body:e}).then(async s=>{if(!s.ok)throw await s.json();return s.json()}).catch(s=>("detail"in s?a=s.detail:a=s,null));if(a)throw a;return i},ct=async(o,t,n)=>{let a=null;const e=await fetch(`${h}/api/v1/pipelines/add`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...o&&{authorization:`Bearer ${o}`}},body:JSON.stringify({url:t,urlIdx:n})}).then(async i=>{if(!i.ok)throw await i.json();return i.json()}).catch(i=>("detail"in i?a=i.detail:a=i,null));if(a)throw a;return e},lt=async(o,t,n)=>{let a=null;const e=await fetch(`${h}/api/v1/pipelines/delete`,{method:"DELETE",headers:{Accept:"application/json","Content-Type":"application/json",...o&&{authorization:`Bearer ${o}`}},body:JSON.stringify({id:t,urlIdx:n})}).then(async i=>{if(!i.ok)throw await i.json();return i.json()}).catch(i=>("detail"in i?a=i.detail:a=i,null));if(a)throw a;return e},pt=async(o,t)=>{let n=null;const a=new URLSearchParams;t!==void 0&&a.append("urlIdx",t);const e=await fetch(`${h}/api/v1/pipelines/?${a.toString()}`,{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json",...o&&{authorization:`Bearer ${o}`}}}).then(async s=>{if(!s.ok)throw await s.json();return s.json()}).catch(s=>(n=s,null));if(n)throw n;return(e==null?void 0:e.data)??[]},ht=async(o,t,n)=>{let a=null;const e=new URLSearchParams;n!==void 0&&e.append("urlIdx",n);const i=await fetch(`${h}/api/v1/pipelines/${t}/valves?${e.toString()}`,{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json",...o&&{authorization:`Bearer ${o}`}}}).then(async s=>{if(!s.ok)throw await s.json();return s.json()}).catch(s=>(a=s,null));if(a)throw a;return i},ut=async(o,t,n)=>{let a=null;const e=new URLSearchParams;n!==void 0&&e.append("urlIdx",n);const i=await fetch(`${h}/api/v1/pipelines/${t}/valves/spec?${e.toString()}`,{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json",...o&&{authorization:`Bearer ${o}`}}}).then(async s=>{if(!s.ok)throw await s.json();return s.json()}).catch(s=>(a=s,null));if(a)throw a;return i}
1,ft=async(o="",t,n,a)=>{let e=null;const i=new URLSearchParams;a!==void 0&&i.append("urlIdx",a);const s=await fetch(`${h}/api/v1/pipelines/${t}/valves/update?${i.toString()}`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json",...o&&{authorization:`Bearer ${o}`}},body:JSON.stringify(n)}).then(async l=>{if(!l.ok)throw await l.json();return l.json()}).catch(l=>("detail"in l?e=l.detail:e=l,null));if(e)throw e;return s},dt=async(o="")=>{let t=null;const n=await fetch(`${h}/api/usage`,{method:"GET",headers:{"Content-Type":"application/json",...o&&{Authorization:`Bearer ${o}`}}}).then(async a=>{if(!a.ok)throw await a.json();return a.json()}).catch(a=>(t=a,null));if(t)throw t;return n},yt=async()=>{let o=null;const t=await fetch(`${h}/api/config`,{method:"GET",credentials:"include",headers:{"Content-Type":"application/json"}}).then(async n=>{if(!n.ok)throw await n.json();return n.json()}).catch(n=>(o=n,null));if(o){if(o instanceof TypeError)try{const n=await fetch(`${h}/api/config`,{method:"GET",credentials:"include",redirect:"manual",headers:{"Content-Type":"application/json"}});if(n.type==="opaqueredirect"||n.status>=300&&n.status<400)throw{authRedirect:!0}}catch(n){if(n!=null&&n.authRedirect)throw n}throw o}return t},wt=async()=>{let o=null;const t=await fetch(`${h}/api/changelog`,{method:"GET",headers:{"Content-Type":"application/json"}}).then(async n=>{if(!n.ok)throw await n.json();return n.json()}).catch(n=>(o=n,null));if(o)throw o;return t},jt=async o=>{let t=null;const n=await fetch(`${h}/api/version`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`}}).then(async a=>{if(!a.ok)throw await a.json();return a.json()}).catch(a=>(t=a,null));if(t)throw t;return n},mt=async o=>{let t=null;const n=await fetch(`${h}/api/version/updates`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`}}).then(async a=>{if(!a.ok)throw await a.json();return a.json()}).catch(a=>(t=a,null));if(t)throw t;return n},gt=async o=>{let t=null;const n=await fetch(`${h}/api/events`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`}}).then(async a=>{if(!a.ok)throw await a.json();return a.json()}).catch(a=>(t=a,null));if(t)throw t;return n},$t=async o=>{let t=null;const n=await fetch(`${h}/api/events/webhooks`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`}}).then(async a=>{if(!a.ok)throw await a.json();return a.json()}).catch(a=>(t=a,null));if(t)throw t;return n},Tt=async(o,t)=>{let n=null;const a=await fetch(`${h}/api/events/webhooks`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(t)}).then(async e=>{if(!e.ok)throw await e.json();return e.json()}).catch(e=>(n=e,null));if(n)throw n;return a},St=async(o,t,n)=>{let a=null;const e=await fetch(`${h}/api/events/webhooks/${t}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(n)}).then(async i=>{if(!i.ok)throw await i.json();return i.json()}).catch(i=>(a=i,null));if(a)throw a;return e},At=async(o,t)=>{let n=null;const a=await fetch(`${h}/api/events/webhooks/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`}}).then(async e=>{if(!e.ok)throw await e.json();return e.json()}).catch(e=>(n=e,null));if(n)throw n;return a};export{lt as A,wt as B,ot as C,at as D,Y as E,K as F,X as G,H,it as I,yt as a,jt as b,et as c,dt as d,Z as e,nt as f,V as g,mt as h,q as i,Q as j,gt as k,$t as l,St as m,L as n,Tt as o,At as p,v as q,tt as r,st as s,ft as t,F as u,pt as v,ut as w,ht as x,rt as y,ct as z};
2//# sourceMappingURL=BIMfEMVU.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.