@adaline/vertex 1.3.0 → 1.3.1

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/dist/index.js CHANGED
@@ -2,24 +2,24 @@
2
2
 
3
3
  var zod = require('zod');
4
4
 
5
- var $n=Object.defineProperty,Un=Object.defineProperties;var Dn=Object.getOwnPropertyDescriptors;var zt=Object.getOwnPropertySymbols;var qn=Object.prototype.hasOwnProperty,Bn=Object.prototype.propertyIsEnumerable;var Be=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),An=t=>{throw TypeError(t)};var Kt=(t,e,o)=>e in t?$n(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,y=(t,e)=>{for(var o in e||(e={}))qn.call(e,o)&&Kt(t,o,e[o]);if(zt)for(var o of zt(e))Bn.call(e,o)&&Kt(t,o,e[o]);return t},k=(t,e)=>Un(t,Dn(e));var be=(t,e,o)=>new Promise((i,a)=>{var l=m=>{try{d(o.next(m));}catch(p){a(p);}},r=m=>{try{d(o.throw(m));}catch(p){a(p);}},d=m=>m.done?i(m.value):Promise.resolve(m.value).then(l,r);d((o=o.apply(t,e)).next());}),Hn=function(t,e){this[0]=t,this[1]=e;};var Yt=t=>{var e=t[Be("asyncIterator")],o=!1,i,a={};return e==null?(e=t[Be("iterator")](),i=l=>a[l]=r=>e[l](r)):(e=e.call(t),i=l=>a[l]=r=>{if(o){if(o=!1,l==="throw")throw r;return r}return o=!0,{done:!1,value:new Hn(new Promise(d=>{var m=e[l](r);m instanceof Object||An("Object expected"),d(m);}),1)}}),a[Be("iterator")]=()=>a,i("next"),"throw"in e?i("throw"):a.throw=l=>{throw l},"return"in e&&i("return"),a};var pe="system",z="user",N="assistant",ee="tool",Vn=[pe,z,N,ee],Ve=zod.z.enum(Vn),zn=[N],Kn=zod.z.enum(zn),te="image",ze="base64",Yn=["png","jpeg","webp","gif"],Wn=zod.z.object({type:zod.z.literal(ze),base64:zod.z.string(),mediaType:zod.z.enum(Yn)}),Jn="url",Zn=zod.z.object({type:zod.z.literal(Jn),url:zod.z.string()}),Xn=zod.z.discriminatedUnion("type",[Wn,Zn]),Qn=["low","medium","high","auto"],ei=zod.z.enum(Qn),ti=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(te),detail:ei,value:Xn,metadata:t}),Xt="reasoning",Qt="partial-reasoning",eo="thinking",oi="redacted",He=zod.z.object({type:zod.z.literal(eo),thinking:zod.z.string(),signature:zod.z.string()}),to=zod.z.object({type:zod.z.literal(oi),data:zod.z.string()}),ni=zod.z.discriminatedUnion("type",[He,to]),ii=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Xt),value:ni,metadata:t}),ai=zod.z.object({type:zod.z.literal(eo),thinking:He.shape.thinking.optional(),signature:He.shape.signature.optional()}),si=zod.z.discriminatedUnion("type",[ai,to]),ri=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Qt),value:si,metadata:t}),C="text",oo=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(C),value:zod.z.string(),metadata:t}),Ke="partial-text",no=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Ke),value:zod.z.string(),metadata:t}),U="tool-call",io=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(U),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),arguments:zod.z.string(),metadata:t}),Ye="partial-tool-call",ao=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Ye),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),arguments:zod.z.string().optional(),metadata:t}),oe="tool-response",li=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(oe),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),data:zod.z.string(),metadata:t}),mi=[C,te,U,oe,Xt],so=zod.z.enum(mi),di=(t=zod.z.undefined(),e=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),a=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[oo(t),ti(e),io(o),li(i),ii(a)]),ci=[Ke,Ye,Qt];zod.z.enum(ci);var pi=(t=zod.z.undefined(),e=zod.z.undefined(),o=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[no(t),ao(e),ri(o)]);var We=(t=Ve,e=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),a=zod.z.undefined(),l=zod.z.undefined(),r=zod.z.undefined())=>zod.z.object({role:t,content:zod.z.array(di(e,o,i,a,r)),metadata:l}),Je=(t=Kn,e=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),a=zod.z.undefined())=>zod.z.object({role:t,partialContent:pi(e,o,i),metadata:a}),ui=zod.z.object({promptTokens:zod.z.number().nonnegative(),completionTokens:zod.z.number().nonnegative(),totalTokens:zod.z.number().nonnegative()}),Wt=zod.z.object({token:zod.z.string(),logProb:zod.z.number(),bytes:zod.z.array(zod.z.number().int()).nullable()}),gi=Wt.extend({topLogProbs:zod.z.array(Wt)}),ro=zod.z.array(gi);zod.z.object({messages:zod.z.array(We()),usage:ui.optional(),logProbs:ro.optional()});var hi=zod.z.object({promptTokens:zod.z.number().nonnegative().optional(),completionTokens:zod.z.number().nonnegative().optional(),totalTokens:zod.z.number().nonnegative().optional()});zod.z.object({partialMessages:zod.z.array(Je()),usage:hi.optional(),logProbs:ro.optional()});var ue=(t=zod.z.record(zod.z.string(),zod.z.any()).optional())=>t,fi=["object","array","number","string","boolean","enum"],Jt=zod.z.enum(fi),bi=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([Jt,zod.z.array(zod.z.union([Jt,zod.z.literal("null")]))]).optional(),default:zod.z.any().optional(),title:zod.z.string().optional(),description:zod.z.string().max(4096).optional(),properties:zod.z.record(zod.z.any()).optional(),required:zod.z.array(zod.z.string()).optional(),minItems:zod.z.number().int().min(0).optional(),maxItems:zod.z.number().int().optional(),items:zod.z.record(zod.z.any()).optional(),enum:zod.z.array(zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()])).optional(),minimum:zod.z.number().optional(),maximum:zod.z.number().optional(),minLength:zod.z.number().int().min(0).optional(),maxLength:zod.z.number().int().optional(),$ref:zod.z.string().optional()}),yi=zod.z.object({type:zod.z.enum(["object"]),required:zod.z.array(zod.z.string()),$defs:zod.z.record(zod.z.any()).optional(),properties:zod.z.record(bi),additionalProperties:zod.z.literal(!1)}),lo=zod.z.object({name:zod.z.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:zod.z.string().max(4096),strict:zod.z.boolean().optional(),schema:yi}).optional(),S="text",mo="token",Ti=[S,mo],co=zod.z.enum(Ti),Mi=zod.z.array(zod.z.string().min(1)),_i=zod.z.array(zod.z.array(zod.z.number().int().nonnegative())),ye=(t=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[zod.z.object({modality:zod.z.literal(S),metadata:t,requests:Mi}),zod.z.object({modality:zod.z.literal(mo),metadata:t,requests:_i})]),ge="float",Ei=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),ki="base64",xi=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.string().base64()}),Zt=zod.z.object({totalTokens:zod.z.number().int().nonnegative()});zod.z.discriminatedUnion("encodingFormat",[zod.z.object({encodingFormat:zod.z.literal(ge),embeddings:zod.z.array(Ei),usage:Zt.optional()}),zod.z.object({encodingFormat:zod.z.literal(ki),embeddings:zod.z.array(xi),usage:Zt.optional()})]);var Pi=t=>{let e=new WeakSet;return JSON.stringify(t,(o,i)=>{if(typeof i=="object"&&i!==null){if(e.has(i))return;e.add(i);}return i})},vi=t=>t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:Pi(t),Ae="GatewayBaseError",J=class po extends Error{constructor({info:e,cause:o},i){super(`[${i!=null?i:Ae}]: ${e}
6
- Message: ${vi(o)}`),this.name=Ae,this.info=e,this.cause=o,this.name=i!=null?i:Ae,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(e){return e instanceof po}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},Ci=zod.z.object({inputPricePerMillion:zod.z.number().nonnegative().describe("Price per 1M input tokens"),outputPricePerMillion:zod.z.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."),Si=zod.z.object({base:Ci.describe("Base (uncached, non\u2011reasoning) rates")}).describe("Holds the `ChatModelTokenPairPrice` for different categories (e.g., base) within a single pricing tier."),Oi=zod.z.object({minTokens:zod.z.number().int().nonnegative().describe("Inclusive lower token bound for this tier."),maxTokens:zod.z.number().int().nullable().optional().describe("Exclusive upper token bound; `null` means \u221E."),prices:Si.describe("Price categories and rates for this specific token range.")}).refine(t=>t.maxTokens===null||typeof t.maxTokens=="number"&&t.maxTokens>t.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.");zod.z.object({modelName:zod.z.string().describe("Model name this schedule applies to."),currency:zod.z.string().default("USD").describe("Currency code (e.g., USD)."),tokenRanges:zod.z.array(Oi).min(1).describe("Pricing tiers (`ChatModelTokenRangePrice`) schedule, sorted by minTokens.")}).superRefine((t,e)=>{let{tokenRanges:o}=t;o[0].minTokens!==0&&e.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",0,"minTokens"],message:"The first tier must have minTokens = 0."});for(let a=1;a<o.length;a++){let l=o[a-1],r=o[a];if(l.maxTokens===null){e.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",a-1,"maxTokens"],message:"Cannot define any tokenRanges after an infinite tier (maxTokens = null)."});break}r.minTokens!==l.maxTokens&&e.addIssue({code:zod.z.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&&e.addIssue({code:zod.z.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 i=o[o.length-1];o.every(a=>a.maxTokens!==null||a===i)&&i.maxTokens!==null&&e.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",o.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 wi="function";var Ri=zod.z.enum(["object","array","number","string","boolean","null"]),Gi=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:Ri.optional(),default:zod.z.any().optional(),title:zod.z.string().optional(),description:zod.z.string().max(4096).optional(),properties:zod.z.record(zod.z.any()).optional(),required:zod.z.array(zod.z.string()).optional(),minItems:zod.z.number().int().min(0).optional(),maxItems:zod.z.number().int().optional(),items:zod.z.record(zod.z.any()).optional(),enum:zod.z.array(zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()])).optional(),minimum:zod.z.number().optional(),maximum:zod.z.number().optional(),minLength:zod.z.number().int().min(0).optional(),maxLength:zod.z.number().int().optional()});zod.z.object({type:zod.z.enum(["object"]),title:zod.z.string().optional(),$defs:zod.z.record(zod.z.any()).optional(),properties:zod.z.record(Gi).optional(),required:zod.z.array(zod.z.string()).optional()});var Ii=zod.z.object({name:zod.z.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:zod.z.string().max(4096),parameters:zod.z.any(),strict:zod.z.boolean().optional()});var ji=zod.z.enum(["function"]),Ni=zod.z.object({type:ji,definition:zod.z.object({schema:Ii})}),Fi=[wi];zod.z.enum(Fi);var uo=(t=zod.z.undefined())=>zod.z.discriminatedUnion("type",[Ni.extend({metadata:t})]),go=t=>oo().parse({modality:C,value:t}),ho=(t,e,o,i)=>io().parse({modality:U,index:t,id:e,name:o,arguments:i});var Ze=(t,e)=>Je().parse({role:t,partialContent:no().parse({modality:Ke,value:e})}),Xe=(t,e,o,i,a)=>Je().parse({role:t,partialContent:ao().parse({modality:Ye,index:e,id:o,name:i,arguments:a})});var Li=Object.defineProperty,fo=Object.getOwnPropertySymbols,$i=Object.prototype.hasOwnProperty,Ui=Object.prototype.propertyIsEnumerable,bo=(t,e,o)=>e in t?Li(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,he=(t,e)=>{for(var o in e||(e={}))$i.call(e,o)&&bo(t,o,e[o]);if(fo)for(var o of fo(e))Ui.call(e,o)&&bo(t,o,e[o]);return t},yo="ProviderError",me=class vo extends J{constructor({info:e,cause:o}){super({info:e,cause:o},yo),this.name=yo,this.info=e,this.cause=o;}static isProviderError(e){return e instanceof vo}},To="ModelError",Te=class Co extends J{constructor({info:e,cause:o}){super({info:e,cause:o},To),this.name=To,this.info=e,this.cause=o;}static isModelError(e){return e instanceof Co}},Mo="ModelResponseError",w=class So extends J{constructor({info:e,cause:o}){super({info:e,cause:o},Mo),this.name=Mo,this.cause=o,this.info=e;}static isModelResponseError(e){return e instanceof So}},_o="InvalidModelRequestError",Z=class Oo extends J{constructor({info:e,cause:o}){super({info:e,cause:o},_o),this.name=_o,this.cause=o,this.info=e,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(e){return e instanceof Oo}},Eo="InvalidConfigError",D=class wo extends J{constructor({info:e,cause:o}){super({info:e,cause:o},Eo),this.name=Eo,this.cause=o,this.info=e,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(e){return e instanceof wo}},ko="InvalidMessagesError",x=class Ro extends J{constructor({info:e,cause:o}){super({info:e,cause:o},ko),this.name=ko,this.cause=o,this.info=e,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(e){return e instanceof Ro}},xo="InvalidToolsError",Qe=class Go extends J{constructor({info:e,cause:o}){super({info:e,cause:o},xo),this.name=xo,this.cause=o,this.info=e,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(e){return e instanceof Go}},Po="InvalidEmbeddingRequestsError",ne=class Io extends J{constructor({info:e,cause:o}){super({info:e,cause:o},Po),this.name=Po,this.info=e,this.cause=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(e){return e instanceof Io}},et="multi-string",jo=zod.z.object({type:zod.z.literal(et),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),max:zod.z.number().int().positive()}),Di=t=>zod.z.array(zod.z.string()).max(t).default([]).optional(),No=t=>({def:jo.parse(he({type:et},t)),schema:Di(t.max)}),tt="object-schema",Fo=zod.z.object({type:zod.z.literal(tt),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),objectSchema:zod.z.any()}),qi=t=>t.optional(),ot=t=>({def:Fo.parse(he({type:tt},t)),schema:qi(t.objectSchema)}),nt="range",Lo=zod.z.object({type:zod.z.literal(nt),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),min:zod.z.number().int(),max:zod.z.number().int(),step:zod.z.number().positive(),default:zod.z.number()}),Bi=(t,e,o,i)=>zod.z.number().min(t).max(e).step(o).default(i).optional(),K=t=>({def:Lo.parse(he({type:nt},t)),schema:Bi(t.min,t.max,t.step,t.default)}),it="select-boolean",$o=zod.z.object({type:zod.z.literal(it),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),default:zod.z.boolean().nullable()}),Ai=t=>zod.z.boolean().nullable().default(t).optional(),Me=t=>({def:$o.parse(he({type:it},t)),schema:Ai(t.default)}),at="select-string",Uo=zod.z.object({type:zod.z.literal(at),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),default:zod.z.string(),choices:zod.z.array(zod.z.string())}),Hi=(t,e)=>zod.z.enum(e).nullable().default(t).optional(),st=t=>({def:Uo.parse(he({type:at},t)),schema:Hi(t.default,t.choices)}),Vi=[nt,et,at,tt,it];zod.z.enum(Vi);var Do=zod.z.discriminatedUnion("type",[Lo,jo,Uo,$o,Fo]),F=(t=Ve,e=so)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(t,zod.z.string().min(1).optional()),modalities:zod.z.array(e).nonempty(),maxInputTokens:zod.z.number().int().positive().min(1),maxOutputTokens:zod.z.number().int().positive().min(1),maxReasoningTokens:zod.z.number().int().positive().min(1).optional(),config:zod.z.object({def:zod.z.record(zod.z.string().min(1),Do),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(o=>{var i,a;let l=Object.keys(o.def),r=Object.keys((a=(i=o.schema)==null?void 0:i.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:zod.z.custom()}),q=(t=co)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),modalities:zod.z.array(t).nonempty(),maxInputTokens:zod.z.number().int().positive().min(1),maxOutputTokens:zod.z.number().int().positive().min(1),config:zod.z.object({def:zod.z.record(zod.z.string().min(1),Do),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(e=>{var o,i;let a=Object.keys(e.def),l=Object.keys((i=(o=e.schema)==null?void 0:o.shape)!=null?i:{});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'"})});zod.z.record(zod.z.string());zod.z.record(zod.z.union([zod.z.boolean(),zod.z.string(),zod.z.number(),zod.z.object({}),zod.z.array(zod.z.any()),zod.z.null(),zod.z.undefined()]));zod.z.string().url();var zi={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."},Ki={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."},Yi={type:"range",title:"Max reasoning tokens",description:"Specify the total tokens for reasoning, where one token approximates four English characters."},Wi=t=>({type:"multi",title:"Stop sequence",description:`Enter up to ${t} sequences that will halt additional text output. The generated text will exclude these sequences.`}),Ji={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."},Zi={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."},Xi={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."},Qi={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."},ea={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."},ta={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."},oa={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."},na={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."},ia={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."},aa={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."},sa={type:"boolean",title:"Echo",description:"If true, the response will contain the prompt."},ra={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."},la={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."},ma={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."},T={TEMPERATURE:zi,MAX_TOKENS:Ki,STOP:Wi,TOP_A:Ji,TOP_P:Zi,TOP_K:Xi,MIN_P:Qi,FREQUENCY_PENALTY:ea,PRESENCE_PENALTY:ta,REPETITION_PENALTY:na,SEED:oa,LOG_PROBS:ia,TOP_LOG_PROBS:aa,ECHO:sa,RESPONSE_FORMAT:ra,RESPONSE_FORMAT_WITH_SCHEMA:la,RESPONSE_SCHEMA:ma,MAX_REASONING_TOKENS:Yi},da={type:"range",title:"Dimensions",description:"Select the number of dimensions for the word embedding."},ca={type:"select",title:"Encoding format",description:"Select the encoding format for the word embedding."},de={DIMENSIONS:da,ENCODING_FORMAT:ca};var fe=t=>Object.fromEntries(Object.entries(t).filter(([e,o])=>o!=null));var ce=t=>t==null?void 0:t.replace(/\/$/,"");var pa=Object.defineProperty,ua=Object.defineProperties,ga=Object.getOwnPropertyDescriptors,qo=Object.getOwnPropertySymbols,ha=Object.prototype.hasOwnProperty,fa=Object.prototype.propertyIsEnumerable,_e=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),ba=t=>{throw TypeError(t)},Bo=(t,e,o)=>e in t?pa(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,M=(t,e)=>{for(var o in e||(e={}))ha.call(e,o)&&Bo(t,o,e[o]);if(qo)for(var o of qo(e))fa.call(e,o)&&Bo(t,o,e[o]);return t},yt=(t,e)=>ua(t,ga(e)),R=(t,e,o)=>new Promise((i,a)=>{var l=m=>{try{d(o.next(m));}catch(p){a(p);}},r=m=>{try{d(o.throw(m));}catch(p){a(p);}},d=m=>m.done?i(m.value):Promise.resolve(m.value).then(l,r);d((o=o.apply(t,e)).next());}),Wo=function(t,e){this[0]=t,this[1]=e;},Ao=(t,e,o)=>{var i=(r,d,m,p)=>{try{var u=o[r](d),h=(d=u.value)instanceof Wo,g=u.done;Promise.resolve(h?d[0]:d).then(f=>h?i(r==="return"?r:"next",d[1]?{done:f.done,value:f.value}:f,m,p):m({value:f,done:g})).catch(f=>i("throw",f,m,p));}catch(f){p(f);}},a=r=>l[r]=d=>new Promise((m,p)=>i(r,d,m,p)),l={};return o=o.apply(t,e),l[_e("asyncIterator")]=()=>l,a("next"),a("throw"),a("return"),l},ya=t=>{var e=t[_e("asyncIterator")],o=!1,i,a={};return e==null?(e=t[_e("iterator")](),i=l=>a[l]=r=>e[l](r)):(e=e.call(t),i=l=>a[l]=r=>{if(o){if(o=!1,l==="throw")throw r;return r}return o=!0,{done:!1,value:new Wo(new Promise(d=>{var m=e[l](r);m instanceof Object||ba("Object expected"),d(m);}),1)}}),a[_e("iterator")]=()=>a,i("next"),"throw"in e?i("throw"):a.throw=l=>{throw l},"return"in e&&i("return"),a},Jo=(t,e)=>K({param:"temperature",title:T.TEMPERATURE.title,description:T.TEMPERATURE.description,min:0,max:t,step:.01,default:e}),Zo=t=>K({param:"maxOutputTokens",title:T.MAX_TOKENS.title,description:T.MAX_TOKENS.description,min:0,max:t,step:1,default:0}),Xo=t=>No({param:"stopSequences",title:T.STOP(t).title,description:T.STOP(t).description,max:t}),Qo=t=>K({param:"topP",title:T.TOP_P.title,description:T.TOP_P.description,min:0,max:1,step:.01,default:t});K({param:"frequencyPenalty",title:T.FREQUENCY_PENALTY.title,description:T.FREQUENCY_PENALTY.description,min:-2,max:2,step:.01,default:0});K({param:"presencePenalty",title:T.PRESENCE_PENALTY.title,description:T.PRESENCE_PENALTY.description,min:-2,max:2,step:.01,default:0});K({param:"seed",title:T.SEED.title,description:T.SEED.description,min:0,max:1e6,step:1,default:0});var en=st({param:"toolChoice",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","any","none"]}),tn=ot({param:"safetySettings",title:"Safety settings",description:"The safety rating contains the category of harm and the harm probability level in that category for a piece of content.",objectSchema:zod.z.array(zod.z.object({threshold:zod.z.enum(["HARM_BLOCK_THRESHOLD_UNSPECIFIED","BLOCK_LOW_AND_ABOVE","BLOCK_MEDIUM_AND_ABOVE","BLOCK_ONLY_HIGH","BLOCK_NONE","OFF"]),category:zod.z.enum(["HARM_CATEGORY_UNSPECIFIED","HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT","HARM_CATEGORY_CIVIC_INTEGRITY"])}))}),on=Me({param:"reasoningEnabled",title:"Reasoning Enabled",description:"Controls whether the model is allowed to think for a longer period of time before generating a response. This can be useful for complex tasks that require more time to think.",default:!1}),nn=(t,e,o,i,a)=>zod.z.object({temperature:Jo(t,e).schema,maxTokens:Zo(o).schema,stop:Xo(i).schema,topP:Qo(a).schema,toolChoice:en.schema,safetySettings:tn.schema}),an=(t,e,o,i,a)=>({temperature:Jo(t,e).def,maxTokens:Zo(o).def,stop:Xo(i).def,topP:Qo(a).def,toolChoice:en.def,safetySettings:tn.def}),sn=ot({param:"response_schema",title:T.RESPONSE_SCHEMA.title,description:T.RESPONSE_SCHEMA.description,objectSchema:lo}),rn=st({param:"response_format",title:T.RESPONSE_FORMAT_WITH_SCHEMA.title,description:T.RESPONSE_FORMAT_WITH_SCHEMA.description,default:"text",choices:["text","json_schema"]}),ln=(t,e,o,i,a)=>yt(M({},an(t,e,o,i,a)),{responseFormat:rn.def,responseSchema:sn.def}),mn=(t,e,o,i,a)=>nn(t,e,o,i,a).extend({responseFormat:rn.schema,responseSchema:sn.schema}),Ta=(t,e,o,i,a)=>mn(t,e,o,i,a).extend({reasoningEnabled:on.schema}),Ma=(t,e,o,i,a)=>yt(M({},ln(t,e,o,i,a)),{reasoningEnabled:on.def}),dn=t=>K({param:"outputDimensionality",title:de.DIMENSIONS.title,description:de.DIMENSIONS.description,min:1,max:t,step:1,default:t}),_a=t=>zod.z.object({dimensions:dn(t).schema}),Ea=t=>({dimensions:dn(t).def}),b={base:(t,e,o,i,a)=>({def:an(t,e,o,i,a),schema:nn(t,e,o,i,a)}),responseSchema:(t,e,o,i,a)=>({def:ln(t,e,o,i,a),schema:mn(t,e,o,i,a)}),reasoning:(t,e,o,i,a)=>({def:Ma(t,e,o,i,a),schema:Ta(t,e,o,i,a)})},Ee={base:t=>({def:Ea(t),schema:_a(t)})},ka="google",Tt=class{constructor(){this.version="v1",this.name=ka,this.chatModelFactories={[rt]:{model:Ua,modelOptions:$a,modelSchema:ke},[lt]:{model:Ba,modelOptions:qa,modelSchema:xe},[mt]:{model:Va,modelOptions:Ha,modelSchema:pn},[dt]:{model:Ya,modelOptions:Ka,modelSchema:Pe},[ct]:{model:Za,modelOptions:Ja,modelSchema:ve},[pt]:{model:es,modelOptions:Qa,modelSchema:Ce},[ut]:{model:ns,modelOptions:os,modelSchema:un},[gt]:{model:ss,modelOptions:as,modelSchema:Se},[ht]:{model:ms,modelOptions:ls,modelSchema:Oe},[ft]:{model:ps,modelOptions:cs,modelSchema:gn},[bt]:{model:hs,modelOptions:gs,modelSchema:hn}},this.embeddingModelFactories={[Tn]:{model:_s,modelOptions:Ms,modelSchema:Mn},[_n]:{model:xs,modelOptions:ks,modelSchema:En}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((t,e)=>(t[e]=this.chatModelFactories[e].modelSchema,t),{})}chatModel(t){let e=t.modelName;if(!(e in this.chatModelFactories))throw new me({info:`Google chat model: ${e} not found`,cause:new Error(`Google chat model: ${e} not found, available chat models:
5
+ var Un=Object.defineProperty,$n=Object.defineProperties;var Dn=Object.getOwnPropertyDescriptors;var zt=Object.getOwnPropertySymbols;var qn=Object.prototype.hasOwnProperty,Bn=Object.prototype.propertyIsEnumerable;var Be=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),An=t=>{throw TypeError(t)};var Kt=(t,e,o)=>e in t?Un(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,y=(t,e)=>{for(var o in e||(e={}))qn.call(e,o)&&Kt(t,o,e[o]);if(zt)for(var o of zt(e))Bn.call(e,o)&&Kt(t,o,e[o]);return t},k=(t,e)=>$n(t,Dn(e));var be=(t,e,o)=>new Promise((i,a)=>{var l=m=>{try{d(o.next(m));}catch(p){a(p);}},r=m=>{try{d(o.throw(m));}catch(p){a(p);}},d=m=>m.done?i(m.value):Promise.resolve(m.value).then(l,r);d((o=o.apply(t,e)).next());}),Hn=function(t,e){this[0]=t,this[1]=e;};var Yt=t=>{var e=t[Be("asyncIterator")],o=!1,i,a={};return e==null?(e=t[Be("iterator")](),i=l=>a[l]=r=>e[l](r)):(e=e.call(t),i=l=>a[l]=r=>{if(o){if(o=!1,l==="throw")throw r;return r}return o=!0,{done:!1,value:new Hn(new Promise(d=>{var m=e[l](r);m instanceof Object||An("Object expected"),d(m);}),1)}}),a[Be("iterator")]=()=>a,i("next"),"throw"in e?i("throw"):a.throw=l=>{throw l},"return"in e&&i("return"),a};var pe="system",z="user",N="assistant",ee="tool",Vn=[pe,z,N,ee],Ve=zod.z.enum(Vn),zn=[N],Kn=zod.z.enum(zn),te="image",ze="base64",Yn=["png","jpeg","webp","gif"],Jn=zod.z.object({type:zod.z.literal(ze),base64:zod.z.string(),mediaType:zod.z.enum(Yn)}),Wn="url",Zn=zod.z.object({type:zod.z.literal(Wn),url:zod.z.string()}),Xn=zod.z.discriminatedUnion("type",[Jn,Zn]),Qn=["low","medium","high","auto"],ei=zod.z.enum(Qn),ti=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(te),detail:ei,value:Xn,metadata:t}),Xt="reasoning",Qt="partial-reasoning",eo="thinking",oi="redacted",He=zod.z.object({type:zod.z.literal(eo),thinking:zod.z.string(),signature:zod.z.string()}),to=zod.z.object({type:zod.z.literal(oi),data:zod.z.string()}),ni=zod.z.discriminatedUnion("type",[He,to]),ii=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Xt),value:ni,metadata:t}),ai=zod.z.object({type:zod.z.literal(eo),thinking:He.shape.thinking.optional(),signature:He.shape.signature.optional()}),si=zod.z.discriminatedUnion("type",[ai,to]),ri=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Qt),value:si,metadata:t}),C="text",oo=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(C),value:zod.z.string(),metadata:t}),Ke="partial-text",no=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Ke),value:zod.z.string(),metadata:t}),$="tool-call",io=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal($),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),arguments:zod.z.string(),metadata:t}),Ye="partial-tool-call",ao=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Ye),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),arguments:zod.z.string().optional(),metadata:t}),oe="tool-response",li=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(oe),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),data:zod.z.string(),apiResponse:zod.z.object({statusCode:zod.z.number().int().nonnegative()}).optional(),metadata:t}),mi=[C,te,$,oe,Xt],so=zod.z.enum(mi),di=(t=zod.z.undefined(),e=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),a=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[oo(t),ti(e),io(o),li(i),ii(a)]),ci=[Ke,Ye,Qt];zod.z.enum(ci);var pi=(t=zod.z.undefined(),e=zod.z.undefined(),o=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[no(t),ao(e),ri(o)]);var Je=(t=Ve,e=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),a=zod.z.undefined(),l=zod.z.undefined(),r=zod.z.undefined())=>zod.z.object({role:t,content:zod.z.array(di(e,o,i,a,r)),metadata:l}),We=(t=Kn,e=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),a=zod.z.undefined())=>zod.z.object({role:t,partialContent:pi(e,o,i),metadata:a}),ui=zod.z.object({promptTokens:zod.z.number().nonnegative(),completionTokens:zod.z.number().nonnegative(),totalTokens:zod.z.number().nonnegative()}),Jt=zod.z.object({token:zod.z.string(),logProb:zod.z.number(),bytes:zod.z.array(zod.z.number().int()).nullable()}),gi=Jt.extend({topLogProbs:zod.z.array(Jt)}),ro=zod.z.array(gi);zod.z.object({messages:zod.z.array(Je()),usage:ui.optional(),logProbs:ro.optional()});var hi=zod.z.object({promptTokens:zod.z.number().nonnegative().optional(),completionTokens:zod.z.number().nonnegative().optional(),totalTokens:zod.z.number().nonnegative().optional()});zod.z.object({partialMessages:zod.z.array(We()),usage:hi.optional(),logProbs:ro.optional()});var ue=(t=zod.z.record(zod.z.string(),zod.z.any()).optional())=>t,fi=["object","array","number","string","boolean","enum"],Wt=zod.z.enum(fi),bi=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([Wt,zod.z.array(zod.z.union([Wt,zod.z.literal("null")]))]).optional(),default:zod.z.any().optional(),title:zod.z.string().optional(),description:zod.z.string().max(4096).optional(),properties:zod.z.record(zod.z.any()).optional(),required:zod.z.array(zod.z.string()).optional(),minItems:zod.z.number().int().min(0).optional(),maxItems:zod.z.number().int().optional(),items:zod.z.record(zod.z.any()).optional(),enum:zod.z.array(zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()])).optional(),minimum:zod.z.number().optional(),maximum:zod.z.number().optional(),minLength:zod.z.number().int().min(0).optional(),maxLength:zod.z.number().int().optional(),$ref:zod.z.string().optional()}),yi=zod.z.object({type:zod.z.enum(["object"]),required:zod.z.array(zod.z.string()),$defs:zod.z.record(zod.z.any()).optional(),properties:zod.z.record(bi),additionalProperties:zod.z.literal(!1)}),lo=zod.z.object({name:zod.z.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:zod.z.string().max(4096),strict:zod.z.boolean().optional(),schema:yi}).optional(),S="text",mo="token",Ti=[S,mo],co=zod.z.enum(Ti),Mi=zod.z.array(zod.z.string().min(1)),_i=zod.z.array(zod.z.array(zod.z.number().int().nonnegative())),ye=(t=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[zod.z.object({modality:zod.z.literal(S),metadata:t,requests:Mi}),zod.z.object({modality:zod.z.literal(mo),metadata:t,requests:_i})]),ge="float",Ei=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),ki="base64",xi=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.string().base64()}),Zt=zod.z.object({totalTokens:zod.z.number().int().nonnegative()});zod.z.discriminatedUnion("encodingFormat",[zod.z.object({encodingFormat:zod.z.literal(ge),embeddings:zod.z.array(Ei),usage:Zt.optional()}),zod.z.object({encodingFormat:zod.z.literal(ki),embeddings:zod.z.array(xi),usage:Zt.optional()})]);var Pi=t=>{let e=new WeakSet;return JSON.stringify(t,(o,i)=>{if(typeof i=="object"&&i!==null){if(e.has(i))return;e.add(i);}return i})},vi=t=>t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:Pi(t),Ae="GatewayBaseError",W=class po extends Error{constructor({info:e,cause:o},i){super(`[${i!=null?i:Ae}]: ${e}
6
+ Message: ${vi(o)}`),this.name=Ae,this.info=e,this.cause=o,this.name=i!=null?i:Ae,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(e){return e instanceof po}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},Ci=zod.z.object({inputPricePerMillion:zod.z.number().nonnegative().describe("Price per 1M input tokens"),outputPricePerMillion:zod.z.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."),Si=zod.z.object({base:Ci.describe("Base (uncached, non\u2011reasoning) rates")}).describe("Holds the `ChatModelTokenPairPrice` for different categories (e.g., base) within a single pricing tier."),Oi=zod.z.object({minTokens:zod.z.number().int().nonnegative().describe("Inclusive lower token bound for this tier."),maxTokens:zod.z.number().int().nullable().optional().describe("Exclusive upper token bound; `null` means \u221E."),prices:Si.describe("Price categories and rates for this specific token range.")}).refine(t=>t.maxTokens===null||typeof t.maxTokens=="number"&&t.maxTokens>t.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.");zod.z.object({modelName:zod.z.string().describe("Model name this schedule applies to."),currency:zod.z.string().default("USD").describe("Currency code (e.g., USD)."),tokenRanges:zod.z.array(Oi).min(1).describe("Pricing tiers (`ChatModelTokenRangePrice`) schedule, sorted by minTokens.")}).superRefine((t,e)=>{let{tokenRanges:o}=t;o[0].minTokens!==0&&e.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",0,"minTokens"],message:"The first tier must have minTokens = 0."});for(let a=1;a<o.length;a++){let l=o[a-1],r=o[a];if(l.maxTokens===null){e.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",a-1,"maxTokens"],message:"Cannot define any tokenRanges after an infinite tier (maxTokens = null)."});break}r.minTokens!==l.maxTokens&&e.addIssue({code:zod.z.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&&e.addIssue({code:zod.z.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 i=o[o.length-1];o.every(a=>a.maxTokens!==null||a===i)&&i.maxTokens!==null&&e.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",o.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 wi="function";var Ri=zod.z.enum(["object","array","number","string","boolean","null"]),Gi=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:Ri.optional(),default:zod.z.any().optional(),title:zod.z.string().optional(),description:zod.z.string().max(4096).optional(),properties:zod.z.record(zod.z.any()).optional(),required:zod.z.array(zod.z.string()).optional(),minItems:zod.z.number().int().min(0).optional(),maxItems:zod.z.number().int().optional(),items:zod.z.record(zod.z.any()).optional(),enum:zod.z.array(zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()])).optional(),minimum:zod.z.number().optional(),maximum:zod.z.number().optional(),minLength:zod.z.number().int().min(0).optional(),maxLength:zod.z.number().int().optional()});zod.z.object({type:zod.z.enum(["object"]),title:zod.z.string().optional(),$defs:zod.z.record(zod.z.any()).optional(),properties:zod.z.record(Gi).optional(),required:zod.z.array(zod.z.string()).optional()});var Ii=zod.z.object({name:zod.z.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:zod.z.string().max(4096),parameters:zod.z.any(),strict:zod.z.boolean().optional()});var ji=zod.z.enum(["function"]),Ni=zod.z.object({maxAttempts:zod.z.number().int().positive(),initialDelay:zod.z.number().int().positive(),exponentialFactor:zod.z.number().int().positive()}),Fi=zod.z.object({type:zod.z.literal("http"),method:zod.z.enum(["get","post"]),url:zod.z.string().url(),proxyUrl:zod.z.string().url().optional(),headers:zod.z.record(zod.z.string()).optional(),query:zod.z.record(zod.z.string()).optional(),body:zod.z.record(zod.z.any()).optional(),retry:Ni.optional()}),Li=zod.z.discriminatedUnion("type",[Fi]),Ui=zod.z.object({type:ji,definition:zod.z.object({schema:Ii}),apiSettings:Li.optional()}),$i=[wi];zod.z.enum($i);var uo=(t=zod.z.undefined())=>zod.z.discriminatedUnion("type",[Ui.extend({metadata:t})]),go=t=>oo().parse({modality:C,value:t}),ho=(t,e,o,i)=>io().parse({modality:$,index:t,id:e,name:o,arguments:i});var Ze=(t,e)=>We().parse({role:t,partialContent:no().parse({modality:Ke,value:e})}),Xe=(t,e,o,i,a)=>We().parse({role:t,partialContent:ao().parse({modality:Ye,index:e,id:o,name:i,arguments:a})});var Di=Object.defineProperty,fo=Object.getOwnPropertySymbols,qi=Object.prototype.hasOwnProperty,Bi=Object.prototype.propertyIsEnumerable,bo=(t,e,o)=>e in t?Di(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,he=(t,e)=>{for(var o in e||(e={}))qi.call(e,o)&&bo(t,o,e[o]);if(fo)for(var o of fo(e))Bi.call(e,o)&&bo(t,o,e[o]);return t},yo="ProviderError",me=class vo extends W{constructor({info:e,cause:o}){super({info:e,cause:o},yo),this.name=yo,this.info=e,this.cause=o;}static isProviderError(e){return e instanceof vo}},To="ModelError",Te=class Co extends W{constructor({info:e,cause:o}){super({info:e,cause:o},To),this.name=To,this.info=e,this.cause=o;}static isModelError(e){return e instanceof Co}},Mo="ModelResponseError",w=class So extends W{constructor({info:e,cause:o}){super({info:e,cause:o},Mo),this.name=Mo,this.cause=o,this.info=e;}static isModelResponseError(e){return e instanceof So}},_o="InvalidModelRequestError",Z=class Oo extends W{constructor({info:e,cause:o}){super({info:e,cause:o},_o),this.name=_o,this.cause=o,this.info=e,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(e){return e instanceof Oo}},Eo="InvalidConfigError",D=class wo extends W{constructor({info:e,cause:o}){super({info:e,cause:o},Eo),this.name=Eo,this.cause=o,this.info=e,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(e){return e instanceof wo}},ko="InvalidMessagesError",x=class Ro extends W{constructor({info:e,cause:o}){super({info:e,cause:o},ko),this.name=ko,this.cause=o,this.info=e,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(e){return e instanceof Ro}},xo="InvalidToolsError",Qe=class Go extends W{constructor({info:e,cause:o}){super({info:e,cause:o},xo),this.name=xo,this.cause=o,this.info=e,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(e){return e instanceof Go}},Po="InvalidEmbeddingRequestsError",ne=class Io extends W{constructor({info:e,cause:o}){super({info:e,cause:o},Po),this.name=Po,this.info=e,this.cause=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(e){return e instanceof Io}},et="multi-string",jo=zod.z.object({type:zod.z.literal(et),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),max:zod.z.number().int().positive()}),Ai=t=>zod.z.array(zod.z.string()).max(t).default([]).optional(),No=t=>({def:jo.parse(he({type:et},t)),schema:Ai(t.max)}),tt="object-schema",Fo=zod.z.object({type:zod.z.literal(tt),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),objectSchema:zod.z.any()}),Hi=t=>t.optional(),ot=t=>({def:Fo.parse(he({type:tt},t)),schema:Hi(t.objectSchema)}),nt="range",Lo=zod.z.object({type:zod.z.literal(nt),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),min:zod.z.number().int(),max:zod.z.number().int(),step:zod.z.number().positive(),default:zod.z.number()}),Vi=(t,e,o,i)=>zod.z.number().min(t).max(e).step(o).default(i).optional(),K=t=>({def:Lo.parse(he({type:nt},t)),schema:Vi(t.min,t.max,t.step,t.default)}),it="select-boolean",Uo=zod.z.object({type:zod.z.literal(it),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),default:zod.z.boolean().nullable()}),zi=t=>zod.z.boolean().nullable().default(t).optional(),Me=t=>({def:Uo.parse(he({type:it},t)),schema:zi(t.default)}),at="select-string",$o=zod.z.object({type:zod.z.literal(at),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),default:zod.z.string(),choices:zod.z.array(zod.z.string())}),Ki=(t,e)=>zod.z.enum(e).nullable().default(t).optional(),st=t=>({def:$o.parse(he({type:at},t)),schema:Ki(t.default,t.choices)}),Yi=[nt,et,at,tt,it];zod.z.enum(Yi);var Do=zod.z.discriminatedUnion("type",[Lo,jo,$o,Uo,Fo]),F=(t=Ve,e=so)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(t,zod.z.string().min(1).optional()),modalities:zod.z.array(e).nonempty(),maxInputTokens:zod.z.number().int().positive().min(1),maxOutputTokens:zod.z.number().int().positive().min(1),maxReasoningTokens:zod.z.number().int().positive().min(1).optional(),config:zod.z.object({def:zod.z.record(zod.z.string().min(1),Do),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(o=>{var i,a;let l=Object.keys(o.def),r=Object.keys((a=(i=o.schema)==null?void 0:i.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:zod.z.custom()}),q=(t=co)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),modalities:zod.z.array(t).nonempty(),maxInputTokens:zod.z.number().int().positive().min(1),maxOutputTokens:zod.z.number().int().positive().min(1),config:zod.z.object({def:zod.z.record(zod.z.string().min(1),Do),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(e=>{var o,i;let a=Object.keys(e.def),l=Object.keys((i=(o=e.schema)==null?void 0:o.shape)!=null?i:{});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'"})});zod.z.record(zod.z.string());zod.z.record(zod.z.union([zod.z.boolean(),zod.z.string(),zod.z.number(),zod.z.object({}),zod.z.array(zod.z.any()),zod.z.null(),zod.z.undefined()]));zod.z.string().url();var Ji={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."},Wi={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."},Zi={type:"range",title:"Max reasoning tokens",description:"Specify the total tokens for reasoning, where one token approximates four English characters."},Xi=t=>({type:"multi",title:"Stop sequence",description:`Enter up to ${t} sequences that will halt additional text output. The generated text will exclude these sequences.`}),Qi={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."},ea={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."},ta={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."},oa={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."},na={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."},ia={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."},aa={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."},sa={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."},ra={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."},la={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."},ma={type:"boolean",title:"Echo",description:"If true, the response will contain the prompt."},da={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."},ca={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."},pa={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."},T={TEMPERATURE:Ji,MAX_TOKENS:Wi,STOP:Xi,TOP_A:Qi,TOP_P:ea,TOP_K:ta,MIN_P:oa,FREQUENCY_PENALTY:na,PRESENCE_PENALTY:ia,REPETITION_PENALTY:sa,SEED:aa,LOG_PROBS:ra,TOP_LOG_PROBS:la,ECHO:ma,RESPONSE_FORMAT:da,RESPONSE_FORMAT_WITH_SCHEMA:ca,RESPONSE_SCHEMA:pa,MAX_REASONING_TOKENS:Zi},ua={type:"range",title:"Dimensions",description:"Select the number of dimensions for the word embedding."},ga={type:"select",title:"Encoding format",description:"Select the encoding format for the word embedding."},de={DIMENSIONS:ua,ENCODING_FORMAT:ga};var fe=t=>Object.fromEntries(Object.entries(t).filter(([e,o])=>o!=null));var ce=t=>t==null?void 0:t.replace(/\/$/,"");var ha=Object.defineProperty,fa=Object.defineProperties,ba=Object.getOwnPropertyDescriptors,qo=Object.getOwnPropertySymbols,ya=Object.prototype.hasOwnProperty,Ta=Object.prototype.propertyIsEnumerable,_e=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),Ma=t=>{throw TypeError(t)},Bo=(t,e,o)=>e in t?ha(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,M=(t,e)=>{for(var o in e||(e={}))ya.call(e,o)&&Bo(t,o,e[o]);if(qo)for(var o of qo(e))Ta.call(e,o)&&Bo(t,o,e[o]);return t},yt=(t,e)=>fa(t,ba(e)),R=(t,e,o)=>new Promise((i,a)=>{var l=m=>{try{d(o.next(m));}catch(p){a(p);}},r=m=>{try{d(o.throw(m));}catch(p){a(p);}},d=m=>m.done?i(m.value):Promise.resolve(m.value).then(l,r);d((o=o.apply(t,e)).next());}),Jo=function(t,e){this[0]=t,this[1]=e;},Ao=(t,e,o)=>{var i=(r,d,m,p)=>{try{var u=o[r](d),h=(d=u.value)instanceof Jo,g=u.done;Promise.resolve(h?d[0]:d).then(f=>h?i(r==="return"?r:"next",d[1]?{done:f.done,value:f.value}:f,m,p):m({value:f,done:g})).catch(f=>i("throw",f,m,p));}catch(f){p(f);}},a=r=>l[r]=d=>new Promise((m,p)=>i(r,d,m,p)),l={};return o=o.apply(t,e),l[_e("asyncIterator")]=()=>l,a("next"),a("throw"),a("return"),l},_a=t=>{var e=t[_e("asyncIterator")],o=!1,i,a={};return e==null?(e=t[_e("iterator")](),i=l=>a[l]=r=>e[l](r)):(e=e.call(t),i=l=>a[l]=r=>{if(o){if(o=!1,l==="throw")throw r;return r}return o=!0,{done:!1,value:new Jo(new Promise(d=>{var m=e[l](r);m instanceof Object||Ma("Object expected"),d(m);}),1)}}),a[_e("iterator")]=()=>a,i("next"),"throw"in e?i("throw"):a.throw=l=>{throw l},"return"in e&&i("return"),a},Wo=(t,e)=>K({param:"temperature",title:T.TEMPERATURE.title,description:T.TEMPERATURE.description,min:0,max:t,step:.01,default:e}),Zo=t=>K({param:"maxOutputTokens",title:T.MAX_TOKENS.title,description:T.MAX_TOKENS.description,min:0,max:t,step:1,default:0}),Xo=t=>No({param:"stopSequences",title:T.STOP(t).title,description:T.STOP(t).description,max:t}),Qo=t=>K({param:"topP",title:T.TOP_P.title,description:T.TOP_P.description,min:0,max:1,step:.01,default:t});K({param:"frequencyPenalty",title:T.FREQUENCY_PENALTY.title,description:T.FREQUENCY_PENALTY.description,min:-2,max:2,step:.01,default:0});K({param:"presencePenalty",title:T.PRESENCE_PENALTY.title,description:T.PRESENCE_PENALTY.description,min:-2,max:2,step:.01,default:0});K({param:"seed",title:T.SEED.title,description:T.SEED.description,min:0,max:1e6,step:1,default:0});var en=st({param:"toolChoice",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","any","none"]}),tn=ot({param:"safetySettings",title:"Safety settings",description:"The safety rating contains the category of harm and the harm probability level in that category for a piece of content.",objectSchema:zod.z.array(zod.z.object({threshold:zod.z.enum(["HARM_BLOCK_THRESHOLD_UNSPECIFIED","BLOCK_LOW_AND_ABOVE","BLOCK_MEDIUM_AND_ABOVE","BLOCK_ONLY_HIGH","BLOCK_NONE","OFF"]),category:zod.z.enum(["HARM_CATEGORY_UNSPECIFIED","HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT","HARM_CATEGORY_CIVIC_INTEGRITY"])}))}),on=Me({param:"reasoningEnabled",title:"Reasoning Enabled",description:"Controls whether the model is allowed to think for a longer period of time before generating a response. This can be useful for complex tasks that require more time to think.",default:!1}),nn=(t,e,o,i,a)=>zod.z.object({temperature:Wo(t,e).schema,maxTokens:Zo(o).schema,stop:Xo(i).schema,topP:Qo(a).schema,toolChoice:en.schema,safetySettings:tn.schema}),an=(t,e,o,i,a)=>({temperature:Wo(t,e).def,maxTokens:Zo(o).def,stop:Xo(i).def,topP:Qo(a).def,toolChoice:en.def,safetySettings:tn.def}),sn=ot({param:"response_schema",title:T.RESPONSE_SCHEMA.title,description:T.RESPONSE_SCHEMA.description,objectSchema:lo}),rn=st({param:"response_format",title:T.RESPONSE_FORMAT_WITH_SCHEMA.title,description:T.RESPONSE_FORMAT_WITH_SCHEMA.description,default:"text",choices:["text","json_schema"]}),ln=(t,e,o,i,a)=>yt(M({},an(t,e,o,i,a)),{responseFormat:rn.def,responseSchema:sn.def}),mn=(t,e,o,i,a)=>nn(t,e,o,i,a).extend({responseFormat:rn.schema,responseSchema:sn.schema}),Ea=(t,e,o,i,a)=>mn(t,e,o,i,a).extend({reasoningEnabled:on.schema}),ka=(t,e,o,i,a)=>yt(M({},ln(t,e,o,i,a)),{reasoningEnabled:on.def}),dn=t=>K({param:"outputDimensionality",title:de.DIMENSIONS.title,description:de.DIMENSIONS.description,min:1,max:t,step:1,default:t}),xa=t=>zod.z.object({dimensions:dn(t).schema}),Pa=t=>({dimensions:dn(t).def}),b={base:(t,e,o,i,a)=>({def:an(t,e,o,i,a),schema:nn(t,e,o,i,a)}),responseSchema:(t,e,o,i,a)=>({def:ln(t,e,o,i,a),schema:mn(t,e,o,i,a)}),reasoning:(t,e,o,i,a)=>({def:ka(t,e,o,i,a),schema:Ea(t,e,o,i,a)})},Ee={base:t=>({def:Pa(t),schema:xa(t)})},va="google",Tt=class{constructor(){this.version="v1",this.name=va,this.chatModelFactories={[rt]:{model:Ba,modelOptions:qa,modelSchema:ke},[lt]:{model:Va,modelOptions:Ha,modelSchema:xe},[mt]:{model:Ya,modelOptions:Ka,modelSchema:pn},[dt]:{model:Za,modelOptions:Wa,modelSchema:Pe},[ct]:{model:es,modelOptions:Qa,modelSchema:ve},[pt]:{model:ns,modelOptions:os,modelSchema:Ce},[ut]:{model:ss,modelOptions:as,modelSchema:un},[gt]:{model:ms,modelOptions:ls,modelSchema:Se},[ht]:{model:ps,modelOptions:cs,modelSchema:Oe},[ft]:{model:hs,modelOptions:gs,modelSchema:gn},[bt]:{model:ys,modelOptions:bs,modelSchema:hn}},this.embeddingModelFactories={[Tn]:{model:xs,modelOptions:ks,modelSchema:Mn},[_n]:{model:Cs,modelOptions:vs,modelSchema:En}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((t,e)=>(t[e]=this.chatModelFactories[e].modelSchema,t),{})}chatModel(t){let e=t.modelName;if(!(e in this.chatModelFactories))throw new me({info:`Google chat model: ${e} not found`,cause:new Error(`Google chat model: ${e} not found, available chat models:
7
7
  [${this.chatModelLiterals().join(", ")}]`)});let o=this.chatModelFactories[e].model,i=this.chatModelFactories[e].modelOptions.parse(t);return new o(i)}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((t,e)=>(t[e]=this.embeddingModelFactories[e].modelSchema,t),{})}embeddingModel(t){let e=t.modelName;if(!(e in this.embeddingModelFactories))throw new me({info:`Google embedding model: ${e} not found`,cause:new Error(`Google embedding model: ${e} not found, available embedding models:
8
- [${this.embeddingModelLiterals().join(", ")}]`)});let o=this.embeddingModelFactories[e].model,i=this.embeddingModelFactories[e].modelOptions.parse(t);return new o(i)}};Tt.baseUrl="https://generativelanguage.googleapis.com/v1beta";var G={"base-gemini-1-chat-model":{modelName:"base-gemini-1-chat-model",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"gemini-1.0-pro-001":{modelName:"gemini-1.0-pro-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro-latest":{modelName:"gemini-1.0-pro-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro-vision":{modelName:"gemini-1.0-pro-vision",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro":{modelName:"gemini-1.0-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.5-flash-001":{modelName:"gemini-1.5-flash-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-flash-002":{modelName:"gemini-1.5-flash-002",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.0375,outputPricePerMillion:.15}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}}]},"gemini-1.5-flash-latest":{modelName:"gemini-1.5-flash-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-flash":{modelName:"gemini-1.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-pro-001":{modelName:"gemini-1.5-pro-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro-002":{modelName:"gemini-1.5-pro-002",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro-latest":{modelName:"gemini-1.5-pro-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro":{modelName:"gemini-1.5-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-2.0-flash-exp":{modelName:"gemini-2.0-flash-exp",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.5-flash-preview-04-17":{modelName:"gemini-2.5-flash-preview-04-17",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-2.5-pro-preview-03-25":{modelName:"gemini-2.5-pro-preview-03-25",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:2e5,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}},{minTokens:200001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:15}}}]},"gemini-pro-vision":{modelName:"gemini-pro-vision",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-pro":{modelName:"gemini-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]}},B=zod.z.enum([pe,z,N,ee]),xa="model",Pa="function",A={system:z,user:z,assistant:xa,tool:Pa},H=[C,te,U,oe],V=zod.z.enum([C,te,U,oe]);zod.z.enum([C]);zod.z.enum([C,te]);zod.z.enum([C,U,oe]);var va=zod.z.object({text:zod.z.string()}),Ca=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())})}),Sa=zod.z.object({candidates:zod.z.array(zod.z.object({content:zod.z.object({role:zod.z.string(),parts:zod.z.array(zod.z.union([va,Ca]))}).optional(),finishReason:zod.z.string(),index:zod.z.number().optional(),safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string(),blocked:zod.z.boolean().optional()})))})),promptFeedback:zod.z.optional(zod.z.object({safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string()})))})),usageMetadata:zod.z.object({promptTokenCount:zod.z.number(),cachedContentTokenCount:zod.z.number().optional(),candidatesTokenCount:zod.z.number().optional(),totalTokenCount:zod.z.number()}).optional()}),Oa=zod.z.object({text:zod.z.string()}),wa=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())})}),Ho=zod.z.object({candidates:zod.z.array(zod.z.object({content:zod.z.object({role:zod.z.string(),parts:zod.z.array(zod.z.union([Oa,wa]))}).optional(),finishReason:zod.z.string().optional(),index:zod.z.number().optional(),safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string(),blocked:zod.z.boolean().optional()})))})),promptFeedback:zod.z.optional(zod.z.object({safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string()})))})),usageMetadata:zod.z.object({promptTokenCount:zod.z.number().optional(),cachedContentTokenCount:zod.z.number().optional(),candidatesTokenCount:zod.z.number().optional(),totalTokenCount:zod.z.number().optional()}).optional()}),cn=zod.z.object({text:zod.z.string().min(1)}),Ra=zod.z.object({inline_data:zod.z.object({mime_type:zod.z.string().min(1),data:zod.z.string().base64()})}),Ga=zod.z.object({function_call:zod.z.object({name:zod.z.string().min(1),args:zod.z.record(zod.z.string().min(1))})}),Ia=zod.z.object({function_response:zod.z.object({name:zod.z.string().min(1),response:zod.z.record(zod.z.string().min(1))})}),ja=zod.z.object({role:zod.z.enum(["user","model","function"]),parts:zod.z.array(zod.z.union([cn,Ra,Ga,Ia]))}),Vo=zod.z.object({parts:zod.z.array(cn)}),Na=zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),parameters:zod.z.any()}),zo=zod.z.object({function_calling_config:zod.z.object({mode:zod.z.enum(["ANY","AUTO","NONE"]),allowed_function_names:zod.z.array(zod.z.string()).optional()})}),Ko=zod.z.object({stopSequences:zod.z.array(zod.z.string()).optional(),maxOutputTokens:zod.z.number().optional(),temperature:zod.z.number().optional(),topP:zod.z.number().optional(),topK:zod.z.number().optional(),presencePenalty:zod.z.number().optional(),frequencyPenalty:zod.z.number().optional(),seed:zod.z.number().optional()}),Yo=zod.z.object({category:zod.z.enum(["HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT","HARM_CATEGORY_CIVIC_INTEGRITY"]),threshold:zod.z.enum(["HARM_BLOCK_THRESHOLD_UNSPECIFIED","BLOCK_LOW_AND_ABOVE","BLOCK_MEDIUM_AND_ABOVE","BLOCK_ONLY_HIGH","BLOCK_NONE","OFF"])}),Fa=zod.z.object({model:zod.z.string().min(1).optional(),contents:zod.z.array(ja),systemInstruction:Vo.optional(),system_instruction:Vo.optional(),generationConfig:Ko.optional(),generation_config:Ko.optional(),safetySettings:zod.z.array(Yo).optional(),safety_settings:zod.z.array(Yo).optional(),tools:zod.z.object({function_declarations:zod.z.array(Na)}).optional(),toolConfig:zo.optional(),tool_config:zo.optional()}),L=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),completeChatUrl:zod.z.string().url().optional(),streamChatUrl:zod.z.string().url().optional()}),I=class{constructor(t,e){this.version="v1";var o;let i=L.parse(e);this.modelSchema=t,this.modelName=i.modelName,this.apiKey=i.apiKey,this.baseUrl=ce((o=i.baseUrl)!=null?o:Tt.baseUrl),this.completeChatUrl=ce(i.completeChatUrl||`${this.baseUrl}/models/${this.modelName}:generateContent?key=${this.apiKey}`),this.streamChatUrl=ce(i.streamChatUrl||`${this.baseUrl}/models/${this.modelName}:streamGenerateContent?key=${this.apiKey}`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"Content-Type":"application/json"}}getDefaultParams(){return {}}getRetryDelay(t){return {shouldRetry:!1,delayMs:0}}getTokenCount(t){return t.reduce((e,o)=>e+o.content.map(i=>i.modality==="text"?i.value:"").join(" ").length,0)}transformModelRequest(t){let e=Fa.safeParse(t);if(!e.success)throw new Z({info:"Invalid model request",cause:e.error});let o=e.data,i=o.model;if(o.system_instruction&&o.systemInstruction)throw new Z({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'system_instruction' and 'systemInstruction' are not allowed at the same time")});if(o.generation_config&&o.generationConfig)throw new Z({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'generation_config' and 'generationConfig' are not allowed at the same time")});if(o.tool_config&&o.toolConfig)throw new Z({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tool_config' and 'toolConfig' are not allowed at the same time")});let a=o.system_instruction||o.systemInstruction,l=o.generation_config||o.generationConfig,r=o.safety_settings||o.safetySettings,d=o.tool_config||o.toolConfig;if(d&&(!o.tools||o.tools.function_declarations.length===0))throw new Z({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let m={};d&&(d.function_calling_config.mode==="ANY"&&d.function_calling_config.allowed_function_names&&d.function_calling_config.allowed_function_names.length===1?m.toolChoice=d.function_calling_config.allowed_function_names[0]:m.toolChoice=d.function_calling_config.mode.toLowerCase()),m.seed=l==null?void 0:l.seed,m.maxTokens=l==null?void 0:l.maxOutputTokens,m.temperature=l==null?void 0:l.temperature,m.topP=l==null?void 0:l.topP,m.presencePenalty=l==null?void 0:l.presencePenalty,m.frequencyPenalty=l==null?void 0:l.frequencyPenalty,m.stop=l==null?void 0:l.stopSequences,m.safetySettings=r;let p=ue().parse(fe(m)),u=[];a&&a.parts.forEach(g=>{u.push({role:pe,content:[{modality:C,value:g.text}]});}),o.contents.forEach(g=>{let f=g.role;switch(f){case"user":{let v=g.parts.map(_=>"text"in _?{modality:C,value:_.text}:{modality:te,detail:"auto",value:{type:ze,base64:_.inline_data.data,mediaType:_.inline_data.mime_type.split("/")[1]}});u.push({role:f,content:v});}break;case"model":{let v=g.parts.map((_,j)=>"text"in _?{modality:C,value:_.text}:{modality:U,id:j.toString(),index:j,name:_.function_call.name,arguments:JSON.stringify(_.function_call.args)});u.push({role:N,content:v});}break;case"function":{let v=g.parts.map((_,j)=>({modality:oe,id:j.toString(),index:j,name:_.function_response.name,data:JSON.stringify(_.function_response.response)}));u.push({role:ee,content:v});}break;default:throw new x({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${g.role}' is not supported for model : ${this.modelName}`)})}});let h=[];return o.tools&&o.tools.function_declarations.forEach(g=>{h.push({type:"function",definition:{schema:{name:g.name,description:g.description,parameters:g.parameters}}});}),{modelName:i,config:p,messages:u,tools:h.length>0?h:void 0}}transformConfig(t,e,o){let i=t.toolChoice;delete t.toolChoice;let a=this.modelSchema.config.schema.safeParse(t);if(!a.success)throw new D({info:`Invalid config for model : '${this.modelName}'`,cause:a.error});let l=a.data;Object.keys(l).forEach(p=>{if(!(p in this.modelSchema.config.def))throw new D({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${p}',
8
+ [${this.embeddingModelLiterals().join(", ")}]`)});let o=this.embeddingModelFactories[e].model,i=this.embeddingModelFactories[e].modelOptions.parse(t);return new o(i)}};Tt.baseUrl="https://generativelanguage.googleapis.com/v1beta";var G={"base-gemini-1-chat-model":{modelName:"base-gemini-1-chat-model",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"gemini-1.0-pro-001":{modelName:"gemini-1.0-pro-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro-latest":{modelName:"gemini-1.0-pro-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro-vision":{modelName:"gemini-1.0-pro-vision",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro":{modelName:"gemini-1.0-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.5-flash-001":{modelName:"gemini-1.5-flash-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-flash-002":{modelName:"gemini-1.5-flash-002",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.0375,outputPricePerMillion:.15}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}}]},"gemini-1.5-flash-latest":{modelName:"gemini-1.5-flash-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-flash":{modelName:"gemini-1.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-pro-001":{modelName:"gemini-1.5-pro-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro-002":{modelName:"gemini-1.5-pro-002",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro-latest":{modelName:"gemini-1.5-pro-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro":{modelName:"gemini-1.5-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-2.0-flash-exp":{modelName:"gemini-2.0-flash-exp",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.5-flash-preview-04-17":{modelName:"gemini-2.5-flash-preview-04-17",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-2.5-pro-preview-03-25":{modelName:"gemini-2.5-pro-preview-03-25",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:2e5,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}},{minTokens:200001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:15}}}]},"gemini-pro-vision":{modelName:"gemini-pro-vision",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-pro":{modelName:"gemini-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]}},B=zod.z.enum([pe,z,N,ee]),Ca="model",Sa="function",A={system:z,user:z,assistant:Ca,tool:Sa},H=[C,te,$,oe],V=zod.z.enum([C,te,$,oe]);zod.z.enum([C]);zod.z.enum([C,te]);zod.z.enum([C,$,oe]);var Oa=zod.z.object({text:zod.z.string()}),wa=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())})}),Ra=zod.z.object({candidates:zod.z.array(zod.z.object({content:zod.z.object({role:zod.z.string(),parts:zod.z.array(zod.z.union([Oa,wa]))}).optional(),finishReason:zod.z.string(),index:zod.z.number().optional(),safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string(),blocked:zod.z.boolean().optional()})))})),promptFeedback:zod.z.optional(zod.z.object({safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string()})))})),usageMetadata:zod.z.object({promptTokenCount:zod.z.number(),cachedContentTokenCount:zod.z.number().optional(),candidatesTokenCount:zod.z.number().optional(),totalTokenCount:zod.z.number()}).optional()}),Ga=zod.z.object({text:zod.z.string()}),Ia=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())})}),Ho=zod.z.object({candidates:zod.z.array(zod.z.object({content:zod.z.object({role:zod.z.string(),parts:zod.z.array(zod.z.union([Ga,Ia]))}).optional(),finishReason:zod.z.string().optional(),index:zod.z.number().optional(),safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string(),blocked:zod.z.boolean().optional()})))})),promptFeedback:zod.z.optional(zod.z.object({safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string()})))})),usageMetadata:zod.z.object({promptTokenCount:zod.z.number().optional(),cachedContentTokenCount:zod.z.number().optional(),candidatesTokenCount:zod.z.number().optional(),totalTokenCount:zod.z.number().optional()}).optional()}),cn=zod.z.object({text:zod.z.string().min(1)}),ja=zod.z.object({inline_data:zod.z.object({mime_type:zod.z.string().min(1),data:zod.z.string().base64()})}),Na=zod.z.object({function_call:zod.z.object({name:zod.z.string().min(1),args:zod.z.record(zod.z.string().min(1))})}),Fa=zod.z.object({function_response:zod.z.object({name:zod.z.string().min(1),response:zod.z.record(zod.z.string().min(1))})}),La=zod.z.object({role:zod.z.enum(["user","model","function"]),parts:zod.z.array(zod.z.union([cn,ja,Na,Fa]))}),Vo=zod.z.object({parts:zod.z.array(cn)}),Ua=zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),parameters:zod.z.any()}),zo=zod.z.object({function_calling_config:zod.z.object({mode:zod.z.enum(["ANY","AUTO","NONE"]),allowed_function_names:zod.z.array(zod.z.string()).optional()})}),Ko=zod.z.object({stopSequences:zod.z.array(zod.z.string()).optional(),maxOutputTokens:zod.z.number().optional(),temperature:zod.z.number().optional(),topP:zod.z.number().optional(),topK:zod.z.number().optional(),presencePenalty:zod.z.number().optional(),frequencyPenalty:zod.z.number().optional(),seed:zod.z.number().optional()}),Yo=zod.z.object({category:zod.z.enum(["HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT","HARM_CATEGORY_CIVIC_INTEGRITY"]),threshold:zod.z.enum(["HARM_BLOCK_THRESHOLD_UNSPECIFIED","BLOCK_LOW_AND_ABOVE","BLOCK_MEDIUM_AND_ABOVE","BLOCK_ONLY_HIGH","BLOCK_NONE","OFF"])}),$a=zod.z.object({model:zod.z.string().min(1).optional(),contents:zod.z.array(La),systemInstruction:Vo.optional(),system_instruction:Vo.optional(),generationConfig:Ko.optional(),generation_config:Ko.optional(),safetySettings:zod.z.array(Yo).optional(),safety_settings:zod.z.array(Yo).optional(),tools:zod.z.object({function_declarations:zod.z.array(Ua)}).optional(),toolConfig:zo.optional(),tool_config:zo.optional()}),L=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),completeChatUrl:zod.z.string().url().optional(),streamChatUrl:zod.z.string().url().optional()}),I=class{constructor(t,e){this.version="v1";var o;let i=L.parse(e);this.modelSchema=t,this.modelName=i.modelName,this.apiKey=i.apiKey,this.baseUrl=ce((o=i.baseUrl)!=null?o:Tt.baseUrl),this.completeChatUrl=ce(i.completeChatUrl||`${this.baseUrl}/models/${this.modelName}:generateContent?key=${this.apiKey}`),this.streamChatUrl=ce(i.streamChatUrl||`${this.baseUrl}/models/${this.modelName}:streamGenerateContent?key=${this.apiKey}`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"Content-Type":"application/json"}}getDefaultParams(){return {}}getRetryDelay(t){return {shouldRetry:!1,delayMs:0}}getTokenCount(t){return t.reduce((e,o)=>e+o.content.map(i=>i.modality==="text"?i.value:"").join(" ").length,0)}transformModelRequest(t){let e=$a.safeParse(t);if(!e.success)throw new Z({info:"Invalid model request",cause:e.error});let o=e.data,i=o.model;if(o.system_instruction&&o.systemInstruction)throw new Z({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'system_instruction' and 'systemInstruction' are not allowed at the same time")});if(o.generation_config&&o.generationConfig)throw new Z({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'generation_config' and 'generationConfig' are not allowed at the same time")});if(o.tool_config&&o.toolConfig)throw new Z({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tool_config' and 'toolConfig' are not allowed at the same time")});let a=o.system_instruction||o.systemInstruction,l=o.generation_config||o.generationConfig,r=o.safety_settings||o.safetySettings,d=o.tool_config||o.toolConfig;if(d&&(!o.tools||o.tools.function_declarations.length===0))throw new Z({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let m={};d&&(d.function_calling_config.mode==="ANY"&&d.function_calling_config.allowed_function_names&&d.function_calling_config.allowed_function_names.length===1?m.toolChoice=d.function_calling_config.allowed_function_names[0]:m.toolChoice=d.function_calling_config.mode.toLowerCase()),m.seed=l==null?void 0:l.seed,m.maxTokens=l==null?void 0:l.maxOutputTokens,m.temperature=l==null?void 0:l.temperature,m.topP=l==null?void 0:l.topP,m.presencePenalty=l==null?void 0:l.presencePenalty,m.frequencyPenalty=l==null?void 0:l.frequencyPenalty,m.stop=l==null?void 0:l.stopSequences,m.safetySettings=r;let p=ue().parse(fe(m)),u=[];a&&a.parts.forEach(g=>{u.push({role:pe,content:[{modality:C,value:g.text}]});}),o.contents.forEach(g=>{let f=g.role;switch(f){case"user":{let v=g.parts.map(_=>"text"in _?{modality:C,value:_.text}:{modality:te,detail:"auto",value:{type:ze,base64:_.inline_data.data,mediaType:_.inline_data.mime_type.split("/")[1]}});u.push({role:f,content:v});}break;case"model":{let v=g.parts.map((_,j)=>"text"in _?{modality:C,value:_.text}:{modality:$,id:j.toString(),index:j,name:_.function_call.name,arguments:JSON.stringify(_.function_call.args)});u.push({role:N,content:v});}break;case"function":{let v=g.parts.map((_,j)=>({modality:oe,id:j.toString(),index:j,name:_.function_response.name,data:JSON.stringify(_.function_response.response)}));u.push({role:ee,content:v});}break;default:throw new x({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${g.role}' is not supported for model : ${this.modelName}`)})}});let h=[];return o.tools&&o.tools.function_declarations.forEach(g=>{h.push({type:"function",definition:{schema:{name:g.name,description:g.description,parameters:g.parameters}}});}),{modelName:i,config:p,messages:u,tools:h.length>0?h:void 0}}transformConfig(t,e,o){let i=t.toolChoice;delete t.toolChoice;let a=this.modelSchema.config.schema.safeParse(t);if(!a.success)throw new D({info:`Invalid config for model : '${this.modelName}'`,cause:a.error});let l=a.data;Object.keys(l).forEach(p=>{if(!(p in this.modelSchema.config.def))throw new D({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${p}',
9
9
  available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let r=Object.keys(l).reduce((p,u)=>{let h=this.modelSchema.config.def[u],g=h.param,f=l[u];return u==="reasoningEnabled"?p.thinkingConfig={includeThoughts:f}:u==="maxReasoningTokens"?p.thinkingConfig=p.thinkingConfig&&typeof p.thinkingConfig=="object"?yt(M({},p.thinkingConfig),{thinkingBudget:f}):{thinkingBudget:f}:g==="maxOutputTokens"&&h.type==="range"&&f===0?p[g]=h.max:p[g]=f,p},{}),d=r.safetySettings;delete r.safetySettings;let m;if(i!==void 0){let p=i;if(!o||o&&o.length===0)throw new D({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(o&&o.length>0){let u=this.modelSchema.config.def.toolChoice;if(u.choices.includes(p))p==="any"?m={function_calling_config:{mode:"ANY",allowed_function_names:o.map(h=>h.definition.schema.name)}}:m={function_calling_config:{mode:p.toUpperCase()}};else if(o.map(h=>h.definition.schema.name).includes(p))m={function_calling_config:{mode:"ANY",allowed_function_names:[p]}};else throw new D({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`toolChoice : '${p}' is not part of provided 'tools' names or
10
- one of [${u.choices.join(", ")}]`)})}}if("response_format"in r&&r.response_format!==void 0){let p=r.response_format;if(p==="json_schema"){let u=r.response_schema;if(!("response_schema"in r)||!r.response_schema||!(u!=null&&u.schema))throw new D({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'responseSchema' is required in config when 'responseFormat' is 'json_schema'")});r.responseSchema=u.schema,r.responseMimeType="application/json","additionalProperties"in u.schema&&delete r.responseSchema.additionalProperties,delete r.response_format,delete r.response_schema;}else p==="json_object"?(r.responseSchema={type:"object"},delete r.response_format):p==="text"&&delete r.response_format;}return M(M({generation_config:r},m?{tool_config:m}:{}),d?{safety_settings:d}:{})}transformMessages(t){if(!t||t&&t.length===0)return {messages:[]};let e=r=>{let d=r.match(/^data:image\/[a-zA-Z]+;base64,/);return d?r.substring(d[0].length):r},o=t.map(r=>{let d=We().safeParse(r);if(!d.success)throw new x({info:"Invalid messages",cause:d.error});return d.data});o.forEach(r=>{r.content.forEach(d=>{if(!this.modelSchema.modalities.includes(d.modality))throw new x({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${d.modality}',
10
+ one of [${u.choices.join(", ")}]`)})}}if("response_format"in r&&r.response_format!==void 0){let p=r.response_format;if(p==="json_schema"){let u=r.response_schema;if(!("response_schema"in r)||!r.response_schema||!(u!=null&&u.schema))throw new D({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'responseSchema' is required in config when 'responseFormat' is 'json_schema'")});r.responseSchema=u.schema,r.responseMimeType="application/json","additionalProperties"in u.schema&&delete r.responseSchema.additionalProperties,delete r.response_format,delete r.response_schema;}else p==="json_object"?(r.responseSchema={type:"object"},delete r.response_format):p==="text"&&delete r.response_format;}return M(M({generation_config:r},m?{tool_config:m}:{}),d?{safety_settings:d}:{})}transformMessages(t){if(!t||t&&t.length===0)return {messages:[]};let e=r=>{let d=r.match(/^data:image\/[a-zA-Z]+;base64,/);return d?r.substring(d[0].length):r},o=t.map(r=>{let d=Je().safeParse(r);if(!d.success)throw new x({info:"Invalid messages",cause:d.error});return d.data});o.forEach(r=>{r.content.forEach(d=>{if(!this.modelSchema.modalities.includes(d.modality))throw new x({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${d.modality}',
11
11
  available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),o.forEach(r=>{if(!Object.keys(this.modelSchema.roles).includes(r.role))throw new x({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${r.role}',
12
- available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})});let i={parts:[]},a=[];if(o.forEach(r=>{switch(r.role){case pe:r.content.forEach(d=>{if(d.modality===C)i.parts.push({text:d.value});else throw new x({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' cannot have content with modality : '${d.modality}'`)})});break;case N:{let d=[];r.content.forEach(m=>{if(m.modality===C)d.push({text:m.value});else if(m.modality===U)d.push({function_call:{name:m.name,args:JSON.parse(m.arguments)}});else throw new x({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' cannot have content with modality : '${m.modality}'`)})}),a.push({role:this.modelSchema.roles[r.role],parts:d});}break;case z:{let d=[];r.content.forEach(m=>{if(m.modality===C)d.push({text:m.value});else if(m.modality===te){if(m.value.type==="base64"){let p=m.value.base64;p=e(p),d.push({inline_data:{mime_type:`image/${m.value.mediaType}`,data:p}});}else if(m.value.type==="url")throw new x({info:`Invalid message 'modality' for model : ${this.modelName}`,cause:new Error(`model: '${this.modelName}' does not support image content type: '${m.value.type}'`)})}else throw new x({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' cannot have content with modality : '${m.modality}'`)})}),a.push({role:this.modelSchema.roles[r.role],parts:d});}break;case ee:{let d=[];r.content.forEach(m=>{if(m.modality===oe)d.push({function_response:{name:m.name,response:JSON.parse(m.data)}});else throw new x({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' cannot have content with modality : '${m.modality}'`)})}),a.push({role:this.modelSchema.roles[r.role],parts:d});}break;default:throw new x({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' is not supported,
13
- available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}}),a[0].role!==this.modelSchema.roles[z])throw new x({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires first message to be from user`)});let l=r=>r===this.modelSchema.roles[z]||r===this.modelSchema.roles[ee]?[this.modelSchema.roles[N]]:[this.modelSchema.roles[z],this.modelSchema.roles[ee]];for(let r=1;r<a.length;r++)if(!l(a[r-1].role).includes(a[r].role))throw new x({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' cannot have message with role : '${a[r].role}' after message with role : '${a[r-1].role}'`)});if(a[a.length-1].role!==this.modelSchema.roles[z]&&a[a.length-1].role!==this.modelSchema.roles[ee])throw new x({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires last message to be from user`)});return M({contents:a},i.parts.length>0?{system_instruction:i}:{})}transformTools(t){if(!this.modelSchema.modalities.includes(U))throw new Qe({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${U}'`)});return !t||t&&t.length===0?{tools:[]}:{tools:[{function_declarations:t.map(e=>{let o=uo().safeParse(e);if(!o.success)throw new Qe({info:"Invalid tools",cause:o.error});return o.data}).map(e=>({name:e.definition.schema.name,description:e.definition.schema.description,parameters:e.definition.schema.parameters}))}]}}getCompleteChatUrl(t,e,o){return R(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getCompleteChatHeaders(t,e,o){return R(this,null,function*(){return new Promise(i=>{i(this.getDefaultHeaders());})})}getCompleteChatData(t,e,o){return R(this,null,function*(){let i=this.transformConfig(t,e,o),a=this.transformMessages(e);if(a.messages&&a.messages.length===0)throw new x({info:"Messages are required",cause:new Error("Messages are required")});let l=o?this.transformTools(o):{};return new Promise(r=>{r(M(M(M(M({},this.getDefaultParams()),i),a),l));})})}transformCompleteChatResponse(t){let e=Sa.safeParse(t);if(e.success){if(e.data.candidates.length===0)throw new w({info:"Invalid response from model",cause:new Error(`No choices in response : ${JSON.stringify(e.data)}`)});let o=e.data,i=[],a,l=o.candidates[0].content;if(l){let d=l.parts.map((m,p)=>{if("text"in m&&m.text!==void 0)return go(m.text);if("functionCall"in m&&m.functionCall!==void 0)return ho(p,`${m.functionCall.name}_${p}`,m.functionCall.name,JSON.stringify(m.functionCall.args))});return i.push({role:N,content:d}),o.usageMetadata&&(a={promptTokens:o.usageMetadata.promptTokenCount,totalTokens:o.usageMetadata.totalTokenCount,completionTokens:o.usageMetadata.candidatesTokenCount||0}),{messages:i,usage:a,logProbs:void 0}}let r=o.candidates[0].safetyRatings;if(r&&r.length>0&&r.forEach(d=>{if(d.blocked)throw new w({info:`Blocked content for category: ${d.category} with probability: ${d.probability}`,cause:new Error(`Blocked content for category: ${d.category} with probability: ${d.probability}`)})}),o.candidates[0].finishReason==="SAFETY")throw new w({info:"Blocked content, model response finished with safety reason",cause:new Error("Blocked content, model response finished with safety reason")})}throw new w({info:"Invalid response from model",cause:e.error})}getStreamChatUrl(t,e,o){return R(this,null,function*(){return new Promise(i=>{i(this.streamChatUrl);})})}getStreamChatHeaders(t,e,o){return R(this,null,function*(){return new Promise(i=>{i(this.getDefaultHeaders());})})}getStreamChatData(t,e,o){return R(this,null,function*(){let i=this.transformConfig(t,e,o),a=this.transformMessages(e);if(a.messages&&a.messages.length===0)throw new x({info:"Messages are required",cause:new Error("Messages are required")});let l=o?this.transformTools(o):{};return new Promise(r=>{r(M(M(M(M({},this.getDefaultParams()),i),a),l));})})}transformStreamChatResponseChunk(t,e){return Ao(this,null,function*(){let o=(e+t).split(",\r").filter(i=>i.trim()!=="");for(let i of o){let a=i;if(a=a.replace(/\n/g,""),a.startsWith("[")||a.startsWith(",{"))a=a.slice(1);else if(a.endsWith("]")){if(a==="]")return;a=a.slice(0,-1);}let l;try{l=JSON.parse(a);}catch(d){if(d instanceof SyntaxError){e=a;continue}else throw d}e="";let r=Ho.safeParse(l);if(r.success){let d={partialMessages:[]},m=r.data;if(m.candidates.length>0){let p=m.candidates[0].content;p&&"parts"in p&&p.parts.length>0&&p.parts.forEach((u,h)=>{if("text"in u&&u.text!==void 0&&d.partialMessages.push(Ze(N,u.text)),"functionCall"in u&&u.functionCall!==void 0){let g=u.functionCall;d.partialMessages.push(Xe(N,h,`${g.name}_${h}`,g.name,JSON.stringify(g.args)));}});}m.usageMetadata&&(d.usage={promptTokens:m.usageMetadata.promptTokenCount,completionTokens:m.usageMetadata.candidatesTokenCount,totalTokens:m.usageMetadata.totalTokenCount}),yield {partialResponse:d,buffer:e};}else throw new w({info:"Invalid response from model",cause:r.error})}yield {partialResponse:{partialMessages:[]},buffer:e};})}transformProxyStreamChatResponseChunk(t,e,o,i,a){return Ao(this,null,function*(){if((a==null?void 0:a.alt)!=="sse"){yield*Yt(ya(this.transformStreamChatResponseChunk(t,e)));return}let l=e+t,r=[],d="",m=0;for(;m<l.length;){let p=l.indexOf(`
14
- `,m);if(p===-1){d=l.substring(m);break}else {let u=l.substring(m,p).trim();u&&r.push(u),m=p+1;}}for(let p of r){if(p==="data: [DONE]")return;if(p.startsWith("data: ")){let u=p.substring(6);try{let h=JSON.parse(u),g=Ho.safeParse(h);if(g.success){let f={partialMessages:[]},v=g.data;if(v.candidates.length>0){let _=v.candidates[0].content;_&&"parts"in _&&_.parts.length>0&&_.parts.forEach((j,Vt)=>{if("text"in j&&j.text!==void 0&&f.partialMessages.push(Ze(N,j.text)),"functionCall"in j&&j.functionCall!==void 0){let qe=j.functionCall;f.partialMessages.push(Xe(N,Vt,`${qe.name}_${Vt}`,qe.name,JSON.stringify(qe.args)));}});}v.usageMetadata&&v.usageMetadata.totalTokenCount&&v.usageMetadata.promptTokenCount&&v.usageMetadata.candidatesTokenCount&&(f.usage={promptTokens:v.usageMetadata.promptTokenCount,completionTokens:v.usageMetadata.candidatesTokenCount,totalTokens:v.usageMetadata.totalTokenCount}),yield {partialResponse:f,buffer:e};}else throw new w({info:"Invalid response from model",cause:g.error})}catch(h){throw new w({info:`Malformed JSON received in stream: ${u}`,cause:h})}}}yield {partialResponse:{partialMessages:[]},buffer:d};})}getProxyCompleteChatUrl(t,e,o){return R(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getProxyStreamChatUrl(t,e,o){return R(this,null,function*(){return new Promise(i=>{if(!o||Object.keys(o).length===0){i(this.streamChatUrl);return}let a=new URL(this.streamChatUrl);Object.entries(o).forEach(([l,r])=>{r!=null&&a.searchParams.set(l,r);}),i(a.toString());})})}getProxyCompleteChatHeaders(t,e,o){return R(this,null,function*(){if(!e)return {};let i=M({},e);return delete i.host,delete i["content-length"],i})}getProxyStreamChatHeaders(t,e,o){return R(this,null,function*(){return yield this.getProxyCompleteChatHeaders(t,e,o)})}getModelPricing(){if(!(this.modelName in G))throw new w({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return G[this.modelName]}},rt="gemini-1.5-flash-001",La="Google's fastest, most cost-efficient multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",ke=F(B,V).parse({name:rt,description:La,maxInputTokens:1e6,maxOutputTokens:8192,roles:A,modalities:H,config:{def:b.responseSchema(2,1,8192,4,.95).def,schema:b.responseSchema(2,1,8192,4,.95).schema},price:G[rt]}),$a=L,Ua=class extends I{constructor(t){super(ke,t);}},lt="gemini-1.5-flash-002",Da="Google's fastest, most cost-efficient multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",xe=F(B,V).parse({name:lt,description:Da,maxInputTokens:1e6,maxOutputTokens:8192,roles:A,modalities:H,config:{def:b.responseSchema(2,1,8192,4,.95).def,schema:b.responseSchema(2,1,8192,4,.95).schema},price:G[lt]}),qa=L,Ba=class extends I{constructor(t){super(xe,t);}},mt="gemini-1.5-flash-latest",Aa="Google's latest multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",pn=F(B,V).parse({name:mt,description:Aa,maxInputTokens:1e6,maxOutputTokens:8192,roles:A,modalities:H,config:{def:b.responseSchema(2,1,8192,4,.95).def,schema:b.responseSchema(2,1,8192,4,.95).schema},price:G[mt]}),Ha=L,Va=class extends I{constructor(t){super(pn,t);}},dt="gemini-1.5-flash",za="Google's fastest, most cost-efficient multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",Pe=F(B,V).parse({name:dt,description:za,maxInputTokens:1e6,maxOutputTokens:8192,roles:A,modalities:H,config:{def:b.responseSchema(2,1,8192,4,.95).def,schema:b.responseSchema(2,1,8192,4,.95).schema},price:G[dt]}),Ka=L,Ya=class extends I{constructor(t){super(Pe,t);}},ct="gemini-1.5-pro-001",Wa="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",ve=F(B,V).parse({name:ct,description:Wa,maxInputTokens:2e6,maxOutputTokens:8192,roles:A,modalities:H,config:{def:b.responseSchema(2,1,8192,4,.95).def,schema:b.responseSchema(2,1,8192,4,.95).schema},price:G[ct]}),Ja=L,Za=class extends I{constructor(t){super(ve,t);}},pt="gemini-1.5-pro-002",Xa="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",Ce=F(B,V).parse({name:pt,description:Xa,maxInputTokens:2e6,maxOutputTokens:8192,roles:A,modalities:H,config:{def:b.responseSchema(2,1,8192,4,.95).def,schema:b.responseSchema(2,1,8192,4,.95).schema},price:G[pt]}),Qa=L,es=class extends I{constructor(t){super(Ce,t);}},ut="gemini-1.5-pro-latest",ts="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",un=F(B,V).parse({name:ut,description:ts,maxInputTokens:2e6,maxOutputTokens:8192,roles:A,modalities:H,config:{def:b.responseSchema(2,1,8192,4,.95).def,schema:b.responseSchema(2,1,8192,4,.95).schema},price:G[ut]}),os=L,ns=class extends I{constructor(t){super(un,t);}},gt="gemini-1.5-pro",is="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",Se=F(B,V).parse({name:gt,description:is,maxInputTokens:2e6,maxOutputTokens:8192,roles:A,modalities:H,config:{def:b.responseSchema(2,1,8192,4,.95).def,schema:b.responseSchema(2,1,8192,4,.95).schema},price:G[gt]}),as=L,ss=class extends I{constructor(t){super(Se,t);}},ht="gemini-2.0-flash-exp",rs="Google's experimental multimodal model with enhanced capabilities. Designed for cutting-edge performance across complex and high-frequency tasks.",Oe=F(B,V).parse({name:ht,description:rs,maxInputTokens:1e6,maxOutputTokens:8192,roles:A,modalities:H,config:{def:b.responseSchema(2,1,8192,4,.95).def,schema:b.responseSchema(2,1,8192,4,.95).schema},price:G[ht]}),ls=L,ms=class extends I{constructor(t){super(Oe,t);}},ft="gemini-2.5-flash-preview-04-17",ds="Google's best model in Gemini 2.5 family in terms of price-performance, offering well-rounded capabilities.",gn=F(B,V).parse({name:ft,description:ds,maxInputTokens:1048576,maxOutputTokens:65536,roles:A,modalities:H,config:{def:b.responseSchema(2,1,65536,4,.95).def,schema:b.responseSchema(2,1,65536,4,.95).schema},price:G[ft]}),cs=L,ps=class extends I{constructor(t){super(gn,t);}},bt="gemini-2.5-pro-preview-03-25",us="Google's preview model in Gemini 2.5 family for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",hn=F(B,V).parse({name:bt,description:us,maxInputTokens:1048576,maxOutputTokens:65536,roles:A,modalities:H,config:{def:b.reasoning(2,1,65536,4,.95).def,schema:b.reasoning(2,1,65536,4,.95).schema},price:G[bt]}),gs=L,hs=class extends I{constructor(t){super(hn,t);}},fn=[S],bn=zod.z.enum([S]),fs=zod.z.object({embeddings:zod.z.array(zod.z.object({values:zod.z.array(zod.z.number())}))}),bs=zod.z.object({model:zod.z.string().min(1),content:zod.z.object({parts:zod.z.array(zod.z.object({text:zod.z.string().min(1)})).min(1)})}),ys=zod.z.object({model:zod.z.string().min(1).optional(),requests:zod.z.array(bs).min(1),outputDimensionality:zod.z.number().int().min(1).optional()}),Mt=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),getEmbeddingsUrl:zod.z.string().url().optional()}),yn=class{constructor(t,e){this.version="v1";let o=Mt.parse(e);this.modelSchema=t,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=ce(o.baseUrl||Tt.baseUrl),this.getEmbeddingsUrl=ce(o.getEmbeddingsUrl||`${this.baseUrl}/models/${this.modelName}:batchEmbedContents?key=${this.apiKey}`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"Content-Type":"application/json"}}getDefaultParams(){return {model:this.modelName}}getRetryDelay(t){return {shouldRetry:!1,delayMs:0}}getTokenCount(t){return t.requests.reduce((e,o)=>e+o.length,0)}transformModelRequest(t){let e=ys.safeParse(t);if(!e.success)throw new Z({info:"Invalid model request",cause:e.error});let o=e.data,i=o.model,a={outputDimensionality:o.outputDimensionality},l=ue().parse(fe(a)),r={modality:S,requests:o.requests.reduce((d,m)=>(d.push(...m.content.parts.map(p=>p.text)),d),[])};return {modelName:i,config:l,embeddingRequests:r}}transformConfig(t,e){let o=this.modelSchema.config.schema.safeParse(t);if(!o.success)throw new D({info:`Invalid config for model : '${this.modelName}'`,cause:o.error});let i=o.data;return Object.keys(i).forEach(a=>{if(!this.modelSchema.config.def[a])throw new D({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${a}',
15
- available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(i).reduce((a,l)=>{let r=this.modelSchema.config.def[l].param,d=i[l];return a[r]=d,a},{})}transformEmbeddingRequests(t){let e=ye().safeParse(t);if(!e.success)throw new ne({info:"Invalid embedding requests",cause:e.error});if(t.modality!==S)throw new ne({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Only '${S}' modality is supported for model : '${this.modelName}'`)});return {requests:e.data.requests.map(o=>({model:`models/${this.modelName}`,content:{parts:[{text:o}]}}))}}getGetEmbeddingsUrl(t,e){return R(this,null,function*(){return new Promise(o=>{o(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(t,e){return R(this,null,function*(){return new Promise(o=>{o(this.getDefaultHeaders());})})}getGetEmbeddingsData(t,e){return R(this,null,function*(){return new Promise(o=>{let i=this.transformConfig(t),a=this.transformEmbeddingRequests(e);if(e.requests.length===0)throw new ne({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error("requests cannot be empty")});i.outputDimensionality&&(a.requests.forEach(l=>{l.outputDimensionality=i.outputDimensionality;}),delete i.outputDimensionality),o(M(M(M({},this.getDefaultParams()),i),a));})})}transformGetEmbeddingsResponse(t){let e=fs.safeParse(t);if(e.success){let o=e.data.embeddings.map((i,a)=>({index:a,embedding:i.values}));return {encodingFormat:ge,embeddings:o}}throw new w({info:"Invalid response from model",cause:e.error})}},Tn="text-embedding-001",Ts="text-embedding-001",Mn=q(bn).parse({name:Tn,description:Ts,modalities:fn,maxInputTokens:2048,maxOutputTokens:768,config:{def:Ee.base(768).def,schema:Ee.base(768).schema}}),Ms=Mt,_s=class extends yn{constructor(t){super(Mn,t);}},_n="text-embedding-004",Es="text-embedding-004",En=q(bn).parse({name:_n,description:Es,modalities:fn,maxInputTokens:2048,maxOutputTokens:768,config:{def:Ee.base(768).def,schema:Ee.base(768).schema}}),ks=Mt,xs=class extends yn{constructor(t){super(En,t);}};var Ps="vertex",se=class{constructor(){this.version="v1";this.name=Ps;this.chatModelFactories={[_t]:{model:we,modelOptions:kn,modelSchema:Et},[kt]:{model:Re,modelOptions:xn,modelSchema:xt},[Pt]:{model:Ge,modelOptions:Pn,modelSchema:vt},[Ct]:{model:Ie,modelOptions:vn,modelSchema:St},[Ot]:{model:je,modelOptions:Cn,modelSchema:wt},[Rt]:{model:Ne,modelOptions:Sn,modelSchema:Gt},[It]:{model:Fe,modelOptions:On,modelSchema:jt}};this.embeddingModelFactories={[Nt]:{model:Le,modelOptions:wn,modelSchema:Ft},[Lt]:{model:$e,modelOptions:Rn,modelSchema:$t},[qt]:{model:De,modelOptions:In,modelSchema:Bt},[Ut]:{model:Ue,modelOptions:Gn,modelSchema:Dt}};}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 me({info:`Vertex chat model: ${o} not found`,cause:new Error(`Vertex chat model: ${o} not found, available chat models:
12
+ available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})});let i={parts:[]},a=[];if(o.forEach(r=>{switch(r.role){case pe:r.content.forEach(d=>{if(d.modality===C)i.parts.push({text:d.value});else throw new x({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' cannot have content with modality : '${d.modality}'`)})});break;case N:{let d=[];r.content.forEach(m=>{if(m.modality===C)d.push({text:m.value});else if(m.modality===$)d.push({function_call:{name:m.name,args:JSON.parse(m.arguments)}});else throw new x({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' cannot have content with modality : '${m.modality}'`)})}),a.push({role:this.modelSchema.roles[r.role],parts:d});}break;case z:{let d=[];r.content.forEach(m=>{if(m.modality===C)d.push({text:m.value});else if(m.modality===te){if(m.value.type==="base64"){let p=m.value.base64;p=e(p),d.push({inline_data:{mime_type:`image/${m.value.mediaType}`,data:p}});}else if(m.value.type==="url")throw new x({info:`Invalid message 'modality' for model : ${this.modelName}`,cause:new Error(`model: '${this.modelName}' does not support image content type: '${m.value.type}'`)})}else throw new x({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' cannot have content with modality : '${m.modality}'`)})}),a.push({role:this.modelSchema.roles[r.role],parts:d});}break;case ee:{let d=[];r.content.forEach(m=>{if(m.modality===oe)d.push({function_response:{name:m.name,response:JSON.parse(m.data)}});else throw new x({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' cannot have content with modality : '${m.modality}'`)})}),a.push({role:this.modelSchema.roles[r.role],parts:d});}break;default:throw new x({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' is not supported,
13
+ available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}}),a[0].role!==this.modelSchema.roles[z])throw new x({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires first message to be from user`)});let l=r=>r===this.modelSchema.roles[z]||r===this.modelSchema.roles[ee]?[this.modelSchema.roles[N]]:[this.modelSchema.roles[z],this.modelSchema.roles[ee]];for(let r=1;r<a.length;r++)if(!l(a[r-1].role).includes(a[r].role))throw new x({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' cannot have message with role : '${a[r].role}' after message with role : '${a[r-1].role}'`)});if(a[a.length-1].role!==this.modelSchema.roles[z]&&a[a.length-1].role!==this.modelSchema.roles[ee])throw new x({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires last message to be from user`)});return M({contents:a},i.parts.length>0?{system_instruction:i}:{})}transformTools(t){if(!this.modelSchema.modalities.includes($))throw new Qe({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${$}'`)});return !t||t&&t.length===0?{tools:[]}:{tools:[{function_declarations:t.map(e=>{let o=uo().safeParse(e);if(!o.success)throw new Qe({info:"Invalid tools",cause:o.error});return o.data}).map(e=>({name:e.definition.schema.name,description:e.definition.schema.description,parameters:e.definition.schema.parameters}))}]}}getCompleteChatUrl(t,e,o){return R(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getCompleteChatHeaders(t,e,o){return R(this,null,function*(){return new Promise(i=>{i(this.getDefaultHeaders());})})}getCompleteChatData(t,e,o){return R(this,null,function*(){let i=this.transformConfig(t,e,o),a=this.transformMessages(e);if(a.messages&&a.messages.length===0)throw new x({info:"Messages are required",cause:new Error("Messages are required")});let l=o?this.transformTools(o):{};return new Promise(r=>{r(M(M(M(M({},this.getDefaultParams()),i),a),l));})})}transformCompleteChatResponse(t){let e=Ra.safeParse(t);if(e.success){if(e.data.candidates.length===0)throw new w({info:"Invalid response from model",cause:new Error(`No choices in response : ${JSON.stringify(e.data)}`)});let o=e.data,i=[],a,l=o.candidates[0].content;if(l){let d=l.parts.map((m,p)=>{if("text"in m&&m.text!==void 0)return go(m.text);if("functionCall"in m&&m.functionCall!==void 0)return ho(p,`${m.functionCall.name}_${p}`,m.functionCall.name,JSON.stringify(m.functionCall.args))});return i.push({role:N,content:d}),o.usageMetadata&&(a={promptTokens:o.usageMetadata.promptTokenCount,totalTokens:o.usageMetadata.totalTokenCount,completionTokens:o.usageMetadata.candidatesTokenCount||0}),{messages:i,usage:a,logProbs:void 0}}let r=o.candidates[0].safetyRatings;if(r&&r.length>0&&r.forEach(d=>{if(d.blocked)throw new w({info:`Blocked content for category: ${d.category} with probability: ${d.probability}`,cause:new Error(`Blocked content for category: ${d.category} with probability: ${d.probability}`)})}),o.candidates[0].finishReason==="SAFETY")throw new w({info:"Blocked content, model response finished with safety reason",cause:new Error("Blocked content, model response finished with safety reason")})}throw new w({info:"Invalid response from model",cause:e.error})}getStreamChatUrl(t,e,o){return R(this,null,function*(){return new Promise(i=>{i(this.streamChatUrl);})})}getStreamChatHeaders(t,e,o){return R(this,null,function*(){return new Promise(i=>{i(this.getDefaultHeaders());})})}getStreamChatData(t,e,o){return R(this,null,function*(){let i=this.transformConfig(t,e,o),a=this.transformMessages(e);if(a.messages&&a.messages.length===0)throw new x({info:"Messages are required",cause:new Error("Messages are required")});let l=o?this.transformTools(o):{};return new Promise(r=>{r(M(M(M(M({},this.getDefaultParams()),i),a),l));})})}transformStreamChatResponseChunk(t,e){return Ao(this,null,function*(){let o=(e+t).split(",\r").filter(i=>i.trim()!=="");for(let i of o){let a=i;if(a=a.replace(/\n/g,""),a.startsWith("[")||a.startsWith(",{"))a=a.slice(1);else if(a.endsWith("]")){if(a==="]")return;a=a.slice(0,-1);}let l;try{l=JSON.parse(a);}catch(d){if(d instanceof SyntaxError){e=a;continue}else throw d}e="";let r=Ho.safeParse(l);if(r.success){let d={partialMessages:[]},m=r.data;if(m.candidates.length>0){let p=m.candidates[0].content;p&&"parts"in p&&p.parts.length>0&&p.parts.forEach((u,h)=>{if("text"in u&&u.text!==void 0&&d.partialMessages.push(Ze(N,u.text)),"functionCall"in u&&u.functionCall!==void 0){let g=u.functionCall;d.partialMessages.push(Xe(N,h,`${g.name}_${h}`,g.name,JSON.stringify(g.args)));}});}m.usageMetadata&&(d.usage={promptTokens:m.usageMetadata.promptTokenCount,completionTokens:m.usageMetadata.candidatesTokenCount,totalTokens:m.usageMetadata.totalTokenCount}),yield {partialResponse:d,buffer:e};}else throw new w({info:"Invalid response from model",cause:r.error})}yield {partialResponse:{partialMessages:[]},buffer:e};})}transformProxyStreamChatResponseChunk(t,e,o,i,a){return Ao(this,null,function*(){if((a==null?void 0:a.alt)!=="sse"){yield*Yt(_a(this.transformStreamChatResponseChunk(t,e)));return}let l=e+t,r=[],d="",m=0;for(;m<l.length;){let p=l.indexOf(`
14
+ `,m);if(p===-1){d=l.substring(m);break}else {let u=l.substring(m,p).trim();u&&r.push(u),m=p+1;}}for(let p of r){if(p==="data: [DONE]")return;if(p.startsWith("data: ")){let u=p.substring(6);try{let h=JSON.parse(u),g=Ho.safeParse(h);if(g.success){let f={partialMessages:[]},v=g.data;if(v.candidates.length>0){let _=v.candidates[0].content;_&&"parts"in _&&_.parts.length>0&&_.parts.forEach((j,Vt)=>{if("text"in j&&j.text!==void 0&&f.partialMessages.push(Ze(N,j.text)),"functionCall"in j&&j.functionCall!==void 0){let qe=j.functionCall;f.partialMessages.push(Xe(N,Vt,`${qe.name}_${Vt}`,qe.name,JSON.stringify(qe.args)));}});}v.usageMetadata&&v.usageMetadata.totalTokenCount&&v.usageMetadata.promptTokenCount&&v.usageMetadata.candidatesTokenCount&&(f.usage={promptTokens:v.usageMetadata.promptTokenCount,completionTokens:v.usageMetadata.candidatesTokenCount,totalTokens:v.usageMetadata.totalTokenCount}),yield {partialResponse:f,buffer:e};}else throw new w({info:"Invalid response from model",cause:g.error})}catch(h){throw new w({info:`Malformed JSON received in stream: ${u}`,cause:h})}}}yield {partialResponse:{partialMessages:[]},buffer:d};})}getProxyCompleteChatUrl(t,e,o){return R(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getProxyStreamChatUrl(t,e,o){return R(this,null,function*(){return new Promise(i=>{if(!o||Object.keys(o).length===0){i(this.streamChatUrl);return}let a=new URL(this.streamChatUrl);Object.entries(o).forEach(([l,r])=>{r!=null&&a.searchParams.set(l,r);}),i(a.toString());})})}getProxyCompleteChatHeaders(t,e,o){return R(this,null,function*(){if(!e)return {};let i=M({},e);return delete i.host,delete i["content-length"],i})}getProxyStreamChatHeaders(t,e,o){return R(this,null,function*(){return yield this.getProxyCompleteChatHeaders(t,e,o)})}getModelPricing(){if(!(this.modelName in G))throw new w({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return G[this.modelName]}},rt="gemini-1.5-flash-001",Da="Google's fastest, most cost-efficient multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",ke=F(B,V).parse({name:rt,description:Da,maxInputTokens:1e6,maxOutputTokens:8192,roles:A,modalities:H,config:{def:b.responseSchema(2,1,8192,4,.95).def,schema:b.responseSchema(2,1,8192,4,.95).schema},price:G[rt]}),qa=L,Ba=class extends I{constructor(t){super(ke,t);}},lt="gemini-1.5-flash-002",Aa="Google's fastest, most cost-efficient multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",xe=F(B,V).parse({name:lt,description:Aa,maxInputTokens:1e6,maxOutputTokens:8192,roles:A,modalities:H,config:{def:b.responseSchema(2,1,8192,4,.95).def,schema:b.responseSchema(2,1,8192,4,.95).schema},price:G[lt]}),Ha=L,Va=class extends I{constructor(t){super(xe,t);}},mt="gemini-1.5-flash-latest",za="Google's latest multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",pn=F(B,V).parse({name:mt,description:za,maxInputTokens:1e6,maxOutputTokens:8192,roles:A,modalities:H,config:{def:b.responseSchema(2,1,8192,4,.95).def,schema:b.responseSchema(2,1,8192,4,.95).schema},price:G[mt]}),Ka=L,Ya=class extends I{constructor(t){super(pn,t);}},dt="gemini-1.5-flash",Ja="Google's fastest, most cost-efficient multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",Pe=F(B,V).parse({name:dt,description:Ja,maxInputTokens:1e6,maxOutputTokens:8192,roles:A,modalities:H,config:{def:b.responseSchema(2,1,8192,4,.95).def,schema:b.responseSchema(2,1,8192,4,.95).schema},price:G[dt]}),Wa=L,Za=class extends I{constructor(t){super(Pe,t);}},ct="gemini-1.5-pro-001",Xa="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",ve=F(B,V).parse({name:ct,description:Xa,maxInputTokens:2e6,maxOutputTokens:8192,roles:A,modalities:H,config:{def:b.responseSchema(2,1,8192,4,.95).def,schema:b.responseSchema(2,1,8192,4,.95).schema},price:G[ct]}),Qa=L,es=class extends I{constructor(t){super(ve,t);}},pt="gemini-1.5-pro-002",ts="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",Ce=F(B,V).parse({name:pt,description:ts,maxInputTokens:2e6,maxOutputTokens:8192,roles:A,modalities:H,config:{def:b.responseSchema(2,1,8192,4,.95).def,schema:b.responseSchema(2,1,8192,4,.95).schema},price:G[pt]}),os=L,ns=class extends I{constructor(t){super(Ce,t);}},ut="gemini-1.5-pro-latest",is="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",un=F(B,V).parse({name:ut,description:is,maxInputTokens:2e6,maxOutputTokens:8192,roles:A,modalities:H,config:{def:b.responseSchema(2,1,8192,4,.95).def,schema:b.responseSchema(2,1,8192,4,.95).schema},price:G[ut]}),as=L,ss=class extends I{constructor(t){super(un,t);}},gt="gemini-1.5-pro",rs="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",Se=F(B,V).parse({name:gt,description:rs,maxInputTokens:2e6,maxOutputTokens:8192,roles:A,modalities:H,config:{def:b.responseSchema(2,1,8192,4,.95).def,schema:b.responseSchema(2,1,8192,4,.95).schema},price:G[gt]}),ls=L,ms=class extends I{constructor(t){super(Se,t);}},ht="gemini-2.0-flash-exp",ds="Google's experimental multimodal model with enhanced capabilities. Designed for cutting-edge performance across complex and high-frequency tasks.",Oe=F(B,V).parse({name:ht,description:ds,maxInputTokens:1e6,maxOutputTokens:8192,roles:A,modalities:H,config:{def:b.responseSchema(2,1,8192,4,.95).def,schema:b.responseSchema(2,1,8192,4,.95).schema},price:G[ht]}),cs=L,ps=class extends I{constructor(t){super(Oe,t);}},ft="gemini-2.5-flash-preview-04-17",us="Google's best model in Gemini 2.5 family in terms of price-performance, offering well-rounded capabilities.",gn=F(B,V).parse({name:ft,description:us,maxInputTokens:1048576,maxOutputTokens:65536,roles:A,modalities:H,config:{def:b.responseSchema(2,1,65536,4,.95).def,schema:b.responseSchema(2,1,65536,4,.95).schema},price:G[ft]}),gs=L,hs=class extends I{constructor(t){super(gn,t);}},bt="gemini-2.5-pro-preview-03-25",fs="Google's preview model in Gemini 2.5 family for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",hn=F(B,V).parse({name:bt,description:fs,maxInputTokens:1048576,maxOutputTokens:65536,roles:A,modalities:H,config:{def:b.reasoning(2,1,65536,4,.95).def,schema:b.reasoning(2,1,65536,4,.95).schema},price:G[bt]}),bs=L,ys=class extends I{constructor(t){super(hn,t);}},fn=[S],bn=zod.z.enum([S]),Ts=zod.z.object({embeddings:zod.z.array(zod.z.object({values:zod.z.array(zod.z.number())}))}),Ms=zod.z.object({model:zod.z.string().min(1),content:zod.z.object({parts:zod.z.array(zod.z.object({text:zod.z.string().min(1)})).min(1)})}),_s=zod.z.object({model:zod.z.string().min(1).optional(),requests:zod.z.array(Ms).min(1),outputDimensionality:zod.z.number().int().min(1).optional()}),Mt=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),getEmbeddingsUrl:zod.z.string().url().optional()}),yn=class{constructor(t,e){this.version="v1";let o=Mt.parse(e);this.modelSchema=t,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=ce(o.baseUrl||Tt.baseUrl),this.getEmbeddingsUrl=ce(o.getEmbeddingsUrl||`${this.baseUrl}/models/${this.modelName}:batchEmbedContents?key=${this.apiKey}`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"Content-Type":"application/json"}}getDefaultParams(){return {model:this.modelName}}getRetryDelay(t){return {shouldRetry:!1,delayMs:0}}getTokenCount(t){return t.requests.reduce((e,o)=>e+o.length,0)}transformModelRequest(t){let e=_s.safeParse(t);if(!e.success)throw new Z({info:"Invalid model request",cause:e.error});let o=e.data,i=o.model,a={outputDimensionality:o.outputDimensionality},l=ue().parse(fe(a)),r={modality:S,requests:o.requests.reduce((d,m)=>(d.push(...m.content.parts.map(p=>p.text)),d),[])};return {modelName:i,config:l,embeddingRequests:r}}transformConfig(t,e){let o=this.modelSchema.config.schema.safeParse(t);if(!o.success)throw new D({info:`Invalid config for model : '${this.modelName}'`,cause:o.error});let i=o.data;return Object.keys(i).forEach(a=>{if(!this.modelSchema.config.def[a])throw new D({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${a}',
15
+ available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(i).reduce((a,l)=>{let r=this.modelSchema.config.def[l].param,d=i[l];return a[r]=d,a},{})}transformEmbeddingRequests(t){let e=ye().safeParse(t);if(!e.success)throw new ne({info:"Invalid embedding requests",cause:e.error});if(t.modality!==S)throw new ne({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Only '${S}' modality is supported for model : '${this.modelName}'`)});return {requests:e.data.requests.map(o=>({model:`models/${this.modelName}`,content:{parts:[{text:o}]}}))}}getGetEmbeddingsUrl(t,e){return R(this,null,function*(){return new Promise(o=>{o(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(t,e){return R(this,null,function*(){return new Promise(o=>{o(this.getDefaultHeaders());})})}getGetEmbeddingsData(t,e){return R(this,null,function*(){return new Promise(o=>{let i=this.transformConfig(t),a=this.transformEmbeddingRequests(e);if(e.requests.length===0)throw new ne({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error("requests cannot be empty")});i.outputDimensionality&&(a.requests.forEach(l=>{l.outputDimensionality=i.outputDimensionality;}),delete i.outputDimensionality),o(M(M(M({},this.getDefaultParams()),i),a));})})}transformGetEmbeddingsResponse(t){let e=Ts.safeParse(t);if(e.success){let o=e.data.embeddings.map((i,a)=>({index:a,embedding:i.values}));return {encodingFormat:ge,embeddings:o}}throw new w({info:"Invalid response from model",cause:e.error})}},Tn="text-embedding-001",Es="text-embedding-001",Mn=q(bn).parse({name:Tn,description:Es,modalities:fn,maxInputTokens:2048,maxOutputTokens:768,config:{def:Ee.base(768).def,schema:Ee.base(768).schema}}),ks=Mt,xs=class extends yn{constructor(t){super(Mn,t);}},_n="text-embedding-004",Ps="text-embedding-004",En=q(bn).parse({name:_n,description:Ps,modalities:fn,maxInputTokens:2048,maxOutputTokens:768,config:{def:Ee.base(768).def,schema:Ee.base(768).schema}}),vs=Mt,Cs=class extends yn{constructor(t){super(En,t);}};var Ss="vertex",se=class{constructor(){this.version="v1";this.name=Ss;this.chatModelFactories={[_t]:{model:we,modelOptions:kn,modelSchema:Et},[kt]:{model:Re,modelOptions:xn,modelSchema:xt},[Pt]:{model:Ge,modelOptions:Pn,modelSchema:vt},[Ct]:{model:Ie,modelOptions:vn,modelSchema:St},[Ot]:{model:je,modelOptions:Cn,modelSchema:wt},[Rt]:{model:Ne,modelOptions:Sn,modelSchema:Gt},[It]:{model:Fe,modelOptions:On,modelSchema:jt}};this.embeddingModelFactories={[Nt]:{model:Le,modelOptions:wn,modelSchema:Ft},[Lt]:{model:Ue,modelOptions:Rn,modelSchema:Ut},[qt]:{model:De,modelOptions:In,modelSchema:Bt},[$t]:{model:$e,modelOptions:Gn,modelSchema:Dt}};}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 me({info:`Vertex chat model: ${o} not found`,cause:new Error(`Vertex chat model: ${o} not found, available chat models:
16
16
  ${this.chatModelLiterals().join(", ")}`)});let i=this.chatModelFactories[o].model,a=this.chatModelFactories[o].modelOptions.parse(e);return new i(a)}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 me({info:`Vertex embedding model: ${o} not found`,cause:new Error(`Vertex embedding model: ${o} not found, available embedding models:
17
- ${this.embeddingModelLiterals().join(", ")}`)});let i=this.embeddingModelFactories[o].model,a=this.embeddingModelFactories[o].modelOptions.parse(e);return new i(a)}};se.baseUrl=(e,o,i="google")=>`https://${e}-aiplatform.googleapis.com/v1/projects/${o}/locations/${e}/publishers/${i}`;var E={"gemini-1.0-pro-001":{modelName:"gemini-1.0-pro-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro-vision":{modelName:"gemini-1.0-pro-vision",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro":{modelName:"gemini-1.0-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.5-flash-001":{modelName:"gemini-1.5-flash-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-flash-002":{modelName:"gemini-1.5-flash-002",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.0375,outputPricePerMillion:.15}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}}]},"gemini-1.5-flash":{modelName:"gemini-1.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-pro-001":{modelName:"gemini-1.5-pro-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro-002":{modelName:"gemini-1.5-pro-002",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro":{modelName:"gemini-1.5-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-2.0-flash-exp":{modelName:"gemini-2.0-flash-exp",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]}};var O=zod.z.object({accessToken:zod.z.string(),modelName:zod.z.string(),baseUrl:zod.z.string().url().optional(),location:zod.z.string().optional(),projectId:zod.z.string().optional(),publisher:zod.z.string().optional()}),P=class extends I{constructor(o,i){let a=O.parse(i),l;if(a.baseUrl)l=a.baseUrl;else if(a.location&&a.projectId)l=se.baseUrl(a.location,a.projectId,a.publisher);else throw new Te({info:"Either 'baseUrl' must be provided or 'location' and 'projectId' must be provided",cause:new Error("Either 'baseUrl' must be provided or 'location' and 'projectId' must be provided")});super(o,{modelName:a.modelName,apiKey:"random-api-key",completeChatUrl:`${l}/models/${a.modelName}:generateContent`,streamChatUrl:`${l}/models/${a.modelName}:streamGenerateContent`});this.version="v1";this.modelSchema=o,this.modelName=a.modelName,this.accessToken=a.accessToken,this.location=a.location,this.projectId=a.projectId,this.publisher=a.publisher;}getDefaultHeaders(){return k(y({},super.getDefaultHeaders()),{Authorization:`Bearer ${this.accessToken}`})}getModelPricing(){if(!(this.modelName in E))throw new w({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return E[this.modelName]}};var _t="gemini-1.5-flash-001",Et=k(y({},ke),{price:E[_t]}),kn=O,we=class extends P{constructor(e){super(Et,e);}};var kt="gemini-1.5-flash-002",xt=k(y({},xe),{price:E[kt]}),xn=O,Re=class extends P{constructor(e){super(xt,e);}};var Pt="gemini-1.5-flash",vt=k(y({},Pe),{price:E[Pt]}),Pn=O,Ge=class extends P{constructor(e){super(vt,e);}};var Ct="gemini-1.5-pro-001",St=k(y({},ve),{price:E[Ct]}),vn=O,Ie=class extends P{constructor(e){super(St,e);}};var Ot="gemini-1.5-pro-002",wt=k(y({},Ce),{price:E[Ot]}),Cn=O,je=class extends P{constructor(e){super(wt,e);}};var Rt="gemini-1.5-pro",Gt=k(y({},Se),{price:E[Rt]}),Sn=O,Ne=class extends P{constructor(e){super(Gt,e);}};var It="gemini-2.0-flash-exp",jt=k(y({},Oe),{price:E[It]}),On=O,Fe=class extends P{constructor(e){super(jt,e);}};var ie=[S],ae=zod.z.enum([S]);var jn=zod.z.object({predictions:zod.z.array(zod.z.object({embeddings:zod.z.object({values:zod.z.array(zod.z.number()),statistics:zod.z.object({token_count:zod.z.number(),truncated:zod.z.boolean()})})}))});var Nn=zod.z.object({model:zod.z.string().min(1).optional(),instances:zod.z.array(zod.z.object({content:zod.z.string().min(1)})).min(1),parameters:zod.z.object({auto_truncate:zod.z.boolean().optional(),output_dimensionality:zod.z.number().int().min(1).optional(),autoTruncate:zod.z.boolean().optional(),outputDimensionality:zod.z.number().int().min(1).optional()}).optional()});var Q=zod.z.object({accessToken:zod.z.string(),modelName:zod.z.string(),baseUrl:zod.z.string().url().optional(),location:zod.z.string().optional(),projectId:zod.z.string().optional(),publisher:zod.z.string().optional()}),W=class{constructor(e,o){this.version="v1";let i=Q.parse(o);this.modelSchema=e,this.modelName=i.modelName,this.accessToken=i.accessToken;let a;if(i.baseUrl)a=i.baseUrl;else if(i.location&&i.projectId)a=se.baseUrl(i.location,i.projectId,i.publisher);else throw new Te({info:"Either 'baseUrl' must be provided or 'location' and 'projectId' must be provided",cause:new Error("Either 'baseUrl' must be provided or 'location' and 'projectId' must be provided")});this.baseUrl=a,this.getEmbeddingsUrl=`${this.baseUrl}/models/${i.modelName}:predict`,this.location=i.location,this.projectId=i.projectId;}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"Content-Type":"application/json",Authorization:`Bearer ${this.accessToken}`}}getDefaultParams(){return {}}getRetryDelay(e){return {shouldRetry:!1,delayMs:0}}getTokenCount(e){return e.requests.reduce((o,i)=>o+i.length,0)}transformModelRequest(e){var m,p,u,h;let o=Nn.safeParse(e);if(!o.success)throw new Z({info:"Invalid model request",cause:o.error});let i=o.data,a=i.model,l={autoTruncate:((m=i.parameters)==null?void 0:m.auto_truncate)||((p=i.parameters)==null?void 0:p.autoTruncate),dimensions:((u=i.parameters)==null?void 0:u.output_dimensionality)||((h=i.parameters)==null?void 0:h.outputDimensionality)},r=ue().parse(fe(l)),d={modality:S,requests:i.instances.map(g=>g.content)};return {modelName:a,config:r,embeddingRequests:d}}transformConfig(e,o){let i=this.modelSchema.config.schema.safeParse(e);if(!i.success)throw new D({info:`Invalid config for model : '${this.modelName}'`,cause:i.error});let a=i.data;return Object.keys(a).forEach(r=>{if(!this.modelSchema.config.def[r])throw new D({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${r}',
18
- available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),{parameters:Object.keys(a).reduce((r,d)=>{let p=this.modelSchema.config.def[d].param,u=a[d];return r[p]=u,r},{})}}transformEmbeddingRequests(e){let o=ye().safeParse(e);if(!o.success)throw new ne({info:"Invalid embedding requests",cause:o.error});if(e.modality!==S)throw new ne({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Only '${S}' modality is supported for model : '${this.modelName}'`)});return {instances:o.data.requests.map(a=>({content:a}))}}getGetEmbeddingsUrl(e,o){return be(this,null,function*(){return new Promise(i=>{i(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(e,o){return be(this,null,function*(){return new Promise(i=>{i(this.getDefaultHeaders());})})}getGetEmbeddingsData(e,o){return be(this,null,function*(){return new Promise(i=>{if(o.requests.length===0)throw new ne({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error("requests cannot be empty")});i(y(y(y({},this.getDefaultParams()),this.transformConfig(e)),this.transformEmbeddingRequests(o)));})})}transformGetEmbeddingsResponse(e){let o=jn.safeParse(e);if(o.success){let a=o.data.predictions.map((l,r)=>({index:r,embedding:l.embeddings.values}));return {encodingFormat:ge,embeddings:a}}throw new w({info:"Invalid response from model",cause:o.error})}};var At=t=>K({param:"output_dimensionality",title:de.DIMENSIONS.title,description:de.DIMENSIONS.description,min:1,max:t,step:1,default:t}),Ht=Me({param:"auto_truncate",title:"Auto truncate",description:"When set to true, input text will be truncated. When set to false, an error is returned if the input text is longer than the maximum length supported by the model.",default:!0});var Fn=t=>zod.z.object({dimensions:At(t).schema,autoTruncate:Ht.schema}),Ln=t=>({dimensions:At(t).def,autoTruncate:Ht.def});var $={base:t=>({def:Ln(t),schema:Fn(t)})};var Nt="text-embedding-004",Os="text-embedding-004",Ft=q(ae).parse({name:Nt,description:Os,modalities:ie,maxInputTokens:2048,maxOutputTokens:768,config:{def:$.base(768).def,schema:$.base(768).schema}}),wn=Q,Le=class extends W{constructor(e){super(Ft,e);}};var Lt="text-multilingual-embedding-002",ws="text-multilingual-embedding-002",$t=q(ae).parse({name:Lt,description:ws,modalities:ie,maxInputTokens:2048,maxOutputTokens:768,config:{def:$.base(768).def,schema:$.base(768).schema}}),Rn=Q,$e=class extends W{constructor(e){super($t,e);}};var Ut="textembedding-gecko-multilingual@001",Rs="textembedding-gecko-multilingual@001",Dt=q(ae).parse({name:Ut,description:Rs,modalities:ie,maxInputTokens:2048,maxOutputTokens:768,config:{def:$.base(768).def,schema:$.base(768).schema}}),Gn=Q,Ue=class extends W{constructor(e){super(Dt,e);}};var qt="textembedding-gecko@003",Gs="textembedding-gecko@003",Bt=q(ae).parse({name:qt,description:Gs,modalities:ie,maxInputTokens:2048,maxOutputTokens:768,config:{def:$.base(768).def,schema:$.base(768).schema}}),In=Q,De=class extends W{constructor(e){super(Bt,e);}};
17
+ ${this.embeddingModelLiterals().join(", ")}`)});let i=this.embeddingModelFactories[o].model,a=this.embeddingModelFactories[o].modelOptions.parse(e);return new i(a)}};se.baseUrl=(e,o,i="google")=>`https://${e}-aiplatform.googleapis.com/v1/projects/${o}/locations/${e}/publishers/${i}`;var E={"gemini-1.0-pro-001":{modelName:"gemini-1.0-pro-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro-vision":{modelName:"gemini-1.0-pro-vision",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro":{modelName:"gemini-1.0-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.5-flash-001":{modelName:"gemini-1.5-flash-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-flash-002":{modelName:"gemini-1.5-flash-002",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.0375,outputPricePerMillion:.15}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}}]},"gemini-1.5-flash":{modelName:"gemini-1.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-pro-001":{modelName:"gemini-1.5-pro-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro-002":{modelName:"gemini-1.5-pro-002",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro":{modelName:"gemini-1.5-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-2.0-flash-exp":{modelName:"gemini-2.0-flash-exp",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]}};var O=zod.z.object({accessToken:zod.z.string(),modelName:zod.z.string(),baseUrl:zod.z.string().url().optional(),location:zod.z.string().optional(),projectId:zod.z.string().optional(),publisher:zod.z.string().optional()}),P=class extends I{constructor(o,i){let a=O.parse(i),l;if(a.baseUrl)l=a.baseUrl;else if(a.location&&a.projectId)l=se.baseUrl(a.location,a.projectId,a.publisher);else throw new Te({info:"Either 'baseUrl' must be provided or 'location' and 'projectId' must be provided",cause:new Error("Either 'baseUrl' must be provided or 'location' and 'projectId' must be provided")});super(o,{modelName:a.modelName,apiKey:"random-api-key",completeChatUrl:`${l}/models/${a.modelName}:generateContent`,streamChatUrl:`${l}/models/${a.modelName}:streamGenerateContent`});this.version="v1";this.modelSchema=o,this.modelName=a.modelName,this.accessToken=a.accessToken,this.location=a.location,this.projectId=a.projectId,this.publisher=a.publisher;}getDefaultHeaders(){return k(y({},super.getDefaultHeaders()),{Authorization:`Bearer ${this.accessToken}`})}getModelPricing(){if(!(this.modelName in E))throw new w({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return E[this.modelName]}};var _t="gemini-1.5-flash-001",Et=k(y({},ke),{price:E[_t]}),kn=O,we=class extends P{constructor(e){super(Et,e);}};var kt="gemini-1.5-flash-002",xt=k(y({},xe),{price:E[kt]}),xn=O,Re=class extends P{constructor(e){super(xt,e);}};var Pt="gemini-1.5-flash",vt=k(y({},Pe),{price:E[Pt]}),Pn=O,Ge=class extends P{constructor(e){super(vt,e);}};var Ct="gemini-1.5-pro-001",St=k(y({},ve),{price:E[Ct]}),vn=O,Ie=class extends P{constructor(e){super(St,e);}};var Ot="gemini-1.5-pro-002",wt=k(y({},Ce),{price:E[Ot]}),Cn=O,je=class extends P{constructor(e){super(wt,e);}};var Rt="gemini-1.5-pro",Gt=k(y({},Se),{price:E[Rt]}),Sn=O,Ne=class extends P{constructor(e){super(Gt,e);}};var It="gemini-2.0-flash-exp",jt=k(y({},Oe),{price:E[It]}),On=O,Fe=class extends P{constructor(e){super(jt,e);}};var ie=[S],ae=zod.z.enum([S]);var jn=zod.z.object({predictions:zod.z.array(zod.z.object({embeddings:zod.z.object({values:zod.z.array(zod.z.number()),statistics:zod.z.object({token_count:zod.z.number(),truncated:zod.z.boolean()})})}))});var Nn=zod.z.object({model:zod.z.string().min(1).optional(),instances:zod.z.array(zod.z.object({content:zod.z.string().min(1)})).min(1),parameters:zod.z.object({auto_truncate:zod.z.boolean().optional(),output_dimensionality:zod.z.number().int().min(1).optional(),autoTruncate:zod.z.boolean().optional(),outputDimensionality:zod.z.number().int().min(1).optional()}).optional()});var Q=zod.z.object({accessToken:zod.z.string(),modelName:zod.z.string(),baseUrl:zod.z.string().url().optional(),location:zod.z.string().optional(),projectId:zod.z.string().optional(),publisher:zod.z.string().optional()}),J=class{constructor(e,o){this.version="v1";let i=Q.parse(o);this.modelSchema=e,this.modelName=i.modelName,this.accessToken=i.accessToken;let a;if(i.baseUrl)a=i.baseUrl;else if(i.location&&i.projectId)a=se.baseUrl(i.location,i.projectId,i.publisher);else throw new Te({info:"Either 'baseUrl' must be provided or 'location' and 'projectId' must be provided",cause:new Error("Either 'baseUrl' must be provided or 'location' and 'projectId' must be provided")});this.baseUrl=a,this.getEmbeddingsUrl=`${this.baseUrl}/models/${i.modelName}:predict`,this.location=i.location,this.projectId=i.projectId;}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"Content-Type":"application/json",Authorization:`Bearer ${this.accessToken}`}}getDefaultParams(){return {}}getRetryDelay(e){return {shouldRetry:!1,delayMs:0}}getTokenCount(e){return e.requests.reduce((o,i)=>o+i.length,0)}transformModelRequest(e){var m,p,u,h;let o=Nn.safeParse(e);if(!o.success)throw new Z({info:"Invalid model request",cause:o.error});let i=o.data,a=i.model,l={autoTruncate:((m=i.parameters)==null?void 0:m.auto_truncate)||((p=i.parameters)==null?void 0:p.autoTruncate),dimensions:((u=i.parameters)==null?void 0:u.output_dimensionality)||((h=i.parameters)==null?void 0:h.outputDimensionality)},r=ue().parse(fe(l)),d={modality:S,requests:i.instances.map(g=>g.content)};return {modelName:a,config:r,embeddingRequests:d}}transformConfig(e,o){let i=this.modelSchema.config.schema.safeParse(e);if(!i.success)throw new D({info:`Invalid config for model : '${this.modelName}'`,cause:i.error});let a=i.data;return Object.keys(a).forEach(r=>{if(!this.modelSchema.config.def[r])throw new D({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${r}',
18
+ available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),{parameters:Object.keys(a).reduce((r,d)=>{let p=this.modelSchema.config.def[d].param,u=a[d];return r[p]=u,r},{})}}transformEmbeddingRequests(e){let o=ye().safeParse(e);if(!o.success)throw new ne({info:"Invalid embedding requests",cause:o.error});if(e.modality!==S)throw new ne({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Only '${S}' modality is supported for model : '${this.modelName}'`)});return {instances:o.data.requests.map(a=>({content:a}))}}getGetEmbeddingsUrl(e,o){return be(this,null,function*(){return new Promise(i=>{i(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(e,o){return be(this,null,function*(){return new Promise(i=>{i(this.getDefaultHeaders());})})}getGetEmbeddingsData(e,o){return be(this,null,function*(){return new Promise(i=>{if(o.requests.length===0)throw new ne({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error("requests cannot be empty")});i(y(y(y({},this.getDefaultParams()),this.transformConfig(e)),this.transformEmbeddingRequests(o)));})})}transformGetEmbeddingsResponse(e){let o=jn.safeParse(e);if(o.success){let a=o.data.predictions.map((l,r)=>({index:r,embedding:l.embeddings.values}));return {encodingFormat:ge,embeddings:a}}throw new w({info:"Invalid response from model",cause:o.error})}};var At=t=>K({param:"output_dimensionality",title:de.DIMENSIONS.title,description:de.DIMENSIONS.description,min:1,max:t,step:1,default:t}),Ht=Me({param:"auto_truncate",title:"Auto truncate",description:"When set to true, input text will be truncated. When set to false, an error is returned if the input text is longer than the maximum length supported by the model.",default:!0});var Fn=t=>zod.z.object({dimensions:At(t).schema,autoTruncate:Ht.schema}),Ln=t=>({dimensions:At(t).def,autoTruncate:Ht.def});var U={base:t=>({def:Ln(t),schema:Fn(t)})};var Nt="text-embedding-004",Gs="text-embedding-004",Ft=q(ae).parse({name:Nt,description:Gs,modalities:ie,maxInputTokens:2048,maxOutputTokens:768,config:{def:U.base(768).def,schema:U.base(768).schema}}),wn=Q,Le=class extends J{constructor(e){super(Ft,e);}};var Lt="text-multilingual-embedding-002",Is="text-multilingual-embedding-002",Ut=q(ae).parse({name:Lt,description:Is,modalities:ie,maxInputTokens:2048,maxOutputTokens:768,config:{def:U.base(768).def,schema:U.base(768).schema}}),Rn=Q,Ue=class extends J{constructor(e){super(Ut,e);}};var $t="textembedding-gecko-multilingual@001",js="textembedding-gecko-multilingual@001",Dt=q(ae).parse({name:$t,description:js,modalities:ie,maxInputTokens:2048,maxOutputTokens:768,config:{def:U.base(768).def,schema:U.base(768).schema}}),Gn=Q,$e=class extends J{constructor(e){super(Dt,e);}};var qt="textembedding-gecko@003",Ns="textembedding-gecko@003",Bt=q(ae).parse({name:qt,description:Ns,modalities:ie,maxInputTokens:2048,maxOutputTokens:768,config:{def:U.base(768).def,schema:U.base(768).schema}}),In=Q,De=class extends J{constructor(e){super(Bt,e);}};
19
19
 
20
20
  exports.BaseChatModelOptions = O;
21
21
  exports.BaseChatModelVertex = P;
22
- exports.BaseEmbeddingModel = W;
22
+ exports.BaseEmbeddingModel = J;
23
23
  exports.BaseEmbeddingModelOptions = Q;
24
24
  exports.Gemini1_5Flash = Ge;
25
25
  exports.Gemini1_5Flash001 = we;
@@ -57,14 +57,14 @@ exports.Text_Embedding_Gecko_003 = De;
57
57
  exports.Text_Embedding_Gecko_003Literal = qt;
58
58
  exports.Text_Embedding_Gecko_003Options = In;
59
59
  exports.Text_Embedding_Gecko_003Schema = Bt;
60
- exports.Text_Embedding_Gecko_Multilingual_001 = Ue;
61
- exports.Text_Embedding_Gecko_Multilingual_001Literal = Ut;
60
+ exports.Text_Embedding_Gecko_Multilingual_001 = $e;
61
+ exports.Text_Embedding_Gecko_Multilingual_001Literal = $t;
62
62
  exports.Text_Embedding_Gecko_Multilingual_001Options = Gn;
63
63
  exports.Text_Embedding_Gecko_Multilingual_001Schema = Dt;
64
- exports.Text_Multilingual_Embedding_002 = $e;
64
+ exports.Text_Multilingual_Embedding_002 = Ue;
65
65
  exports.Text_Multilingual_Embedding_002Literal = Lt;
66
66
  exports.Text_Multilingual_Embedding_002Options = Rn;
67
- exports.Text_Multilingual_Embedding_002Schema = $t;
67
+ exports.Text_Multilingual_Embedding_002Schema = Ut;
68
68
  exports.Vertex = se;
69
69
  //# sourceMappingURL=index.js.map
70
70
  //# sourceMappingURL=index.js.map