UNPKG

@adaline/azure

Version:
7 lines (6 loc) 95.7 kB
import { z as z$1 } from 'zod'; var ot=(e,o)=>(o=Symbol[e])?o:Symbol.for("Symbol."+e),Oa=e=>{throw TypeError(e)};var Ma=function(e,o){this[0]=e,this[1]=o;};var nt=e=>{var o=e[ot("asyncIterator")],n=!1,s,a={};return o==null?(o=e[ot("iterator")](),s=l=>a[l]=r=>o[l](r)):(o=o.call(e),s=l=>a[l]=r=>{if(n){if(n=!1,l==="throw")throw r;return r}return n=!0,{done:!1,value:new Ma(new Promise(d=>{var u=o[l](r);u instanceof Object||Oa("Object expected"),d(u);}),1)}}),a[ot("iterator")]=()=>a,s("next"),"throw"in o?s("throw"):a.throw=l=>{throw l},"return"in o&&s("return"),a};var C=z$1.object({apiKey:z$1.string().min(1),deploymentId:z$1.string().min(1),resourceName:z$1.string().min(1).optional(),baseUrl:z$1.string().optional()});var me="system",de="user",A="assistant",pe="tool",ka=[me,de,A,pe],it=z$1.enum(ka),Ca=[A],wa=z$1.enum(Ca),io="error",ro="safety",Ea=z$1.object({type:z$1.literal(ro),value:z$1.object({category:z$1.string(),probability:z$1.string(),blocked:z$1.boolean(),message:z$1.string()})}),Ia=(e=z$1.undefined())=>z$1.object({modality:z$1.literal(io),value:z$1.discriminatedUnion("type",[Ea]),metadata:e}),lo="partial-error",Ra=z$1.object({type:z$1.literal(ro),category:z$1.string().optional(),probability:z$1.string().optional(),blocked:z$1.boolean().optional(),message:z$1.string().optional()}),Ga=(e=z$1.undefined())=>z$1.object({modality:z$1.literal(lo),value:z$1.discriminatedUnion("type",[Ra]),metadata:e}),J="image",rt="base64",ja=["png","jpeg","webp","gif"],La=z$1.object({type:z$1.literal(rt),base64:z$1.string(),mediaType:z$1.enum(ja)}),lt="url",Na=z$1.object({type:z$1.literal(lt),url:z$1.string()}),Aa=z$1.discriminatedUnion("type",[La,Na]),Ua=["low","medium","high","auto"],$a=z$1.enum(Ua),Ba=(e=z$1.undefined())=>z$1.object({modality:z$1.literal(J),detail:$a,value:Aa,metadata:e}),mo="pdf",qa="base64",Da=z$1.object({type:z$1.literal(qa),base64:z$1.string()}),za="url",Fa=z$1.object({type:z$1.literal(za),url:z$1.string()}),Ha=z$1.discriminatedUnion("type",[Da,Fa]),Ka=(e=z$1.undefined())=>z$1.object({modality:z$1.literal(mo),value:Ha,file:z$1.object({name:z$1.string(),id:z$1.string(),size:z$1.number().optional()}),metadata:e}),po="reasoning",co="partial-reasoning",uo="thinking",Ja="redacted",st=z$1.object({type:z$1.literal(uo),thinking:z$1.string(),signature:z$1.string()}),go=z$1.object({type:z$1.literal(Ja),data:z$1.string()}),Va=z$1.discriminatedUnion("type",[st,go]),Wa=(e=z$1.undefined())=>z$1.object({modality:z$1.literal(po),value:Va,metadata:e}),Za=z$1.object({type:z$1.literal(uo),thinking:st.shape.thinking.optional(),signature:st.shape.signature.optional()}),Ya=z$1.discriminatedUnion("type",[Za,go]),Qa=(e=z$1.undefined())=>z$1.object({modality:z$1.literal(co),value:Ya,metadata:e}),ho="search-result",fo="google",Xa=z$1.object({type:z$1.literal(fo),query:z$1.string(),responses:z$1.array(z$1.object({source:z$1.string(),url:z$1.string(),title:z$1.string(),snippet:z$1.string().optional()})),references:z$1.array(z$1.object({text:z$1.string(),responseIndices:z$1.array(z$1.number()),startIndex:z$1.number().optional(),endIndex:z$1.number().optional(),confidenceScores:z$1.array(z$1.number()).optional()}))}),es=(e=z$1.undefined())=>z$1.object({modality:z$1.literal(ho),value:z$1.discriminatedUnion("type",[Xa]),metadata:e}),_o="partial-search-result",ts=z$1.object({type:z$1.literal(fo),query:z$1.string().optional(),responses:z$1.array(z$1.object({source:z$1.string().optional(),url:z$1.string().optional(),title:z$1.string().optional(),snippet:z$1.string().optional()})).optional(),references:z$1.array(z$1.object({text:z$1.string().optional(),responseIndices:z$1.array(z$1.number()).optional(),startIndex:z$1.number().optional(),endIndex:z$1.number().optional(),confidenceScores:z$1.array(z$1.number()).optional()})).optional()}),os=(e=z$1.undefined())=>z$1.object({modality:z$1.literal(_o),value:z$1.discriminatedUnion("type",[ts]),metadata:e}),U="text",yo=(e=z$1.undefined())=>z$1.object({modality:z$1.literal(U),value:z$1.string(),metadata:e}),mt="partial-text",bo=(e=z$1.undefined())=>z$1.object({modality:z$1.literal(mt),value:z$1.string(),metadata:e}),D="tool-call",To=(e=z$1.undefined())=>z$1.object({modality:z$1.literal(D),index:z$1.number().int().nonnegative(),id:z$1.string().min(1),name:z$1.string().min(1),arguments:z$1.string(),serverName:z$1.string().optional(),thoughtSignature:z$1.string().optional(),metadata:e}),dt="partial-tool-call",Po=(e=z$1.undefined())=>z$1.object({modality:z$1.literal(dt),index:z$1.number().int().nonnegative(),id:z$1.string().optional(),name:z$1.string().optional(),arguments:z$1.string().optional(),serverName:z$1.string().optional(),thoughtSignature:z$1.string().optional(),metadata:e}),H="tool-response",ns=(e=z$1.undefined())=>z$1.object({modality:z$1.literal(H),index:z$1.number().int().nonnegative(),id:z$1.string().min(1),name:z$1.string().min(1),data:z$1.string(),apiResponse:z$1.object({statusCode:z$1.number().int().nonnegative()}).optional(),metadata:e}),as="partial-tool-response",ss=(e=z$1.undefined())=>z$1.object({modality:z$1.literal(as),index:z$1.number().int().nonnegative(),id:z$1.string().optional(),name:z$1.string().optional(),data:z$1.string().optional(),apiResponse:z$1.object({statusCode:z$1.number().int().nonnegative()}).optional(),metadata:e}),is=[U,J,mo,D,H,po,io,ho],vo=z$1.enum(is),rs=(e=z$1.undefined(),o=z$1.undefined(),n=z$1.undefined(),s=z$1.undefined(),a=z$1.undefined(),l=z$1.undefined(),r=z$1.undefined(),d=z$1.undefined())=>z$1.discriminatedUnion("modality",[yo(e),Ba(o),Ka(n),To(s),ns(a),Wa(l),Ia(r),es(d)]),ls=[mt,dt,co,lo,_o];z$1.enum(ls);var ms=(e=z$1.undefined(),o=z$1.undefined(),n=z$1.undefined(),s=z$1.undefined(),a=z$1.undefined(),l=z$1.undefined())=>z$1.discriminatedUnion("modality",[bo(e),Po(o),Qa(s),ss(n),Ga(a),os(l)]);var Ce=(e=it,o=z$1.undefined(),n=z$1.undefined(),s=z$1.undefined(),a=z$1.undefined(),l=z$1.undefined(),r=z$1.undefined(),d=z$1.undefined())=>z$1.object({role:e,content:z$1.array(rs(o,n,s,a,r,l)),metadata:d}),pt=(e=wa,o=z$1.undefined(),n=z$1.undefined(),s=z$1.undefined(),a=z$1.undefined(),l=z$1.undefined())=>z$1.object({role:e,partialContent:ms(o,n,s,l),metadata:a}),ds=z$1.object({promptTokens:z$1.number().nonnegative(),completionTokens:z$1.number().nonnegative(),totalTokens:z$1.number().nonnegative()}),no=z$1.object({token:z$1.string(),logProb:z$1.number(),bytes:z$1.array(z$1.number().int()).nullable()}),ps=no.extend({topLogProbs:z$1.array(no)}),xo=z$1.array(ps);z$1.object({messages:z$1.array(Ce()),usage:ds.optional(),logProbs:xo.optional()});var cs=z$1.object({promptTokens:z$1.number().nonnegative().optional(),completionTokens:z$1.number().nonnegative().optional(),totalTokens:z$1.number().nonnegative().optional()});z$1.object({partialMessages:z$1.array(pt()),usage:cs.optional(),logProbs:xo.optional()});var we=(e=z$1.record(z$1.string(),z$1.any()).optional())=>e,us=z$1.object({enabled:z$1.boolean().default(!0),allowedTools:z$1.array(z$1.string().min(1))});z$1.object({type:z$1.literal("url"),url:z$1.string().url().refine(e=>e.startsWith("https://"),{message:"MCP server URL must start with https://"}),name:z$1.string().min(1),toolConfiguration:us.optional(),authorizationToken:z$1.string().min(1).optional()});var gs=["object","array","number","string","boolean","enum"],ao=z$1.enum(gs),hs=z$1.object({anyOf:z$1.array(z$1.any()).optional(),type:z$1.union([ao,z$1.array(z$1.union([ao,z$1.literal("null")]))]).optional(),default:z$1.any().optional(),title:z$1.string().optional(),description:z$1.string().max(4096).optional(),properties:z$1.record(z$1.any()).optional(),required:z$1.array(z$1.string()).optional(),minItems:z$1.number().int().min(0).optional(),maxItems:z$1.number().int().optional(),items:z$1.record(z$1.any()).optional(),enum:z$1.array(z$1.union([z$1.string(),z$1.number(),z$1.boolean(),z$1.null()])).optional(),minimum:z$1.number().optional(),maximum:z$1.number().optional(),minLength:z$1.number().int().min(0).optional(),maxLength:z$1.number().int().optional(),$ref:z$1.string().optional()}),fs=z$1.object({type:z$1.enum(["object"]),required:z$1.array(z$1.string()),$defs:z$1.record(z$1.any()).optional(),properties:z$1.record(hs),additionalProperties:z$1.literal(!1)}),So=z$1.object({name:z$1.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:z$1.string().max(4096),strict:z$1.boolean().optional(),schema:fs}).optional(),se="text",ce="token",_s=[se,ce],Oo=z$1.enum(_s),ys=z$1.array(z$1.string().min(1)),bs=z$1.array(z$1.array(z$1.number().int().nonnegative())),Mo=(e=z$1.undefined())=>z$1.discriminatedUnion("modality",[z$1.object({modality:z$1.literal(se),metadata:e,requests:ys}),z$1.object({modality:z$1.literal(ce),metadata:e,requests:bs})]),ct="float",Ts=z$1.object({index:z$1.number().int().nonnegative(),embedding:z$1.array(z$1.number())}),ut="base64",Ps=z$1.object({index:z$1.number().int().nonnegative(),embedding:z$1.string().base64()}),so=z$1.object({totalTokens:z$1.number().int().nonnegative()});z$1.discriminatedUnion("encodingFormat",[z$1.object({encodingFormat:z$1.literal(ct),embeddings:z$1.array(Ts),usage:so.optional()}),z$1.object({encodingFormat:z$1.literal(ut),embeddings:z$1.array(Ps),usage:so.optional()})]);var vs=e=>{let o=new WeakSet;return JSON.stringify(e,(n,s)=>{if(typeof s=="object"&&s!==null){if(o.has(s))return;o.add(s);}return s})},xs=e=>e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:vs(e),at="GatewayBaseError",oe=class ko extends Error{constructor({info:o,cause:n},s){super(`[${s!=null?s:at}]: ${o} Message: ${xs(n)}`),this.name=at,this.info=o,this.cause=n,this.name=s!=null?s:at,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(o){return o instanceof ko}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},Ss=z$1.object({inputPricePerMillion:z$1.number().nonnegative().describe("Price per 1M input tokens"),outputPricePerMillion:z$1.number().nonnegative().describe("Price per 1M output tokens")}).describe("Input/output price pair (per 1M tokens) for a specific category within a ChatModel pricing tier."),Os=z$1.object({base:Ss.describe("Base (uncached, non\u2011reasoning) rates")}).describe("Holds the `ChatModelTokenPairPrice` for different categories (e.g., base) within a single pricing tier."),Ms=z$1.object({minTokens:z$1.number().int().nonnegative().describe("Inclusive lower token bound for this tier."),maxTokens:z$1.number().int().nullable().optional().describe("Exclusive upper token bound; `null` means \u221E."),prices:Os.describe("Price categories and rates for this specific token range.")}).refine(e=>e.maxTokens===null||typeof e.maxTokens=="number"&&e.maxTokens>e.minTokens,{message:"maxTokens must be > minTokens (or null for infinite).",path:["maxTokens"]}).describe("A single pricing tier defined by a token range and associated prices.");z$1.object({modelName:z$1.string().describe("Model name this schedule applies to."),currency:z$1.string().default("USD").describe("Currency code (e.g., USD)."),tokenRanges:z$1.array(Ms).min(1).describe("Pricing tiers (`ChatModelTokenRangePrice`) schedule, sorted by minTokens.")}).superRefine((e,o)=>{let{tokenRanges:n}=e;n[0].minTokens!==0&&o.addIssue({code:z$1.ZodIssueCode.custom,path:["tokenRanges",0,"minTokens"],message:"The first tier must have minTokens = 0."});for(let a=1;a<n.length;a++){let l=n[a-1],r=n[a];if(l.maxTokens===null){o.addIssue({code:z$1.ZodIssueCode.custom,path:["tokenRanges",a-1,"maxTokens"],message:"Cannot define any tokenRanges after an infinite tier (maxTokens = null)."});break}r.minTokens!==l.maxTokens&&o.addIssue({code:z$1.ZodIssueCode.custom,path:["tokenRanges",a,"minTokens"],message:`Tier ${a} minTokens (${r.minTokens}) must equal previous tier's maxTokens (${l.maxTokens}) for contiguity.`}),r.minTokens<l.minTokens&&o.addIssue({code:z$1.ZodIssueCode.custom,path:["tokenRanges",a,"minTokens"],message:`tokenRanges must be sorted by ascending minTokens. Tier ${a} (${r.minTokens}) starts before Tier ${a-1} (${l.minTokens}).`});}let s=n[n.length-1];n.every(a=>a.maxTokens!==null||a===s)&&s.maxTokens!==null&&o.addIssue({code:z$1.ZodIssueCode.custom,path:["tokenRanges",n.length-1,"maxTokens"],message:"The final tier must have maxTokens = null (representing infinity)."});}).describe("Complete pricing schedule for a single chat model, including all its token-based tiers.");var ks="function";var Cs=z$1.enum(["object","array","number","string","boolean","null"]),ws=z$1.object({anyOf:z$1.array(z$1.any()).optional(),type:Cs.optional(),default:z$1.any().optional(),title:z$1.string().optional(),description:z$1.string().max(4096).optional(),properties:z$1.record(z$1.any()).optional(),required:z$1.array(z$1.string()).optional(),minItems:z$1.number().int().min(0).optional(),maxItems:z$1.number().int().optional(),items:z$1.record(z$1.any()).optional(),enum:z$1.array(z$1.union([z$1.string(),z$1.number(),z$1.boolean(),z$1.null()])).optional(),minimum:z$1.number().optional(),maximum:z$1.number().optional(),minLength:z$1.number().int().min(0).optional(),maxLength:z$1.number().int().optional()});z$1.object({type:z$1.enum(["object"]),title:z$1.string().optional(),$defs:z$1.record(z$1.any()).optional(),properties:z$1.record(ws).optional(),required:z$1.array(z$1.string()).optional()});var Es=z$1.object({name:z$1.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:z$1.string().max(4096),parameters:z$1.any(),strict:z$1.boolean().optional()});var Is=z$1.enum(["function"]),Rs=z$1.object({maxAttempts:z$1.number().int().positive(),initialDelay:z$1.number().int().positive(),exponentialFactor:z$1.number().int().positive()}),Gs=z$1.object({type:z$1.literal("http"),method:z$1.enum(["get","post"]),url:z$1.string().url(),headers:z$1.record(z$1.string()).optional(),query:z$1.record(z$1.string()).optional(),body:z$1.record(z$1.any()).optional(),proxyUrl:z$1.string().url().optional(),proxyHeaders:z$1.record(z$1.string()).optional(),retry:Rs.optional()}),js=z$1.discriminatedUnion("type",[Gs]),Ls=z$1.object({type:Is,definition:z$1.object({schema:Es}),request:js.optional()}),Ns=[ks];z$1.enum(Ns);var gt=(e=z$1.undefined())=>z$1.discriminatedUnion("type",[Ls.extend({metadata:e})]),ue=e=>yo().parse({modality:U,value:e}),Ee=(e,o,n,s,a,l)=>To().parse({modality:D,index:e,id:o,name:n,arguments:s,serverName:a,thoughtSignature:l});var Z=(e,o)=>pt().parse({role:e,partialContent:bo().parse({modality:mt,value:o})}),ge=(e,o,n,s,a,l,r)=>pt().parse({role:e,partialContent:Po().parse({modality:dt,index:o,id:n,name:s,arguments:a,serverName:l,thoughtSignature:r})});var As=Object.defineProperty,Co=Object.getOwnPropertySymbols,Us=Object.prototype.hasOwnProperty,$s=Object.prototype.propertyIsEnumerable,wo=(e,o,n)=>o in e?As(e,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[o]=n,Te=(e,o)=>{for(var n in o||(o={}))Us.call(o,n)&&wo(e,n,o[n]);if(Co)for(var n of Co(o))$s.call(o,n)&&wo(e,n,o[n]);return e},Eo="ProviderError",ht=class $o extends oe{constructor({info:o,cause:n}){super({info:o,cause:n},Eo),this.name=Eo,this.info=o,this.cause=n;}static isProviderError(o){return o instanceof $o}},Io="ModelError",Ie=class Bo extends oe{constructor({info:o,cause:n}){super({info:o,cause:n},Io),this.name=Io,this.info=o,this.cause=n;}static isModelError(o){return o instanceof Bo}},Ro="ModelResponseError",z=class qo extends oe{constructor({info:o,cause:n}){super({info:o,cause:n},Ro),this.name=Ro,this.cause=n,this.info=o;}static isModelResponseError(o){return o instanceof qo}},Go="InvalidModelRequestError",Pe=class Do extends oe{constructor({info:o,cause:n}){super({info:o,cause:n},Go),this.name=Go,this.cause=n,this.info=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(o){return o instanceof Do}},jo="InvalidConfigError",K=class zo extends oe{constructor({info:o,cause:n}){super({info:o,cause:n},jo),this.name=jo,this.cause=n,this.info=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(o){return o instanceof zo}},Lo="InvalidMessagesError",N=class Fo extends oe{constructor({info:o,cause:n}){super({info:o,cause:n},Lo),this.name=Lo,this.cause=n,this.info=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(o){return o instanceof Fo}},No="InvalidToolsError",ve=class Ho extends oe{constructor({info:o,cause:n}){super({info:o,cause:n},No),this.name=No,this.cause=n,this.info=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(o){return o instanceof Ho}},Ao="InvalidEmbeddingRequestsError",Ko=class Jo extends oe{constructor({info:o,cause:n}){super({info:o,cause:n},Ao),this.name=Ao,this.info=o,this.cause=n,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(o){return o instanceof Jo}},ft="multi-string",Vo=z$1.object({type:z$1.literal(ft),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),max:z$1.number().int().positive()}),Bs=e=>z$1.array(z$1.string()).max(e).default([]).optional(),Wo=e=>({def:Vo.parse(Te({type:ft},e)),schema:Bs(e.max)}),_t="object-schema",Zo=z$1.object({type:z$1.literal(_t),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),objectSchema:z$1.any()}),qs=e=>e.optional(),Yo=e=>({def:Zo.parse(Te({type:_t},e)),schema:qs(e.objectSchema)}),Qo="paired-select",Ds=z$1.object({value:z$1.string().min(1),label:z$1.string().min(1)}),Uo=z$1.object({key:z$1.string().min(1),label:z$1.string().min(1),description:z$1.string().min(1).max(500).optional(),choices:z$1.array(Ds).min(1)}),zs=z$1.object({type:z$1.literal(Qo),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),fields:z$1.tuple([Uo,Uo]),uniqueByField:z$1.string().min(1).optional()});var yt="range",Xo=z$1.object({type:z$1.literal(yt),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),min:z$1.number().int(),max:z$1.number().int(),step:z$1.number().positive(),default:z$1.number()}),Fs=(e,o,n,s)=>z$1.number().min(e).max(o).step(n).default(s).optional(),Y=e=>({def:Xo.parse(Te({type:yt},e)),schema:Fs(e.min,e.max,e.step,e.default)}),bt="select-boolean",en=z$1.object({type:z$1.literal(bt),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),default:z$1.boolean().nullable()}),Hs=e=>z$1.boolean().nullable().default(e).optional(),tn=e=>({def:en.parse(Te({type:bt},e)),schema:Hs(e.default)}),Tt="select-string",on=z$1.object({type:z$1.literal(Tt),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),default:z$1.string(),choices:z$1.array(z$1.string())}),Ks=(e,o)=>z$1.enum(o).nullable().default(e).optional(),ie=e=>({def:on.parse(Te({type:Tt},e)),schema:Ks(e.default,e.choices)}),Js=[yt,ft,Tt,_t,bt,Qo];z$1.enum(Js);var nn=z$1.discriminatedUnion("type",[Xo,Vo,on,en,Zo,zs]),_=(e=it,o=vo)=>z$1.object({name:z$1.string().min(1),description:z$1.string().min(1),roles:z$1.record(e,z$1.string().min(1).optional()),modalities:z$1.array(o).nonempty(),maxInputTokens:z$1.number().int().positive().min(1),maxOutputTokens:z$1.number().int().positive().min(1),maxReasoningTokens:z$1.number().int().positive().min(1).optional(),config:z$1.object({def:z$1.record(z$1.string().min(1),nn),schema:z$1.instanceof(z$1.ZodObject)}).refine(n=>{var s,a;let l=Object.keys(n.def),r=Object.keys((a=(s=n.schema)==null?void 0:s.shape)!=null?a:{});return l.every(d=>r.includes(d))&&r.every(d=>l.includes(d))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"}),price:z$1.custom()}),he=(e=Oo)=>z$1.object({name:z$1.string().min(1),description:z$1.string().min(1),modalities:z$1.array(e).nonempty(),maxInputTokens:z$1.number().int().positive().min(1),maxOutputTokens:z$1.number().int().positive().min(1),config:z$1.object({def:z$1.record(z$1.string().min(1),nn),schema:z$1.instanceof(z$1.ZodObject)}).refine(o=>{var n,s;let a=Object.keys(o.def),l=Object.keys((s=(n=o.schema)==null?void 0:n.shape)!=null?s:{});return a.every(r=>l.includes(r))&&l.every(r=>a.includes(r))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})});z$1.record(z$1.string());z$1.record(z$1.union([z$1.boolean(),z$1.string(),z$1.number(),z$1.object({}),z$1.array(z$1.any()),z$1.null(),z$1.undefined()]));z$1.string().url();var Vs={type:"range",title:"Temperature",description:"Adjusts the model's creativity level. With a setting of 0, the model strictly picks the most probable next word. For endeavors that benefit from a dash of inventiveness, consider dialing it up to 0.7 or higher, enabling the model to produce text that's unexpectedly fresh."},Ws={type:"range",title:"Max tokens",description:"Specify the total tokens for generation, where one token approximates four English characters. Setting this to 0 defaults to the model's maximum capacity."},Zs={type:"range",title:"Max reasoning tokens",description:"Specify the total tokens for reasoning, where one token approximates four English characters."},Ys=e=>({type:"multi",title:"Stop sequence",description:`Enter up to ${e} sequences that will halt additional text output. The generated text will exclude these sequences.`}),Qs={type:"range",title:"Top A",description:"Considers only the top tokens that have 'sufficiently high' probabilities relative to the most likely token, functioning like a dynamic Top-P. A lower Top-A value narrows down the token choices based on the highest probability token, while a higher Top-A value refines the filtering without necessarily impacting the creativity of the output."},Xs={type:"range",title:"Top P",description:"Selects a subset of likely tokens for generation, restricting choices to the top-P fraction of possibilities, such as the top 10% when P=0.1. This approach can limit the variety of the output. By default, it's set to 1, indicating no restriction. It's advised to adjust this parameter or temperature to modulate output diversity, but not to modify both simultaneously."},ei={type:"range",title:"Top K",description:"Select only from the highest K probabilities for each following word, effectively eliminating the less likely 'long tail' options."},ti={type:"range",title:"Min P",description:"Specifies the minimum probability a token must have to be considered, in relation to the probability of the most likely token. (This value varies based on the confidence level of the top token.) For example, if Min-P is set to 0.1, only tokens with at least 1/10th the probability of the highest-ranked token will be considered."},oi={type:"range",title:"Frequency penalty",description:"Minimize redundancy. By assigning a penalty to frequently used tokens within the text, the likelihood of repeating identical phrases is reduced. The default setting for this penalty is zero."},ni={type:"range",title:"Presence penalty",description:"Enhance the introduction of novel subjects by reducing the preference for tokens that have already appeared in the text, thus boosting the chances of exploring fresh topics. The standard setting for this is zero."},ai={type:"range",title:"Seed",description:"When seed is fixed to a specific value, the model makes a best effort to provide the same response for repeated requests. Deterministic output isn't guaranteed. Also, changing the model or parameter settings, such as the temperature, can cause variations in the response even when you use the same seed value. By default, a random seed value is used."},si={type:"range",title:"Repetition penalty",description:"Reduces the likelihood of repeating tokens from the input. Increasing this value makes the model less prone to repetition, but setting it too high may lead to less coherent output, often resulting in run-on sentences missing smaller words. The token penalty is scaled according to the original token's probability."},ii={type:"boolean",title:"Log probs",description:"Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned."},ri={type:"range",title:"Top log probs",description:"The number of most likely tokens to return at each token position, each with an associated log probability. 'logprobs' must be set to true if this parameter is used."},li={type:"boolean",title:"Echo",description:"If true, the response will contain the prompt."},mi={type:"select",title:"Response format",description:"Choose the response format of your model. For JSON, you must include the string 'JSON' in some form within your system / user prompt."},di={type:"select",title:"Response format",description:"Choose the response format of your model. 'json_object' colloquially known as JSON mode, instructs the model to respond with a valid JSON (must include the term 'json' in prompt). 'json_schema' colloquially known as structured outputs, allows you to specify a strict response schema that the model will adhere to."},pi={type:"object",title:"Response schema",description:"When response format is set to 'json_schema', the model will return a JSON object of the specified schema."},ci={type:"object",title:"MCP servers",description:"MCP servers to use for the model."},E={TEMPERATURE:Vs,MAX_TOKENS:Ws,STOP:Ys,TOP_A:Qs,TOP_P:Xs,TOP_K:ei,MIN_P:ti,FREQUENCY_PENALTY:oi,PRESENCE_PENALTY:ni,REPETITION_PENALTY:si,SEED:ai,LOG_PROBS:ii,TOP_LOG_PROBS:ri,ECHO:li,RESPONSE_FORMAT:mi,RESPONSE_FORMAT_WITH_SCHEMA:di,RESPONSE_SCHEMA:pi,MAX_REASONING_TOKENS:Zs,MCP_SERVERS:ci};var Pt=e=>Object.fromEntries(Object.entries(e).filter(([o,n])=>n!=null));var an=e=>e.split(";")[0].split("/")[1],re=e=>e==null?void 0:e.replace(/\/$/,"");var ui=Object.defineProperty,gi=Object.defineProperties,hi=Object.getOwnPropertyDescriptors,sn=Object.getOwnPropertySymbols,fi=Object.prototype.hasOwnProperty,_i=Object.prototype.propertyIsEnumerable,Ge=(e,o)=>(o=Symbol[e])?o:Symbol.for("Symbol."+e),yi=e=>{throw TypeError(e)},rn=(e,o,n)=>o in e?ui(e,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[o]=n,k=(e,o)=>{for(var n in o||(o={}))fi.call(o,n)&&rn(e,n,o[n]);if(sn)for(var n of sn(o))_i.call(o,n)&&rn(e,n,o[n]);return e},ne=(e,o)=>gi(e,hi(o)),$=(e,o,n)=>new Promise((s,a)=>{var l=u=>{try{d(n.next(u));}catch(c){a(c);}},r=u=>{try{d(n.throw(u));}catch(c){a(c);}},d=u=>u.done?s(u.value):Promise.resolve(u.value).then(l,r);d((n=n.apply(e,o)).next());}),ln=function(e,o){this[0]=e,this[1]=o;},je=(e,o,n)=>{var s=(r,d,u,c)=>{try{var x=n[r](d),f=(d=x.value)instanceof ln,y=x.done;Promise.resolve(f?d[0]:d).then(g=>f?s(r==="return"?r:"next",d[1]?{done:g.done,value:g.value}:g,u,c):u({value:g,done:y})).catch(g=>s("throw",g,u,c));}catch(g){c(g);}},a=r=>l[r]=d=>new Promise((u,c)=>s(r,d,u,c)),l={};return n=n.apply(e,o),l[Ge("asyncIterator")]=()=>l,a("next"),a("throw"),a("return"),l},mn=e=>{var o=e[Ge("asyncIterator")],n=!1,s,a={};return o==null?(o=e[Ge("iterator")](),s=l=>a[l]=r=>o[l](r)):(o=o.call(e),s=l=>a[l]=r=>{if(n){if(n=!1,l==="throw")throw r;return r}return n=!0,{done:!1,value:new ln(new Promise(d=>{var u=o[l](r);u instanceof Object||yi("Object expected"),d(u);}),1)}}),a[Ge("iterator")]=()=>a,s("next"),"throw"in o?s("throw"):a.throw=l=>{throw l},"return"in o&&s("return"),a},dn=Y({param:"temperature",title:E.TEMPERATURE.title,description:E.TEMPERATURE.description,min:0,max:2,step:.01,default:1}),pn=e=>Y({param:"max_completion_tokens",title:E.MAX_TOKENS.title,description:E.MAX_TOKENS.description,min:0,max:e,step:1,default:0}),cn=e=>Wo({param:"stop",title:E.STOP(e).title,description:E.STOP(e).description,max:e}),un=Y({param:"top_p",title:E.TOP_P.title,description:E.TOP_P.description,min:0,max:1,step:.01,default:1}),gn=Y({param:"frequency_penalty",title:E.FREQUENCY_PENALTY.title,description:E.FREQUENCY_PENALTY.description,min:-2,max:2,step:.01,default:0}),hn=Y({param:"presence_penalty",title:E.PRESENCE_PENALTY.title,description:E.PRESENCE_PENALTY.description,min:-2,max:2,step:.01,default:0}),fn=Y({param:"seed",title:E.SEED.title,description:E.SEED.description,min:0,max:1e6,step:1,default:0}),_n=tn({param:"logprobs",title:E.LOG_PROBS.title,description:E.LOG_PROBS.description,default:!1}),yn=Y({param:"top_logprobs",title:E.TOP_LOG_PROBS.title,description:E.TOP_LOG_PROBS.description,min:0,max:20,step:1,default:0}),bn=ie({param:"tool_choice",title:"Tool choice",description:"Controls which (if any) tool is called by the model. 'none' means the model will not call a function. 'auto' means the model can pick between generating a message or calling a tool.",default:"auto",choices:["auto","required","none"]}),Tn=ie({param:"reasoning_effort",title:"Reasoning Effort",description:"Controls the depth of the model's reasoning before delivering an answer. 'minimal' prioritizes speed, 'high' engages in deep reasoning.",default:"medium",choices:["minimal","low","medium","high"]}),Pn=ie({param:"verbosity",title:"Verbosity",description:"Controls the length and detail of the model's responses, independent of reasoning depth. 'low' generates concise answers, 'high' provides comprehensive responses.",default:"medium",choices:["low","medium","high"]}),Ae=(e,o)=>z$1.object({temperature:dn.schema,maxTokens:pn(e).schema,stop:cn(o).schema,topP:un.schema,frequencyPenalty:gn.schema,presencePenalty:hn.schema,seed:fn.schema.transform(n=>n===0?void 0:n),logProbs:_n.schema,topLogProbs:yn.schema,toolChoice:bn.schema}),Ue=(e,o)=>({temperature:dn.def,maxTokens:pn(e).def,stop:cn(o).def,topP:un.def,frequencyPenalty:gn.def,presencePenalty:hn.def,seed:fn.def,logProbs:_n.def,topLogProbs:yn.def,toolChoice:bn.def}),vn=Yo({param:"response_schema",title:E.RESPONSE_SCHEMA.title,description:E.RESPONSE_SCHEMA.description,objectSchema:So}),xn=ie({param:"response_format",title:E.RESPONSE_FORMAT_WITH_SCHEMA.title,description:E.RESPONSE_FORMAT_WITH_SCHEMA.description,default:"text",choices:["text","json_object","json_schema"]}),Le=(e,o)=>ne(k({},Ue(e,o)),{responseFormat:xn.def,responseSchema:vn.def}),Ne=(e,o)=>Ae(e,o).extend({responseFormat:xn.schema,responseSchema:vn.schema}),bi=(e,o)=>ne(k({},Ue(e,o)),{reasoningEffort:Tn.def,verbosity:Pn.def,responseFormat:Le(e,o).responseFormat,responseSchema:Le(e,o).responseSchema}),Ti=(e,o)=>Ae(e,o).extend({reasoningEffort:Tn.schema,verbosity:Pn.schema,responseFormat:Ne(e,o).shape.responseFormat,responseSchema:Ne(e,o).shape.responseSchema}),Sn=Y({param:"temperature",title:E.TEMPERATURE.title,description:E.TEMPERATURE.description,min:1,max:1,step:.01,default:1}),On=ie({param:"reasoning_effort",title:"Reasoning Effort",description:"Constrains effort on reasoning for reasoning models. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.",default:"medium",choices:["low","medium","high"]}),Pi=(e,o)=>ne(k({},Le(e,o)),{temperature:Sn.def,reasoningEffort:On.def}),vi=(e,o)=>Ne(e,o).extend({temperature:Sn.schema,reasoningEffort:On.schema}),Mn=ie({param:"response_format",title:E.RESPONSE_FORMAT.title,description:E.RESPONSE_FORMAT.description,default:"text",choices:["text","json_object"]}),xi=(e,o)=>ne(k({},Ue(e,o)),{responseFormat:Mn.def}),Si=(e,o)=>Ae(e,o).extend({responseFormat:Mn.schema}),kn=ie({param:"encoding_format",title:"Encoding format",description:"Select the encoding format for the word embedding.",default:"float",choices:["float","base64"]}),Cn=e=>Y({param:"dimensions",title:"Dimensions",description:"Select the number of dimensions for the word embedding.",min:1,max:e,step:1,default:e}),wn=()=>z$1.object({encodingFormat:kn.schema}),En=()=>({encodingFormat:kn.def}),Oi=e=>wn().extend({dimensions:Cn(e).schema}),Mi=e=>ne(k({},En()),{dimensions:Cn(e).def}),p={base:(e,o)=>({def:Ue(e,o),schema:Ae(e,o)}),responseFormat:(e,o)=>({def:xi(e,o),schema:Si(e,o)}),responseSchema:(e,o)=>({def:Le(e,o),schema:Ne(e,o)}),oSeries:(e,o)=>({def:Pi(e,o),schema:vi(e,o)}),gpt5:(e,o)=>({def:bi(e,o),schema:Ti(e,o)})},ae={base:()=>({def:En(),schema:wn()}),dimensions:e=>({def:Mi(e),schema:Oi(e)})},S={"gpt-3.5-turbo-0125":{modelName:"gpt-3.5-turbo-0125",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gpt-3.5-turbo-1106":{modelName:"gpt-3.5-turbo-1106",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gpt-3.5-turbo":{modelName:"gpt-3.5-turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gpt-4-0125-preview":{modelName:"gpt-4-0125-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:30,outputPricePerMillion:60}}}]},"gpt-4-0613":{modelName:"gpt-4-0613",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:30,outputPricePerMillion:60}}}]},"gpt-4-1106-preview":{modelName:"gpt-4-1106-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:30,outputPricePerMillion:60}}}]},"gpt-4-turbo-2024-04-09":{modelName:"gpt-4-turbo-2024-04-09",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:10,outputPricePerMillion:30}}}]},"gpt-4-turbo-preview":{modelName:"gpt-4-turbo-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:10,outputPricePerMillion:30}}}]},"gpt-4-turbo":{modelName:"gpt-4-turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:10,outputPricePerMillion:30}}}]},"gpt-4":{modelName:"gpt-4",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:30,outputPricePerMillion:60}}}]},"gpt-4o-2024-05-13":{modelName:"gpt-4o-2024-05-13",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:5,outputPricePerMillion:20}}}]},"gpt-4o-2024-08-06":{modelName:"gpt-4o-2024-08-06",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gpt-4o-mini-2024-07-18":{modelName:"gpt-4o-mini-2024-07-18",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.6,outputPricePerMillion:2.4}}}]},"gpt-4o-mini":{modelName:"gpt-4o-mini",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.6,outputPricePerMillion:2.4}}}]},"gpt-4o":{modelName:"gpt-4o",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:5,outputPricePerMillion:20}}}]},"o1-2024-12-17":{modelName:"o1-2024-12-17",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:15,outputPricePerMillion:60}}}]},o1:{modelName:"o1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:15,outputPricePerMillion:60}}}]},"o3-mini-2025-01-31":{modelName:"o3-mini-2025-01-31",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.1,outputPricePerMillion:4.4}}}]},"o3-mini":{modelName:"o3-mini",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.1,outputPricePerMillion:4.4}}}]},"o3-2025-04-16":{modelName:"o3-2025-04-16",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:10,outputPricePerMillion:40}}}]},o3:{modelName:"o3",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:10,outputPricePerMillion:40}}}]},"o4-mini-2025-04-16":{modelName:"o4-mini-2025-04-16",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.1,outputPricePerMillion:4.4}}}]},"o4-mini":{modelName:"o4-mini",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.1,outputPricePerMillion:4.4}}}]},"gpt-4.1":{modelName:"gpt-4.1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:2,outputPricePerMillion:8}}}]},"gpt-4.1-mini":{modelName:"gpt-4.1-mini",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.4,outputPricePerMillion:1.6}}}]},"gpt-4.1-nano":{modelName:"gpt-4.1-nano",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gpt-5":{modelName:"gpt-5",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gpt-5-mini":{modelName:"gpt-5-mini",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.25,outputPricePerMillion:2}}}]},"gpt-5-nano":{modelName:"gpt-5-nano",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.05,outputPricePerMillion:.4}}}]},"gpt-5-chat-latest":{modelName:"gpt-5-chat-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gpt-5.1":{modelName:"gpt-5.1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.5,outputPricePerMillion:12}}}]},"gpt-5.2":{modelName:"gpt-5.2",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.75,outputPricePerMillion:14}}}]},"gpt-5.2-chat-latest":{modelName:"gpt-5.2-chat-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.75,outputPricePerMillion:14}}}]},"gpt-5.2-pro":{modelName:"gpt-5.2-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:21,outputPricePerMillion:168}}}]}},ki="openai",$e=class{constructor(){this.version="v1",this.name=ki,this.chatModelFactories={[St]:{model:Xi,modelOptions:Qi,modelSchema:De},[vt]:{model:Ji,modelOptions:Ki,modelSchema:Be},[xt]:{model:Zi,modelOptions:Wi,modelSchema:qe},[Ot]:{model:or,modelOptions:tr,modelSchema:Gn},[Mt]:{model:sr,modelOptions:ar,modelSchema:ze},[kt]:{model:lr,modelOptions:rr,modelSchema:Fe},[Ct]:{model:pr,modelOptions:dr,modelSchema:jn},[wt]:{model:gr,modelOptions:ur,modelSchema:Ln},[Et]:{model:_r,modelOptions:fr,modelSchema:Nn},[Lt]:{model:jr,modelOptions:Gr,modelSchema:qn},[It]:{model:Tr,modelOptions:br,modelSchema:An},[Rt]:{model:xr,modelOptions:vr,modelSchema:Un},[jt]:{model:Ir,modelOptions:Er,modelSchema:Bn},[Gt]:{model:Cr,modelOptions:kr,modelSchema:$n},[Nt]:{model:Ar,modelOptions:Nr,modelSchema:Dn},[At]:{model:Br,modelOptions:$r,modelSchema:zn},[Ut]:{model:Hr,modelOptions:Fr,modelSchema:Fn},[$t]:{model:Vr,modelOptions:Jr,modelSchema:He},[Bt]:{model:Yr,modelOptions:Zr,modelSchema:Hn},[qt]:{model:el,modelOptions:Xr,modelSchema:Kn},[Dt]:{model:nl,modelOptions:ol,modelSchema:Ke},[Ft]:{model:ml,modelOptions:ll,modelSchema:Ve},[Kt]:{model:hl,modelOptions:gl,modelSchema:Ze},[Jt]:{model:yl,modelOptions:_l,modelSchema:Ye},[Ht]:{model:cl,modelOptions:pl,modelSchema:We},[zt]:{model:il,modelOptions:sl,modelSchema:Je},[Wt]:{model:Sl,modelOptions:xl,modelSchema:Vn},[Vt]:{model:Pl,modelOptions:Tl,modelSchema:Jn},[ta]:{model:Nl,modelOptions:Ll,modelSchema:oa},[Xn]:{model:Gl,modelOptions:Rl,modelSchema:ea},[Wn]:{model:kl,modelOptions:Ml,modelSchema:Zn},[Yn]:{model:El,modelOptions:wl,modelSchema:Qn},[na]:{model:$l,modelOptions:Ul,modelSchema:aa},[sa]:{model:Dl,modelOptions:ql,modelSchema:ia}},this.embeddingModelFactories={[ra]:{model:Vl,modelOptions:Jl,modelSchema:Xe},[la]:{model:Yl,modelOptions:Zl,modelSchema:et},[ma]:{model:em,modelOptions:Xl,modelSchema:tt}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((e,o)=>(e[o]=this.chatModelFactories[o].modelSchema,e),{})}chatModel(e){let o=e.modelName;if(!(o in this.chatModelFactories))throw new ht({info:`OpenAI chat model: ${o} not found`,cause:new Error(`OpenAI chat model: ${o} not found, available chat models: [${this.chatModelLiterals().join(", ")}]`)});let n=this.chatModelFactories[o].model,s=this.chatModelFactories[o].modelOptions.parse(e);return new n(s)}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((e,o)=>(e[o]=this.embeddingModelFactories[o].modelSchema,e),{})}embeddingModel(e){let o=e.modelName;if(!(o in this.embeddingModelFactories))throw new ht({info:`OpenAI embedding model: ${o} not found`,cause:new Error(`OpenAI embedding model: ${o} not found, available embedding models: [${this.embeddingModelLiterals().join(", ")}]`)});let n=this.embeddingModelFactories[o].model,s=this.embeddingModelFactories[o].modelOptions.parse(e);return new n(s)}};$e.baseUrl="https://api.openai.com/v1";var b=z$1.enum([me,de,A,pe]),T={system:me,user:de,assistant:A,tool:pe},j=[U,J,D,H],L=z$1.enum([U,J,D,H]);z$1.enum([U]);var Q=[U,D,H],X=z$1.enum([U,D,H]),Re=z$1.object({token:z$1.string(),logprob:z$1.number(),bytes:z$1.array(z$1.number()).nullable()}),In=z$1.object({content:z$1.array(Re.extend({top_logprobs:z$1.array(Re)})).nullable().optional(),refusal:z$1.array(Re.extend({top_logprobs:z$1.array(Re)})).nullable().optional()}).nullable(),Ci=z$1.array(z$1.object({id:z$1.string().min(1),type:z$1.enum(["function"]),function:z$1.object({name:z$1.string(),arguments:z$1.string()})})),wi=z$1.object({id:z$1.string(),object:z$1.literal("chat.completion"),created:z$1.number(),model:z$1.string(),system_fingerprint:z$1.string().nullable(),choices:z$1.array(z$1.object({index:z$1.number(),message:z$1.object({role:z$1.string(),content:z$1.string().nullable().optional(),tool_calls:Ci.optional(),refusal:z$1.string().nullable().optional()}),logprobs:In.optional(),finish_reason:z$1.string()})),usage:z$1.object({prompt_tokens:z$1.number(),completion_tokens:z$1.number(),total_tokens:z$1.number()})}),Ei=z$1.array(z$1.object({index:z$1.number().int(),id:z$1.string().min(1).optional(),type:z$1.enum(["function"]).optional(),function:z$1.object({name:z$1.string().min(1).optional(),arguments:z$1.string().optional()}).optional()})),Ii=z$1.object({id:z$1.string(),object:z$1.string(),created:z$1.number(),model:z$1.string(),system_fingerprint:z$1.string().nullable().optional(),choices:z$1.array(z$1.object({index:z$1.number(),delta:z$1.object({content:z$1.string().nullable().optional(),tool_calls:Ei.optional(),refusal:z$1.string().nullable().optional()}).or(z$1.object({})),logprobs:In.optional(),finish_reason:z$1.string().nullable()})),usage:z$1.object({prompt_tokens:z$1.number(),completion_tokens:z$1.number(),total_tokens:z$1.number()}).nullable().optional()}),Ri=z$1.object({type:z$1.literal("function"),function:z$1.object({name:z$1.string().min(1),description:z$1.string().min(1).optional(),strict:z$1.boolean().optional(),parameters:z$1.any()})}),Gi=z$1.enum(["none","auto","required"]),ji=z$1.object({type:z$1.literal("function"),function:z$1.object({name:z$1.string().min(1)})}),Li=z$1.object({type:z$1.enum(["text","json_object"])}).or(z$1.object({type:z$1.literal("json_schema"),json_schema:z$1.object({name:z$1.string().min(1),description:z$1.string().min(1).optional(),strict:z$1.boolean().optional(),schema:z$1.any()})})),Zt=z$1.object({text:z$1.string().min(1),type:z$1.literal("text")}),Ni=z$1.object({type:z$1.literal("image_url"),image_url:z$1.object({url:z$1.string().url().min(1),detail:z$1.enum(["low","high","auto"]).optional()})}),Ai=z$1.object({id:z$1.string().min(1),type:z$1.literal("function"),function:z$1.object({name:z$1.string().min(1),arguments:z$1.string().min(1)})}),Ui=z$1.object({role:z$1.literal("system"),content:z$1.string().min(1).or(z$1.array(Zt).min(1))}),$i=z$1.object({role:z$1.literal("user"),content:z$1.string().min(1).or(z$1.array(z$1.union([Zt,Ni])).min(1))}),Bi=z$1.object({role:z$1.literal("assistant"),content:z$1.string().min(1).or(z$1.array(Zt).min(1)).optional(),tool_calls:z$1.array(Ai).min(1).optional()}),qi=z$1.object({role:z$1.literal("tool"),tool_call_id:z$1.string().min(1),content:z$1.string().min(1)}),Di=z$1.union([Ui,$i,Bi,qi]),zi=z$1.object({model:z$1.string().min(1).optional(),messages:z$1.array(Di).min(1),frequency_penalty:z$1.number().min(-2).max(2).nullable().optional(),logprobs:z$1.boolean().nullable().optional(),top_logprobs:z$1.number().min(0).max(20).nullable().optional(),max_completion_tokens:z$1.number().min(0).nullable().optional(),presence_penalty:z$1.number().min(-2).max(2).nullable().optional(),response_format:Li.optional(),seed:z$1.number().nullable().optional(),stop:z$1.string().or(z$1.array(z$1.string()).max(4)).nullable().optional(),temperature:z$1.number().min(0).max(2).nullable().optional(),top_p:z$1.number().min(0).max(1).nullable().optional(),tools:z$1.array(Ri).optional(),tool_choice:Gi.or(ji).optional(),reasoning_effort:z$1.enum(["minimal","low","medium","high"]).optional(),verbosity:z$1.enum(["low","medium","high"]).optional()}),v=z$1.object({modelName:z$1.string(),apiKey:z$1.string(),baseUrl:z$1.string().url().optional(),completeChatUrl:z$1.string().url().optional(),streamChatUrl:z$1.string().url().optional(),organization:z$1.string().optional()}),P=class{constructor(e,o){this.version="v1";let n=v.parse(o);this.modelSchema=e,this.modelName=n.modelName,this.apiKey=n.apiKey,this.baseUrl=re(n.baseUrl||$e.baseUrl),this.streamChatUrl=re(n.streamChatUrl||`${this.baseUrl}/chat/completions`),this.completeChatUrl=re(n.completeChatUrl||`${this.baseUrl}/chat/completions`),this.organization=n.organization;}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return k({Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},this.organization?{"OpenAI-Organization":this.organization}:{})}getDefaultParams(){return {model:this.modelName}}getRetryDelay(e){let o=r=>{let d=/(\d+)(h|m|s|ms)/g,u={h:36e5,m:6e4,s:1e3,ms:1},c,x=0;for(;(c=d.exec(r))!==null;){let f=parseInt(c[1]),y=c[2];x+=f*u[y];}return x},n=0,s=0,a=!0;e["x-ratelimit-reset-requests"]&&(n=o(e["x-ratelimit-reset-requests"])),e["x-ratelimit-reset-tokens"]&&(s=o(e["x-ratelimit-reset-tokens"]));let l=Math.max(n,s);return {shouldRetry:a,delayMs:l}}getTokenCount(e){return e.reduce((o,n)=>o+n.content.map(s=>s.modality==="text"?s.value:"").join(" ").length,0)}transformModelRequest(e){let o=zi.safeParse(e);if(!o.success)throw new Pe({info:"Invalid model request",cause:o.error});let n=o.data,s=n.model;if(n.tool_choice&&(!n.tools||n.tools.length===0))throw new Pe({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let a={};n.response_format&&(a.responseFormat=n.response_format.type,n.response_format.type==="json_schema"&&(a.responseSchema={name:n.response_format.json_schema.name,description:n.response_format.json_schema.description||"",strict:n.response_format.json_schema.strict,schema:n.response_format.json_schema.schema})),n.tool_choice&&(typeof n.tool_choice=="string"?a.toolChoice=n.tool_choice:a.toolChoice=n.tool_choice.function.name),a.seed=n.seed,a.maxTokens=n.max_completion_tokens,a.temperature=n.temperature,a.topP=n.top_p,a.presencePenalty=n.presence_penalty,a.frequencyPenalty=n.frequency_penalty,a.stop=n.stop,a.logProbs=n.logprobs,a.topLogProbs=n.top_logprobs,a.reasoningEffort=n.reasoning_effort,a.verbosity=n.verbosity;let l=we().parse(Pt(a)),r=[],d={};n.messages.forEach(c=>{let x=c.role;switch(x){case"system":{let f=c.content;if(typeof f=="string")r.push({role:x,content:[{modality:U,value:f}]});else {let y=f.map(g=>({modality:U,value:g.text}));r.push({role:x,content:y});}}break;case"user":{let f=c.content;if(typeof f=="string")r.push({role:x,content:[{modality:U,value:f}]});else {let y=f.map(g=>g.type==="text"?{modality:U,value:g.text}:g.image_url.url.startsWith("data:")?{modality:J,detail:g.image_url.detail||"auto",value:{type:rt,base64:g.image_url.url,mediaType:an(g.image_url.url)}}:{modality:J,detail:g.image_url.detail||"auto",value:{type:lt,url:g.image_url.url}});r.push({role:x,content:y});}}break;case"assistant":{let f=[];if(!c.content&&!c.tool_calls)throw new Pe({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("one of'content' or 'tool_calls' must be provided")});if(c.content){let y=c.content;typeof y=="string"?f.push({modality:U,value:y}):y.forEach(g=>{f.push({modality:U,value:g.text});});}c.tool_calls&&c.tool_calls.forEach((y,g)=>{let I={modality:D,id:y.id,index:g,name:y.function.name,arguments:y.function.arguments};f.push(I),d[I.id]=I;}),r.push({role:x,content:f});}break;case"tool":{let f=c;r.push({role:x,content:[{modality:H,id:f.tool_call_id,index:d[f.tool_call_id].index,name:d[f.tool_call_id].name,data:f.content}]});}break}});let u=[];return n.tools&&n.tools.forEach(c=>{u.push({type:"function",definition:{schema:{name:c.function.name,description:c.function.description||"",strict:c.function.strict,parameters:c.function.parameters}}});}),{modelName:s,config:l,messages:r,tools:u.length>0?u:void 0}}transformConfig(e,o,n){let s=e.toolChoice;delete e.toolChoice;let a=this.modelSchema.config.schema.safeParse(e);if(!a.success)throw new K({info:`Invalid config for model : '${this.modelName}'`,cause:a.error});let l=a.data;s!==void 0&&(l.toolChoice=s),Object.keys(l).forEach(d=>{if(!(d in this.modelSchema.config.def))throw new K({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${d}', available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let r=Object.keys(l).reduce((d,u)=>{let c=this.modelSchema.config.def[u],x=c.param,f=l[u];return x==="max_completion_tokens"&&c.type==="range"&&f===0?d[x]=c.max:d[x]=f,d},{});if(r.top_logprobs&&!r.logprobs)throw new K({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'logprobs' must be 'true' when 'top_logprobs' is specified")});if("tool_choice"in r&&r.tool_choice!==void 0){let d=r.tool_choice;if(!n||n&&n.length===0)throw new K({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(n&&n.length>0){let u=this.modelSchema.config.def.toolChoice;if(!u.choices.includes(d))if(n.map(c