@cldmv/llm-translator 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/dist/api/convert/anthropic/messages/to/ollama/chat/request.mjs +2 -0
- package/dist/api/convert/anthropic/messages/to/openai/chat/request.mjs +10 -10
- package/dist/api/convert/ollama/chat/to/anthropic/messages/response.mjs +2 -0
- package/dist/api/convert/ollama/chat/to/anthropic/messages/stream.mjs +2 -0
- package/dist/api/convert/ollama/chat/to/openai/chat/response.mjs +2 -0
- package/dist/api/convert/ollama/chat/to/openai/chat/stream.mjs +2 -0
- package/dist/api/convert/openai/chat/to/anthropic/messages/response.mjs +1 -1
- package/dist/api/convert/openai/chat/to/anthropic/messages/stream.mjs +1 -1
- package/dist/api/convert/openai/chat/to/ollama/chat/request.mjs +2 -0
- package/dist/api/detect.mjs +1 -1
- package/dist/api/driver/azure/detect.mjs +1 -1
- package/dist/api/driver/azure/info.mjs +1 -1
- package/dist/api/driver/deepseek/info.mjs +1 -1
- package/dist/api/driver/fireworks/detect.mjs +2 -0
- package/dist/api/driver/fireworks/info.mjs +2 -0
- package/dist/api/driver/fireworks/path.mjs +2 -0
- package/dist/api/driver/fireworks/request.mjs +2 -0
- package/dist/api/driver/fireworks/settings.mjs +2 -0
- package/dist/api/driver/gemini/detect.mjs +2 -0
- package/dist/api/driver/gemini/info.mjs +2 -0
- package/dist/api/driver/gemini/path.mjs +2 -0
- package/dist/api/driver/gemini/request.mjs +2 -0
- package/dist/api/driver/gemini/settings.mjs +2 -0
- package/dist/api/driver/groq/detect.mjs +2 -0
- package/dist/api/driver/groq/info.mjs +2 -0
- package/dist/api/driver/groq/path.mjs +2 -0
- package/dist/api/driver/groq/request.mjs +2 -0
- package/dist/api/driver/groq/settings.mjs +2 -0
- package/dist/api/driver/llamacpp/info.mjs +1 -1
- package/dist/api/driver/mistral/info.mjs +1 -1
- package/dist/api/driver/ollama/info.mjs +1 -1
- package/dist/api/driver/ollama/request.mjs +1 -1
- package/dist/api/driver/openai/info.mjs +1 -1
- package/dist/api/driver/openrouter/info.mjs +1 -1
- package/dist/api/driver/together/detect.mjs +2 -0
- package/dist/api/driver/together/info.mjs +2 -0
- package/dist/api/driver/together/request.mjs +2 -0
- package/dist/api/driver/together/settings.mjs +2 -0
- package/dist/api/driver/vllm/detect.mjs +1 -1
- package/dist/api/driver/vllm/info.mjs +1 -1
- package/dist/api/driver/vllm/model/list.mjs +1 -1
- package/dist/api/driver/xai/detect.mjs +2 -0
- package/dist/api/driver/xai/info.mjs +2 -0
- package/dist/api/driver/xai/request.mjs +2 -0
- package/dist/api/driver/xai/settings.mjs +2 -0
- package/dist/api/embeddings/send.mjs +1 -1
- package/dist/api/health/check.mjs +2 -0
- package/dist/api/model/list.mjs +1 -1
- package/dist/api/request.mjs +2 -2
- package/dist/api/response.mjs +1 -1
- package/dist/api/send.mjs +1 -1
- package/dist/api/status.mjs +1 -1
- package/dist/api/stream.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/lib/cache.mjs +2 -0
- package/dist/lib/capture.mjs +1 -1
- package/dist/lib/config.mjs +1 -1
- package/dist/lib/constraint.mjs +2 -0
- package/dist/lib/context.mjs +2 -0
- package/dist/lib/health.mjs +2 -0
- package/dist/lib/http.mjs +1 -1
- package/dist/lib/models.mjs +1 -1
- package/dist/lib/ndjson.mjs +4 -0
- package/dist/lib/ollama.mjs +3 -0
- package/dist/lib/passthrough.mjs +1 -1
- package/dist/lib/pool.mjs +1 -1
- package/dist/lib/presets.mjs +2 -0
- package/dist/lib/route.mjs +1 -1
- package/dist/lib/routes.mjs +1 -1
- package/dist/lib/settings.mjs +1 -1
- package/dist/lib/vllm.mjs +4 -0
- package/package.json +1 -1
- package/types/src/api/convert/anthropic/messages/to/ollama/chat/request.d.mts +14 -0
- package/types/src/api/convert/ollama/chat/to/anthropic/messages/response.d.mts +10 -0
- package/types/src/api/convert/ollama/chat/to/anthropic/messages/stream.d.mts +14 -0
- package/types/src/api/convert/ollama/chat/to/openai/chat/response.d.mts +10 -0
- package/types/src/api/convert/ollama/chat/to/openai/chat/stream.d.mts +13 -0
- package/types/src/api/convert/openai/chat/to/ollama/chat/request.d.mts +12 -0
- package/types/src/api/detect.d.mts +1 -1
- package/types/src/api/driver/azure/info.d.mts +2 -1
- package/types/src/api/driver/deepseek/info.d.mts +2 -1
- package/types/src/api/driver/fireworks/detect.d.mts +8 -0
- package/types/src/api/driver/fireworks/info.d.mts +13 -0
- package/types/src/api/driver/fireworks/path.d.mts +7 -0
- package/types/src/api/driver/fireworks/request.d.mts +7 -0
- package/types/src/api/driver/fireworks/settings.d.mts +5 -0
- package/types/src/api/driver/gemini/detect.d.mts +8 -0
- package/types/src/api/driver/gemini/info.d.mts +13 -0
- package/types/src/api/driver/gemini/path.d.mts +7 -0
- package/types/src/api/driver/gemini/request.d.mts +7 -0
- package/types/src/api/driver/gemini/settings.d.mts +5 -0
- package/types/src/api/driver/groq/detect.d.mts +8 -0
- package/types/src/api/driver/groq/info.d.mts +13 -0
- package/types/src/api/driver/groq/path.d.mts +7 -0
- package/types/src/api/driver/groq/request.d.mts +7 -0
- package/types/src/api/driver/groq/settings.d.mts +5 -0
- package/types/src/api/driver/mistral/info.d.mts +2 -1
- package/types/src/api/driver/ollama/info.d.mts +7 -2
- package/types/src/api/driver/openai/info.d.mts +3 -1
- package/types/src/api/driver/openrouter/info.d.mts +2 -1
- package/types/src/api/driver/together/detect.d.mts +8 -0
- package/types/src/api/driver/together/info.d.mts +13 -0
- package/types/src/api/driver/together/request.d.mts +7 -0
- package/types/src/api/driver/together/settings.d.mts +5 -0
- package/types/src/api/driver/vllm/detect.d.mts +1 -1
- package/types/src/api/driver/vllm/info.d.mts +1 -1
- package/types/src/api/driver/vllm/model/list.d.mts +3 -1
- package/types/src/api/driver/xai/detect.d.mts +8 -0
- package/types/src/api/driver/xai/info.d.mts +13 -0
- package/types/src/api/driver/xai/request.d.mts +7 -0
- package/types/src/api/driver/xai/settings.d.mts +5 -0
- package/types/src/api/endpoint/status.d.mts +5 -2
- package/types/src/api/health/check.d.mts +8 -0
- package/types/src/api/request.d.mts +1 -1
- package/types/src/api/send.d.mts +1 -1
- package/types/src/api/status.d.mts +1 -1
- package/types/src/lib/cache.d.mts +30 -0
- package/types/src/lib/config.d.mts +4 -0
- package/types/src/lib/constraint.d.mts +36 -0
- package/types/src/lib/context.d.mts +34 -0
- package/types/src/lib/events.d.mts +2 -2
- package/types/src/lib/health.d.mts +22 -0
- package/types/src/lib/models.d.mts +25 -0
- package/types/src/lib/ndjson.d.mts +16 -0
- package/types/src/lib/ollama.d.mts +86 -0
- package/types/src/lib/pool.d.mts +30 -4
- package/types/src/lib/presets.d.mts +99 -0
- package/types/src/lib/route.d.mts +1 -1
- package/types/src/lib/settings.d.mts +25 -0
- package/types/src/lib/vllm.d.mts +47 -0
package/dist/api/request.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
2
|
-
${
|
|
1
|
+
var M=Object.defineProperty;var h=(e,a)=>M(e,"name",{value:a,configurable:!0});import{context as B,self as E}from"../lib/runtime.mjs";import{capture as K}from"../lib/capture.mjs";import{resolve as P}from"../lib/route.mjs";import*as S from"../lib/http.mjs";import{filterChatBody as R}from"../lib/passthrough.mjs";import{addSampling as H}from"../lib/sampling.mjs";import{addConstraint as z}from"../lib/constraint.mjs";import{addCache as A}from"../lib/cache.mjs";import*as C from"../lib/images.mjs";import*as T from"../lib/tools.mjs";import{LIMITS as D}from"../lib/toolsearch.mjs";import{warn as v}from"../lib/warn.mjs";import{emit as G}from"../lib/events.mjs";import{fit as J,pinBody as N}from"../lib/effort.mjs";import{relax as Q,strictTools as V}from"../lib/strict.mjs";import{TranslatorError as W}from"../lib/errors.mjs";import*as X from"../lib/vllm.mjs";function Y(e){return`${e.driver}:${e.protocol}:${URL.canParse(e.url)?new URL(e.url).host:e.url}`}h(Y,"producerOf");async function ue(e,a={}){const r=K(E,B,a.front),f=P(r,e,{endpoint:a.endpoint,advance:a.hold===!0&&a.endpoint===void 0});if(a.hold!==!0)return q(r,e,a,f);f.endpoint.health.inflight++;try{return await q(r,e,a,f)}catch(n){throw f.endpoint.health.inflight--,n}}h(ue,"request");function Z(e,a,r,f,n,p){const k=V(a);if(k.length===0)return a;const l=k.filter(s=>s.problems.length>0);if(l.length>0&&n.unknownFields==="error")throw new W(`tools: ${l[0].name}: schema is outside the strict subset (${l[0].problems.join("; ")})`,{code:"unsupported_content",param:"tools"});const _=Q(a);if(p.retry===!0)return _;const g=h((s,j)=>v(e.config,e.state,s,{kind:j,endpoint:r.name,log:p.log}),"tell");for(const s of l)g(`Upstream ${r.name}: strict tool ${s.name} has a schema outside the strict subset: ${s.problems.join("; ")} (sent without strict)`,"strict");const u=k.filter(s=>s.problems.length===0);return f.info.strict!==!0&&u.length>0&&g(`Upstream ${r.name}: the ${f.name} backend does not enforce strict tool use (${u.map(s=>s.name).join(", ")})`,"strict"),_}h(Z,"checkStrict");async function q(e,a,r,f){const{endpoint:n,model:p,unserved:k,convert:l,pool:_,pin:g}=f,u=Object.hasOwn(e.config.efforts,p)?e.config.efforts[p]:void 0;g&&(a=N(a,g,e.front));const s=e.driver(n),j=e.front==="anthropic"?a.metadata?.prompt_cache_key:void 0;let w=e.front==="anthropic"?a.metadata?.constraint:void 0;e.front==="openai"&&a.constraint!==void 0&&({constraint:w,...a}=a);const $=`${n.name}
|
|
2
|
+
${p}`,U=r.images===!1||e.state.textOnly.has($)&&e.settings(n).imageFallback,b=e.settings(n),I=r.jsonObject==="instruction"||e.state.jsonInstruction.has($)&&b.jsonObjectFallback,c={...U?{...b,images:!1}:b,...I?{jsonObject:"instruction"}:{},...g?.effort===void 0?{}:{effort:!0}},y=a.stream===!0,m=l===null?e.front==="anthropic"?"anthropic.messages":"openai.chat":n.protocol,O=m==="anthropic.messages"&&n.protocol==="openai.chat";let t,o;l?({body:t,state:o}=await l.request(a,c,{producer:Y(n),budget:r.budget,listed:u!==void 0,toolCallIds:s.info.toolCallIds}),o.toolSearch?.capped&&v(e.config,e.state,`Tool search: more than ${D.definitions} tool definitions came back in ToolSearch results for ${n.name}; the rest are not offered.`,{kind:"toolsearch",endpoint:n.name,log:r.log})):O?t=X.request(a,c):t=e.front==="openai"&&(r.filter??c.passthroughFilter===!0)?R(a,s.info.fields):{...a};const F=e.front==="anthropic"?a.metadata?.sampling:void 0;if(m==="openai.chat"){const i=[];t=H(t,F,c,s.info.fields,i),o&&o.dropped.push(...i.filter(d=>!o.dropped.includes(d)))}else if(!l&&F!==void 0&&t.metadata?.sampling!==void 0){const{sampling:i,...d}=t.metadata;t={...t,metadata:d}}if(m==="openai.chat"){const i=[],d={name:s.info.name,version:n.facts?.version??n.version};t=z(t,w,c,d,i),t=A(t,{salt:r.cacheSalt,key:j},c,d.name,i),o&&o.dropped.push(...i.filter(L=>!o.dropped.includes(L)))}else{if(o&&!o.dropped.includes("cache_salt")&&(r.cacheSalt??c.cacheSalt)!=null&&o.dropped.push("cache_salt"),o&&!o.dropped.includes("prompt_cache_key")&&(j??c.promptCacheKey)!=null&&o.dropped.push("prompt_cache_key"),!l&&t.metadata?.prompt_cache_key!==void 0){const{prompt_cache_key:i,...d}=t.metadata;t={...t,metadata:d}}if(o&&(w??c.constraint)!=null&&!o.dropped.includes("constraint")&&o.dropped.push("constraint"),!l&&t.metadata?.constraint!==void 0){const{constraint:i,...d}=t.metadata;t={...t,metadata:d}}}if(r.usage===!0&&y&&e.front==="openai"){if(l)o.includeUsage=!0;else if(c.streamUsage){const i=t.stream_options&&typeof t.stream_options=="object"?t.stream_options:{};t.stream_options={...i,include_usage:!0}}}U&&!l&&e.front==="openai"&&(t=C.strip(t)),r.tools===!1&&(t=T.strip(t)),t.model=p,t=Z(e,t,n,s,c,r),u&&m==="openai.chat"&&J(t,u,p,(i,d)=>v(e.config,e.state,i,{type:"effort",endpoint:n.name,model:p,...d,log:r.log})),o?.reasoningMissing&&v(e.config,e.state,`Upstream ${n.name}: assistant turns with tool calls have no reasoning to send back (the client dropped its thinking blocks or their signatures), which servers that need it with tools will refuse.`,{kind:"reasoning",endpoint:n.name,log:r.log}),s.request&&!O&&(t=await s.request(t,{endpoint:n,settings:c,levels:u,state:o,warn:h(i=>v(e.config,e.state,i,{kind:"driver",endpoint:n.name,log:r.log}),"warn")})),o?.dropped?.length>0&&r.retry!==!0&&G(e,{type:"dropped",level:"debug",message:`Upstream ${n.name}: dropped ${o.dropped.join(", ")}`,endpoint:n.name,model:p,fields:[...o.dropped],log:r.log});const x=await S.pathOf(s,m==="anthropic.messages"?"messages":"chat",n,p);return{upstream:n.name,pool:_.map(i=>i.name),method:"POST",url:S.join(n.url,x),path:x,headers:{"content-type":"application/json",accept:y?"text/event-stream":"application/json",...s.info.headers,...l===null&&n.protocol==="anthropic.messages"?r.clientHeaders:void 0,...S.headers(n,s.info.auth,r.headers)},body:t,state:{v:1,upstream:n.name,front:e.front,native:l===null,messages:O,model:a.model,stream:y,unserved:k,convert:o},images:{sent:C.carries(t),retry:c.imageFallback&&m==="openai.chat",key:$},tools:{sent:T.carries(t),retry:c.toolFallback&&m==="openai.chat"},json:{sent:o?.jsonSchemaEmulated===!0,retry:c.jsonObjectFallback&&m==="anthropic.messages",key:$}}}h(q,"prepare");export{ue as request};
|
|
3
3
|
//# sourceMappingURL=request.mjs.map
|
package/dist/api/response.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var m=Object.defineProperty;var t=(s,e)=>m(s,"name",{value:e,configurable:!0});import{context as p,self as d}from"../lib/runtime.mjs";import{capture as c}from"../lib/capture.mjs";import*as f from"../lib/vllm.mjs";async function g(s,e){const o=c(d,p,e.front),r=o.endpoint(e.upstream),i=o.driver(r);let n=s;return i.response&&(n=await i.response(n,{endpoint:r,settings:o.settings(r),state:e})),e.messages&&(n=f.response(n)),e.native?n.model===void 0?n:{...n,model:e.model??n.model}:o.converters(r).response(n,e.convert,o.settings(r))}t(g,"response");export{g as response};
|
|
2
2
|
//# sourceMappingURL=response.mjs.map
|
package/dist/api/send.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var le=Object.defineProperty;var u=(c,s)=>le(c,"name",{value:s,configurable:!0});import{context as K,self as ee}from"../lib/runtime.mjs";import{TranslatorError as z}from"../lib/errors.mjs";import*as te from"../lib/http.mjs";import*as ue from"../lib/images.mjs";import*as ce from"../lib/tools.mjs";import{parse as ae}from"../lib/upstream-error.mjs";import{meter as me,normalize as de}from"../lib/usage.mjs";import{capture as fe}from"../lib/capture.mjs";import{estimate as pe,bodyLength as ge,output as he,patch as ye,stream as we}from"../lib/estimate.mjs";import{warn as re}from"../lib/warn.mjs";import{start as be}from"../lib/record.mjs";import{emit as se}from"../lib/events.mjs";import*as ne from"../lib/pool.mjs";import{createBudget as ke}from"../lib/thinking.mjs";import*as oe from"../lib/fanout.mjs";import{refresh as je}from"../lib/health.mjs";const ve={"content-type":"text/event-stream; charset=utf-8","cache-control":"no-cache","x-accel-buffering":"no"};async function _e(c,s={}){const{transport:w,textOnly:f,jsonInstruction:v}=K.state,{request:_,response:$,stream:o,error:p}=ee,d=p.build,{config:i,state:b}=K,g=fe(ee,K,s.front),U=c&&typeof c=="object"&&!Array.isArray(c),T={model:null,requested:U&&typeof c.model=="string"?c.model:null,upstream:null,front:s.front??i.front,stream:U&&c.stream===!0},k=me(T,s.onUsage,(m,A)=>re(i,b,m,{type:"usage",...A,log:s.log})),q=u(m=>Object.defineProperty(m,"usage",{value:k.usage,enumerable:!1,configurable:!0}),"attach");let J=!1;try{const m=oe.wants(g,c);if(m>0){J=!0;const A=u((n,S)=>re(i,b,n,{type:"usage",...S,log:s.log}),"warning");return await oe.run({body:c,count:m,options:s,send:_e,warn:A})}return q(await $e({transport:w,textOnly:f,jsonInstruction:v,request:_,response:$,stream:o,error:p,captured:g},c,s,k))}catch(m){if(J)throw m;if(!(m instanceof z))throw s.signal?.aborted||se(g,{type:"error",kind:"exception",level:"error",message:String(m?.message??m),log:s.log}),k.finish(s.signal?.aborted?"aborted":"error"),m;return k.finish("error"),q(d(m.status,m.message,{type:m.type,code:m.code,param:m.param,front:s.front}))}}u(_e,"send");async function $e({transport:c,textOnly:s,jsonInstruction:w,request:f,response:v,stream:_,error:$,captured:o},p,d,i){const b={front:d.front,headers:d.headers,clientHeaders:d.clientHeaders,filter:d.filter,cacheSalt:d.cacheSalt,usage:!0,budget:ke(),log:d.log},g=u(t=>{se(o,{...t,log:d.log})},"announce"),U=i.meta.front==="openai"&&p?.stream_options?.include_usage!==!0,T=u(t=>{i.meta.model=t.body.model??null,i.meta.upstream=t.upstream,t.state.native?i.source(null):i.source(()=>t.state.convert?.upstreamUsage,t.state.front==="anthropic"?"openai":"folded")},"note"),k=u(t=>{if(t.state.native)return{input:!1,output:!1};const e=de(t.state.front==="anthropic"?"openai":"folded",t.state.convert?.upstreamUsage);return e===null?{input:!0,output:!0}:{input:e.input_tokens===null&&e.cache_read_input_tokens===null&&e.cache_creation_input_tokens===null,output:e.output_tokens===null}},"gaps"),q=u(async t=>{const e=o.endpoint(t.upstream),a=o.driver(e);return(a.count&&!(U&&t.state.stream)?await a.count({endpoint:e,request:t.body,transport:c,signal:d.signal,timeout:o.config.detectTimeout}):null)??pe(t.body)},"input"),J=u(async(t,e)=>{const a=k(t);return!a.input&&!a.output?null:{input_tokens:a.input?await q(t):null,output_tokens:a.output?he(e):null}},"counts"),m=u((t,e,a,r,R)=>(i.finish(R),$(t,e,a,r)),"fail"),A=u(async t=>{let e=t,a=await Q(c,e,d.signal,I());const r=a.status;if(r===404&&e.state.messages){const y=await C(a);return y?.type==="error"?{upstream:e,result:a,failure:y}:(o.state.noMessages.add(e.upstream),g({type:"fallback",kind:"messages",level:"warn",message:`Upstream ${e.upstream}: /v1/messages answered 404; sent the request converted to Chat Completions, and will do so for this upstream until the next detection. Set nativeMessages: false on this upstream to skip the first attempt.`,endpoint:e.upstream,model:e.body.model,status:r,reason:String(ae(y,r).message).trim().slice(0,500),action:"conversion"}),e=await f(p,{...b,endpoint:e.upstream,retry:!0}),T(e),{upstream:e,result:await Q(c,e,d.signal,I())})}const R=r===400&&[e.images,e.tools].some(y=>y.sent&&y.retry),F=(r===400||r===422)&&e.json.sent&&e.json.retry;if(!a.ok&&(R||F)){const y=await C(a),O=ae(y,r).message,h={};if(r===400&&e.images.sent&&e.images.retry&&ue.refused(O)?(s.add(e.images.key),h.images=!1):r===400&&e.tools.sent&&e.tools.retry&&ce.refused(O)?h.tools=!1:F&&(h.jsonObject="instruction"),!("images"in h||"tools"in h||"jsonObject"in h))return{upstream:e,result:a,failure:y};const j={upstream:e,result:a,failure:y};if("images"in h||"tools"in h){const G="images"in h?"images":"tools";g({type:"fallback",kind:G,level:"warn",message:`Upstream ${e.upstream}: ${e.state.model} refused ${G==="images"?"images":"tools"} (${r}: "${String(O).trim().slice(0,500)}"); sent the request again without them.`,endpoint:e.upstream,model:e.body.model,status:r,reason:String(O).trim().slice(0,500),action:G==="images"?"text-only":"without-tools"})}if(e=await f(p,{...b,...h,endpoint:e.upstream,retry:!0}),T(e),a=await Q(c,e,d.signal,I()),F&&"jsonObject"in h){if(!a.ok){try{await a.body?.cancel?.()}catch{}return T(j.upstream),j}w.add(j.upstream.json.key),g({type:"fallback",kind:"json_object",level:"warn",message:`Upstream ${j.upstream.upstream}: ${j.upstream.state.model} rejected the json_object schema emulation (${r}: "${String(O).trim().slice(0,500)}"); sent it as a system instruction instead. Set jsonObject: "instruction" on this upstream to skip the first attempt.`,endpoint:j.upstream.upstream,model:j.upstream.body.model,status:r,reason:String(O).trim().slice(0,500),action:"instruction"})}}return{upstream:e,result:a}},"attempt");await je(o,p,d.signal);let n=await f(p,{...b,hold:!0});const S=n.pool;let B=0;const D=S.length>1?o.config.pool:null,I=u(()=>D&&{connectTimeout:D.connectTimeout,headersTimeout:B+1<S.length?D.headersTimeout:0},"limitsNow");let E=o.endpoint(n.upstream);const V=u(()=>E.health.inflight--,"release");let l,x,W=null,X=0;const Y=u(t=>{const e=be(o,{body:p,sent:n,front:i.meta.front,requested:i.meta.requested,headers:t,log:d.log,exchange:W,attempt:X});return W??=e.id,e},"begin"),Z=u(async t=>{const e=Y();if(!e.on)return;if(l===void 0)return e.attempt({error:x.message},t);let a=null;try{a=x??await C(l)}catch{}e.attempt({status:l.status,headers:te.plain(l.headers),body:a},t)},"keep");try{for(;;){const t=E;t.health.requests++,X++,T(n);let e=null;try{({upstream:n,result:l,failure:x}=await A(n)),!l.ok&&l.status>=500&&(e=`HTTP ${l.status}`,g({type:"error",kind:"upstream",level:"error",message:`Upstream ${t.name} answered HTTP ${l.status}`,endpoint:t.name,model:n.body.model,status:l.status}))}catch(r){if(!(r instanceof z)||r.code!=="upstream_unreachable")throw r;e=r.message,l=void 0,x=r,g({type:"error",kind:"transport",level:"error",message:r.message,endpoint:t.name,model:n.body.model})}if(e===null){ne.succeeded(t);break}ne.failed(o.config,t,e);let a=null;for(;a===null&&!d.signal?.aborted&&B+1<S.length;)try{a=await f(p,{...b,endpoint:S[++B],hold:!0})}catch(r){if(!(r instanceof z)||r.code!=="endpoint_not_in_pool")throw r}if(a===null){if(l===void 0)throw await Z(),x;break}await Z(e),g({type:"failover",level:"warn",message:`Upstream ${t.name} failed (${e}); trying ${a.upstream}`,from:t.name,to:a.upstream,model:a.body.model,reason:e});try{await l?.body?.cancel?.()}catch{}V(),E=o.endpoint(a.upstream),n=a}}catch(t){throw V(),t}const ie=E;E=null,i.usage.then(()=>ie.health.inflight--);const H=te.plain(l.headers),M=Y(H);if(!l.ok){const t=x??await C(l);return M.reply(l.status,H,t),m(l.status,t,H,n.state,"upstream_error")}if(n.state.stream){const t=_(M.raw(l.body),n.state),e=n.state.native?t:we(i.meta.front,t,{gaps:u(()=>k(n),"gaps"),input:u(()=>q(n),"input"),report:u(a=>i.estimate(a),"report")});return{status:200,headers:ve,stream:M.events(i.track(e,d.signal,U))}}const P=await C(l);if(M.reply(l.status,H,P),P===null||typeof P!="object")return g({type:"error",kind:"upstream",level:"error",message:`Upstream ${n.upstream} returned a body that is not JSON`,endpoint:n.upstream,model:n.body.model,status:502}),m(502,"The upstream returned a body that is not JSON",H,n.state,"error");const N=await v(P,n.state),L=await J(n,ge(i.meta.front,N));return L&&(N.usage=ye(i.meta.front,N.usage,L),i.estimate(L)),i.json(N),i.finish("done"),{status:200,headers:{"content-type":"application/json"},body:N}}u($e,"round");async function Q(c,s,w,f=null){let v,_=!1,$=w;if(f&&f.headersTimeout>0){const o=new AbortController;$=w?AbortSignal.any([w,o.signal]):o.signal,v=setTimeout(()=>{_=!0,o.abort()},f.headersTimeout)}try{return await c(s.url,{method:s.method,headers:s.headers,body:JSON.stringify(s.body),signal:$,redirect:"error",...f&&f.connectTimeout>0?{connectTimeout:f.connectTimeout}:{}})}catch(o){if(w?.aborted)throw o;const p=_?`no response headers within ${f.headersTimeout} ms`:o.message;throw new z(`Could not reach the upstream (${s.upstream}): ${p}`,{code:"upstream_unreachable",status:502,details:{cause:o}})}finally{clearTimeout(v)}}u(Q,"call");async function C(c){const s=await c.text();try{return JSON.parse(s)}catch{return s===""?null:s}}u(C,"parse");export{_e as send};
|
|
2
2
|
//# sourceMappingURL=send.mjs.map
|
package/dist/api/status.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var m=Object.defineProperty;var e=(s,a)=>m(s,"name",{value:a,configurable:!0});import{context as t}from"../lib/runtime.mjs";import{describe as l}from"../lib/pool.mjs";import{resolve as o}from"../lib/settings.mjs";import{wants as f}from"../lib/vllm.mjs";function h(){const{config:s,state:a}=t;return{front:s.front,upstreams:a.endpoints.map(r=>({name:r.name,url:r.url,backend:r.backend,driver:r.driver,protocol:r.protocol,version:r.facts?.version??r.version,models:r.models??r.facts?.models??[],default:r.default,facts:r.facts,probed:r.probed,messages:r.driver==="vllm"?f(r,o(r.driverSettings,r.probed,s.settings,r.settings))&&!a.noMessages.has(r.name):null,health:l(r)}))}}e(h,"status");export{h as status};
|
|
2
2
|
//# sourceMappingURL=status.mjs.map
|
package/dist/api/stream.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var b=Object.defineProperty;var i=(e,o)=>b(e,"name",{value:o,configurable:!0});import{context as j,self as A}from"../lib/runtime.mjs";import{capture as B}from"../lib/capture.mjs";import{messages as v}from"../lib/sse.mjs";import*as D from"../lib/vllm.mjs";function u(e,o){return!o||!e||typeof e!="object"?e:e.message&&typeof e.message=="object"&&e.message.model!==void 0?{...e,message:{...e.message,model:o}}:e.model===void 0?e:{...e,model:o}}i(u,"restore");function E(e){return!!e&&Array.isArray(e.choices)&&(e.choices.length===0||e.choices.some(o=>o?.finish_reason))}i(E,"ends");function _(e,o){const r=B(A,j,o.front),c=r.endpoint(o.upstream),a=r.driver(c),l=r.settings(c),f=o.native?null:r.converters(c),t=a.chunk,m={endpoint:c,settings:l,state:o};async function*d(){for(const n of await a.flush?.(m)??[])yield{data:n}}if(i(d,"flushed"),f&&!t)return f.stream(e,o.convert,l);if(f)return f.stream((async function*(){for await(const n of v(e))n.data!=="[DONE]"&&(yield await t(n.data,m));for await(const n of d())yield n.data})(),o.convert,l);const w=!!(t&&a.flush),y=(async function*(){const n=[];let g=!1;for await(const s of v(e)){if(s.data==="[DONE]"){for await(const x of d())yield{data:u(x.data,o.model)};yield*n.splice(0),g=!0,yield s;continue}const h=t?await t(s.data,m):s.data,p={...s,data:u(h,o.model)};w&&E(h)?n.push(p):yield p}if(!g){for await(const s of d())yield{data:u(s.data,o.model)};yield*n}})();return o.messages?D.stream(y):y}i(_,"stream");export{_ as stream};
|
|
2
2
|
//# sourceMappingURL=stream.mjs.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var i=Object.defineProperty;var a=(r,
|
|
1
|
+
var i=Object.defineProperty;var a=(r,e)=>i(r,"name",{value:e,configurable:!0});import{fileURLToPath as d}from"node:url";import p from"@cldmv/slothlet";import{normalize as c}from"./lib/config.mjs";import{load as l}from"./lib/pdf.mjs";import{transport as f}from"./lib/transport.mjs";import{create as m,open as u}from"./lib/events.mjs";import{warn as s}from"./lib/warn.mjs";async function w(r){const e=c(r),n={endpoints:e.endpoints,transport:e.transport??f,servers:new Set,warned:new Set,events:m(e.onEvent),textOnly:new Set,jsonInstruction:new Set,noMessages:new Set,cursors:new Map,front:void 0};u(n.events,e.logs);const t=await l();t.errors.canvas&&s(e,n,`@napi-rs/canvas could not be loaded (${t.errors.canvas}); PDFs will be read as text only, without page images`,{type:"detect",kind:"canvas",reason:String(t.errors.canvas)}),t.errors.unpdf&&s(e,n,`unpdf could not be loaded (${t.errors.unpdf}); PDF documents cannot be read and fall back to a note`,{type:"detect",kind:"unpdf",reason:String(t.errors.unpdf)});const o=await p({...r.slothlet,base:d(new URL("./api",import.meta.url)),mode:"eager",context:{config:e,state:n},silent:!0});return await o.detect({network:e.detect}),o}a(w,"createTranslator");import{TranslatorError as D}from"./lib/errors.mjs";var P=w;export{D as TranslatorError,w as createTranslator,P as default};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var h=Object.defineProperty;var a=(e,t)=>h(e,"name",{value:t,configurable:!0});import{TranslatorError as i}from"./errors.mjs";const f=["vllm"],_=["openai"];function d(e){return e==null||typeof e=="string"&&e!==""}a(d,"valid");function w(e,t,r,l,s=[]){if(!d(t.salt))throw new i("cacheSalt: expected a non-empty string",{code:"invalid_request",param:"cacheSalt"});if(!d(t.key))throw new i("metadata.prompt_cache_key: expected a non-empty string",{code:"invalid_request",param:"metadata.prompt_cache_key"});let c=e;const u=a(n=>{if(r.unknownFields==="error")throw new i(`${n}: is not accepted by this upstream`,{code:"unsupported_field",param:n});s.includes(n)||s.push(n)},"refuse"),o=t.salt??r.cacheSalt;o!=null&&(f.includes(l)?c={...c,cache_salt:o}:u("cache_salt"));const p=t.key??r.promptCacheKey;return p!=null&&!Object.hasOwn(e,"prompt_cache_key")&&(_.includes(l)?c={...c,prompt_cache_key:p}:u("prompt_cache_key")),c}a(w,"addCache");export{_ as KEY_DRIVERS,f as SALT_DRIVERS,w as addCache,d as valid};
|
|
2
|
+
//# sourceMappingURL=cache.mjs.map
|
package/dist/lib/capture.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var b=Object.defineProperty;var s=(o,n)=>b(o,"name",{value:n,configurable:!0});import{resolve as f}from"./settings.mjs";import*as v from"./vllm.mjs";import{PROTOCOL as k}from"./ollama.mjs";function x(o){const n=[];for(const a of Object.keys(o??{})){const t=o[a];typeof t?.info=="function"&&n.push({name:a,info:t.info(),detect:t.detect,settings:t.settings,probe:t.probe,path:t.path,request:t.request,response:t.response,chunk:t.chunk,flush:t.flush,error:t.error,count:t.token?.count,list:t.model?.list})}return n.sort((a,t)=>a.info.order-t.info.order)}s(x,"collect");function w(o,n,a){const{config:t,state:i}=n,p=o.convert.anthropic.messages.to.openai.chat,u=o.convert.openai.chat.to.anthropic.messages,g={anthropic:o.convert.anthropic.messages.to.ollama.chat,openai:o.convert.openai.chat.to.ollama.chat},m={anthropic:o.convert.ollama.chat.to.anthropic.messages,openai:o.convert.ollama.chat.to.openai.chat},r=a??t.front,l=x(o.driver),d=r==="anthropic"?"anthropic.messages":"openai.chat",q=r==="anthropic"?{request:p.request,response:u.response,stream:u.stream}:{request:u.request,response:p.response,stream:p.stream},O={request:g[r].request,response:m[r].response,stream:m[r].stream};return{config:t,state:i,front:r,drivers:l,endpoint:s(e=>i.endpoints.find(c=>c.name===e),"endpoint"),driver:s(e=>l.find(c=>c.name===e.driver),"driver"),settings:s(e=>f(e.driverSettings,e.probed,t.settings,e.settings),"settings"),converters:s((e,c)=>{if(e.protocol===k)return O;if(e.protocol===d)return null;if(r==="anthropic"&&c!==void 0&&e.driver==="vllm"&&!i.noMessages.has(e.name)){const h=f(e.driverSettings,e.probed,t.settings,e.settings);if(v.wants(e,h)&&v.unsuited(c,h)===null)return null}return q},"converters")}}s(w,"capture");export{w as capture,x as collect};
|
|
2
2
|
//# sourceMappingURL=capture.mjs.map
|
package/dist/lib/config.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var i=Object.defineProperty;var
|
|
1
|
+
var i=Object.defineProperty;var a=(t,r)=>i(t,"name",{value:r,configurable:!0});import{TranslatorError as o}from"./errors.mjs";import*as n from"./pool.mjs";import{valid as p}from"./record.mjs";import{normalizeAliases as u,normalizeEfforts as l}from"./effort.mjs";function d(t){let r=t.length;for(;t[r-1]==="/";)r--;const e=t.slice(0,r);return e.endsWith("/v1")?e.slice(0,-3):e}a(d,"baseUrl");function f(t,r){const e=typeof t=="string"?{url:t}:t;if(!e||typeof e!="object"||typeof e.url!="string"||e.url==="")throw new o(`upstreams[${r}] needs a "url"`,{code:"INVALID_CONFIG",status:500});for(const s of["apiVersion","deployment"])if(e[s]!==void 0&&(typeof e[s]!="string"||e[s]===""))throw new o(`upstreams[${r}].${s} must be a non-empty string`,{code:"INVALID_CONFIG",status:500});if(e.api!==void 0&&e.api!=="openai"&&e.api!=="native")throw new o(`upstreams[${r}].api must be "openai" or "native" (got ${JSON.stringify(e.api)})`,{code:"INVALID_CONFIG",status:500});return{name:e.name??`upstream-${r}`,url:d(e.url),apiKey:e.apiKey,headers:{...e.headers},apiVersion:e.apiVersion,deployment:e.deployment,api:e.api??"openai",backend:e.backend??"auto",models:Array.isArray(e.models)?[...e.models]:void 0,default:e.default===!0,settings:{...e.settings},version:e.version,driver:null,facts:null,driverSettings:{},probed:{},health:n.health()}}a(f,"endpoint");function y(t={}){const r=t.front??"anthropic";if(r!=="anthropic"&&r!=="openai")throw new o(`front must be "anthropic" or "openai" (got ${JSON.stringify(r)})`,{code:"INVALID_CONFIG",status:500});let e=t.upstreams??t.upstream;if(e!==void 0&&!Array.isArray(e)&&(e=[e]),!e||e.length===0)throw new o("at least one upstream is required (config.upstreams)",{code:"INVALID_CONFIG",status:500});const s=t.logs??!1;if(typeof s!="boolean"&&(typeof s!="string"||s===""))throw new o("logs must be true, false or a file path (got "+JSON.stringify(s)+")",{code:"INVALID_CONFIG",status:500});if(t.onEvent!==void 0&&typeof t.onEvent!="function")throw new o("onEvent must be a function",{code:"INVALID_CONFIG",status:500});if(!p(t.capture))throw new o("capture must be false, a directory path or a function (got "+JSON.stringify(t.capture)+")",{code:"INVALID_CONFIG",status:500});return{front:r,endpoints:e.map(f),...u(t.aliases),efforts:l(t.efforts),pool:n.normalize(t.pool),settings:{...t.settings},detect:t.detect!==!1,detectTimeout:t.detectTimeout??5e3,transport:t.transport,logs:s,capture:t.capture||!1,events:t.events!==!1,onEvent:t.onEvent}}a(y,"normalize");export{f as endpoint,y as normalize};
|
|
2
2
|
//# sourceMappingURL=config.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var g=Object.defineProperty;var i=(r,o)=>g(r,"name",{value:o,configurable:!0});import{atLeast as h}from"./normalize.mjs";import{TranslatorError as l}from"./errors.mjs";const u=["json","regex","choice","grammar"],j="0.11.0",x=i(r=>r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escape");function y(r){if(r==null)return null;if(typeof r!="object"||Array.isArray(r))return`expected an object with one of ${u.join(", ")}`;const o=Object.keys(r).filter(t=>r[t]!==void 0&&r[t]!==null);if(o.length!==1||!u.includes(o[0]))return`expected exactly one of ${u.join(", ")}`;const[n]=o,e=r[n];return n==="json"&&(typeof e!="object"||Array.isArray(e))?"json must be a JSON Schema object":(n==="regex"||n==="grammar")&&(typeof e!="string"||e==="")?`${n} must be a non-empty string`:n==="choice"&&!(Array.isArray(e)&&e.length>0&&e.every(t=>typeof t=="string"&&t!==""))?"choice must be a non-empty list of non-empty strings":null}i(y,"check");function _(r,o,n,e){const t=i(()=>`(?:${e.map(x).join("|")})`,"alternation"),f={type:"json_schema",json_schema:{name:"constraint",schema:e,strict:!0}};switch(r){case"vllm":case"compatible":return h(o,j)?{structured_outputs:{[n]:e}}:{[`guided_${n}`]:e};case"sglang":return n==="json"?{response_format:f}:n==="regex"?{regex:e}:n==="choice"?{regex:t()}:{ebnf:e};case"llamacpp":return n==="json"?{json_schema:e}:n==="grammar"?{grammar:e}:n==="choice"?{grammar:`root ::= ${e.map(s=>JSON.stringify(s)).join(" | ")}`}:null;case"tgi":return n==="json"?{response_format:{type:"json",value:e}}:n==="regex"?{response_format:{type:"regex",value:e}}:n==="choice"?{response_format:{type:"regex",value:t()}}:null;default:return n==="json"?{response_format:f}:null}}i(_,"fields");function A(r,o,n,e,t=[]){const f=y(o);if(f!==null)throw new l(`constraint: ${f}`,{code:"invalid_request",param:"constraint"});const s=o??n.constraint;if(s==null)return r;const a=u.find(c=>s[c]!==void 0&&s[c]!==null),p=i(c=>{t.includes(c)||t.push(c)},"note"),m=_(e.name,e.version,a,s[a]);if(m===null){if(n.unknownFields==="error")throw new l(`constraint.${a}: is not accepted by this upstream`,{code:"unsupported_field",param:`constraint.${a}`});return p(`constraint.${a}`),r}return["vllm","compatible"].includes(e.name)&&Array.isArray(r.tools)&&r.tools.length>0&&r.tool_choice!=="none"?(p(`constraint.${a}`),r):Object.keys(m).some(c=>Object.hasOwn(r,c))?r:{...r,...m}}i(A,"addConstraint");export{u as KINDS,j as STRUCTURED_OUTPUTS_VERSION,A as addConstraint,y as check,_ as fields};
|
|
2
|
+
//# sourceMappingURL=constraint.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var m=Object.defineProperty;var u=(e,o)=>m(e,"name",{value:o,configurable:!0});import{estimate as x,tokens as d}from"./estimate.mjs";import{restoreName as y}from"./ids.mjs";const v=1e5,k=3,a="[Tool result cleared to save context]",c=u((e,o)=>e!==null&&typeof e=="object"&&o.includes(e.type)&&Number.isInteger(e.value)&&e.value>=0,"threshold");function N(e){return e.trigger!==void 0&&!c(e.trigger,["input_tokens","tool_uses"])||e.keep!==void 0&&!c(e.keep,["tool_uses"])||e.clear_at_least!==void 0&&!c(e.clear_at_least,["input_tokens"])||e.exclude_tools!==void 0&&!(Array.isArray(e.exclude_tools)&&e.exclude_tools.every(o=>typeof o=="string"))?!1:e.clear_tool_inputs===void 0||typeof e.clear_tool_inputs=="boolean"}u(N,"valid");function D(e,o,p){const l=[];for(const t of o.messages)if(t.role==="assistant")for(const n of t.tool_calls??[])l.push({call:n,result:o.messages.find(r=>r.role==="tool"&&r.tool_call_id===n.id)});const f=e.trigger??{type:"input_tokens",value:v};if((f.type==="tool_uses"?l.length:x(o))<=f.value)return null;const g=e.keep?.value??k,h=new Set(e.exclude_tools??[]),s=l.slice(0,Math.max(0,l.length-g)).filter(t=>t.result!==void 0&&t.result.content!==a&&!h.has(y(p,t.call.function.name))),i=[];for(const t of s){const n=JSON.stringify([t.result.content,e.clear_tool_inputs===!0?t.call.function.arguments:""]).length,r=JSON.stringify([a,e.clear_tool_inputs===!0?"{}":""]).length;i.push(Math.max(0,n-r))}const _=d(i.reduce((t,n)=>t+n,0));if(s.length===0||_<(e.clear_at_least?.value??0))return null;for(const t of s)t.result.content=a,e.clear_tool_inputs===!0&&(t.call.function.arguments="{}");return{type:e.type,cleared_tool_uses:s.length,cleared_input_tokens:_}}u(D,"clearToolUses");export{k as DEFAULT_KEEP,v as DEFAULT_TRIGGER,a as PLACEHOLDER,D as clearToolUses,N as valid};
|
|
2
|
+
//# sourceMappingURL=context.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var d=Object.defineProperty;var l=(e,a)=>d(e,"name",{value:a,configurable:!0});import*as i from"./http.mjs";import{emit as u}from"./events.mjs";import{pick as c}from"./route.mjs";async function m(e,a,n,o){const t=a.health,s=await i.json(e.state.transport,i.join(a.url,n.info.paths.health),{method:"GET",headers:i.headers(a,n.info.auth),signal:o,timeout:e.config.pool.healthTimeout});if(o?.aborted)return;const r=t.ready;t.checkedAt=Date.now(),s.ok?(t.ready=!0,t.readyReason=null):s.status===0||s.status>=500?(t.ready=!1,t.readyReason=s.status===0?String(s.error?.message??"no answer"):`HTTP ${s.status}`):(t.ready=null,t.readyReason=null,t.unsupported=!0),t.ready===!1&&r!==!1?u(e,{type:"health",kind:"down",level:"warn",message:`Upstream ${a.name} is not ready (${t.readyReason}); requests go to other endpoints that serve the same model first`,endpoint:a.name,reason:t.readyReason}):t.ready===!0&&r===!1&&u(e,{type:"health",kind:"up",level:"info",message:`Upstream ${a.name} is ready again`,endpoint:a.name})}l(m,"run");async function p(e,a,n={}){const o=Date.now(),{healthInterval:t}=e.config.pool;await Promise.all(a.map(s=>{const r=s.health,f=e.driver(s);if(!f.info.paths?.health)return;if(n.force)r.unsupported=!1;else if(r.unsupported||t<=0)return;const h=Math.max(r.checkedAt??0,r.ready===!1?0:r.lastSuccess??0);if(!(!n.force&&o-h<t))return r.checking??=m(e,s,f,n.signal).finally(()=>{r.checking=null}),r.checking}))}l(p,"probe");async function w(e,a,n){if(e.config.pool.healthInterval<=0||!a||typeof a!="object")return;const{pool:o}=c(e.config,e.state.endpoints,a.model,e.state);o.length>1&&await p(e,o,{signal:n})}l(w,"refresh");export{p as probe,w as refresh};
|
|
2
|
+
//# sourceMappingURL=health.mjs.map
|
package/dist/lib/http.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var h=Object.defineProperty;var r=(t,e)=>h(t,"name",{value:e,configurable:!0});function y(t,e){return t+e}r(y,"join");async function m(t,e,a,n){return t.path?t.path(e,{endpoint:a,model:n}):(t.info.native!==void 0&&a.protocol===t.info.native.protocol?t.info.native.paths:void 0)?.[e]??t.info.paths[e]??p[e]}r(m,"pathOf");const p={embeddings:"/v1/embeddings",models:"/v1/models"};function k(t){return t==="localhost"||t==="::1"||/^127\./.test(t)}r(k,"isLoopback");function d(t,e="bearer",a){const n={...t.headers};return t.apiKey&&(e==="x-api-key"||e==="api-key"?n[e]=t.apiKey:n.authorization=`Bearer ${t.apiKey}`),{...n,...a}}r(d,"headers");function S({endpoint:t,transport:e,signal:a,timeout:n,probes:s},c,u){const i=u!==void 0&&(u.auth==="x-api-key"||u.auth==="api-key"||u.headers!==void 0),o=i?{auth:u.auth,extra:u.headers}:{},l=r(()=>g(e,y(t.url,c),{method:"GET",headers:d(t,o.auth,o.extra),signal:a,timeout:n}),"run");if(!s)return l();const f=i?JSON.stringify([c,o.auth,o.extra]):c;return s.has(f)||s.set(f,l()),s.get(f)}r(S,"probe");function x(t){const e={};if(!t)return e;if(typeof t.forEach=="function")return t.forEach((a,n)=>{e[n.toLowerCase()]=a}),e;for(const[a,n]of Object.entries(t))e[a.toLowerCase()]=String(n);return e}r(x,"plain");async function g(t,e,a={}){const{timeout:n,signal:s,body:c,...u}=a,i=[];s&&i.push(s),n>0&&i.push(AbortSignal.timeout(n));try{const o=await t(e,{...u,redirect:"error",body:c===void 0?void 0:JSON.stringify(c),signal:i.length>1?AbortSignal.any(i):i[0]}),l=await o.text();let f=null;try{f=JSON.parse(l)}catch{f=l===""?null:l}return{ok:o.ok,status:o.status,body:f,headers:x(o.headers)}}catch(o){return{ok:!1,status:0,body:null,error:o}}}r(g,"json");export{d as headers,k as isLoopback,y as join,g as json,m as pathOf,x as plain,S as probe};
|
|
2
2
|
//# sourceMappingURL=http.mjs.map
|
package/dist/lib/models.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var c=Object.defineProperty;var r=(t,a)=>c(t,"name",{value:a,configurable:!0});import*as s from"./http.mjs";function l(t){return!t.ok||!Array.isArray(t.body?.data)?null:t.body.data.filter(a=>a&&typeof a.id=="string")}r(l,"modelsOf");function i(t){return t.filter(a=>typeof a?.parent=="string"&&a.parent!=="").map(a=>({id:a.id,parent:a.parent}))}r(i,"adaptersOf");function u(t){const a=new Set((t.facts?.adapters??[]).map(e=>e.id));return(t.models??t.facts?.models??[]).filter(e=>!a.has(e))}r(u,"baseModels");function h(t){const a=new Map((t.facts?.adapters??[]).map(e=>[e.id,e.parent]));return(t.models??t.facts?.models??[]).map(e=>a.has(e)?{id:e,parent:a.get(e)}:{id:e})}r(h,"knownModels");async function x({endpoint:t,transport:a,signal:e,timeout:o,auth:n,extraHeaders:p,path:f="/v1/models"}){const d=await s.json(a,s.join(t.url,f),{method:"GET",headers:s.headers(t,n,p),signal:e,timeout:o});return l(d)}r(x,"fetchModels");export{i as adaptersOf,u as baseModels,x as fetchModels,h as knownModels,l as modelsOf};
|
|
2
2
|
//# sourceMappingURL=models.mjs.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var i=Object.defineProperty;var o=(e,s)=>i(e,"name",{value:s,configurable:!0});import{items as c}from"./source.mjs";import{TranslatorError as d}from"./errors.mjs";function l(e){try{return JSON.parse(e)}catch{throw new d("Upstream sent a stream line that is not valid JSON",{code:"invalid_stream_data",status:502,details:{data:e}})}}o(l,"decode");function f(){let e="";const s=o((r,t)=>{const n=r.replace(/\r$/,"").trim();n!==""&&t.push(l(n))},"lines");return{push(r){const t=[];e+=r;let n=0;for(let a=e.indexOf(`
|
|
2
|
+
`);a!==-1;a=e.indexOf(`
|
|
3
|
+
`,n))s(e.slice(n,a),t),n=a+1;return e=e.slice(n),t},flush(){const r=[];return s(e,r),e="",r}}}o(f,"createParser");async function*h(e){const s=f(),r=new TextDecoder;for await(const t of c(e))typeof t=="string"||t instanceof Uint8Array?yield*s.push(typeof t=="string"?t:r.decode(t,{stream:!0})):yield t;yield*s.push(r.decode()),yield*s.flush()}o(h,"parse");export{f as createParser,h as parse};
|
|
4
|
+
//# sourceMappingURL=ndjson.mjs.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var v=Object.defineProperty;var r=(t,o)=>v(t,"name",{value:o,configurable:!0});import{TranslatorError as F}from"./errors.mjs";import{callId as S,completionId as k}from"./ids.mjs";import{parseArguments as D}from"./arguments.mjs";import{reasoningOf as E}from"./thinking.mjs";const z="ollama.chat",x=["temperature","top_p","top_k","min_p","seed","frequency_penalty","presence_penalty"],L=new Set(["model","messages","stream","tools","tool_choice","max_tokens","max_completion_tokens","stop","response_format","reasoning_effort","chat_template_kwargs","think","options","format","keep_alive",...x,"repetition_penalty"]),M=new Set(["stream_options","user","metadata","store","service_tier"]),T="[An image was omitted because Ollama accepts base64 images only and the translator does not fetch URLs.]",O={none:!1,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"high",max:"max"};function h(t,o){t.includes(o)||t.push(o)}r(h,"drop");const A=r(t=>t!==null&&typeof t=="object"&&!Array.isArray(t),"isObject");function I(t,o){if(typeof t=="string")return{text:t,images:[]};const n=[],i=[];for(const e of Array.isArray(t)?t:[])if(e?.type==="text"&&typeof e.text=="string")n.push(e.text);else if(e?.type==="image_url"){const a=String(e.image_url?.url??e.image_url??""),c=/^data:[^;,]*;base64,(.*)$/s.exec(a);c?i.push(c[1]):(n.push(T),h(o,"image_url"))}else h(o,`content.${e?.type??"part"}`);return{text:n.join(`
|
|
2
|
+
`),images:i}}r(I,"contentOf");function R(t,o){return t.map(n=>(typeof n.id=="string"&&o.set(n.id,n.function?.name),{type:"function",function:{name:n.function?.name,arguments:D(n.function?.arguments)}}))}r(R,"callsOf");function U(t,o,n){const{text:i,images:e}=I(t?.content,n);if(t?.role==="tool"){const c=o.get(t.tool_call_id)??t.name;return{role:"tool",...typeof c=="string"?{tool_name:c}:{},content:i}}const a={role:t?.role==="developer"?"system":t?.role,content:i};if(e.length>0&&(a.images=e),t?.role==="assistant"){const c=E(t);c!==""&&(a.thinking=c),Array.isArray(t.tool_calls)&&t.tool_calls.length>0&&(a.tool_calls=R(t.tool_calls,o))}return a}r(U,"messageOf");function C(t){if(typeof t.reasoning_effort=="string")return Object.hasOwn(O,t.reasoning_effort)?O[t.reasoning_effort]:t.reasoning_effort;if(t.think!==void 0)return t.think;const o=t.chat_template_kwargs?.enable_thinking;return typeof o=="boolean"?o:void 0}r(C,"thinkOf");function H(t,o){const n={};for(const[e,a]of Object.entries(o))n[e==="repetition_penalty"?"repeat_penalty":e]=a;for(const e of x)t[e]!==void 0&&t[e]!==null&&(n[e]=t[e]);t.repetition_penalty!==void 0&&(n.repeat_penalty=t.repetition_penalty);const i=t.max_completion_tokens??t.max_tokens;return i!=null&&(n.num_predict=i),t.stop!==void 0&&t.stop!==null&&(n.stop=Array.isArray(t.stop)?t.stop:[t.stop]),A(t.options)?{...n,...t.options}:n}r(H,"optionsOf");function $(t){if(t.format!==void 0)return t.format;const o=t.response_format;if(o?.type==="json_object")return"json";if(o?.type==="json_schema"&&A(o.json_schema?.schema))return o.json_schema.schema}r($,"formatOf");function G(t,o={}){const n=o.dropped??[],i=new Map,e={model:t.model,messages:(Array.isArray(t.messages)?t.messages:[]).map(s=>U(s,i,n)),stream:t.stream===!0};Array.isArray(t.tools)&&t.tools.length>0&&t.tool_choice!=="none"?(e.tools=t.tools.map(s=>({type:"function",function:{name:s.function?.name,description:s.function?.description,parameters:s.function?.parameters??{type:"object",properties:{}}}})),t.tool_choice!==void 0&&t.tool_choice!=="auto"&&h(n,"tool_choice")):t.tool_choice==="none"&&Array.isArray(t.tools)&&h(n,"tools");const a=H(t,o.sampling??{});Object.keys(a).length>0&&(e.options=a);const c=$(t);c!==void 0&&(e.format=c);const f=C(t);f!==void 0&&(e.think=f),t.keep_alive!==void 0&&(e.keep_alive=t.keep_alive);for(const s of Object.keys(t))L.has(s)||M.has(s)||s==="n"&&!(t.n>1)||h(n,s);return e}r(G,"chatBody");function j(t,o=0){return(Array.isArray(t)?t:[]).map((n,i)=>{const e=n?.function?.arguments;return{index:o+i,id:typeof n?.id=="string"&&n.id!==""?n.id:S(),type:"function",function:{name:n?.function?.name,arguments:typeof e=="string"?e:JSON.stringify(e??{})}}})}r(j,"callsOfReply");function y(t,o){return o?"tool_calls":t?.done_reason==="length"?"length":"stop"}r(y,"finishOf");function w(t){const o=t?.prompt_eval_count,n=t?.eval_count;if(!Number.isFinite(o)&&!Number.isFinite(n))return;const i=Number.isFinite(o)?o:0,e=Number.isFinite(n)?n:0;return{prompt_tokens:i,completion_tokens:e,total_tokens:i+e}}r(w,"usageOf");function Q(t){return t===void 0?void 0:{input_tokens:t.prompt_tokens,output_tokens:t.completion_tokens}}r(Q,"folded");function N(t){return typeof t?.error=="string"?t.error:null}r(N,"errorOf");function V(t,o={}){const n=N(t);if(n!==null)throw new F(n,{code:"upstream_error",status:502});const i=t?.message??{},e=j(i.tool_calls),a={role:"assistant",content:typeof i.content=="string"?i.content:""};typeof i.thinking=="string"&&i.thinking!==""&&(a[o.reasoningField??"reasoning"]=i.thinking),e.length>0&&(a.tool_calls=e.map(s=>({id:s.id,type:s.type,function:s.function})));const c=w(t),f=Date.parse(t?.created_at);return{id:k(),object:"chat.completion",created:Number.isNaN(f)?Math.floor(Date.now()/1e3):Math.floor(f/1e3),model:t?.model,choices:[{index:0,message:a,finish_reason:y(t,e.length>0)}],...c===void 0?{}:{usage:c}}}r(V,"completion");function W(t={}){const o=k(),n=Math.floor(Date.now()/1e3),i=t.reasoningField??"reasoning";let e=t.model,a=!1,c=0,f=!1,s;const g=r((u,_=null)=>({id:o,object:"chat.completion.chunk",created:n,model:e,choices:[{index:0,delta:u,finish_reason:_}]}),"make");return{line(u){const _=N(u);if(_!==null)return f=!0,[{error:{message:_,type:"api_error",param:null,code:null}}];e=t.model??u?.model??e;const p=[];a||(a=!0,p.push(g({role:"assistant",content:""})));const l=u?.message??{},m={};typeof l.thinking=="string"&&l.thinking!==""&&(m[i]=l.thinking),typeof l.content=="string"&&l.content!==""&&(m.content=l.content);const d=j(l.tool_calls,c);return d.length>0&&(c+=d.length,m.tool_calls=d),Object.keys(m).length>0&&p.push(g(m)),u?.done===!0&&(f=!0,s=w(u),p.push(g({},y(u,c>0))),t.includeUsage!==!1&&s!==void 0&&p.push({id:o,object:"chat.completion.chunk",created:n,model:e,choices:[],usage:s})),p},finished:r(()=>f,"finished"),usage:r(()=>s,"usage")}}r(W,"createChunker");export{z as PROTOCOL,j as callsOfReply,G as chatBody,V as completion,W as createChunker,N as errorOf,y as finishOf,Q as folded,w as usageOf};
|
|
3
|
+
//# sourceMappingURL=ollama.mjs.map
|
package/dist/lib/passthrough.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var a=Object.defineProperty;var i=(t,o)=>a(t,"name",{value:o,configurable:!0});const p=["model","messages","stream","stream_options","max_tokens","max_completion_tokens","temperature","top_p","n","stop","presence_penalty","frequency_penalty","logit_bias","logprobs","top_logprobs","seed","response_format","tools","tool_choice","parallel_tool_calls","reasoning_effort","user","metadata","store","service_tier"],d=["top_k","min_p","repetition_penalty","length_penalty","min_tokens","stop_token_ids","include_stop_str_in_output","ignore_eos","skip_special_tokens","spaces_between_special_tokens","allowed_token_ids","bad_words","prompt_logprobs","truncate_prompt_tokens","add_generation_prompt","continue_final_message","add_special_tokens","chat_template_kwargs","thinking_token_budget","include_reasoning","structured_outputs","guided_json","guided_regex","guided_choice","guided_grammar"],c=new Set(p),l=new Set(["include_usage","continuous_usage_stats"]);function g(t,o=[]){const s={};for(const[e,n]of Object.entries(t))if(!(!c.has(e)&&!o.includes(e)))if(e==="stream_options"){const _=Object.fromEntries(Object.entries(n??{}).filter(([r])=>l.has(r)));Object.keys(_).length>0&&(s.stream_options=_)}else s[e]=n;return s}i(g,"filterChatBody");export{d as VLLM_FIELDS,g as filterChatBody};
|
|
2
2
|
//# sourceMappingURL=passthrough.mjs.map
|
package/dist/lib/pool.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var k=Object.defineProperty;var i=(t,r)=>k(t,"name",{value:r,configurable:!0});import{TranslatorError as S}from"./errors.mjs";const d=Object.freeze(["failover","round_robin","least_busy"]),m=Object.freeze({base:1e3,max:6e4}),y=Object.freeze({connect:1e4,headers:0}),p=Object.freeze({interval:1e4,timeout:2e3});function F(){return{failures:0,until:0,inflight:0,requests:0,errors:0,lastError:null,lastFailure:null,lastSuccess:null,ready:null,checkedAt:null,readyReason:null,unsupported:!1,checking:null}}i(F,"health");function j(t={}){const r=i(a=>new S(`pool: ${a}`,{code:"INVALID_CONFIG",status:500}),"bad");if(!t||typeof t!="object"||Array.isArray(t))throw r("must be an object");const e=t.strategy??"failover",s={...t.models};for(const[a,f]of[["strategy",e],...Object.entries(s).map(([x,O])=>[`models.${x}`,O])])if(!d.includes(f))throw r(`${a} must be one of ${d.join(", ")} (got ${JSON.stringify(f)})`);const o=t.backoff?.base??m.base,l=t.backoff?.max??m.max;if(!(Number.isFinite(o)&&o>0)||!(Number.isFinite(l)&&l>=o))throw r("backoff.base must be a positive number of ms and backoff.max at least backoff.base");const u=t.connectTimeout??y.connect,c=t.headersTimeout??y.headers,b=t.healthInterval??p.interval,h=t.healthTimeout??p.timeout,n={connectTimeout:u,headersTimeout:c,healthInterval:b,healthTimeout:h};for(const a of Object.keys(n)){const f=n[a];if(typeof f!="number"||!(Number.isFinite(f)&&f>=0))throw r(`${a} must be a number of ms, 0 or more (got ${JSON.stringify(f)})`)}return{strategy:e,backoff:{base:o,max:l},connectTimeout:u,headersTimeout:c,healthInterval:b,healthTimeout:h,models:s}}i(j,"normalize");function g(t,r){return t.health.until<=r&&t.health.ready!==!1}i(g,"available");function A(t,r,e,s,o,l=Date.now()){const u=t.pool.models[s]??t.pool.strategy,c=e.filter(n=>g(n,l)),b=e.filter(n=>!g(n,l)).sort((n,a)=>n.health.until-a.health.until);let h=c;if(u==="least_busy")h=[...c].sort((n,a)=>n.health.inflight-a.health.inflight);else if(u==="round_robin"&&c.length>0){const n=r.cursors.get(s)??0;o&&r.cursors.set(s,n+1);const a=n%c.length;h=[...c.slice(a),...c.slice(0,a)]}return[...h,...b]}i(A,"order");function E(t,r,e,s=Date.now()){const o=r.health;o.failures++,o.errors++,o.lastError=e,o.lastFailure=s;const{base:l,max:u}=t.pool.backoff;o.until=s+Math.min(u,l*2**Math.min(o.failures-1,30))}i(E,"failed");function I(t,r=Date.now()){const e=t.health;e.failures=0,e.until=0,e.lastSuccess=r,e.ready===!1&&(e.ready=!0)}i(I,"succeeded");function N(t,r=Date.now()){const e=t.health,s=i(l=>l===null?null:new Date(l).toISOString(),"iso"),o=e.until>r;return{healthy:!o&&e.ready!==!1,ready:e.ready,readyReason:e.ready===!1?e.readyReason:null,checkedAt:s(e.checkedAt),failures:e.failures,retryAt:o?s(e.until):null,inflight:e.inflight,requests:e.requests,errors:e.errors,lastError:e.lastError,lastFailure:s(e.lastFailure),lastSuccess:s(e.lastSuccess)}}i(N,"describe");export{m as BACKOFF,p as PROBES,d as STRATEGIES,y as TIMEOUTS,N as describe,E as failed,F as health,j as normalize,A as order,I as succeeded};
|
|
2
2
|
//# sourceMappingURL=pool.mjs.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var f=Object.defineProperty;var s=(e,t)=>f(e,"name",{value:t,configurable:!0});import{noEmptyTools as d}from"./normalize.mjs";const p={chat:"/v1/chat/completions",embeddings:"/v1/embeddings",models:"/v1/models"},c={chat:"/chat/completions",embeddings:"/embeddings",models:"/models"};function m(e){return/^grok-(3-mini|4|code)/.test(String(e))&&!/non-reasoning/.test(String(e))}s(m,"grokReasons");const l=Object.freeze({groq:{order:21,hosts:["api.groq.com"],root:"/openai",paths:p,settings:{reasoningField:"reasoning",maxTokensField:"max_completion_tokens",thinking:"none",thinkingBudget:!1,effort:!0,topK:!1,prefill:"none",streamUsage:!0,continuousUsage:!1},drop:["logprobs","top_logprobs","logit_bias"],dropName:!0},together:{order:22,hosts:["api.together.ai","api.together.xyz","us-api.together.ai"],paths:p,fields:["top_k","min_p","repetition_penalty"],settings:{reasoningField:"reasoning",reasoningRoundTrip:!0,maxTokensField:"max_tokens",thinking:"none",thinkingBudget:!1,effort:!0,topK:!0,prefill:"none",parallelToolCalls:!1,streamUsage:!1,continuousUsage:!1}},fireworks:{order:23,hosts:["api.fireworks.ai"],root:"/inference",paths:p,fields:["top_k","min_p","repetition_penalty"],settings:{reasoningField:"reasoning_content",reasoningRoundTrip:!0,maxTokensField:"max_tokens",thinking:"reasoning_effort",thinkingBudget:!1,effort:!0,topK:!0,prefill:"none",streamUsage:!0,continuousUsage:!1}},xai:{order:24,hosts:["api.x.ai"],paths:p,settings:{reasoningField:"reasoning_content",maxTokensField:"max_completion_tokens",thinking:"none",thinkingBudget:!1,effort:!0,topK:!1,prefill:"none",streamUsage:!0,continuousUsage:!1},dropWhen:s(e=>m(e.model)?["stop","presence_penalty","frequency_penalty"]:[],"dropWhen")},gemini:{order:25,hosts:["generativelanguage.googleapis.com"],root:"/v1beta/openai",paths:c,settings:{maxTokensField:"max_tokens",thinking:"none",thinkingBudget:!1,effort:!0,topK:!1,prefill:"none",streamUsage:!0,continuousUsage:!1}}});function _(e){const t=l[e],o={name:e,protocol:"openai.chat",order:t.order,auth:"bearer",strict:!1,hosts:[...t.hosts],paths:{...t.paths}};return t.fields?{...o,fields:[...t.fields]}:o}s(_,"describe");function x(e,t){const o=URL.canParse(t.url)?new URL(t.url).hostname:"";return l[e].hosts.includes(o)?{host:o}:null}s(x,"match");function U(e){return{...l[e].settings}}s(U,"settingsOf");function b(e,t,o){const i=l[e],a=i.root??"";return(o.url.endsWith(a)?"":a)+i.paths[t]}s(b,"route");function y(e,t,o){const i=l[e],a=o?.state?.dropped,g=s(n=>{Array.isArray(a)&&!a.includes(n)&&a.push(n)},"note"),r={...d(t)};for(const n of[...i.drop??[],...i.dropWhen?.(t)??[]])r[n]!==void 0&&(delete r[n],g(n));return i.dropName&&Array.isArray(r.messages)&&r.messages.some(n=>n&&"name"in n)&&(r.messages=r.messages.map(n=>{const u={...n};return delete u.name,u}),g("messages[].name")),r}s(y,"trim");export{l as PRESETS,_ as describe,x as match,b as route,U as settingsOf,y as trim};
|
|
2
|
+
//# sourceMappingURL=presets.mjs.map
|
package/dist/lib/route.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var m=Object.defineProperty;var u=(e,n)=>m(e,"name",{value:n,configurable:!0});import{TranslatorError as f}from"./errors.mjs";import{order as v}from"./pool.mjs";function
|
|
1
|
+
var m=Object.defineProperty;var u=(e,n)=>m(e,"name",{value:n,configurable:!0});import{TranslatorError as f}from"./errors.mjs";import{order as v}from"./pool.mjs";import{baseModels as h}from"./models.mjs";function w(e,n){return(e.models??e.facts?.models??[]).includes(n)?!0:e.protocol==="anthropic.messages"&&e.models===void 0&&/^claude-/.test(n)}u(w,"serves");function O(e,n,t,r,l=!1){const a=Object.hasOwn(e.aliases,t),o=a?e.aliases[t]:t,d=a&&Object.hasOwn(e.pins,t)?e.pins[t]:void 0,c=n.filter(s=>w(s,o)),i=n.find(s=>s.default)??n[0];if(c.length>0){const s=v(e,r,c,o,l);return{endpoint:s[0],model:o,unserved:!1,pool:s,pin:d}}const p=h(i);return p.length===1?{endpoint:i,model:p[0],unserved:!1,pool:[i],pin:d}:{endpoint:i,model:o,unserved:!0,pool:[i],pin:d}}u(O,"pick");function x(e,n,t={}){if(!n||typeof n!="object"||Array.isArray(n))throw new f("The request body must be a JSON object",{code:"invalid_body",status:400});const r=O(e.config,e.state.endpoints,n.model,e.state,t.advance===!0);if(t.endpoint!==void 0){const o=r.pool.find(d=>d.name===t.endpoint);if(!o)throw new f(`Endpoint ${t.endpoint} no longer serves ${r.model}`,{code:"endpoint_not_in_pool",status:500});return{endpoint:o,model:r.model,requested:n.model,unserved:r.unserved,pin:r.pin,convert:e.converters(o,n),pool:[o]}}const{endpoint:l,pool:a}=r;return{endpoint:l,model:r.model,requested:n.model,unserved:r.unserved,pin:r.pin,convert:e.converters(l,n),pool:a}}u(x,"resolve");export{O as pick,x as resolve,w as serves};
|
|
2
2
|
//# sourceMappingURL=route.mjs.map
|
package/dist/lib/routes.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var H=Object.defineProperty;var c=(e,o)=>H(e,"name",{value:o,configurable:!0});import{timingSafeEqual as O}from"node:crypto";import{TranslatorError as p}from"./errors.mjs";import{messageId as T}from"./ids.mjs";import{sign as j}from"./thinking.mjs";const C=64*1024*1024,D={"content-type":"text/event-stream; charset=utf-8","cache-control":"no-cache","x-accel-buffering":"no"},v=Symbol("stalled"),x=Symbol("gone");async function I(e,o){if(!(o>0))return e;let s;const d=new Promise(f=>{s=setTimeout(f,o,v)});try{return await Promise.race([e,d])}finally{clearTimeout(s)}}c(I,"settle");async function*L(e,o,s){let d=!1;try{const f=o.front==="anthropic";f&&(yield{event:"message_start",data:{type:"message_start",message:{id:T(),type:"message",role:"assistant",model:s,content:[],stop_reason:null,stop_sequence:null,usage:{input_tokens:0,output_tokens:0,cache_creation_input_tokens:0,cache_read_input_tokens:0}}}},yield{event:"content_block_start",data:{type:"content_block_start",index:0,content_block:{type:"thinking",thinking:"",signature:""}}});const a=await e,b=c(function*(){yield{event:"content_block_delta",data:{type:"content_block_delta",index:0,delta:{type:"signature_delta",signature:j()}}},yield{event:"content_block_stop",data:{type:"content_block_stop",index:0}}},"closeEarly");if(a.stream){d=!0;let u=null;for await(const i of a.stream){if(!f){yield i;continue}if(i.event!=="message_start"){if(u===null&&i.event==="content_block_start"&&i.data.content_block.type==="thinking"){u=0;continue}u===null&&(yield*b(),u=1),yield u>0&&typeof i.data?.index=="number"?{...i,data:{...i.data,index:i.data.index+u}}:i}}return}f&&(yield*b()),yield*S(o,a.body)}finally{d||e.then(f=>f.stream?.return?.(),()=>{})}}c(L,"late");function*S(e,o){if(e.front==="anthropic"){yield{event:"error",data:o};return}yield{data:o},yield{data:"[DONE]"}}c(S,"failure");async function E(e,o,s,d,f,a=200,b=D){e.hijack();const u=e.raw;u.writeHead(a,b);try{await o.write(u,d,{front:o.front,interval:f})}catch(i){if(!s.signal.aborted){const y=i instanceof p;y||(e.log.error(i),o.emit({type:"error",kind:"route",level:"error",message:String(i?.message??i),log:!1}));const{body:g}=o.build(y?i.status:502,y?i.message:"Internal server error",y?{type:i.type,code:i.code}:{});for(const w of S(o,g))u.write(o.encode(w))}}return u.end(),e}c(E,"stream");function U(e,o){const s=Buffer.from(e),d=Buffer.from(o);return s.length===d.length&&O(s,d)}c(U,"same");function z(e){const o=/^Bearer\s+(.+)$/i.exec(e.authorization??"");return e["x-api-key"]||o?.[1]||""}c(z,"keyOf");function B(e){const o={};for(const[s,d]of Object.entries(e))(s==="anthropic-beta"||s==="anthropic-version"||s.startsWith("x-claude-code-"))&&(o[s]=String(d));return o}c(B,"forwardable");function P(e){if(e===!0)return{ok:!0,context:void 0};if(e&&typeof e=="object"&&e.ok===!0)return{ok:!0,context:e.context,cacheSalt:e.cacheSalt};const o=e&&typeof e=="object"&&e.ok===!1?e:{};return{ok:!1,status:Number.isInteger(o.status)&&o.status>=400&&o.status<=599?o.status:401,message:typeof o.message=="string"&&o.message!==""?o.message:"unauthorized"}}c(P,"verdictOf");function R(e,o,s){const{front:d,filter:f}=s,a={...s,build:c((t,n,r={})=>s.build(t,n,{...r,front:d}),"build"),send:c((t,n)=>s.send(t,{...n,front:d,filter:f}),"send"),route:c(t=>s.route(t,{front:d}),"route"),count:c((t,n)=>s.count(t,{...n,front:d}),"count"),embed:c((t,n)=>s.embed(t,n),"embed"),list:c(t=>s.list({...t,front:d}),"list"),get:c((t,n)=>s.get(t,{...n,front:d}),"get")},b=[o.apiKey??[]].flat().filter(Boolean),u=o.bodyLimit??C,i=new WeakMap,y=new WeakMap,g=c((t,n)=>t.code(n.status).headers(n.headers).send(n.body),"reject");e.setErrorHandler((t,n,r)=>{if(t instanceof p)return g(r,a.build(t.status,t.message,{type:t.type,code:t.code,param:t.param}));const l=t.statusCode??500;return l<500?g(r,a.build(l,t.message)):(n.log.error(t),a.emit({type:"error",kind:"route",level:"error",message:String(t.message),status:l,log:!1}),g(r,a.build(l,"Internal server error")))}),e.addHook("onRequest",async(t,n)=>{if(b.length===0||t.routeOptions.config?.public)return;const r=z(t.headers);if(!(r&&b.some(l=>U(r,l))))return g(n,a.build(401,"invalid x-api-key"))}),typeof o.authorize=="function"&&e.addHook("preHandler",async(t,n)=>{if(t.routeOptions.config?.public)return;let r=null;if(t.body&&typeof t.body=="object"&&!Array.isArray(t.body))try{r=a.route(t.body)}catch{}let l;try{l=P(await o.authorize({method:t.method,url:t.url,headers:t.headers,body:t.body,front:a.front,route:r}))}catch(m){t.log.error(m),a.emit({type:"error",kind:"route",level:"error",message:String(m?.message??m),log:!1}),l={ok:!1,status:401,message:"unauthorized"}}if(!l.ok)return g(n,a.build(l.status,l.message));i.set(t,l.context),typeof l.cacheSalt=="string"&&l.cacheSalt!==""&&y.set(t,l.cacheSalt)}),e.route({method:["GET","HEAD"],url:"/",config:{public:!0},handler:c(async(t,n)=>n.send({ok:!0}),"handler")}),e.route({method:["GET","HEAD"],url:"/api/hello",config:{public:!0},handler:c(async(t,n)=>n.send({ok:!0}),"handler")}),e.get("/v1/models",async(t,n)=>{const r=new AbortController;return n.raw.on("close",()=>r.abort()),a.list({signal:r.signal})}),e.get("/v1/models/*",async(t,n)=>{const r=new AbortController;return n.raw.on("close",()=>r.abort()),a.get(t.params["*"],{signal:r.signal})});const w=a.front==="anthropic"?"/v1/messages":"/v1/chat/completions";e.post(w,{bodyLimit:u},async(t,n)=>{if(n.raw.destroyed)return n;const r=new AbortController;n.raw.on("close",()=>{n.raw.writableFinished||r.abort()});const l=typeof o.onUsage=="function"?k=>o.onUsage(k,i.get(t)):void 0,m=a.interval(t.body),_=a.send(t.body,{signal:r.signal,clientHeaders:B(t.headers),cacheSalt:y.get(t),onUsage:l,log:t.log});_.catch(()=>{});const A=new Promise(k=>r.signal.addEventListener("abort",()=>k(x),{once:!0})),h=await I(Promise.race([_,A]),t.body?.stream===!0?m:0);return h===x?(_.then(k=>k.stream?.return?.(),()=>{}),n):h===v?E(n,a,r,L(_,a,t.body?.model),m):h.stream?E(n,a,r,h.stream,m,h.status,h.headers):g(n,h)}),a.front==="openai"&&e.post("/v1/embeddings",{bodyLimit:u},async(t,n)=>{const r=new AbortController;n.raw.on("close",()=>{n.raw.writableFinished||r.abort()});const l=typeof o.onUsage=="function"?m=>o.onUsage(m,i.get(t)):void 0;return g(n,await a.embed(t.body,{signal:r.signal,onUsage:l,log:t.log}))}),a.front==="anthropic"&&e.post("/v1/messages/count_tokens",{bodyLimit:u},async(t,n)=>{const r=new AbortController;return n.raw.on("close",()=>r.abort()),a.count(t.body,{signal:r.signal})})}c(R,"register");export{L as late,R as register};
|
|
2
2
|
//# sourceMappingURL=routes.mjs.map
|
package/dist/lib/settings.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var f=Object.defineProperty;var l=(o,e)=>f(o,"name",{value:e,configurable:!0});import{TranslatorError as n}from"./errors.mjs";import{check as c}from"./constraint.mjs";import{valid as d}from"./cache.mjs";const r=Object.freeze({inlineSystem:"auto",stripBillingHeader:!0,reasoningField:"reasoning",thinkTags:!0,thinkOpen:!1,reasoningRoundTrip:!1,thinking:"chat_template_kwargs",thinkingBudget:!1,effort:!1,images:!0,imageFallback:!0,toolFallback:!1,documents:"extract",documentConverter:null,pdf:Object.freeze({pages:!0,maxPages:100,maxBytes:32*1024*1024,maxImages:20,scale:1.5}),toolSchema:"pass",deferredTools:"forward",toolSearch:"expand",jsonObject:"schema",jsonObjectFallback:!0,toolErrors:!1,toolErrorMarker:"[error] ",toolErrorInference:!1,maxTokensField:"max_completion_tokens",streamUsage:!0,continuousUsage:!1,prefill:"continue_final_message",topK:!0,responseFormat:!0,parallelToolCalls:!0,unknownFields:"drop",sampling:Object.freeze({}),constraint:null,cacheSalt:null,promptCacheKey:null,pingInterval:1e4,toolStreaming:"buffer",effortPassthrough:!1,passthroughFilter:!1,nativeMessages:!1,contextWindow:0,defaultMaxTokens:8192}),g={inlineSystem:["auto","keep","hoist","user","drop"],reasoningField:["reasoning","reasoning_content"],thinking:["chat_template_kwargs","reasoning_effort","none"],documents:["extract","note","error"],toolSchema:["pass","sanitize"],deferredTools:["forward","drop"],toolSearch:["expand","inline","native"],jsonObject:["schema","instruction","drop"],maxTokensField:["max_completion_tokens","max_tokens"],prefill:["continue_final_message","none"],unknownFields:["drop","error"],toolStreaming:["buffer","stream"]},p=["effortPassthrough","passthroughFilter","imageFallback","toolFallback","jsonObjectFallback","thinkOpen","reasoningRoundTrip","toolErrorInference"];function y(...o){const e={...r,pdf:{...r.pdf},sampling:{...r.sampling}};for(const t of o)if(t)for(const[s,a]of Object.entries(t))a!==void 0&&(s==="pdf"?Object.assign(e.pdf,a):s==="sampling"&&a!==null&&typeof a=="object"&&!Array.isArray(a)?Object.assign(e.sampling,a):e[s]=a);for(const[t,s]of Object.entries(g))if(!s.includes(e[t]))throw new n(`Invalid setting ${t}: ${JSON.stringify(e[t])} (expected one of ${s.join(", ")})`,{code:"invalid_setting",status:500,details:{key:t,allowed:s}});for(const t of p)if(typeof e[t]!="boolean")throw new n(`Invalid setting ${t}: ${JSON.stringify(e[t])} (expected true or false)`,{code:"invalid_setting",status:500,details:{key:t}});if(e.nativeMessages!==!0&&e.nativeMessages!==!1&&e.nativeMessages!=="auto")throw new n(`Invalid setting nativeMessages: ${JSON.stringify(e.nativeMessages)} (expected true, false or "auto")`,{code:"invalid_setting",status:500,details:{key:"nativeMessages"}});if(typeof e.toolErrorMarker!="string"||e.toolErrorMarker.trim()==="")throw new n(`Invalid setting toolErrorMarker: ${JSON.stringify(e.toolErrorMarker)} (expected a non-empty string)`,{code:"invalid_setting",status:500,details:{key:"toolErrorMarker"}});if(e.sampling===null||typeof e.sampling!="object"||Array.isArray(e.sampling))throw new n(`Invalid setting sampling: ${JSON.stringify(e.sampling)} (expected an object of field names and values)`,{code:"invalid_setting",status:500,details:{key:"sampling"}});const i=c(e.constraint);if(i!==null)throw new n(`Invalid setting constraint: ${JSON.stringify(e.constraint)} (${i})`,{code:"invalid_setting",status:500,details:{key:"constraint"}});for(const t of["cacheSalt","promptCacheKey"])if(!d(e[t]))throw new n(`Invalid setting ${t}: ${JSON.stringify(e[t])} (expected a non-empty string or null)`,{code:"invalid_setting",status:500,details:{key:t}});if(!(Number.isFinite(e.pdf.scale)&&e.pdf.scale>0))throw new n(`Invalid setting pdf.scale: ${JSON.stringify(e.pdf.scale)} (expected a positive number)`,{code:"invalid_setting",status:500,details:{key:"pdf.scale"}});return e}l(y,"resolve");export{r as DEFAULTS,y as resolve};
|
|
2
2
|
//# sourceMappingURL=settings.mjs.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var c=Object.defineProperty;var s=(t,r)=>c(t,"name",{value:r,configurable:!0});import{atLeast as f,semver as l}from"./normalize.mjs";import{sign as a}from"./thinking.mjs";const u="0.11.1",y="x-anthropic-billing-header:";function A(t,r){if(t.driver!=="vllm"||r.nativeMessages===!1)return!1;if(r.nativeMessages===!0)return!0;const n=t.facts?.version??t.version;return l(n)!==null&&f(n,u)}s(A,"wants");function*p(t){for(const r of t)if(Array.isArray(r?.content))for(const n of r.content)yield n,n?.type==="tool_result"&&Array.isArray(n.content)&&(yield*n.content)}s(p,"blocks");function v(t,r){const n=Array.isArray(t.messages)?t.messages:[];if(n.at(-1)?.role==="assistant")return"prefill";const e=[...p(n)];return e.some(o=>o?.type==="document")?"document":r.toolSearch!=="native"&&(Array.isArray(t.tools)&&t.tools.some(i=>i?.defer_loading!==void 0)||e.some(i=>["tool_reference","tool_addition","tool_removal"].includes(i?.type)))?"toolsearch":null}s(v,"unsuited");function d(t,r){return(typeof t=="string"?[{type:"text",text:t}]:t).filter(e=>e?.type==="text"&&typeof e.text=="string").filter(e=>!(r.stripBillingHeader&&e.text.trimStart().startsWith(y))).map(e=>e.text).join(`
|
|
2
|
+
|
|
3
|
+
`)}s(d,"systemText");function m(t,r){const n=r.toolErrorMarker;return typeof t.content=="string"?{...t,content:`${n}${t.content}`}:Array.isArray(t.content)?{...t,content:[{type:"text",text:n.trimEnd()},...t.content]}:{...t,content:n.trimEnd()}}s(m,"marked");function h(t,r){const n={...t};if(n.system!==void 0&&n.system!==null){const e=d(n.system,r);e===""?delete n.system:n.system=e}return r.toolErrors&&Array.isArray(n.messages)&&(n.messages=n.messages.map(e=>Array.isArray(e?.content)?{...e,content:e.content.map(o=>o?.type==="tool_result"&&o.is_error===!0?m(o,r):o)}:e)),n}s(h,"request");function E(t){return Array.isArray(t?.content)?{...t,content:t.content.map(r=>r?.type==="thinking"&&typeof r.signature!="string"?{...r,signature:a()}:r)}:t}s(E,"response");async function*M(t){const r=new Map;for await(const n of t){const e=n.data;e?.type==="content_block_start"&&e.content_block?.type==="thinking"?r.set(e.index,typeof e.content_block.signature=="string"):e?.type==="content_block_delta"&&e.delta?.type==="signature_delta"?r.set(e.index,!0):e?.type==="content_block_stop"&&r.get(e.index)===!1&&(yield{event:"content_block_delta",data:{type:"content_block_delta",index:e.index,delta:{type:"signature_delta",signature:a()}}}),e?.type==="content_block_stop"&&r.delete(e.index),yield n,e?.type==="message_start"&&(yield{event:"ping",data:{type:"ping"}})}}s(M,"stream");export{u as MIN_VERSION,h as request,E as response,M as stream,v as unsuited,A as wants};
|
|
4
|
+
//# sourceMappingURL=vllm.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cldmv/llm-translator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Bidirectional Anthropic Messages ⇄ OpenAI Chat Completions translator with backend auto-detection (vLLM and other OpenAI-compatible servers), built on slothlet, with an optional standalone server for running Claude Code against local models.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert an Anthropic Messages request to an Ollama `/api/chat` body. The Anthropic conversion to Chat Completions does the work (system, tool
|
|
3
|
+
* blocks, images, tool names, dropped fields); `chatBody` then puts the result in Ollama's shape: tool arguments as objects, tool results by tool
|
|
4
|
+
* name, `images` as base64, the sampling fields and `max_tokens` in `options`, `thinking` and `output_config.effort` as `think`, and
|
|
5
|
+
* `output_config.format` as `format`. The upstream's `sampling` setting and `metadata.sampling` become further `options`.
|
|
6
|
+
* @param {any} body - Anthropic request body.
|
|
7
|
+
* @param {Partial<import("../../../../../../../lib/settings.mjs").Settings>} [settings] - Translator settings.
|
|
8
|
+
* @param {any} [context] - `{ producer, budget, listed, toolCallIds }`, as for the Chat Completions conversion.
|
|
9
|
+
* @returns {Promise<{body: any, state: any}>} The Ollama body and the conversion state the response converters read.
|
|
10
|
+
*/
|
|
11
|
+
export function request(body: any, settings?: Partial<import("../../../../../../../lib/settings.mjs").Settings>, context?: any): Promise<{
|
|
12
|
+
body: any;
|
|
13
|
+
state: any;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert an Ollama reply to an Anthropic message: the reply is read as a Chat Completions `chat.completion` (thinking, tool calls with generated
|
|
3
|
+
* ids, `done_reason` as `finish_reason`, the evaluation counts as `usage`) and the Chat Completions conversion builds the message.
|
|
4
|
+
* @param {any} reply - Parsed Ollama reply.
|
|
5
|
+
* @param {any} [state] - State from the request converter.
|
|
6
|
+
* @param {Partial<import("../../../../../../../lib/settings.mjs").Settings>} [settings] - Translator settings.
|
|
7
|
+
* @returns {any} Anthropic message.
|
|
8
|
+
* @throws {import("../../../../../../../lib/errors.mjs").TranslatorError} When the reply is an error.
|
|
9
|
+
*/
|
|
10
|
+
export function response(reply: any, state?: any, settings?: Partial<import("../../../../../../../lib/settings.mjs").Settings>): any;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert an Ollama stream (one JSON object per line, possibly split anywhere across chunks) to Anthropic events. The lines become Chat
|
|
3
|
+
* Completions chunks (one id for the reply, tool calls whole with generated ids, the final line as the finish and usage chunks) and the Chat
|
|
4
|
+
* Completions conversion writes the events. A line that is not JSON, an `{ error }` line and a stream that ends before its final line each
|
|
5
|
+
* end the stream with an `error` event.
|
|
6
|
+
* @param {ReadableStream|AsyncIterable<unknown>|Iterable<unknown>|string|Uint8Array} source - Ollama NDJSON bytes or text.
|
|
7
|
+
* @param {any} [state] - State from the request converter.
|
|
8
|
+
* @param {Partial<import("../../../../../../../lib/settings.mjs").Settings>} [settings] - Translator settings.
|
|
9
|
+
* @returns {AsyncGenerator<{ event: string, data: any }, void, undefined>} Anthropic events.
|
|
10
|
+
*/
|
|
11
|
+
export function stream(source: ReadableStream | AsyncIterable<unknown> | Iterable<unknown> | string | Uint8Array, state?: any, settings?: Partial<import("../../../../../../../lib/settings.mjs").Settings>): AsyncGenerator<{
|
|
12
|
+
event: string;
|
|
13
|
+
data: any;
|
|
14
|
+
}, void, undefined>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert an Ollama reply to a Chat Completions `chat.completion` (see `completion`). The model name is the one the client asked for, and the
|
|
3
|
+
* counts are kept on the state for the usage report.
|
|
4
|
+
* @param {any} reply - Parsed Ollama reply.
|
|
5
|
+
* @param {any} [state] - State from the request converter.
|
|
6
|
+
* @param {Partial<import("../../../../../../../lib/settings.mjs").Settings>} [settings] - Translator settings.
|
|
7
|
+
* @returns {any} `chat.completion` object.
|
|
8
|
+
* @throws {import("../../../../../../../lib/errors.mjs").TranslatorError} When the reply is an error.
|
|
9
|
+
*/
|
|
10
|
+
export function response(reply: any, state?: any, settings?: Partial<import("../../../../../../../lib/settings.mjs").Settings>): any;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert an Ollama stream (one JSON object per line, possibly split anywhere across chunks) to Chat Completions chunks followed by `[DONE]`.
|
|
3
|
+
* Every chunk carries one completion id, tool calls come whole with generated ids, and the final line gives the finish chunk and, unless
|
|
4
|
+
* `state.includeUsage` is false, a usage chunk. A line that is not JSON, an `{ error }` line and a stream that ends before its final line
|
|
5
|
+
* each become an `{ error }` chunk followed by `[DONE]`.
|
|
6
|
+
* @param {ReadableStream|AsyncIterable<unknown>|Iterable<unknown>|string|Uint8Array} source - Ollama NDJSON bytes or text.
|
|
7
|
+
* @param {any} [state] - State from the request converter (model, `includeUsage`).
|
|
8
|
+
* @param {Partial<import("../../../../../../../lib/settings.mjs").Settings>} [settings] - Translator settings.
|
|
9
|
+
* @returns {AsyncGenerator<{ data: any|string }, void, undefined>} Chat Completions chunks.
|
|
10
|
+
*/
|
|
11
|
+
export function stream(source: ReadableStream | AsyncIterable<unknown> | Iterable<unknown> | string | Uint8Array, state?: any, settings?: Partial<import("../../../../../../../lib/settings.mjs").Settings>): AsyncGenerator<{
|
|
12
|
+
data: any | string;
|
|
13
|
+
}, void, undefined>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a Chat Completions request to an Ollama `/api/chat` body (see `chatBody`). A client may also send Ollama's own `think`, `options`,
|
|
3
|
+
* `format` and `keep_alive`; they are used as sent. The upstream's `sampling` setting fills in `options` fields the request does not name.
|
|
4
|
+
* @param {any} body - Chat Completions request body.
|
|
5
|
+
* @param {Partial<import("../../../../../../../lib/settings.mjs").Settings>} [settings] - Translator settings.
|
|
6
|
+
* @returns {{body: any, state: any}} The Ollama body and the conversion state the response converters read.
|
|
7
|
+
* @throws {TranslatorError} `invalid_request` when `messages` is missing.
|
|
8
|
+
*/
|
|
9
|
+
export function request(body: any, settings?: Partial<import("../../../../../../../lib/settings.mjs").Settings>): {
|
|
10
|
+
body: any;
|
|
11
|
+
state: any;
|
|
12
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Bind every endpoint to a driver. `backend: "auto"` endpoints are probed (drivers tried in `info().order
|
|
2
|
+
* Bind every endpoint to a driver. `backend: "auto"` endpoints are probed (drivers tried in `info().order` after any driver whose `info().hosts` names the endpoint host, the generic
|
|
3
3
|
* driver matches last); endpoints with an explicit `backend` skip detection. Call it again to re-probe.
|
|
4
4
|
* @param {any} [options] - `{ network, signal }`. `network: false` skips all probing (auto endpoints fall back to the generic driver).
|
|
5
5
|
* @returns {Promise<any>} The `status()` result.
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
/**
|
|
20
20
|
* Describe the Azure OpenAI driver. The key goes in the `api-key` header. The real paths come from the `path` leaf, because they depend on the
|
|
21
21
|
* upstream's `apiVersion` and `deployment`; `paths` holds the v1 API paths for a base URL without `/openai`.
|
|
22
|
-
* @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, paths: Record<string,string>}} Driver facts.
|
|
22
|
+
* @returns {{name: string, protocol: string, order: number, auth: string, strict: boolean, hostSuffixes: string[], paths: Record<string,string>}} Driver facts.
|
|
23
23
|
*/
|
|
24
24
|
export function info(): {
|
|
25
25
|
name: string;
|
|
@@ -27,5 +27,6 @@ export function info(): {
|
|
|
27
27
|
order: number;
|
|
28
28
|
auth: string;
|
|
29
29
|
strict: boolean;
|
|
30
|
+
hostSuffixes: string[];
|
|
30
31
|
paths: Record<string, string>;
|
|
31
32
|
};
|