@adaline/vertex 1.13.1 → 1.13.2
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 +90 -90
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
var jose = require('jose');
|
|
4
4
|
var zod = require('zod');
|
|
5
5
|
|
|
6
|
-
var Ia=Object.defineProperty,La=Object.defineProperties;var ja=Object.getOwnPropertyDescriptors;var yo=Object.getOwnPropertySymbols;var Na=Object.prototype.hasOwnProperty,Ua=Object.prototype.propertyIsEnumerable;var Ct=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Da=e=>{throw TypeError(e)};var bo=(e,t,o)=>t in e?Ia(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,y=(e,t)=>{for(var o in t||(t={}))Na.call(t,o)&&bo(e,o,t[o]);if(yo)for(var o of yo(t))Ua.call(t,o)&&bo(e,o,t[o]);return e},_=(e,t)=>La(e,ja(t));var X=(e,t,o)=>new Promise((n,s)=>{var r=d=>{try{m(o.next(d));}catch(c){s(c);}},l=d=>{try{m(o.throw(d));}catch(c){s(c);}},m=d=>d.done?n(d.value):Promise.resolve(d.value).then(r,l);m((o=o.apply(e,t)).next());}),$a=function(e,t){this[0]=e,this[1]=t;};var To=e=>{var t=e[Ct("asyncIterator")],o=!1,n,s={};return t==null?(t=e[Ct("iterator")](),n=r=>s[r]=l=>t[r](l)):(t=t.call(e),n=r=>s[r]=l=>{if(o){if(o=!1,r==="throw")throw l;return l}return o=!0,{done:!1,value:new $a(new Promise(m=>{var d=t[r](l);d instanceof Object||Da("Object expected"),m(d);}),1)}}),s[Ct("iterator")]=()=>s,n("next"),"throw"in t?n("throw"):s.throw=r=>{throw r},"return"in t&&n("return"),s};var Ee="system",Q="user",F="assistant",ee="tool",Ba=[Ee,Q,F,ee],Ot=zod.z.enum(Ba),Aa=[F],qa=zod.z.enum(Aa),be="error",Re="safety",za=zod.z.object({type:zod.z.literal(Re),value:zod.z.object({category:zod.z.string(),probability:zod.z.string(),blocked:zod.z.boolean(),message:zod.z.string()})}),_o=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(be),value:zod.z.discriminatedUnion("type",[za]),metadata:e}),Rt="partial-error",Ha=zod.z.object({type:zod.z.literal(Re),category:zod.z.string().optional(),probability:zod.z.string().optional(),blocked:zod.z.boolean().optional(),message:zod.z.string().optional()}),ko=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Rt),value:zod.z.discriminatedUnion("type",[Ha]),metadata:e}),le="image",Ft="base64",Va=["png","jpeg","webp","gif"],Ka=zod.z.object({type:zod.z.literal(Ft),base64:zod.z.string(),mediaType:zod.z.enum(Va)}),Ya="url",Ja=zod.z.object({type:zod.z.literal(Ya),url:zod.z.string()}),Wa=zod.z.discriminatedUnion("type",[Ka,Ja]),Za=["low","medium","high","auto"],Xa=zod.z.enum(Za),Qa=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(le),detail:Xa,value:Wa,metadata:e}),ge="pdf",es="base64",ts=zod.z.object({type:zod.z.literal(es),base64:zod.z.string()}),is="url",os=zod.z.object({type:zod.z.literal(is),url:zod.z.string()}),ns=zod.z.discriminatedUnion("type",[ts,os]),as=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(ge),value:ns,file:zod.z.object({name:zod.z.string(),id:zod.z.string(),size:zod.z.number().optional()}),metadata:e}),he="reasoning",It="partial-reasoning",Fe="thinking",ss="redacted",Gt=zod.z.object({type:zod.z.literal(Fe),thinking:zod.z.string(),signature:zod.z.string()}),So=zod.z.object({type:zod.z.literal(ss),data:zod.z.string()}),rs=zod.z.discriminatedUnion("type",[Gt,So]),xo=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(he),value:rs,metadata:e}),ls=zod.z.object({type:zod.z.literal(Fe),thinking:Gt.shape.thinking.optional(),signature:Gt.shape.signature.optional()}),ms=zod.z.discriminatedUnion("type",[ls,So]),Eo=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(It),value:ms,metadata:e}),Te="search-result",Ie="google",ds=zod.z.object({type:zod.z.literal(Ie),query:zod.z.string(),responses:zod.z.array(zod.z.object({source:zod.z.string(),url:zod.z.string(),title:zod.z.string(),snippet:zod.z.string().optional()})),references:zod.z.array(zod.z.object({text:zod.z.string(),responseIndices:zod.z.array(zod.z.number()),startIndex:zod.z.number().optional(),endIndex:zod.z.number().optional(),confidenceScores:zod.z.array(zod.z.number()).optional()}))}),Co=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Te),value:zod.z.discriminatedUnion("type",[ds]),metadata:e}),Lt="partial-search-result",cs=zod.z.object({type:zod.z.literal(Ie),query:zod.z.string().optional(),responses:zod.z.array(zod.z.object({source:zod.z.string().optional(),url:zod.z.string().optional(),title:zod.z.string().optional(),snippet:zod.z.string().optional()})).optional(),references:zod.z.array(zod.z.object({text:zod.z.string().optional(),responseIndices:zod.z.array(zod.z.number()).optional(),startIndex:zod.z.number().optional(),endIndex:zod.z.number().optional(),confidenceScores:zod.z.array(zod.z.number()).optional()})).optional()}),wo=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Lt),value:zod.z.discriminatedUnion("type",[cs]),metadata:e}),B="text",Go=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(B),value:zod.z.string(),metadata:e}),jt="partial-text",Oo=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(jt),value:zod.z.string(),metadata:e}),Y="tool-call",Ro=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Y),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),arguments:zod.z.string(),serverName:zod.z.string().optional(),thoughtSignature:zod.z.string().optional(),metadata:e}),Nt="partial-tool-call",Fo=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Nt),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),arguments:zod.z.string().optional(),serverName:zod.z.string().optional(),thoughtSignature:zod.z.string().optional(),metadata:e}),me="tool-response",ps=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(me),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:e}),us="partial-tool-response",gs=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(us),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),data:zod.z.string().optional(),apiResponse:zod.z.object({statusCode:zod.z.number().int().nonnegative()}).optional(),metadata:e}),hs=[B,le,ge,Y,me,he,be,Te],Io=zod.z.enum(hs),fs=(e=zod.z.undefined(),t=zod.z.undefined(),o=zod.z.undefined(),n=zod.z.undefined(),s=zod.z.undefined(),r=zod.z.undefined(),l=zod.z.undefined(),m=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[Go(e),Qa(t),as(o),Ro(n),ps(s),xo(r),_o(l),Co(m)]),ys=[jt,Nt,It,Rt,Lt];zod.z.enum(ys);var bs=(e=zod.z.undefined(),t=zod.z.undefined(),o=zod.z.undefined(),n=zod.z.undefined(),s=zod.z.undefined(),r=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[Oo(e),Fo(t),Eo(n),gs(o),ko(s),wo(r)]);var Ut=(e=Ot,t=zod.z.undefined(),o=zod.z.undefined(),n=zod.z.undefined(),s=zod.z.undefined(),r=zod.z.undefined(),l=zod.z.undefined(),m=zod.z.undefined())=>zod.z.object({role:e,content:zod.z.array(fs(t,o,n,s,l,r)),metadata:m}),Pe=(e=qa,t=zod.z.undefined(),o=zod.z.undefined(),n=zod.z.undefined(),s=zod.z.undefined(),r=zod.z.undefined())=>zod.z.object({role:e,partialContent:bs(t,o,n,r),metadata:s}),Ts=zod.z.object({promptTokens:zod.z.number().nonnegative(),completionTokens:zod.z.number().nonnegative(),totalTokens:zod.z.number().nonnegative()}),Po=zod.z.object({token:zod.z.string(),logProb:zod.z.number(),bytes:zod.z.array(zod.z.number().int()).nullable()}),Ps=Po.extend({topLogProbs:zod.z.array(Po)}),Lo=zod.z.array(Ps);zod.z.object({messages:zod.z.array(Ut()),usage:Ts.optional(),logProbs:Lo.optional()});var vs=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(Pe()),usage:vs.optional(),logProbs:Lo.optional()});var Ce=(e=zod.z.record(zod.z.string(),zod.z.any()).optional())=>e,Ms=zod.z.object({enabled:zod.z.boolean().default(!0),allowedTools:zod.z.array(zod.z.string().min(1))});zod.z.object({type:zod.z.literal("url"),url:zod.z.string().url().refine(e=>e.startsWith("https://"),{message:"MCP server URL must start with https://"}),name:zod.z.string().min(1),toolConfiguration:Ms.optional(),authorizationToken:zod.z.string().min(1).optional()});var _s=["object","array","number","string","boolean","enum"],vo=zod.z.enum(_s),ks=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([vo,zod.z.array(zod.z.union([vo,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()}),Ss=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(ks),additionalProperties:zod.z.literal(!1)}),jo=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:Ss}).optional(),A="text",No="token",xs=[A,No],Uo=zod.z.enum(xs),Es=zod.z.array(zod.z.string().min(1)),Cs=zod.z.array(zod.z.array(zod.z.number().int().nonnegative())),Le=(e=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[zod.z.object({modality:zod.z.literal(A),metadata:e,requests:Es}),zod.z.object({modality:zod.z.literal(No),metadata:e,requests:Cs})]),we="float",ws=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),Gs="base64",Os=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.string().base64()}),Mo=zod.z.object({totalTokens:zod.z.number().int().nonnegative()});zod.z.discriminatedUnion("encodingFormat",[zod.z.object({encodingFormat:zod.z.literal(we),embeddings:zod.z.array(ws),usage:Mo.optional()}),zod.z.object({encodingFormat:zod.z.literal(Gs),embeddings:zod.z.array(Os),usage:Mo.optional()})]);var Rs=e=>{let t=new WeakSet;return JSON.stringify(e,(o,n)=>{if(typeof n=="object"&&n!==null){if(t.has(n))return;t.add(n);}return n})},Fs=e=>e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:Rs(e),wt="GatewayBaseError",ne=class Do extends Error{constructor({info:t,cause:o},n){super(`[${n!=null?n:wt}]: ${t}
|
|
7
|
-
Message: ${Fs(o)}`),this.name=wt,this.info=t,this.cause=o,this.name=n!=null?n:wt,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(t){return t instanceof Do}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},Is=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."),Ls=zod.z.object({base:Is.describe("Base (uncached, non\u2011reasoning) rates")}).describe("Holds the `ChatModelTokenPairPrice` for different categories (e.g., base) within a single pricing tier."),js=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:Ls.describe("Price categories and rates for this specific token range.")}).refine(e=>e.maxTokens===null||typeof e.maxTokens=="number"&&e.maxTokens>e.minTokens,{message:"maxTokens must be > minTokens (or null for infinite).",path:["maxTokens"]}).describe("A single pricing tier defined by a token range and associated prices.");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(js).min(1).describe("Pricing tiers (`ChatModelTokenRangePrice`) schedule, sorted by minTokens.")}).superRefine((e,t)=>{let{tokenRanges:o}=e;o[0].minTokens!==0&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",0,"minTokens"],message:"The first tier must have minTokens = 0."});for(let s=1;s<o.length;s++){let r=o[s-1],l=o[s];if(r.maxTokens===null){t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",s-1,"maxTokens"],message:"Cannot define any tokenRanges after an infinite tier (maxTokens = null)."});break}l.minTokens!==r.maxTokens&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",s,"minTokens"],message:`Tier ${s} minTokens (${l.minTokens}) must equal previous tier's maxTokens (${r.maxTokens}) for contiguity.`}),l.minTokens<r.minTokens&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",s,"minTokens"],message:`tokenRanges must be sorted by ascending minTokens. Tier ${s} (${l.minTokens}) starts before Tier ${s-1} (${r.minTokens}).`});}let n=o[o.length-1];o.every(s=>s.maxTokens!==null||s===n)&&n.maxTokens!==null&&t.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 Ns="function";var Us=zod.z.enum(["object","array","number","string","boolean","null"]),Ds=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:Us.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(Ds).optional(),required:zod.z.array(zod.z.string()).optional()});var $s=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 Bs=zod.z.enum(["function"]),As=zod.z.object({maxAttempts:zod.z.number().int().positive(),initialDelay:zod.z.number().int().positive(),exponentialFactor:zod.z.number().int().positive()}),qs=zod.z.object({type:zod.z.literal("http"),method:zod.z.enum(["get","post"]),url:zod.z.string().url(),headers:zod.z.record(zod.z.string()).optional(),query:zod.z.record(zod.z.string()).optional(),body:zod.z.record(zod.z.any()).optional(),proxyUrl:zod.z.string().url().optional(),proxyHeaders:zod.z.record(zod.z.string()).optional(),retry:As.optional()}),zs=zod.z.discriminatedUnion("type",[qs]),Hs=zod.z.object({type:Bs,definition:zod.z.object({schema:$s}),request:zs.optional()}),Vs=[Ns];zod.z.enum(Vs);var $o=(e=zod.z.undefined())=>zod.z.discriminatedUnion("type",[Hs.extend({metadata:e})]),Bo=e=>Go().parse({modality:B,value:e}),Ao=(e,t,o,n,s,r)=>Ro().parse({modality:Y,index:e,id:t,name:o,arguments:n,serverName:s,thoughtSignature:r});var Dt=(e,t)=>Pe().parse({role:e,partialContent:Oo().parse({modality:jt,value:t})}),$t=(e,t,o,n,s,r,l)=>Pe().parse({role:e,partialContent:Fo().parse({modality:Nt,index:t,id:o,name:n,arguments:s,serverName:r,thoughtSignature:l})});var qo=(e,t)=>xo().parse({modality:he,value:{type:Fe,thinking:e,signature:t}});var Bt=(e,t,o)=>Pe().parse({role:e,partialContent:Eo().parse({modality:It,value:{type:Fe,thinking:t,signature:o}})});var At=(e,t,o,n)=>_o().parse({modality:be,value:{type:Re,value:{category:e,probability:t,blocked:o,message:n}}});var qt=(e,t,o,n,s)=>Pe().parse({role:e,partialContent:ko().parse({modality:Rt,value:{type:Re,category:t,probability:o,blocked:n,message:s}})}),zt=(e,t,o)=>Co().parse({modality:Te,value:{type:Ie,query:e,responses:t,references:o}});var Ht=(e,t,o,n)=>Pe().parse({role:e,partialContent:wo().parse({modality:Lt,value:{type:Ie,query:t,responses:o,references:n}})});var Ks=Object.defineProperty,zo=Object.getOwnPropertySymbols,Ys=Object.prototype.hasOwnProperty,Js=Object.prototype.propertyIsEnumerable,Ho=(e,t,o)=>t in e?Ks(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,ve=(e,t)=>{for(var o in t||(t={}))Ys.call(t,o)&&Ho(e,o,t[o]);if(zo)for(var o of zo(t))Js.call(t,o)&&Ho(e,o,t[o]);return e},Vo="ProviderError",Me=class tn extends ne{constructor({info:t,cause:o}){super({info:t,cause:o},Vo),this.name=Vo,this.info=t,this.cause=o;}static isProviderError(t){return t instanceof tn}},Ko="ModelError",_e=class on extends ne{constructor({info:t,cause:o}){super({info:t,cause:o},Ko),this.name=Ko,this.info=t,this.cause=o;}static isModelError(t){return t instanceof on}},Yo="ModelResponseError",H=class nn extends ne{constructor({info:t,cause:o}){super({info:t,cause:o},Yo),this.name=Yo,this.cause=o,this.info=t;}static isModelResponseError(t){return t instanceof nn}},Jo="InvalidModelRequestError",ae=class an extends ne{constructor({info:t,cause:o}){super({info:t,cause:o},Jo),this.name=Jo,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(t){return t instanceof an}},Wo="InvalidConfigError",V=class sn extends ne{constructor({info:t,cause:o}){super({info:t,cause:o},Wo),this.name=Wo,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(t){return t instanceof sn}},Zo="InvalidMessagesError",I=class rn extends ne{constructor({info:t,cause:o}){super({info:t,cause:o},Zo),this.name=Zo,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(t){return t instanceof rn}},Xo="InvalidToolsError",Vt=class ln extends ne{constructor({info:t,cause:o}){super({info:t,cause:o},Xo),this.name=Xo,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(t){return t instanceof ln}},Qo="InvalidEmbeddingRequestsError",de=class mn extends ne{constructor({info:t,cause:o}){super({info:t,cause:o},Qo),this.name=Qo,this.info=t,this.cause=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(t){return t instanceof mn}},Kt="multi-string",dn=zod.z.object({type:zod.z.literal(Kt),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()}),Ws=e=>zod.z.array(zod.z.string()).max(e).default([]).optional(),cn=e=>({def:dn.parse(ve({type:Kt},e)),schema:Ws(e.max)}),Yt="object-schema",pn=zod.z.object({type:zod.z.literal(Yt),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),objectSchema:zod.z.any()}),Zs=e=>e.optional(),un=e=>({def:pn.parse(ve({type:Yt},e)),schema:Zs(e.objectSchema)}),Jt="paired-select",Xs=zod.z.object({value:zod.z.string().min(1),label:zod.z.string().min(1)}),en=zod.z.object({key:zod.z.string().min(1),label:zod.z.string().min(1),description:zod.z.string().min(1).max(500).optional(),choices:zod.z.array(Xs).min(1)}),gn=zod.z.object({type:zod.z.literal(Jt),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),fields:zod.z.tuple([en,en]),uniqueByField:zod.z.string().min(1).optional()}),Qs=e=>{let t=e.map(s=>s.value);if(t.length===0)throw new Error("PairedSelectConfigItem fields must define at least one choice");let[o,...n]=t;return zod.z.enum([o,...n])},er=e=>{let t=e.reduce((o,n)=>(o[n.key]=Qs(n.choices),o),{});return zod.z.array(zod.z.object(t)).optional()},hn=e=>{let t=gn.parse(ve({type:Jt},e)),o=new Set(t.fields.map(n=>n.key));if(o.size!==t.fields.length)throw new Error("PairedSelectConfigItem fields must have unique keys");if(t.uniqueByField&&!o.has(t.uniqueByField))throw new Error("uniqueByField must reference one of the defined field keys");return {def:t,schema:er(t.fields)}},Wt="range",fn=zod.z.object({type:zod.z.literal(Wt),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()}),tr=(e,t,o,n)=>zod.z.number().min(e).max(t).step(o).default(n).optional(),J=e=>({def:fn.parse(ve({type:Wt},e)),schema:tr(e.min,e.max,e.step,e.default)}),Zt="select-boolean",yn=zod.z.object({type:zod.z.literal(Zt),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()}),ir=e=>zod.z.boolean().nullable().default(e).optional(),Ge=e=>({def:yn.parse(ve({type:Zt},e)),schema:ir(e.default)}),Xt="select-string",bn=zod.z.object({type:zod.z.literal(Xt),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())}),or=(e,t)=>zod.z.enum(t).nullable().default(e).optional(),je=e=>({def:bn.parse(ve({type:Xt},e)),schema:or(e.default,e.choices)}),nr=[Wt,Kt,Xt,Yt,Zt,Jt];zod.z.enum(nr);var Tn=zod.z.discriminatedUnion("type",[fn,dn,bn,yn,pn,gn]),E=(e=Ot,t=Io)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(e,zod.z.string().min(1).optional()),modalities:zod.z.array(t).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),Tn),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(o=>{var n,s;let r=Object.keys(o.def),l=Object.keys((s=(n=o.schema)==null?void 0:n.shape)!=null?s:{});return r.every(m=>l.includes(m))&&l.every(m=>r.includes(m))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"}),price:zod.z.custom()}),W=(e=Uo)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),modalities:zod.z.array(e).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),Tn),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(t=>{var o,n;let s=Object.keys(t.def),r=Object.keys((n=(o=t.schema)==null?void 0:o.shape)!=null?n:{});return s.every(l=>r.includes(l))&&r.every(l=>s.includes(l))},{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 ar={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."},sr={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."},rr={type:"range",title:"Max reasoning tokens",description:"Specify the total tokens for reasoning, where one token approximates four English characters."},lr=e=>({type:"multi",title:"Stop sequence",description:`Enter up to ${e} sequences that will halt additional text output. The generated text will exclude these sequences.`}),mr={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."},dr={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."},cr={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."},pr={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."},ur={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."},gr={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."},hr={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."},fr={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."},yr={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."},br={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."},Tr={type:"boolean",title:"Echo",description:"If true, the response will contain the prompt."},Pr={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."},vr={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."},Mr={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."},_r={type:"object",title:"MCP servers",description:"MCP servers to use for the model."},U={TEMPERATURE:ar,MAX_TOKENS:sr,STOP:lr,TOP_A:mr,TOP_P:dr,TOP_K:cr,MIN_P:pr,FREQUENCY_PENALTY:ur,PRESENCE_PENALTY:gr,REPETITION_PENALTY:fr,SEED:hr,LOG_PROBS:yr,TOP_LOG_PROBS:br,ECHO:Tr,RESPONSE_FORMAT:Pr,RESPONSE_FORMAT_WITH_SCHEMA:vr,RESPONSE_SCHEMA:Mr,MAX_REASONING_TOKENS:rr,MCP_SERVERS:_r},kr={type:"range",title:"Dimensions",description:"Select the number of dimensions for the word embedding."},Sr={type:"select",title:"Encoding format",description:"Select the encoding format for the word embedding."},ke={DIMENSIONS:kr,ENCODING_FORMAT:Sr};var Oe=e=>Object.fromEntries(Object.entries(e).filter(([t,o])=>o!=null)),Qt=()=>typeof window!="undefined"&&typeof window.document!="undefined"&&typeof navigator!="undefined",Pn=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),o=globalThis.atob(t);return Uint8Array.from(o,n=>n.codePointAt(0))};var Se=e=>e==null?void 0:e.replace(/\/$/,"");var xr=Object.defineProperty,Er=Object.defineProperties,Cr=Object.getOwnPropertyDescriptors,vn=Object.getOwnPropertySymbols,wr=Object.prototype.hasOwnProperty,Gr=Object.prototype.propertyIsEnumerable,Ne=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Or=e=>{throw TypeError(e)},Mn=(e,t,o)=>t in e?xr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,x=(e,t)=>{for(var o in t||(t={}))wr.call(t,o)&&Mn(e,o,t[o]);if(vn)for(var o of vn(t))Gr.call(t,o)&&Mn(e,o,t[o]);return e},ce=(e,t)=>Er(e,Cr(t)),$=(e,t,o)=>new Promise((n,s)=>{var r=d=>{try{m(o.next(d));}catch(c){s(c);}},l=d=>{try{m(o.throw(d));}catch(c){s(c);}},m=d=>d.done?n(d.value):Promise.resolve(d.value).then(r,l);m((o=o.apply(e,t)).next());}),On=function(e,t){this[0]=e,this[1]=t;},_n=(e,t,o)=>{var n=(l,m,d,c)=>{try{var g=o[l](m),P=(m=g.value)instanceof On,u=g.done;Promise.resolve(P?m[0]:m).then(h=>P?n(l==="return"?l:"next",m[1]?{done:h.done,value:h.value}:h,d,c):d({value:h,done:u})).catch(h=>n("throw",h,d,c));}catch(h){c(h);}},s=l=>r[l]=m=>new Promise((d,c)=>n(l,m,d,c)),r={};return o=o.apply(e,t),r[Ne("asyncIterator")]=()=>r,s("next"),s("throw"),s("return"),r},Rr=e=>{var t=e[Ne("asyncIterator")],o=!1,n,s={};return t==null?(t=e[Ne("iterator")](),n=r=>s[r]=l=>t[r](l)):(t=t.call(e),n=r=>s[r]=l=>{if(o){if(o=!1,r==="throw")throw l;return l}return o=!0,{done:!1,value:new On(new Promise(m=>{var d=t[r](l);d instanceof Object||Or("Object expected"),m(d);}),1)}}),s[Ne("iterator")]=()=>s,n("next"),"throw"in t?n("throw"):s.throw=r=>{throw r},"return"in t&&n("return"),s},Fr=["HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT","HARM_CATEGORY_CIVIC_INTEGRITY"],Ir=["HARM_BLOCK_THRESHOLD_UNSPECIFIED","BLOCK_LOW_AND_ABOVE","BLOCK_MEDIUM_AND_ABOVE","BLOCK_ONLY_HIGH","BLOCK_NONE","OFF"],Rn=(e,t)=>e.replace(t,"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,o=>o.toUpperCase()),Lr=Fr.map(e=>({value:e,label:Rn(e,"HARM_CATEGORY_")})),jr=Ir.map(e=>({value:e,label:Rn(e,"HARM_BLOCK_THRESHOLD_")})),Fn=(e,t)=>J({param:"temperature",title:U.TEMPERATURE.title,description:U.TEMPERATURE.description,min:0,max:e,step:.01,default:t}),In=e=>J({param:"maxOutputTokens",title:U.MAX_TOKENS.title,description:U.MAX_TOKENS.description,min:0,max:e,step:1,default:0}),Ln=e=>cn({param:"stopSequences",title:U.STOP(e).title,description:U.STOP(e).description,max:e}),jn=e=>J({param:"topP",title:U.TOP_P.title,description:U.TOP_P.description,min:0,max:1,step:.01,default:e});J({param:"frequencyPenalty",title:U.FREQUENCY_PENALTY.title,description:U.FREQUENCY_PENALTY.description,min:-2,max:2,step:.01,default:0});J({param:"presencePenalty",title:U.PRESENCE_PENALTY.title,description:U.PRESENCE_PENALTY.description,min:-2,max:2,step:.01,default:0});J({param:"seed",title:U.SEED.title,description:U.SEED.description,min:0,max:1e6,step:1,default:0});var Nn=je({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"]}),Un=hn({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.",fields:[{key:"category",label:"Category",choices:Lr},{key:"threshold",label:"Threshold",choices:jr}],uniqueByField:"category"}),Dn=Ge({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}),$n=(e,t)=>J({param:"thinkingBudget",title:"Thinking budget",description:"Specify the total tokens for thinking (or reasoning), where one token approximates four English characters.",min:e,max:t,step:1,default:0}),Bn=je({param:"thinkingLevel",title:"Thinking Level",description:"Controls the depth of the model's reasoning process. Higher levels may result in more thorough reasoning but use more tokens.",default:"LOW",choices:["LOW","HIGH"]}),An=Ge({param:"googleSearch",title:"Google Search Tool",description:"Controls whether the model is allowed to use the Google Search tool. Powered by Google.",default:!1}),qn=(e,t,o,n,s)=>zod.z.object({temperature:Fn(e,t).schema,maxTokens:In(o).schema,stop:Ln(n).schema,topP:jn(s).schema,toolChoice:Nn.schema,safetySettings:Un.schema,googleSearchTool:An.schema}),zn=(e,t,o,n,s)=>({temperature:Fn(e,t).def,maxTokens:In(o).def,stop:Ln(n).def,topP:jn(s).def,toolChoice:Nn.def,safetySettings:Un.def,googleSearchTool:An.def}),Hn=un({param:"response_schema",title:U.RESPONSE_SCHEMA.title,description:U.RESPONSE_SCHEMA.description,objectSchema:jo}),Vn=je({param:"response_format",title:U.RESPONSE_FORMAT_WITH_SCHEMA.title,description:U.RESPONSE_FORMAT_WITH_SCHEMA.description,default:"text",choices:["text","json_schema"]}),Kn=(e,t,o,n,s)=>ce(x({},zn(e,t,o,n,s)),{responseFormat:Vn.def,responseSchema:Hn.def}),Yn=(e,t,o,n,s)=>qn(e,t,o,n,s).extend({responseFormat:Vn.schema,responseSchema:Hn.schema}),Nr=(e,t,o,n,s,r,l)=>Yn(e,t,o,n,s).extend({reasoningEnabled:Dn.schema,maxReasoningTokens:$n(r,l).schema,reasoningEffort:Bn.schema}),Ur=(e,t,o,n,s,r,l)=>ce(x({},Kn(e,t,o,n,s)),{reasoningEnabled:Dn.def,maxReasoningTokens:$n(r,l).def,reasoningEffort:Bn.def}),Jn=e=>J({param:"outputDimensionality",title:ke.DIMENSIONS.title,description:ke.DIMENSIONS.description,min:1,max:e,step:1,default:e}),Dr=e=>zod.z.object({dimensions:Jn(e).schema}),$r=e=>({dimensions:Jn(e).def}),v={base:(e,t,o,n,s)=>({def:zn(e,t,o,n,s),schema:qn(e,t,o,n,s)}),responseSchema:(e,t,o,n,s)=>({def:Kn(e,t,o,n,s),schema:Yn(e,t,o,n,s)}),reasoning:(e,t,o,n,s,r,l)=>({def:Ur(e,t,o,n,s,r,l),schema:Nr(e,t,o,n,s,r,l)})},Ue={base:e=>({def:$r(e),schema:Dr(e)})},Br="google",bi=class{constructor(){this.version="v1",this.name=Br,this.chatModelFactories={[ei]:{model:cl,modelOptions:dl,modelSchema:De},[ti]:{model:gl,modelOptions:ul,modelSchema:$e},[ii]:{model:yl,modelOptions:fl,modelSchema:Be},[oi]:{model:Pl,modelOptions:Tl,modelSchema:Ae},[ni]:{model:_l,modelOptions:Ml,modelSchema:qe},[ai]:{model:xl,modelOptions:Sl,modelSchema:ze},[si]:{model:wl,modelOptions:Cl,modelSchema:He},[ri]:{model:Rl,modelOptions:Ol,modelSchema:Ve},[li]:{model:jl,modelOptions:Ll,modelSchema:Ke},[mi]:{model:Dl,modelOptions:Ul,modelSchema:Ye},[pi]:{model:Yl,modelOptions:Kl,modelSchema:Ze},[gi]:{model:em,modelOptions:Ql,modelSchema:Qe},[ui]:{model:Zl,modelOptions:Wl,modelSchema:Xe},[hi]:{model:om,modelOptions:im,modelSchema:et},[fi]:{model:sm,modelOptions:am,modelSchema:tt},[yi]:{model:mm,modelOptions:lm,modelSchema:it},[di]:{model:Al,modelOptions:Bl,modelSchema:Je},[ci]:{model:Hl,modelOptions:zl,modelSchema:We}},this.embeddingModelFactories={[ia]:{model:hm,modelOptions:gm,modelSchema:oa},[na]:{model:bm,modelOptions:ym,modelSchema:aa}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((e,t)=>(e[t]=this.chatModelFactories[t].modelSchema,e),{})}chatModel(e){let t=e.modelName;if(!(t in this.chatModelFactories))throw new Me({info:`Google chat model: ${t} not found`,cause:new Error(`Google chat model: ${t} not found, available chat models:
|
|
6
|
+
var Ua=Object.defineProperty,Da=Object.defineProperties;var $a=Object.getOwnPropertyDescriptors;var Po=Object.getOwnPropertySymbols;var Ba=Object.prototype.hasOwnProperty,Aa=Object.prototype.propertyIsEnumerable;var Et=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),qa=e=>{throw TypeError(e)};var To=(e,t,o)=>t in e?Ua(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,b=(e,t)=>{for(var o in t||(t={}))Ba.call(t,o)&&To(e,o,t[o]);if(Po)for(var o of Po(t))Aa.call(t,o)&&To(e,o,t[o]);return e},k=(e,t)=>Da(e,$a(t));var X=(e,t,o)=>new Promise((n,s)=>{var r=d=>{try{m(o.next(d));}catch(c){s(c);}},l=d=>{try{m(o.throw(d));}catch(c){s(c);}},m=d=>d.done?n(d.value):Promise.resolve(d.value).then(r,l);m((o=o.apply(e,t)).next());}),za=function(e,t){this[0]=e,this[1]=t;};var vo=e=>{var t=e[Et("asyncIterator")],o=!1,n,s={};return t==null?(t=e[Et("iterator")](),n=r=>s[r]=l=>t[r](l)):(t=t.call(e),n=r=>s[r]=l=>{if(o){if(o=!1,r==="throw")throw l;return l}return o=!0,{done:!1,value:new za(new Promise(m=>{var d=t[r](l);d instanceof Object||qa("Object expected"),m(d);}),1)}}),s[Et("iterator")]=()=>s,n("next"),"throw"in t?n("throw"):s.throw=r=>{throw r},"return"in t&&n("return"),s};var we="system",Q="user",L="assistant",ee="tool",Ha=[we,Q,L,ee],Ot=zod.z.enum(Ha),Va=[L],Ka=zod.z.enum(Va),be="error",Re="safety",Ya=zod.z.object({type:zod.z.literal(Re),value:zod.z.object({category:zod.z.string(),probability:zod.z.string(),blocked:zod.z.boolean(),message:zod.z.string()})}),xo=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(be),value:zod.z.discriminatedUnion("type",[Ya]),metadata:e}),Rt="partial-error",Ja=zod.z.object({type:zod.z.literal(Re),category:zod.z.string().optional(),probability:zod.z.string().optional(),blocked:zod.z.boolean().optional(),message:zod.z.string().optional()}),So=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Rt),value:zod.z.discriminatedUnion("type",[Ja]),metadata:e}),le="image",It="base64",Wa=["png","jpeg","webp","gif"],Za=zod.z.object({type:zod.z.literal(It),base64:zod.z.string(),mediaType:zod.z.enum(Wa)}),Xa="url",Qa=zod.z.object({type:zod.z.literal(Xa),url:zod.z.string()}),es=zod.z.discriminatedUnion("type",[Za,Qa]),ts=["low","medium","high","auto"],is=zod.z.enum(ts),os=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(le),detail:is,value:es,metadata:e}),ge="pdf",ns="base64",as=zod.z.object({type:zod.z.literal(ns),base64:zod.z.string()}),ss="url",rs=zod.z.object({type:zod.z.literal(ss),url:zod.z.string()}),ls=zod.z.discriminatedUnion("type",[as,rs]),ms=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(ge),value:ls,file:zod.z.object({name:zod.z.string(),id:zod.z.string(),size:zod.z.number().optional()}),metadata:e}),he="reasoning",Ft="partial-reasoning",Ie="thinking",ds="redacted",Gt=zod.z.object({type:zod.z.literal(Ie),thinking:zod.z.string(),signature:zod.z.string()}),wo=zod.z.object({type:zod.z.literal(ds),data:zod.z.string()}),cs=zod.z.discriminatedUnion("type",[Gt,wo]),Eo=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(he),value:cs,metadata:e}),ps=zod.z.object({type:zod.z.literal(Ie),thinking:Gt.shape.thinking.optional(),signature:Gt.shape.signature.optional()}),us=zod.z.discriminatedUnion("type",[ps,wo]),Co=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Ft),value:us,metadata:e}),Pe="search-result",Fe="google",gs=zod.z.object({type:zod.z.literal(Fe),query:zod.z.string(),responses:zod.z.array(zod.z.object({source:zod.z.string(),url:zod.z.string(),title:zod.z.string(),snippet:zod.z.string().optional()})),references:zod.z.array(zod.z.object({text:zod.z.string(),responseIndices:zod.z.array(zod.z.number()),startIndex:zod.z.number().optional(),endIndex:zod.z.number().optional(),confidenceScores:zod.z.array(zod.z.number()).optional()}))}),Go=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Pe),value:zod.z.discriminatedUnion("type",[gs]),metadata:e}),Lt="partial-search-result",hs=zod.z.object({type:zod.z.literal(Fe),query:zod.z.string().optional(),responses:zod.z.array(zod.z.object({source:zod.z.string().optional(),url:zod.z.string().optional(),title:zod.z.string().optional(),snippet:zod.z.string().optional()})).optional(),references:zod.z.array(zod.z.object({text:zod.z.string().optional(),responseIndices:zod.z.array(zod.z.number()).optional(),startIndex:zod.z.number().optional(),endIndex:zod.z.number().optional(),confidenceScores:zod.z.array(zod.z.number()).optional()})).optional()}),Oo=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Lt),value:zod.z.discriminatedUnion("type",[hs]),metadata:e}),B="text",Ro=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(B),value:zod.z.string(),metadata:e}),jt="partial-text",Io=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(jt),value:zod.z.string(),metadata:e}),Y="tool-call",Fo=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Y),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),arguments:zod.z.string(),serverName:zod.z.string().optional(),thoughtSignature:zod.z.string().optional(),metadata:e}),Nt="partial-tool-call",Lo=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Nt),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),arguments:zod.z.string().optional(),serverName:zod.z.string().optional(),thoughtSignature:zod.z.string().optional(),metadata:e}),me="tool-response",fs=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(me),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:e}),ys="partial-tool-response",bs=(e=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(ys),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),data:zod.z.string().optional(),apiResponse:zod.z.object({statusCode:zod.z.number().int().nonnegative()}).optional(),metadata:e}),Ps=[B,le,ge,Y,me,he,be,Pe],jo=zod.z.enum(Ps),Ts=(e=zod.z.undefined(),t=zod.z.undefined(),o=zod.z.undefined(),n=zod.z.undefined(),s=zod.z.undefined(),r=zod.z.undefined(),l=zod.z.undefined(),m=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[Ro(e),os(t),ms(o),Fo(n),fs(s),Eo(r),xo(l),Go(m)]),vs=[jt,Nt,Ft,Rt,Lt];zod.z.enum(vs);var Ms=(e=zod.z.undefined(),t=zod.z.undefined(),o=zod.z.undefined(),n=zod.z.undefined(),s=zod.z.undefined(),r=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[Io(e),Lo(t),Co(n),bs(o),So(s),Oo(r)]);var Ut=(e=Ot,t=zod.z.undefined(),o=zod.z.undefined(),n=zod.z.undefined(),s=zod.z.undefined(),r=zod.z.undefined(),l=zod.z.undefined(),m=zod.z.undefined())=>zod.z.object({role:e,content:zod.z.array(Ts(t,o,n,s,l,r)),metadata:m}),Te=(e=Ka,t=zod.z.undefined(),o=zod.z.undefined(),n=zod.z.undefined(),s=zod.z.undefined(),r=zod.z.undefined())=>zod.z.object({role:e,partialContent:Ms(t,o,n,r),metadata:s}),ks=zod.z.object({promptTokens:zod.z.number().nonnegative(),completionTokens:zod.z.number().nonnegative(),totalTokens:zod.z.number().nonnegative()}),Mo=zod.z.object({token:zod.z.string(),logProb:zod.z.number(),bytes:zod.z.array(zod.z.number().int()).nullable()}),_s=Mo.extend({topLogProbs:zod.z.array(Mo)}),No=zod.z.array(_s);zod.z.object({messages:zod.z.array(Ut()),usage:ks.optional(),logProbs:No.optional()});var xs=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(Te()),usage:xs.optional(),logProbs:No.optional()});var Ee=(e=zod.z.record(zod.z.string(),zod.z.any()).optional())=>e,Ss=zod.z.object({enabled:zod.z.boolean().default(!0),allowedTools:zod.z.array(zod.z.string().min(1))});zod.z.object({type:zod.z.literal("url"),url:zod.z.string().url().refine(e=>e.startsWith("https://"),{message:"MCP server URL must start with https://"}),name:zod.z.string().min(1),toolConfiguration:Ss.optional(),authorizationToken:zod.z.string().min(1).optional()});var ws=["object","array","number","string","boolean","enum"],ko=zod.z.enum(ws),Es=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([ko,zod.z.array(zod.z.union([ko,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()}),Cs=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(Es),additionalProperties:zod.z.literal(!1)}),Uo=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:Cs}).optional(),A="text",Do="token",Gs=[A,Do],$o=zod.z.enum(Gs),Os=zod.z.array(zod.z.string().min(1)),Rs=zod.z.array(zod.z.array(zod.z.number().int().nonnegative())),Le=(e=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[zod.z.object({modality:zod.z.literal(A),metadata:e,requests:Os}),zod.z.object({modality:zod.z.literal(Do),metadata:e,requests:Rs})]),Ce="float",Is=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),Fs="base64",Ls=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.string().base64()}),_o=zod.z.object({totalTokens:zod.z.number().int().nonnegative()});zod.z.discriminatedUnion("encodingFormat",[zod.z.object({encodingFormat:zod.z.literal(Ce),embeddings:zod.z.array(Is),usage:_o.optional()}),zod.z.object({encodingFormat:zod.z.literal(Fs),embeddings:zod.z.array(Ls),usage:_o.optional()})]);var js=e=>{let t=new WeakSet;return JSON.stringify(e,(o,n)=>{if(typeof n=="object"&&n!==null){if(t.has(n))return;t.add(n);}return n})},Ns=e=>e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:js(e),Ct="GatewayBaseError",ne=class Bo extends Error{constructor({info:t,cause:o},n){super(`[${n!=null?n:Ct}]: ${t}
|
|
7
|
+
Message: ${Ns(o)}`),this.name=Ct,this.info=t,this.cause=o,this.name=n!=null?n:Ct,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(t){return t instanceof Bo}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},Us=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."),Ds=zod.z.object({base:Us.describe("Base (uncached, non\u2011reasoning) rates")}).describe("Holds the `ChatModelTokenPairPrice` for different categories (e.g., base) within a single pricing tier."),$s=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:Ds.describe("Price categories and rates for this specific token range.")}).refine(e=>e.maxTokens===null||typeof e.maxTokens=="number"&&e.maxTokens>e.minTokens,{message:"maxTokens must be > minTokens (or null for infinite).",path:["maxTokens"]}).describe("A single pricing tier defined by a token range and associated prices.");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($s).min(1).describe("Pricing tiers (`ChatModelTokenRangePrice`) schedule, sorted by minTokens.")}).superRefine((e,t)=>{let{tokenRanges:o}=e;o[0].minTokens!==0&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",0,"minTokens"],message:"The first tier must have minTokens = 0."});for(let s=1;s<o.length;s++){let r=o[s-1],l=o[s];if(r.maxTokens===null){t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",s-1,"maxTokens"],message:"Cannot define any tokenRanges after an infinite tier (maxTokens = null)."});break}l.minTokens!==r.maxTokens&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",s,"minTokens"],message:`Tier ${s} minTokens (${l.minTokens}) must equal previous tier's maxTokens (${r.maxTokens}) for contiguity.`}),l.minTokens<r.minTokens&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",s,"minTokens"],message:`tokenRanges must be sorted by ascending minTokens. Tier ${s} (${l.minTokens}) starts before Tier ${s-1} (${r.minTokens}).`});}let n=o[o.length-1];o.every(s=>s.maxTokens!==null||s===n)&&n.maxTokens!==null&&t.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 Bs="function";var As=zod.z.enum(["object","array","number","string","boolean","null"]),qs=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:As.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(qs).optional(),required:zod.z.array(zod.z.string()).optional()});var zs=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 Hs=zod.z.enum(["function"]),Vs=zod.z.object({maxAttempts:zod.z.number().int().positive(),initialDelay:zod.z.number().int().positive(),exponentialFactor:zod.z.number().int().positive()}),Ks=zod.z.object({type:zod.z.literal("http"),method:zod.z.enum(["get","post"]),url:zod.z.string().url(),headers:zod.z.record(zod.z.string()).optional(),query:zod.z.record(zod.z.string()).optional(),body:zod.z.record(zod.z.any()).optional(),proxyUrl:zod.z.string().url().optional(),proxyHeaders:zod.z.record(zod.z.string()).optional(),retry:Vs.optional()}),Ys=zod.z.discriminatedUnion("type",[Ks]),Js=zod.z.object({type:Hs,definition:zod.z.object({schema:zs}),request:Ys.optional()}),Ws=[Bs];zod.z.enum(Ws);var Ao=(e=zod.z.undefined())=>zod.z.discriminatedUnion("type",[Js.extend({metadata:e})]),qo=e=>Ro().parse({modality:B,value:e}),zo=(e,t,o,n,s,r)=>Fo().parse({modality:Y,index:e,id:t,name:o,arguments:n,serverName:s,thoughtSignature:r});var Dt=(e,t)=>Te().parse({role:e,partialContent:Io().parse({modality:jt,value:t})}),$t=(e,t,o,n,s,r,l)=>Te().parse({role:e,partialContent:Lo().parse({modality:Nt,index:t,id:o,name:n,arguments:s,serverName:r,thoughtSignature:l})});var Ho=(e,t)=>Eo().parse({modality:he,value:{type:Ie,thinking:e,signature:t}});var Bt=(e,t,o)=>Te().parse({role:e,partialContent:Co().parse({modality:Ft,value:{type:Ie,thinking:t,signature:o}})});var At=(e,t,o,n)=>xo().parse({modality:be,value:{type:Re,value:{category:e,probability:t,blocked:o,message:n}}});var qt=(e,t,o,n,s)=>Te().parse({role:e,partialContent:So().parse({modality:Rt,value:{type:Re,category:t,probability:o,blocked:n,message:s}})}),zt=(e,t,o)=>Go().parse({modality:Pe,value:{type:Fe,query:e,responses:t,references:o}});var Ht=(e,t,o,n)=>Te().parse({role:e,partialContent:Oo().parse({modality:Lt,value:{type:Fe,query:t,responses:o,references:n}})});var Zs=Object.defineProperty,Vo=Object.getOwnPropertySymbols,Xs=Object.prototype.hasOwnProperty,Qs=Object.prototype.propertyIsEnumerable,Ko=(e,t,o)=>t in e?Zs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,ve=(e,t)=>{for(var o in t||(t={}))Xs.call(t,o)&&Ko(e,o,t[o]);if(Vo)for(var o of Vo(t))Qs.call(t,o)&&Ko(e,o,t[o]);return e},Yo="ProviderError",Me=class nn extends ne{constructor({info:t,cause:o}){super({info:t,cause:o},Yo),this.name=Yo,this.info=t,this.cause=o;}static isProviderError(t){return t instanceof nn}},Jo="ModelError",ke=class an extends ne{constructor({info:t,cause:o}){super({info:t,cause:o},Jo),this.name=Jo,this.info=t,this.cause=o;}static isModelError(t){return t instanceof an}},Wo="ModelResponseError",H=class sn extends ne{constructor({info:t,cause:o}){super({info:t,cause:o},Wo),this.name=Wo,this.cause=o,this.info=t;}static isModelResponseError(t){return t instanceof sn}},Zo="InvalidModelRequestError",ae=class rn extends ne{constructor({info:t,cause:o}){super({info:t,cause:o},Zo),this.name=Zo,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(t){return t instanceof rn}},Xo="InvalidConfigError",V=class ln extends ne{constructor({info:t,cause:o}){super({info:t,cause:o},Xo),this.name=Xo,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(t){return t instanceof ln}},Qo="InvalidMessagesError",j=class mn extends ne{constructor({info:t,cause:o}){super({info:t,cause:o},Qo),this.name=Qo,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(t){return t instanceof mn}},en="InvalidToolsError",Vt=class dn extends ne{constructor({info:t,cause:o}){super({info:t,cause:o},en),this.name=en,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(t){return t instanceof dn}},tn="InvalidEmbeddingRequestsError",de=class cn extends ne{constructor({info:t,cause:o}){super({info:t,cause:o},tn),this.name=tn,this.info=t,this.cause=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(t){return t instanceof cn}},Kt="multi-string",pn=zod.z.object({type:zod.z.literal(Kt),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()}),er=e=>zod.z.array(zod.z.string()).max(e).default([]).optional(),un=e=>({def:pn.parse(ve({type:Kt},e)),schema:er(e.max)}),Yt="object-schema",gn=zod.z.object({type:zod.z.literal(Yt),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),objectSchema:zod.z.any()}),tr=e=>e.optional(),hn=e=>({def:gn.parse(ve({type:Yt},e)),schema:tr(e.objectSchema)}),Jt="paired-select",ir=zod.z.object({value:zod.z.string().min(1),label:zod.z.string().min(1)}),on=zod.z.object({key:zod.z.string().min(1),label:zod.z.string().min(1),description:zod.z.string().min(1).max(500).optional(),choices:zod.z.array(ir).min(1)}),fn=zod.z.object({type:zod.z.literal(Jt),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),fields:zod.z.tuple([on,on]),uniqueByField:zod.z.string().min(1).optional()}),or=e=>{let t=e.map(s=>s.value);if(t.length===0)throw new Error("PairedSelectConfigItem fields must define at least one choice");let[o,...n]=t;return zod.z.enum([o,...n])},nr=e=>{let t=e.reduce((o,n)=>(o[n.key]=or(n.choices),o),{});return zod.z.array(zod.z.object(t)).optional()},yn=e=>{let t=fn.parse(ve({type:Jt},e)),o=new Set(t.fields.map(n=>n.key));if(o.size!==t.fields.length)throw new Error("PairedSelectConfigItem fields must have unique keys");if(t.uniqueByField&&!o.has(t.uniqueByField))throw new Error("uniqueByField must reference one of the defined field keys");return {def:t,schema:nr(t.fields)}},Wt="range",bn=zod.z.object({type:zod.z.literal(Wt),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()}),ar=(e,t,o,n)=>zod.z.number().min(e).max(t).step(o).default(n).optional(),J=e=>({def:bn.parse(ve({type:Wt},e)),schema:ar(e.min,e.max,e.step,e.default)}),Zt="select-boolean",Pn=zod.z.object({type:zod.z.literal(Zt),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()}),sr=e=>zod.z.boolean().nullable().default(e).optional(),Ge=e=>({def:Pn.parse(ve({type:Zt},e)),schema:sr(e.default)}),Xt="select-string",Tn=zod.z.object({type:zod.z.literal(Xt),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())}),rr=(e,t)=>zod.z.enum(t).nullable().default(e).optional(),je=e=>({def:Tn.parse(ve({type:Xt},e)),schema:rr(e.default,e.choices)}),lr=[Wt,Kt,Xt,Yt,Zt,Jt];zod.z.enum(lr);var vn=zod.z.discriminatedUnion("type",[bn,pn,Tn,Pn,gn,fn]),w=(e=Ot,t=jo)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(e,zod.z.string().min(1).optional()),modalities:zod.z.array(t).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),vn),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(o=>{var n,s;let r=Object.keys(o.def),l=Object.keys((s=(n=o.schema)==null?void 0:n.shape)!=null?s:{});return r.every(m=>l.includes(m))&&l.every(m=>r.includes(m))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"}),price:zod.z.custom()}),W=(e=$o)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),modalities:zod.z.array(e).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),vn),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(t=>{var o,n;let s=Object.keys(t.def),r=Object.keys((n=(o=t.schema)==null?void 0:o.shape)!=null?n:{});return s.every(l=>r.includes(l))&&r.every(l=>s.includes(l))},{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 mr={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."},dr={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."},cr={type:"range",title:"Max reasoning tokens",description:"Specify the total tokens for reasoning, where one token approximates four English characters."},pr=e=>({type:"multi",title:"Stop sequence",description:`Enter up to ${e} sequences that will halt additional text output. The generated text will exclude these sequences.`}),ur={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."},gr={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."},hr={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."},fr={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."},yr={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."},br={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."},Pr={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."},Tr={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."},vr={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."},Mr={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."},kr={type:"boolean",title:"Echo",description:"If true, the response will contain the prompt."},_r={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."},xr={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."},Sr={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."},wr={type:"object",title:"MCP servers",description:"MCP servers to use for the model."},D={TEMPERATURE:mr,MAX_TOKENS:dr,STOP:pr,TOP_A:ur,TOP_P:gr,TOP_K:hr,MIN_P:fr,FREQUENCY_PENALTY:yr,PRESENCE_PENALTY:br,REPETITION_PENALTY:Tr,SEED:Pr,LOG_PROBS:vr,TOP_LOG_PROBS:Mr,ECHO:kr,RESPONSE_FORMAT:_r,RESPONSE_FORMAT_WITH_SCHEMA:xr,RESPONSE_SCHEMA:Sr,MAX_REASONING_TOKENS:cr,MCP_SERVERS:wr},Er={type:"range",title:"Dimensions",description:"Select the number of dimensions for the word embedding."},Cr={type:"select",title:"Encoding format",description:"Select the encoding format for the word embedding."},_e={DIMENSIONS:Er,ENCODING_FORMAT:Cr};var Oe=e=>Object.fromEntries(Object.entries(e).filter(([t,o])=>o!=null)),Qt=()=>typeof window!="undefined"&&typeof window.document!="undefined"&&typeof navigator!="undefined",Mn=e=>{let t=e.replace(/-/g,"+").replace(/_/g,"/"),o=globalThis.atob(t);return Uint8Array.from(o,n=>n.codePointAt(0))};var xe=e=>e==null?void 0:e.replace(/\/$/,"");var Gr=Object.defineProperty,Or=Object.defineProperties,Rr=Object.getOwnPropertyDescriptors,kn=Object.getOwnPropertySymbols,Ir=Object.prototype.hasOwnProperty,Fr=Object.prototype.propertyIsEnumerable,Ne=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Lr=e=>{throw TypeError(e)},_n=(e,t,o)=>t in e?Gr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,S=(e,t)=>{for(var o in t||(t={}))Ir.call(t,o)&&_n(e,o,t[o]);if(kn)for(var o of kn(t))Fr.call(t,o)&&_n(e,o,t[o]);return e},ce=(e,t)=>Or(e,Rr(t)),$=(e,t,o)=>new Promise((n,s)=>{var r=d=>{try{m(o.next(d));}catch(c){s(c);}},l=d=>{try{m(o.throw(d));}catch(c){s(c);}},m=d=>d.done?n(d.value):Promise.resolve(d.value).then(r,l);m((o=o.apply(e,t)).next());}),In=function(e,t){this[0]=e,this[1]=t;},xn=(e,t,o)=>{var n=(l,m,d,c)=>{try{var g=o[l](m),v=(m=g.value)instanceof In,u=g.done;Promise.resolve(v?m[0]:m).then(h=>v?n(l==="return"?l:"next",m[1]?{done:h.done,value:h.value}:h,d,c):d({value:h,done:u})).catch(h=>n("throw",h,d,c));}catch(h){c(h);}},s=l=>r[l]=m=>new Promise((d,c)=>n(l,m,d,c)),r={};return o=o.apply(e,t),r[Ne("asyncIterator")]=()=>r,s("next"),s("throw"),s("return"),r},jr=e=>{var t=e[Ne("asyncIterator")],o=!1,n,s={};return t==null?(t=e[Ne("iterator")](),n=r=>s[r]=l=>t[r](l)):(t=t.call(e),n=r=>s[r]=l=>{if(o){if(o=!1,r==="throw")throw l;return l}return o=!0,{done:!1,value:new In(new Promise(m=>{var d=t[r](l);d instanceof Object||Lr("Object expected"),m(d);}),1)}}),s[Ne("iterator")]=()=>s,n("next"),"throw"in t?n("throw"):s.throw=r=>{throw r},"return"in t&&n("return"),s},Nr=["HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT","HARM_CATEGORY_CIVIC_INTEGRITY"],Ur=["HARM_BLOCK_THRESHOLD_UNSPECIFIED","BLOCK_LOW_AND_ABOVE","BLOCK_MEDIUM_AND_ABOVE","BLOCK_ONLY_HIGH","BLOCK_NONE","OFF"],Fn=(e,t)=>e.replace(t,"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,o=>o.toUpperCase()),Dr=Nr.map(e=>({value:e,label:Fn(e,"HARM_CATEGORY_")})),$r=Ur.map(e=>({value:e,label:Fn(e,"HARM_BLOCK_THRESHOLD_")})),Ln=(e,t)=>J({param:"temperature",title:D.TEMPERATURE.title,description:D.TEMPERATURE.description,min:0,max:e,step:.01,default:t}),jn=e=>J({param:"maxOutputTokens",title:D.MAX_TOKENS.title,description:D.MAX_TOKENS.description,min:0,max:e,step:1,default:0}),Nn=e=>un({param:"stopSequences",title:D.STOP(e).title,description:D.STOP(e).description,max:e}),Un=e=>J({param:"topP",title:D.TOP_P.title,description:D.TOP_P.description,min:0,max:1,step:.01,default:e});J({param:"frequencyPenalty",title:D.FREQUENCY_PENALTY.title,description:D.FREQUENCY_PENALTY.description,min:-2,max:2,step:.01,default:0});J({param:"presencePenalty",title:D.PRESENCE_PENALTY.title,description:D.PRESENCE_PENALTY.description,min:-2,max:2,step:.01,default:0});J({param:"seed",title:D.SEED.title,description:D.SEED.description,min:0,max:1e6,step:1,default:0});var Dn=je({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"]}),$n=yn({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.",fields:[{key:"category",label:"Category",choices:Dr},{key:"threshold",label:"Threshold",choices:$r}],uniqueByField:"category"}),Bn=Ge({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}),An=(e,t)=>J({param:"thinkingBudget",title:"Thinking budget",description:"Specify the total tokens for thinking (or reasoning), where one token approximates four English characters.",min:e,max:t,step:1,default:0}),qn=je({param:"thinkingLevel",title:"Thinking Level",description:"Controls the depth of the model's reasoning process. Higher levels may result in more thorough reasoning but use more tokens.",default:"LOW",choices:["LOW","HIGH"]}),zn=Ge({param:"googleSearch",title:"Google Search Tool",description:"Controls whether the model is allowed to use the Google Search tool. Powered by Google.",default:!1}),Hn=(e,t,o,n,s)=>zod.z.object({temperature:Ln(e,t).schema,maxTokens:jn(o).schema,stop:Nn(n).schema,topP:Un(s).schema,toolChoice:Dn.schema,safetySettings:$n.schema,googleSearchTool:zn.schema}),Vn=(e,t,o,n,s)=>({temperature:Ln(e,t).def,maxTokens:jn(o).def,stop:Nn(n).def,topP:Un(s).def,toolChoice:Dn.def,safetySettings:$n.def,googleSearchTool:zn.def}),Kn=hn({param:"response_schema",title:D.RESPONSE_SCHEMA.title,description:D.RESPONSE_SCHEMA.description,objectSchema:Uo}),Yn=je({param:"response_format",title:D.RESPONSE_FORMAT_WITH_SCHEMA.title,description:D.RESPONSE_FORMAT_WITH_SCHEMA.description,default:"text",choices:["text","json_schema"]}),Jn=(e,t,o,n,s)=>ce(S({},Vn(e,t,o,n,s)),{responseFormat:Yn.def,responseSchema:Kn.def}),Wn=(e,t,o,n,s)=>Hn(e,t,o,n,s).extend({responseFormat:Yn.schema,responseSchema:Kn.schema}),Br=(e,t,o,n,s,r,l)=>Wn(e,t,o,n,s).extend({reasoningEnabled:Bn.schema,maxReasoningTokens:An(r,l).schema,reasoningEffort:qn.schema}),Ar=(e,t,o,n,s,r,l)=>ce(S({},Jn(e,t,o,n,s)),{reasoningEnabled:Bn.def,maxReasoningTokens:An(r,l).def,reasoningEffort:qn.def}),Zn=e=>J({param:"outputDimensionality",title:_e.DIMENSIONS.title,description:_e.DIMENSIONS.description,min:1,max:e,step:1,default:e}),qr=e=>zod.z.object({dimensions:Zn(e).schema}),zr=e=>({dimensions:Zn(e).def}),f={base:(e,t,o,n,s)=>({def:Vn(e,t,o,n,s),schema:Hn(e,t,o,n,s)}),responseSchema:(e,t,o,n,s)=>({def:Jn(e,t,o,n,s),schema:Wn(e,t,o,n,s)}),reasoning:(e,t,o,n,s,r,l)=>({def:Ar(e,t,o,n,s,r,l),schema:Br(e,t,o,n,s,r,l)})},Ue={base:e=>({def:zr(e),schema:qr(e)})},Hr="google",Ti=class{constructor(){this.version="v1",this.name=Hr,this.chatModelFactories={[ei]:{model:hl,modelOptions:gl,modelSchema:De},[ti]:{model:bl,modelOptions:yl,modelSchema:$e},[ii]:{model:vl,modelOptions:Tl,modelSchema:Be},[oi]:{model:_l,modelOptions:kl,modelSchema:Ae},[ni]:{model:wl,modelOptions:Sl,modelSchema:qe},[ai]:{model:Gl,modelOptions:Cl,modelSchema:ze},[si]:{model:Il,modelOptions:Rl,modelSchema:He},[ri]:{model:jl,modelOptions:Ll,modelSchema:Ve},[li]:{model:$l,modelOptions:Dl,modelSchema:Ke},[mi]:{model:ql,modelOptions:Al,modelSchema:Ye},[pi]:{model:Xl,modelOptions:Zl,modelSchema:Ze},[gi]:{model:nm,modelOptions:om,modelSchema:Qe},[ui]:{model:tm,modelOptions:em,modelSchema:Xe},[hi]:{model:rm,modelOptions:sm,modelSchema:et},[bi]:{model:fm,modelOptions:hm,modelSchema:tt},[yi]:{model:um,modelOptions:pm,modelSchema:ia},[fi]:{model:dm,modelOptions:mm,modelSchema:ta},[Pi]:{model:Pm,modelOptions:bm,modelSchema:it},[di]:{model:Vl,modelOptions:Hl,modelSchema:Je},[ci]:{model:Jl,modelOptions:Yl,modelSchema:We}},this.embeddingModelFactories={[sa]:{model:xm,modelOptions:_m,modelSchema:ra},[la]:{model:Em,modelOptions:wm,modelSchema:ma}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((e,t)=>(e[t]=this.chatModelFactories[t].modelSchema,e),{})}chatModel(e){let t=e.modelName;if(!(t in this.chatModelFactories))throw new Me({info:`Google chat model: ${t} not found`,cause:new Error(`Google chat model: ${t} not found, available chat models:
|
|
8
8
|
[${this.chatModelLiterals().join(", ")}]`)});let o=this.chatModelFactories[t].model,n=this.chatModelFactories[t].modelOptions.parse(e);return new o(n)}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((e,t)=>(e[t]=this.embeddingModelFactories[t].modelSchema,e),{})}embeddingModel(e){let t=e.modelName;if(!(t in this.embeddingModelFactories))throw new Me({info:`Google embedding model: ${t} not found`,cause:new Error(`Google embedding model: ${t} not found, available embedding models:
|
|
9
|
-
[${this.embeddingModelLiterals().join(", ")}]`)});let o=this.embeddingModelFactories[t].model,n=this.embeddingModelFactories[t].modelOptions.parse(e);return new o(n)}};bi.baseUrl="https://generativelanguage.googleapis.com/v1beta";var C={"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}}}]},"gemini-2.5-pro":{modelName:"gemini-2.5-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gemini-3-pro-preview":{modelName:"gemini-3-pro-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gemini-2.5-flash":{modelName:"gemini-2.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.3,outputPricePerMillion:2.5}}}]},"gemini-2.0-flash":{modelName:"gemini-2.0-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.0-flash-lite":{modelName:"gemini-2.0-flash-lite",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}}]},"gemini-2.5-flash-lite":{modelName:"gemini-2.5-flash-lite",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.5-flash-lite-preview-09-2025":{modelName:"gemini-2.5-flash-lite-preview-09-2025",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-3-flash-preview":{modelName:"gemini-3-flash-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:3}}}]}},w=zod.z.enum([Ee,Q,F,ee]),Ar="model",qr="function",G={system:Q,user:Q,assistant:Ar,tool:qr},O=[B,le,ge,Y,me,he,Te,be],R=zod.z.enum([B,le,ge,Y,me,he,Te,be]);zod.z.enum([B]);zod.z.enum([B,le]);zod.z.enum([B,Y,me]);var zr=zod.z.object({renderedContent:zod.z.string().optional()}),Hr=zod.z.object({uri:zod.z.string().optional(),title:zod.z.string().optional()}),Vr=zod.z.object({web:Hr.optional()}),Kr=zod.z.object({startIndex:zod.z.number().optional(),endIndex:zod.z.number().optional(),text:zod.z.string().optional()}),Yr=zod.z.object({segment:Kr.optional(),groundingChunkIndices:zod.z.array(zod.z.number()).optional(),confidenceScores:zod.z.array(zod.z.number()).optional()}),Wn=zod.z.object({searchEntryPoint:zr.optional(),groundingChunks:zod.z.array(Vr).optional(),groundingSupports:zod.z.array(Yr).optional(),webSearchQueries:zod.z.array(zod.z.string()).optional()}),Jr=zod.z.object({text:zod.z.string(),thought:zod.z.boolean().optional()}),Wr=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())}),thoughtSignature:zod.z.string().optional()}),Zr=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([Jr,Wr]))}).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()}))),groundingMetadata:Wn.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()}),Xr=zod.z.object({text:zod.z.string(),thought:zod.z.boolean().optional()}),Qr=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())}),thoughtSignature:zod.z.string().optional()}),kn=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([Xr,Qr]))}).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()}))),groundingMetadata:Wn.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()}),Zn=zod.z.object({text:zod.z.string().min(1)}),el=zod.z.object({inline_data:zod.z.object({mime_type:zod.z.string().min(1),data:zod.z.string().base64()})}),tl=zod.z.object({file_data:zod.z.object({mime_type:zod.z.string().min(1),file_uri:zod.z.string().min(1)})}),il=zod.z.object({function_call:zod.z.object({name:zod.z.string().min(1),args:zod.z.record(zod.z.string().min(1))}),thought_signature:zod.z.string().optional()}),ol=zod.z.object({function_response:zod.z.object({name:zod.z.string().min(1),response:zod.z.record(zod.z.string().min(1))})}),Sn=zod.z.object({text:zod.z.string(),thought:zod.z.literal(!0),thought_signature:zod.z.string().min(1)}),nl=zod.z.object({role:zod.z.enum(["user","model","function"]),parts:zod.z.array(zod.z.union([Zn,el,tl,il,ol,Sn,Sn]))}),xn=zod.z.object({parts:zod.z.array(Zn)}),al=zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),parameters:zod.z.any()}),sl=zod.z.object({timeRangeFilter:zod.z.object({startTime:zod.z.string().datetime().optional(),endTime:zod.z.string().datetime().optional()}).optional()}),En=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()})}),rl=zod.z.object({thinkingBudget:zod.z.number().optional(),includeThoughts:zod.z.boolean().optional(),thinkingLevel:zod.z.enum(["LOW","HIGH"]).optional()}),Cn=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(),thinkingConfig:rl.optional()}),wn=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"])}),ll=zod.z.object({model:zod.z.string().min(1).optional(),contents:zod.z.array(nl),systemInstruction:xn.optional(),system_instruction:xn.optional(),generationConfig:Cn.optional(),generation_config:Cn.optional(),safetySettings:zod.z.array(wn).optional(),safety_settings:zod.z.array(wn).optional(),tools:zod.z.object({function_declarations:zod.z.array(al),google_search:sl.optional()}).optional(),toolConfig:En.optional(),tool_config:En.optional()}),D=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()}),L=class{constructor(e,t){this.version="v1";var o;let n=D.parse(t);this.modelSchema=e,this.modelName=n.modelName,this.apiKey=n.apiKey,this.baseUrl=Se((o=n.baseUrl)!=null?o:bi.baseUrl),this.completeChatUrl=Se(n.completeChatUrl||`${this.baseUrl}/models/${this.modelName}:generateContent?key=${this.apiKey}`),this.streamChatUrl=Se(n.streamChatUrl||`${this.baseUrl}/models/${this.modelName}:streamGenerateContent?key=${this.apiKey}`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"Content-Type":"application/json"}}getDefaultParams(){return {}}getRetryDelay(e,t){var o;let n=0,s=r=>{let l=r.match(/^(\d+(?:\.\d+)?)s$/);return l?Math.ceil(parseFloat(l[1])*1e3):0};if(t&&typeof t=="object"){let r=t;if((o=r.error)!=null&&o.details&&Array.isArray(r.error.details)){let l=r.error.details.find(m=>m["@type"]==="type.googleapis.com/google.rpc.RetryInfo");l!=null&&l.retryDelay&&(n=s(l.retryDelay));}}return {shouldRetry:!0,delayMs:n}}getTokenCount(e){return e.reduce((t,o)=>t+o.content.map(n=>n.modality==="text"?n.value:"").join(" ").length,0)}transformPdfMessages(e){return $(this,null,function*(){let t=l=>$(this,null,function*(){let m={};Qt()||(m["User-Agent"]="Mozilla/5.0 (compatible; GoogleFilesAPI/1.0)");let d=yield fetch(l,{headers:m});if(!d.ok)throw new I({info:`Failed to download PDF from URL: ${l}`,cause:new Error(`HTTP ${d.status}: ${d.statusText}`)});let c=yield d.arrayBuffer();return new Uint8Array(c)}),o=l=>$(this,null,function*(){try{let m=yield fetch(`https://generativelanguage.googleapis.com/v1beta/files?key=${this.apiKey}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!m.ok)return null;let d=((yield m.json()).files||[]).find(c=>c.displayName===l);return d?d.uri:null}catch(m){return null}}),n=(l,m)=>$(this,null,function*(){let d=yield fetch(`https://generativelanguage.googleapis.com/upload/v1beta/files?key=${this.apiKey}`,{method:"POST",headers:{"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":l.length.toString(),"X-Goog-Upload-Header-Content-Type":"application/pdf","Content-Type":"application/json"},body:JSON.stringify({file:{display_name:m}})});if(!d.ok)throw new I({info:"Failed to start PDF upload to Google Files API",cause:new Error(`HTTP ${d.status}: ${d.statusText}`)});let c=d.headers.get("x-goog-upload-url");if(!c)throw new I({info:"No upload URL received from Google Files API",cause:new Error("Missing x-goog-upload-url header")});let g={"X-Goog-Upload-Offset":"0","X-Goog-Upload-Command":"upload, finalize"};Qt()||(g["Content-Length"]=l.length.toString());let P=yield fetch(c,{method:"POST",headers:g,body:l});if(!P.ok)throw new I({info:"Failed to upload PDF content to Google Files API",cause:new Error(`HTTP ${P.status}: ${P.statusText}`)});return (yield P.json()).file.uri}),s=l=>$(this,null,function*(){let m=yield o(l.file.id);if(m)return m;let d;if(l.value.type==="url")d=yield t(l.value.url);else {let c=l.value.base64,g="data:application/pdf;base64,";c=c.startsWith(g)?c.substring(g.length):c,d=Pn(c);}return yield n(d,l.file.id)}),r=[];for(let l of e){let m=[];for(let d of l.content)if(d.modality===ge){let c=yield s(d);m.push(ce(x({},d),{value:{type:"url",url:c}}));}else m.push(d);r.push(ce(x({},l),{content:m}));}return r})}transformModelRequest(e){let t=ll.safeParse(e);if(!t.success)throw new ae({info:"Invalid model request",cause:t.error});let o=t.data,n=o.model;if(o.system_instruction&&o.systemInstruction)throw new ae({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 ae({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 ae({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tool_config' and 'toolConfig' are not allowed at the same time")});let s=o.system_instruction||o.systemInstruction,r=o.generation_config||o.generationConfig,l=o.safety_settings||o.safetySettings,m=o.tool_config||o.toolConfig;if(m&&(!o.tools||o.tools.function_declarations.length===0))throw new ae({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let d={};m&&(m.function_calling_config.mode==="ANY"&&m.function_calling_config.allowed_function_names&&m.function_calling_config.allowed_function_names.length===1?d.toolChoice=m.function_calling_config.allowed_function_names[0]:d.toolChoice=m.function_calling_config.mode.toLowerCase()),d.seed=r==null?void 0:r.seed,d.maxTokens=r==null?void 0:r.maxOutputTokens,d.temperature=r==null?void 0:r.temperature,d.topP=r==null?void 0:r.topP,d.presencePenalty=r==null?void 0:r.presencePenalty,d.frequencyPenalty=r==null?void 0:r.frequencyPenalty,d.stop=r==null?void 0:r.stopSequences,d.safetySettings=l;let c=Ce().parse(Oe(d)),g=[];s&&s.parts.forEach(u=>{g.push({role:Ee,content:[{modality:B,value:u.text}]});}),o.contents.forEach(u=>{let h=u.role;switch(h){case"user":{let f=u.parts.map(k=>"text"in k?{modality:B,value:k.text}:{modality:le,detail:"auto",value:{type:Ft,base64:k.inline_data.data,mediaType:k.inline_data.mime_type.split("/")[1]}});g.push({role:h,content:f});}break;case"model":{let f=u.parts.map((k,j)=>"text"in k?{modality:B,value:k.text}:{modality:Y,id:j.toString(),index:j,name:k.function_call.name,arguments:JSON.stringify(k.function_call.args)});g.push({role:F,content:f});}break;case"function":{let f=u.parts.map((k,j)=>({modality:me,id:j.toString(),index:j,name:k.function_response.name,data:JSON.stringify(k.function_response.response)}));g.push({role:ee,content:f});}break;default:throw new I({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${u.role}' is not supported for model : ${this.modelName}`)})}});let P=[];return o.tools&&o.tools.function_declarations.forEach(u=>{P.push({type:"function",definition:{schema:{name:u.name,description:u.description,parameters:u.parameters}}});}),{modelName:n,config:c,messages:g,tools:P.length>0?P:void 0}}transformConfig(e,t,o){let n=e.toolChoice;delete e.toolChoice;let s=this.modelSchema.config.schema.safeParse(e);if(!s.success)throw new V({info:`Invalid config for model : '${this.modelName}'`,cause:s.error});let r=s.data;Object.keys(r).forEach(c=>{if(!(c in this.modelSchema.config.def))throw new V({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${c}',
|
|
10
|
-
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let l=Object.keys(r).reduce((c,g)=>{let
|
|
11
|
-
one of [${g.choices.join(", ")}]`)})}}if("response_format"in l&&l.response_format!==void 0){let c=l.response_format;if(c==="json_schema"){let g=l.response_schema;if(!("response_schema"in l)||!l.response_schema||!(g!=null&&g.schema))throw new V({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'responseSchema' is required in config when 'responseFormat' is 'json_schema'")});l.responseSchema=this.stripAdditionalProperties(g.schema),l.responseMimeType="application/json",delete l.response_format,delete l.response_schema;}else c==="json_object"?(l.responseSchema={type:"object"},delete l.response_format):c==="text"&&delete l.response_format;}return
|
|
12
|
-
available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),o.forEach(m=>{if(!Object.keys(this.modelSchema.roles).includes(m.role))throw new
|
|
13
|
-
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}),o.forEach(m=>{m.content=m.content.filter(d=>d.modality!=="error"&&d.modality!=="search-result");});let n=[];for(let m of o){let d=n[n.length-1];if(m.role===ee&&(d==null?void 0:d.role)===ee){n[n.length-1]=ce(
|
|
14
|
-
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}}),r[0].role!==this.modelSchema.roles[Q])throw new
|
|
15
|
-
`,P);if(u===-1){g=d.substring(P);break}else {let h=d.substring(P,u).trim();h&&c.push(h),P=u+1;}}for(let u of c){if(u==="data: [DONE]")return;if(u.startsWith("data: ")){let h=u.substring(6);try{let f=JSON.parse(h),k=kn.safeParse(f);if(k.success){let j={partialMessages:[]},q=k.data;if(q.candidates.length>0){let Z=q.candidates[0].content;Z&&"parts"in Z&&Z.parts.length>0&&Z.parts.forEach((z,N)=>{if("text"in z&&z.text!==void 0&&(z.thought===!0?j.partialMessages.push(Bt(F,z.text,"")):j.partialMessages.push(Dt(F,z.text))),"functionCall"in z&&z.functionCall!==void 0){let oe=z.functionCall;j.partialMessages.push($t(F,N,`${oe.name}_${N}`,oe.name,JSON.stringify(oe.args),void 0,z.thoughtSignature));}});}if(q.usageMetadata&&q.usageMetadata.totalTokenCount&&q.usageMetadata.promptTokenCount&&q.usageMetadata.candidatesTokenCount&&(j.usage={promptTokens:q.usageMetadata.promptTokenCount,completionTokens:q.usageMetadata.candidatesTokenCount,totalTokens:q.usageMetadata.totalTokenCount}),q.candidates.length>0){let Z=q.candidates[0];Z.groundingMetadata&&j.partialMessages.push(Ht(F,((r=Z.groundingMetadata.webSearchQueries)==null?void 0:r[0])||"",((l=Z.groundingMetadata.groundingChunks)==null?void 0:l.map(N=>{var oe,xe;return {source:N.web?"web":"",url:((oe=N.web)==null?void 0:oe.uri)||"",title:((xe=N.web)==null?void 0:xe.title)||""}}))||[],((m=Z.groundingMetadata.groundingSupports)==null?void 0:m.map(N=>{var oe,xe,fo;return {text:((oe=N.segment)==null?void 0:oe.text)||"",responseIndices:N.groundingChunkIndices||[],startIndex:((xe=N.segment)==null?void 0:xe.startIndex)||void 0,endIndex:((fo=N.segment)==null?void 0:fo.endIndex)||void 0,confidenceScores:N.confidenceScores||void 0}}))||[]));let z=Z.safetyRatings;z&&z.length>0&&z.forEach(N=>{N.blocked&&j.partialMessages.push(qt(F,N.category,N.probability,N.blocked,`Blocked content for category: ${N.category} with probability: ${N.probability}`));});}yield {partialResponse:j,buffer:t};}else throw new H({info:"Invalid response from model",cause:k.error})}catch(f){throw new H({info:`Malformed JSON received in stream: ${h}`,cause:f})}}}yield {partialResponse:{partialMessages:[]},buffer:g};})}getProxyCompleteChatUrl(e,t,o){return $(this,null,function*(){return new Promise(n=>{n(this.completeChatUrl);})})}getProxyStreamChatUrl(e,t,o){return $(this,null,function*(){return new Promise(n=>{if(!o||Object.keys(o).length===0){n(this.streamChatUrl);return}let s=new URL(this.streamChatUrl);Object.entries(o).forEach(([r,l])=>{l!=null&&s.searchParams.set(r,l);}),n(s.toString());})})}getProxyCompleteChatHeaders(e,t,o){return $(this,null,function*(){if(!t)return {};let n=x({},t);return delete n.host,delete n["content-length"],n})}getProxyStreamChatHeaders(e,t,o){return $(this,null,function*(){return yield this.getProxyCompleteChatHeaders(e,t,o)})}getModelPricing(){if(!(this.modelName in C))throw new H({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return C[this.modelName]}},ei="gemini-1.5-flash-001",ml="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",De=E(w,R).parse({name:ei,description:ml,maxInputTokens:1e6,maxOutputTokens:8192,roles:G,modalities:O,config:{def:v.responseSchema(2,1,8192,4,.95).def,schema:v.responseSchema(2,1,8192,4,.95).schema},price:C[ei]}),dl=D,cl=class extends L{constructor(e){super(De,e);}},ti="gemini-1.5-flash-002",pl="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",$e=E(w,R).parse({name:ti,description:pl,maxInputTokens:1e6,maxOutputTokens:8192,roles:G,modalities:O,config:{def:v.responseSchema(2,1,8192,4,.95).def,schema:v.responseSchema(2,1,8192,4,.95).schema},price:C[ti]}),ul=D,gl=class extends L{constructor(e){super($e,e);}},ii="gemini-1.5-flash-latest",hl="Google's latest multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",Be=E(w,R).parse({name:ii,description:hl,maxInputTokens:1e6,maxOutputTokens:8192,roles:G,modalities:O,config:{def:v.responseSchema(2,1,8192,4,.95).def,schema:v.responseSchema(2,1,8192,4,.95).schema},price:C[ii]}),fl=D,yl=class extends L{constructor(e){super(Be,e);}},oi="gemini-1.5-flash",bl="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",Ae=E(w,R).parse({name:oi,description:bl,maxInputTokens:1e6,maxOutputTokens:8192,roles:G,modalities:O,config:{def:v.responseSchema(2,1,8192,4,.95).def,schema:v.responseSchema(2,1,8192,4,.95).schema},price:C[oi]}),Tl=D,Pl=class extends L{constructor(e){super(Ae,e);}},ni="gemini-1.5-pro-001",vl="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",qe=E(w,R).parse({name:ni,description:vl,maxInputTokens:2e6,maxOutputTokens:8192,roles:G,modalities:O,config:{def:v.responseSchema(2,1,8192,4,.95).def,schema:v.responseSchema(2,1,8192,4,.95).schema},price:C[ni]}),Ml=D,_l=class extends L{constructor(e){super(qe,e);}},ai="gemini-1.5-pro-002",kl="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",ze=E(w,R).parse({name:ai,description:kl,maxInputTokens:2e6,maxOutputTokens:8192,roles:G,modalities:O,config:{def:v.responseSchema(2,1,8192,4,.95).def,schema:v.responseSchema(2,1,8192,4,.95).schema},price:C[ai]}),Sl=D,xl=class extends L{constructor(e){super(ze,e);}},si="gemini-1.5-pro-latest",El="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",He=E(w,R).parse({name:si,description:El,maxInputTokens:2e6,maxOutputTokens:8192,roles:G,modalities:O,config:{def:v.responseSchema(2,1,8192,4,.95).def,schema:v.responseSchema(2,1,8192,4,.95).schema},price:C[si]}),Cl=D,wl=class extends L{constructor(e){super(He,e);}},ri="gemini-1.5-pro",Gl="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",Ve=E(w,R).parse({name:ri,description:Gl,maxInputTokens:2e6,maxOutputTokens:8192,roles:G,modalities:O,config:{def:v.responseSchema(2,1,8192,4,.95).def,schema:v.responseSchema(2,1,8192,4,.95).schema},price:C[ri]}),Ol=D,Rl=class extends L{constructor(e){super(Ve,e);}},Gn="gemini-2.0-flash-exp",Fl="Google's experimental multimodal model with enhanced capabilities. Designed for cutting-edge performance across complex and high-frequency tasks.",Xn=E(w,R).parse({name:Gn,description:Fl,maxInputTokens:1e6,maxOutputTokens:8192,roles:G,modalities:O,config:{def:v.responseSchema(2,1,8192,4,.95).def,schema:v.responseSchema(2,1,8192,4,.95).schema},price:C[Gn]});var li="gemini-2.0-flash",Il="Google's Gemini 2.0 Flash model optimized for low-latency, high-performance tasks. Supports multimodal inputs including text, images, video, and audio with enhanced speed and efficiency.",Ke=E(w,R).parse({name:li,description:Il,maxInputTokens:1048576,maxOutputTokens:8192,roles:G,modalities:O,config:{def:v.responseSchema(2,1,8192,4,.95).def,schema:v.responseSchema(2,1,8192,4,.95).schema},price:C[li]}),Ll=D,jl=class extends L{constructor(e){super(Ke,e);}},mi="gemini-2.0-flash-lite",Nl="Google's lightweight Gemini 2.0 Flash Lite model for high-throughput, low-cost text generation and classification workloads.",Ye=E(w,R).parse({name:mi,description:Nl,maxInputTokens:1048576,maxOutputTokens:8192,roles:G,modalities:O,config:{def:v.responseSchema(2,1,8192,4,.95).def,schema:v.responseSchema(2,1,8192,4,.95).schema},price:C[mi]}),Ul=D,Dl=class extends L{constructor(e){super(Ye,e);}},di="gemini-2.5-flash-lite",$l="Google's most cost-efficient and fastest model in the 2.5 series. Optimized for high-volume, latency-sensitive tasks like translation and classification with enhanced reasoning capabilities.",Je=E(w,R).parse({name:di,description:$l,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:O,config:{def:v.responseSchema(2,1,65536,4,.95).def,schema:v.responseSchema(2,1,65536,4,.95).schema},price:C[di]}),Bl=D,Al=class extends L{constructor(e){super(Je,e);}},ci="gemini-2.5-flash-lite-preview-09-2025",ql="Google's preview Flash Lite variant in the Gemini 2.5 family, optimized for low-latency, high-volume tasks.",We=E(w,R).parse({name:ci,description:ql,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:O,config:{def:v.responseSchema(2,1,65536,4,.95).def,schema:v.responseSchema(2,1,65536,4,.95).schema},price:C[ci]}),zl=D,Hl=class extends L{constructor(e){super(We,e);}},pi="gemini-2.5-flash-preview-04-17",Vl="Google's best model in Gemini 2.5 family in terms of price-performance, offering well-rounded capabilities.",Ze=E(w,R).parse({name:pi,description:Vl,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:O,config:{def:v.reasoning(2,1,65536,4,.95,1,24576).def,schema:v.reasoning(2,1,65536,4,.95,1,24576).schema},price:C[pi]}),Kl=D,Yl=class extends L{constructor(e){super(Ze,e);}},ui="gemini-2.5-flash",Jl="Google's Gemini 2.5 Flash model for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",Xe=E(w,R).parse({name:ui,description:Jl,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:O,config:{def:v.reasoning(2,1,65536,4,.95,1,24576).def,schema:v.reasoning(2,1,65536,4,.95,1,24576).schema},price:C[ui]}),Wl=D,Zl=class extends L{constructor(e){super(Xe,e);}},gi="gemini-2.5-pro-preview-03-25",Xl="Google's preview model in Gemini 2.5 family for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",Qe=E(w,R).parse({name:gi,description:Xl,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:O,config:{def:v.reasoning(2,1,65536,4,.95,1,65536).def,schema:v.reasoning(2,1,65536,4,.95,1,65536).schema},price:C[gi]}),Ql=D,em=class extends L{constructor(e){super(Qe,e);}},hi="gemini-2.5-pro",tm="Google's Gemini 2.5 Pro model for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",et=E(w,R).parse({name:hi,description:tm,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:O,config:{def:v.reasoning(2,1,65536,4,.95,1,65536).def,schema:v.reasoning(2,1,65536,4,.95,1,65536).schema},price:C[hi]}),im=D,om=class extends L{constructor(e){super(et,e);}},fi="gemini-3-flash-preview",nm="Google's Gemini 3 Flash Preview model - a lightweight and efficient AI model with enhanced multimodal understanding, reasoning, and advanced coding capabilities. Optimized for speed and cost-effectiveness. Supports Text, Image, Video, Audio, and PDF inputs. Knowledge cutoff: January 2025.",tt=E(w,R).parse({name:fi,description:nm,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:O,config:{def:v.reasoning(2,1,65536,4,.95,1,65536).def,schema:v.reasoning(2,1,65536,4,.95,1,65536).schema},price:C[fi]}),am=D,sm=class extends L{constructor(e){super(tt,e);}},yi="gemini-3-pro-preview",rm="Google's latest Gemini 3 Pro Preview model with enhanced multimodal understanding, reasoning, and thinking capabilities. Supports Text, Image, Video, Audio, and PDF inputs. Knowledge cutoff: January 2025.",it=E(w,R).parse({name:yi,description:rm,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:O,config:{def:v.reasoning(2,1,65536,4,.95,1,65536).def,schema:v.reasoning(2,1,65536,4,.95,1,65536).schema},price:C[yi]}),lm=D,mm=class extends L{constructor(e){super(it,e);}},Qn=[A],ea=zod.z.enum([A]),dm=zod.z.object({embeddings:zod.z.array(zod.z.object({values:zod.z.array(zod.z.number())}))}),cm=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)})}),pm=zod.z.object({model:zod.z.string().min(1).optional(),requests:zod.z.array(cm).min(1),outputDimensionality:zod.z.number().int().min(1).optional()}),Ti=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),getEmbeddingsUrl:zod.z.string().url().optional()}),ta=class{constructor(e,t){this.version="v1";let o=Ti.parse(t);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=Se(o.baseUrl||bi.baseUrl),this.getEmbeddingsUrl=Se(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(e,t){var o;let n=0,s=r=>{let l=r.match(/^(\d+(?:\.\d+)?)s$/);return l?Math.ceil(parseFloat(l[1])*1e3):0};if(t&&typeof t=="object"){let r=t;if((o=r.error)!=null&&o.details&&Array.isArray(r.error.details)){let l=r.error.details.find(m=>m["@type"]==="type.googleapis.com/google.rpc.RetryInfo");l!=null&&l.retryDelay&&(n=s(l.retryDelay));}}return {shouldRetry:!0,delayMs:n}}getTokenCount(e){return e.requests.reduce((t,o)=>t+o.length,0)}transformModelRequest(e){let t=pm.safeParse(e);if(!t.success)throw new ae({info:"Invalid model request",cause:t.error});let o=t.data,n=o.model,s={outputDimensionality:o.outputDimensionality},r=Ce().parse(Oe(s)),l={modality:A,requests:o.requests.reduce((m,d)=>(m.push(...d.content.parts.map(c=>c.text)),m),[])};return {modelName:n,config:r,embeddingRequests:l}}transformConfig(e,t){let o=this.modelSchema.config.schema.safeParse(e);if(!o.success)throw new V({info:`Invalid config for model : '${this.modelName}'`,cause:o.error});let n=o.data;return Object.keys(n).forEach(s=>{if(!this.modelSchema.config.def[s])throw new V({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${s}',
|
|
16
|
-
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(n).reduce((s,r)=>{let l=this.modelSchema.config.def[r].param,m=n[r];return s[l]=m,s},{})}transformEmbeddingRequests(e){let t=Le().safeParse(e);if(!t.success)throw new de({info:"Invalid embedding requests",cause:t.error});if(e.modality!==A)throw new de({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Only '${A}' modality is supported for model : '${this.modelName}'`)});return {requests:t.data.requests.map(o=>({model:`models/${this.modelName}`,content:{parts:[{text:o}]}}))}}getGetEmbeddingsUrl(e,t){return $(this,null,function*(){return new Promise(o=>{o(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(e,t){return $(this,null,function*(){return new Promise(o=>{o(this.getDefaultHeaders());})})}getGetEmbeddingsData(e,t){return $(this,null,function*(){return new Promise(o=>{let n=this.transformConfig(e),s=this.transformEmbeddingRequests(t);if(t.requests.length===0)throw new de({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error("requests cannot be empty")});n.outputDimensionality&&(s.requests.forEach(r=>{r.outputDimensionality=n.outputDimensionality;}),delete n.outputDimensionality),o(
|
|
9
|
+
[${this.embeddingModelLiterals().join(", ")}]`)});let o=this.embeddingModelFactories[t].model,n=this.embeddingModelFactories[t].modelOptions.parse(e);return new o(n)}};Ti.baseUrl="https://generativelanguage.googleapis.com/v1beta";var E={"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}}}]},"gemini-2.5-pro":{modelName:"gemini-2.5-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gemini-3-pro-preview":{modelName:"gemini-3-pro-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gemini-3.1-pro-preview":{modelName:"gemini-3.1-pro-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:2e5,prices:{base:{inputPricePerMillion:2,outputPricePerMillion:12}}},{minTokens:200001,maxTokens:null,prices:{base:{inputPricePerMillion:4,outputPricePerMillion:18}}}]},"gemini-3.1-pro-preview-customtools":{modelName:"gemini-3.1-pro-preview-customtools",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:2e5,prices:{base:{inputPricePerMillion:2,outputPricePerMillion:12}}},{minTokens:200001,maxTokens:null,prices:{base:{inputPricePerMillion:4,outputPricePerMillion:18}}}]},"gemini-2.5-flash":{modelName:"gemini-2.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.3,outputPricePerMillion:2.5}}}]},"gemini-2.0-flash":{modelName:"gemini-2.0-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.0-flash-lite":{modelName:"gemini-2.0-flash-lite",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}}]},"gemini-2.5-flash-lite":{modelName:"gemini-2.5-flash-lite",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.5-flash-lite-preview-09-2025":{modelName:"gemini-2.5-flash-lite-preview-09-2025",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-3-flash-preview":{modelName:"gemini-3-flash-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:3}}}]}},C=zod.z.enum([we,Q,L,ee]),Vr="model",Kr="function",G={system:Q,user:Q,assistant:Vr,tool:Kr},O=[B,le,ge,Y,me,he,Pe,be],R=zod.z.enum([B,le,ge,Y,me,he,Pe,be]);zod.z.enum([B]);zod.z.enum([B,le]);zod.z.enum([B,Y,me]);var Yr=zod.z.object({renderedContent:zod.z.string().optional()}),Jr=zod.z.object({uri:zod.z.string().optional(),title:zod.z.string().optional()}),Wr=zod.z.object({web:Jr.optional()}),Zr=zod.z.object({startIndex:zod.z.number().optional(),endIndex:zod.z.number().optional(),text:zod.z.string().optional()}),Xr=zod.z.object({segment:Zr.optional(),groundingChunkIndices:zod.z.array(zod.z.number()).optional(),confidenceScores:zod.z.array(zod.z.number()).optional()}),Xn=zod.z.object({searchEntryPoint:Yr.optional(),groundingChunks:zod.z.array(Wr).optional(),groundingSupports:zod.z.array(Xr).optional(),webSearchQueries:zod.z.array(zod.z.string()).optional()}),Qr=zod.z.object({text:zod.z.string(),thought:zod.z.boolean().optional()}),el=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())}),thoughtSignature:zod.z.string().optional()}),tl=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([Qr,el]))}).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()}))),groundingMetadata:Xn.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()}),il=zod.z.object({text:zod.z.string(),thought:zod.z.boolean().optional()}),ol=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())}),thoughtSignature:zod.z.string().optional()}),Sn=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([il,ol]))}).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()}))),groundingMetadata:Xn.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()}),Qn=zod.z.object({text:zod.z.string().min(1)}),nl=zod.z.object({inline_data:zod.z.object({mime_type:zod.z.string().min(1),data:zod.z.string().base64()})}),al=zod.z.object({file_data:zod.z.object({mime_type:zod.z.string().min(1),file_uri:zod.z.string().min(1)})}),sl=zod.z.object({function_call:zod.z.object({name:zod.z.string().min(1),args:zod.z.record(zod.z.string().min(1))}),thought_signature:zod.z.string().optional()}),rl=zod.z.object({function_response:zod.z.object({name:zod.z.string().min(1),response:zod.z.record(zod.z.string().min(1))})}),wn=zod.z.object({text:zod.z.string(),thought:zod.z.literal(!0),thought_signature:zod.z.string().min(1)}),ll=zod.z.object({role:zod.z.enum(["user","model","function"]),parts:zod.z.array(zod.z.union([Qn,nl,al,sl,rl,wn,wn]))}),En=zod.z.object({parts:zod.z.array(Qn)}),ml=zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),parameters:zod.z.any()}),dl=zod.z.object({timeRangeFilter:zod.z.object({startTime:zod.z.string().datetime().optional(),endTime:zod.z.string().datetime().optional()}).optional()}),Cn=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()})}),cl=zod.z.object({thinkingBudget:zod.z.number().optional(),includeThoughts:zod.z.boolean().optional(),thinkingLevel:zod.z.enum(["LOW","HIGH"]).optional()}),Gn=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(),thinkingConfig:cl.optional()}),On=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"])}),pl=zod.z.object({model:zod.z.string().min(1).optional(),contents:zod.z.array(ll),systemInstruction:En.optional(),system_instruction:En.optional(),generationConfig:Gn.optional(),generation_config:Gn.optional(),safetySettings:zod.z.array(On).optional(),safety_settings:zod.z.array(On).optional(),tools:zod.z.object({function_declarations:zod.z.array(ml),google_search:dl.optional()}).optional(),toolConfig:Cn.optional(),tool_config:Cn.optional()}),F=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(e,t){this.version="v1";var o;let n=F.parse(t);this.modelSchema=e,this.modelName=n.modelName,this.apiKey=n.apiKey,this.baseUrl=xe((o=n.baseUrl)!=null?o:Ti.baseUrl),this.completeChatUrl=xe(n.completeChatUrl||`${this.baseUrl}/models/${this.modelName}:generateContent?key=${this.apiKey}`),this.streamChatUrl=xe(n.streamChatUrl||`${this.baseUrl}/models/${this.modelName}:streamGenerateContent?key=${this.apiKey}`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"Content-Type":"application/json"}}getDefaultParams(){return {}}getRetryDelay(e,t){var o;let n=0,s=r=>{let l=r.match(/^(\d+(?:\.\d+)?)s$/);return l?Math.ceil(parseFloat(l[1])*1e3):0};if(t&&typeof t=="object"){let r=t;if((o=r.error)!=null&&o.details&&Array.isArray(r.error.details)){let l=r.error.details.find(m=>m["@type"]==="type.googleapis.com/google.rpc.RetryInfo");l!=null&&l.retryDelay&&(n=s(l.retryDelay));}}return {shouldRetry:!0,delayMs:n}}getTokenCount(e){return e.reduce((t,o)=>t+o.content.map(n=>n.modality==="text"?n.value:"").join(" ").length,0)}transformPdfMessages(e){return $(this,null,function*(){let t=l=>$(this,null,function*(){let m={};Qt()||(m["User-Agent"]="Mozilla/5.0 (compatible; GoogleFilesAPI/1.0)");let d=yield fetch(l,{headers:m});if(!d.ok)throw new j({info:`Failed to download PDF from URL: ${l}`,cause:new Error(`HTTP ${d.status}: ${d.statusText}`)});let c=yield d.arrayBuffer();return new Uint8Array(c)}),o=l=>$(this,null,function*(){try{let m=yield fetch(`https://generativelanguage.googleapis.com/v1beta/files?key=${this.apiKey}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!m.ok)return null;let d=((yield m.json()).files||[]).find(c=>c.displayName===l);return d?d.uri:null}catch(m){return null}}),n=(l,m)=>$(this,null,function*(){let d=yield fetch(`https://generativelanguage.googleapis.com/upload/v1beta/files?key=${this.apiKey}`,{method:"POST",headers:{"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":l.length.toString(),"X-Goog-Upload-Header-Content-Type":"application/pdf","Content-Type":"application/json"},body:JSON.stringify({file:{display_name:m}})});if(!d.ok)throw new j({info:"Failed to start PDF upload to Google Files API",cause:new Error(`HTTP ${d.status}: ${d.statusText}`)});let c=d.headers.get("x-goog-upload-url");if(!c)throw new j({info:"No upload URL received from Google Files API",cause:new Error("Missing x-goog-upload-url header")});let g={"X-Goog-Upload-Offset":"0","X-Goog-Upload-Command":"upload, finalize"};Qt()||(g["Content-Length"]=l.length.toString());let v=yield fetch(c,{method:"POST",headers:g,body:l});if(!v.ok)throw new j({info:"Failed to upload PDF content to Google Files API",cause:new Error(`HTTP ${v.status}: ${v.statusText}`)});return (yield v.json()).file.uri}),s=l=>$(this,null,function*(){let m=yield o(l.file.id);if(m)return m;let d;if(l.value.type==="url")d=yield t(l.value.url);else {let c=l.value.base64,g="data:application/pdf;base64,";c=c.startsWith(g)?c.substring(g.length):c,d=Mn(c);}return yield n(d,l.file.id)}),r=[];for(let l of e){let m=[];for(let d of l.content)if(d.modality===ge){let c=yield s(d);m.push(ce(S({},d),{value:{type:"url",url:c}}));}else m.push(d);r.push(ce(S({},l),{content:m}));}return r})}transformModelRequest(e){let t=pl.safeParse(e);if(!t.success)throw new ae({info:"Invalid model request",cause:t.error});let o=t.data,n=o.model;if(o.system_instruction&&o.systemInstruction)throw new ae({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 ae({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 ae({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tool_config' and 'toolConfig' are not allowed at the same time")});let s=o.system_instruction||o.systemInstruction,r=o.generation_config||o.generationConfig,l=o.safety_settings||o.safetySettings,m=o.tool_config||o.toolConfig;if(m&&(!o.tools||o.tools.function_declarations.length===0))throw new ae({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let d={};m&&(m.function_calling_config.mode==="ANY"&&m.function_calling_config.allowed_function_names&&m.function_calling_config.allowed_function_names.length===1?d.toolChoice=m.function_calling_config.allowed_function_names[0]:d.toolChoice=m.function_calling_config.mode.toLowerCase()),d.seed=r==null?void 0:r.seed,d.maxTokens=r==null?void 0:r.maxOutputTokens,d.temperature=r==null?void 0:r.temperature,d.topP=r==null?void 0:r.topP,d.presencePenalty=r==null?void 0:r.presencePenalty,d.frequencyPenalty=r==null?void 0:r.frequencyPenalty,d.stop=r==null?void 0:r.stopSequences,d.safetySettings=l;let c=Ee().parse(Oe(d)),g=[];s&&s.parts.forEach(u=>{g.push({role:we,content:[{modality:B,value:u.text}]});}),o.contents.forEach(u=>{let h=u.role;switch(h){case"user":{let y=u.parts.map(_=>"text"in _?{modality:B,value:_.text}:{modality:le,detail:"auto",value:{type:It,base64:_.inline_data.data,mediaType:_.inline_data.mime_type.split("/")[1]}});g.push({role:h,content:y});}break;case"model":{let y=u.parts.map((_,N)=>"text"in _?{modality:B,value:_.text}:{modality:Y,id:N.toString(),index:N,name:_.function_call.name,arguments:JSON.stringify(_.function_call.args)});g.push({role:L,content:y});}break;case"function":{let y=u.parts.map((_,N)=>({modality:me,id:N.toString(),index:N,name:_.function_response.name,data:JSON.stringify(_.function_response.response)}));g.push({role:ee,content:y});}break;default:throw new j({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${u.role}' is not supported for model : ${this.modelName}`)})}});let v=[];return o.tools&&o.tools.function_declarations.forEach(u=>{v.push({type:"function",definition:{schema:{name:u.name,description:u.description,parameters:u.parameters}}});}),{modelName:n,config:c,messages:g,tools:v.length>0?v:void 0}}transformConfig(e,t,o){let n=e.toolChoice;delete e.toolChoice;let s=this.modelSchema.config.schema.safeParse(e);if(!s.success)throw new V({info:`Invalid config for model : '${this.modelName}'`,cause:s.error});let r=s.data;Object.keys(r).forEach(c=>{if(!(c in this.modelSchema.config.def))throw new V({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${c}',
|
|
10
|
+
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let l=Object.keys(r).reduce((c,g)=>{let v=this.modelSchema.config.def[g],u=v.param,h=r[g];return g==="reasoningEnabled"?c.thinkingConfig=c.thinkingConfig&&typeof c.thinkingConfig=="object"?ce(S({},c.thinkingConfig),{includeThoughts:h}):{includeThoughts:h}:g==="maxReasoningTokens"?c.thinkingConfig=c.thinkingConfig&&typeof c.thinkingConfig=="object"?ce(S({},c.thinkingConfig),{thinkingBudget:h}):{thinkingBudget:h}:g==="reasoningEffort"?c.thinkingConfig=c.thinkingConfig&&typeof c.thinkingConfig=="object"?ce(S({},c.thinkingConfig),{thinkingLevel:h}):{thinkingLevel:h}:u==="maxOutputTokens"&&v.type==="range"&&h===0?c[u]=v.max:c[u]=h,c},{});if(l.thinkingConfig&&typeof l.thinkingConfig=="object"&&"thinkingBudget"in l.thinkingConfig&&"thinkingLevel"in l.thinkingConfig&&l.thinkingConfig.thinkingBudget!==void 0&&l.thinkingConfig.thinkingBudget!==0&&l.thinkingConfig.thinkingLevel!==void 0)throw new V({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("Only one of 'thinkingBudget' or 'thinkingLevel' can be set, not both.")});let m=l.safetySettings;delete l.safetySettings,delete l.googleSearch;let d;if(n!==void 0){let c=n;if(!o||o&&o.length===0)throw new V({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(o&&o.length>0){let g=this.modelSchema.config.def.toolChoice;if(g.choices.includes(c))c==="any"?d={function_calling_config:{mode:"ANY",allowed_function_names:o.map(v=>v.definition.schema.name)}}:d={function_calling_config:{mode:c.toUpperCase()}};else if(o.map(v=>v.definition.schema.name).includes(c))d={function_calling_config:{mode:"ANY",allowed_function_names:[c]}};else throw new V({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`toolChoice : '${c}' is not part of provided 'tools' names or
|
|
11
|
+
one of [${g.choices.join(", ")}]`)})}}if("response_format"in l&&l.response_format!==void 0){let c=l.response_format;if(c==="json_schema"){let g=l.response_schema;if(!("response_schema"in l)||!l.response_schema||!(g!=null&&g.schema))throw new V({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'responseSchema' is required in config when 'responseFormat' is 'json_schema'")});l.responseSchema=this.stripAdditionalProperties(g.schema),l.responseMimeType="application/json",delete l.response_format,delete l.response_schema;}else c==="json_object"?(l.responseSchema={type:"object"},delete l.response_format):c==="text"&&delete l.response_format;}return S(S({generation_config:l},d?{tool_config:d}:{}),m?{safety_settings:m}:{})}transformMessages(e){if(!e||e&&e.length===0)return {messages:[]};let t=m=>{let d=m.match(/^data:(image\/[a-zA-Z]+|application\/pdf);base64,/);return d?m.substring(d[0].length):m},o=e.map(m=>{let d=Ut().safeParse(m);if(!d.success)throw new j({info:"Invalid messages",cause:d.error});return d.data});o.forEach(m=>{m.content.forEach(d=>{if(!this.modelSchema.modalities.includes(d.modality))throw new j({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${d.modality}',
|
|
12
|
+
available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),o.forEach(m=>{if(!Object.keys(this.modelSchema.roles).includes(m.role))throw new j({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${m.role}',
|
|
13
|
+
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}),o.forEach(m=>{m.content=m.content.filter(d=>d.modality!=="error"&&d.modality!=="search-result");});let n=[];for(let m of o){let d=n[n.length-1];if(m.role===ee&&(d==null?void 0:d.role)===ee){n[n.length-1]=ce(S({},d),{content:[...d.content,...m.content]});continue}n.push(m);}let s={parts:[]},r=[];if(n.forEach(m=>{switch(m.role){case we:m.content.forEach(d=>{if(d.modality===B)s.parts.push({text:d.value});else throw new j({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${m.role}' cannot have content with modality : '${d.modality}'`)})});break;case L:{let d=[];m.content.forEach(c=>{if(c.modality===B)d.push({text:c.value});else if(c.modality===Y)d.push(S({function_call:{name:c.name,args:JSON.parse(c.arguments)}},c.thoughtSignature?{thought_signature:c.thoughtSignature}:{}));else if(c.modality===he)c.value.type==="thinking"&&c.value.thinking&&d.push({text:c.value.thinking,thought:!0,thought_signature:c.value.signature});else throw new j({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${m.role}' cannot have content with modality : '${c.modality}'`)})}),r.push({role:this.modelSchema.roles[m.role],parts:d});}break;case Q:{let d=[];m.content.forEach(c=>{if(c.modality===B)d.push({text:c.value});else if(c.modality===le){if(c.value.type==="base64"){let g=c.value.base64;g=t(g),d.push({inline_data:{mime_type:`image/${c.value.mediaType}`,data:g}});}else if(c.value.type==="url")throw new j({info:`Invalid message 'modality' for model : ${this.modelName}`,cause:new Error(`model: '${this.modelName}' does not support image content type: '${c.value.type}'`)})}else if(c.modality===ge)if(c.value.type==="base64"){let g=c.value.base64;g=t(g),d.push({inline_data:{mime_type:"application/pdf",data:g}});}else c.value.type==="url"&&d.push({file_data:{mime_type:"application/pdf",file_uri:c.value.url}});else throw new j({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${m.role}' cannot have content with modality : '${c.modality}'`)})}),r.push({role:this.modelSchema.roles[m.role],parts:d});}break;case ee:{let d=[];m.content.forEach(c=>{if(c.modality===me)d.push({function_response:{name:c.name,response:JSON.parse(c.data)}});else throw new j({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${m.role}' cannot have content with modality : '${c.modality}'`)})}),r.push({role:this.modelSchema.roles[m.role],parts:d});}break;default:throw new j({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${m.role}' is not supported,
|
|
14
|
+
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}}),r[0].role!==this.modelSchema.roles[Q])throw new j({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires first message to be from user`)});let l=m=>m===this.modelSchema.roles[Q]||m===this.modelSchema.roles[ee]?[this.modelSchema.roles[L]]:[this.modelSchema.roles[Q],this.modelSchema.roles[ee]];for(let m=1;m<r.length;m++)if(!l(r[m-1].role).includes(r[m].role))throw new j({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' cannot have message with role : '${r[m].role}' after message with role : '${r[m-1].role}'`)});if(r[r.length-1].role!==this.modelSchema.roles[Q]&&r[r.length-1].role!==this.modelSchema.roles[ee])throw new j({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires last message to be from user`)});return S({contents:r},s.parts.length>0?{system_instruction:s}:{})}stripAdditionalProperties(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(o=>this.stripAdditionalProperties(o));let t={};for(let[o,n]of Object.entries(e))o!=="additionalProperties"&&(t[o]=this.stripAdditionalProperties(n));return t}transformTools(e,t){if(!this.modelSchema.modalities.includes(Y))throw new Vt({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${Y}'`)});if((!e||e.length===0)&&!(t!=null&&t.googleSearchTool))return {tools:[]};let o=(e!=null?e:[]).map(n=>{let s=Ao().safeParse(n);if(!s.success)throw new Vt({info:"Invalid tools",cause:s.error});return s.data}).map(n=>({name:n.definition.schema.name,description:n.definition.schema.description,parameters:this.stripAdditionalProperties(n.definition.schema.parameters)}));return {tools:[S(S({},o.length>0?{function_declarations:o}:{}),t!=null&&t.googleSearchTool?{google_search:{}}:{})]}}getCompleteChatUrl(e,t,o){return $(this,null,function*(){return new Promise(n=>{n(this.completeChatUrl);})})}getCompleteChatHeaders(e,t,o){return $(this,null,function*(){return new Promise(n=>{n(this.getDefaultHeaders());})})}getCompleteChatData(e,t,o){return $(this,null,function*(){let n=this.transformConfig(e,t,o),s=yield this.transformPdfMessages(t),r=this.transformMessages(s);if(r.messages&&r.messages.length===0)throw new j({info:"Messages are required",cause:new Error("Messages are required")});let l=this.transformTools(o||[],e);return S(S(S(S({},this.getDefaultParams()),n),r),l)})}transformCompleteChatResponse(e){var t,o,n,s,r,l;let m=tl.safeParse(e);if(m.success){if(m.data.candidates.length===0)throw new H({info:"Invalid response from model",cause:new Error(`No choices in response : ${JSON.stringify(m.data)}`)});let d={messages:[],usage:void 0,logProbs:void 0},c=m.data;c.usageMetadata&&(d.usage={promptTokens:c.usageMetadata.promptTokenCount,totalTokens:c.usageMetadata.totalTokenCount,completionTokens:c.usageMetadata.candidatesTokenCount||0});let g=c.candidates[0];if(g.content){let u=g.content.parts.map((h,y)=>{if("text"in h&&h.text!==void 0)return h.thought===!0?Ho(h.text,""):qo(h.text);if("functionCall"in h&&h.functionCall!==void 0)return zo(y,`${h.functionCall.name}_${y}`,h.functionCall.name,JSON.stringify(h.functionCall.args),void 0,h.thoughtSignature)});d.messages.push({role:L,content:u});}g.groundingMetadata&&(d.messages.length===0?d.messages.push({role:L,content:[zt(((t=g.groundingMetadata.webSearchQueries)==null?void 0:t[0])||"",((o=g.groundingMetadata.groundingChunks)==null?void 0:o.map(u=>{var h,y;return {source:u.web?"web":"",url:((h=u.web)==null?void 0:h.uri)||"",title:((y=u.web)==null?void 0:y.title)||""}}))||[],((n=g.groundingMetadata.groundingSupports)==null?void 0:n.map(u=>{var h,y,_;return {text:((h=u.segment)==null?void 0:h.text)||"",responseIndices:u.groundingChunkIndices||[],startIndex:((y=u.segment)==null?void 0:y.startIndex)||void 0,endIndex:((_=u.segment)==null?void 0:_.endIndex)||void 0,confidenceScores:u.confidenceScores||void 0}}))||[])]}):d.messages[0].content.push(zt(((s=g.groundingMetadata.webSearchQueries)==null?void 0:s[0])||"",((r=g.groundingMetadata.groundingChunks)==null?void 0:r.map(u=>{var h,y;return {source:u.web?"web":"",url:((h=u.web)==null?void 0:h.uri)||"",title:((y=u.web)==null?void 0:y.title)||""}}))||[],((l=g.groundingMetadata.groundingSupports)==null?void 0:l.map(u=>{var h,y,_;return {text:((h=u.segment)==null?void 0:h.text)||"",responseIndices:u.groundingChunkIndices||[],startIndex:((y=u.segment)==null?void 0:y.startIndex)||void 0,endIndex:((_=u.segment)==null?void 0:_.endIndex)||void 0,confidenceScores:u.confidenceScores||void 0}}))||[])));let v=g.safetyRatings;if(v&&v.length>0&&v.forEach(u=>{u.blocked&&(d.messages.length===0?d.messages.push({role:L,content:[At(u.category,u.probability,u.blocked,`Blocked content for category: ${u.category} with probability: ${u.probability}`)]}):d.messages[0].content.push(At(u.category,u.probability,u.blocked,`Blocked content for category: ${u.category} with probability: ${u.probability}`)));}),d.messages.length>0)return d;if(d.messages.length===0&&g.finishReason==="SAFETY")throw new H({info:"Blocked content, model response finished with safety reason",cause:new Error("Blocked content, model response finished with safety reason")})}throw new H({info:"Invalid response from model",cause:m.error})}getStreamChatUrl(e,t,o){return $(this,null,function*(){return new Promise(n=>{n(this.streamChatUrl);})})}getStreamChatHeaders(e,t,o){return $(this,null,function*(){return new Promise(n=>{n(this.getDefaultHeaders());})})}getStreamChatData(e,t,o){return $(this,null,function*(){let n=this.transformConfig(e,t,o),s=yield this.transformPdfMessages(t),r=this.transformMessages(s);if(r.messages&&r.messages.length===0)throw new j({info:"Messages are required",cause:new Error("Messages are required")});let l=this.transformTools(o||[],e);return S(S(S(S({},this.getDefaultParams()),n),r),l)})}transformStreamChatResponseChunk(e,t){return xn(this,null,function*(){var o,n,s;let r=(t+e).split(",\r").filter(l=>l.trim()!=="");for(let l of r){let m=l;if(m=m.replace(/\n/g,""),m.startsWith("[")||m.startsWith(",{"))m=m.slice(1);else if(m.endsWith("]")){if(m==="]")return;m=m.slice(0,-1);}let d;try{d=JSON.parse(m);}catch(g){if(g instanceof SyntaxError){t=m;continue}else throw g}t="";let c=Sn.safeParse(d);if(c.success){let g={partialMessages:[]},v=c.data;if(v.candidates.length>0){let u=v.candidates[0].content;u&&"parts"in u&&u.parts.length>0&&u.parts.forEach((h,y)=>{if("text"in h&&h.text!==void 0&&(h.thought===!0?g.partialMessages.push(Bt(L,h.text,"")):g.partialMessages.push(Dt(L,h.text))),"functionCall"in h&&h.functionCall!==void 0){let _=h.functionCall;g.partialMessages.push($t(L,y,`${_.name}_${y}`,_.name,JSON.stringify(_.args),void 0,h.thoughtSignature));}});}if(v.usageMetadata&&(g.usage={promptTokens:v.usageMetadata.promptTokenCount,completionTokens:v.usageMetadata.candidatesTokenCount,totalTokens:v.usageMetadata.totalTokenCount}),v.candidates.length>0){let u=v.candidates[0];u.groundingMetadata&&g.partialMessages.push(Ht(L,((o=u.groundingMetadata.webSearchQueries)==null?void 0:o[0])||"",((n=u.groundingMetadata.groundingChunks)==null?void 0:n.map(y=>{var _,N;return {source:y.web?"web":"",url:((_=y.web)==null?void 0:_.uri)||"",title:((N=y.web)==null?void 0:N.title)||""}}))||[],((s=u.groundingMetadata.groundingSupports)==null?void 0:s.map(y=>{var _,N,q;return {text:((_=y.segment)==null?void 0:_.text)||"",responseIndices:y.groundingChunkIndices||[],startIndex:((N=y.segment)==null?void 0:N.startIndex)||void 0,endIndex:((q=y.segment)==null?void 0:q.endIndex)||void 0,confidenceScores:y.confidenceScores||void 0}}))||[]));let h=u.safetyRatings;h&&h.length>0&&h.forEach(y=>{y.blocked&&g.partialMessages.push(qt(L,y.category,y.probability,y.blocked,`Blocked content for category: ${y.category} with probability: ${y.probability}`));});}yield {partialResponse:g,buffer:t};}else throw new H({info:"Invalid response from model",cause:c.error})}yield {partialResponse:{partialMessages:[]},buffer:t};})}transformProxyStreamChatResponseChunk(e,t,o,n,s){return xn(this,null,function*(){var r,l,m;if((s==null?void 0:s.alt)!=="sse"){yield*vo(jr(this.transformStreamChatResponseChunk(e,t)));return}let d=t+e,c=[],g="",v=0;for(;v<d.length;){let u=d.indexOf(`
|
|
15
|
+
`,v);if(u===-1){g=d.substring(v);break}else {let h=d.substring(v,u).trim();h&&c.push(h),v=u+1;}}for(let u of c){if(u==="data: [DONE]")return;if(u.startsWith("data: ")){let h=u.substring(6);try{let y=JSON.parse(h),_=Sn.safeParse(y);if(_.success){let N={partialMessages:[]},q=_.data;if(q.candidates.length>0){let Z=q.candidates[0].content;Z&&"parts"in Z&&Z.parts.length>0&&Z.parts.forEach((z,U)=>{if("text"in z&&z.text!==void 0&&(z.thought===!0?N.partialMessages.push(Bt(L,z.text,"")):N.partialMessages.push(Dt(L,z.text))),"functionCall"in z&&z.functionCall!==void 0){let oe=z.functionCall;N.partialMessages.push($t(L,U,`${oe.name}_${U}`,oe.name,JSON.stringify(oe.args),void 0,z.thoughtSignature));}});}if(q.usageMetadata&&q.usageMetadata.totalTokenCount&&q.usageMetadata.promptTokenCount&&q.usageMetadata.candidatesTokenCount&&(N.usage={promptTokens:q.usageMetadata.promptTokenCount,completionTokens:q.usageMetadata.candidatesTokenCount,totalTokens:q.usageMetadata.totalTokenCount}),q.candidates.length>0){let Z=q.candidates[0];Z.groundingMetadata&&N.partialMessages.push(Ht(L,((r=Z.groundingMetadata.webSearchQueries)==null?void 0:r[0])||"",((l=Z.groundingMetadata.groundingChunks)==null?void 0:l.map(U=>{var oe,Se;return {source:U.web?"web":"",url:((oe=U.web)==null?void 0:oe.uri)||"",title:((Se=U.web)==null?void 0:Se.title)||""}}))||[],((m=Z.groundingMetadata.groundingSupports)==null?void 0:m.map(U=>{var oe,Se,bo;return {text:((oe=U.segment)==null?void 0:oe.text)||"",responseIndices:U.groundingChunkIndices||[],startIndex:((Se=U.segment)==null?void 0:Se.startIndex)||void 0,endIndex:((bo=U.segment)==null?void 0:bo.endIndex)||void 0,confidenceScores:U.confidenceScores||void 0}}))||[]));let z=Z.safetyRatings;z&&z.length>0&&z.forEach(U=>{U.blocked&&N.partialMessages.push(qt(L,U.category,U.probability,U.blocked,`Blocked content for category: ${U.category} with probability: ${U.probability}`));});}yield {partialResponse:N,buffer:t};}else throw new H({info:"Invalid response from model",cause:_.error})}catch(y){throw new H({info:`Malformed JSON received in stream: ${h}`,cause:y})}}}yield {partialResponse:{partialMessages:[]},buffer:g};})}getProxyCompleteChatUrl(e,t,o){return $(this,null,function*(){return new Promise(n=>{n(this.completeChatUrl);})})}getProxyStreamChatUrl(e,t,o){return $(this,null,function*(){return new Promise(n=>{if(!o||Object.keys(o).length===0){n(this.streamChatUrl);return}let s=new URL(this.streamChatUrl);Object.entries(o).forEach(([r,l])=>{l!=null&&s.searchParams.set(r,l);}),n(s.toString());})})}getProxyCompleteChatHeaders(e,t,o){return $(this,null,function*(){if(!t)return {};let n=S({},t);return delete n.host,delete n["content-length"],n})}getProxyStreamChatHeaders(e,t,o){return $(this,null,function*(){return yield this.getProxyCompleteChatHeaders(e,t,o)})}getModelPricing(){if(!(this.modelName in E))throw new H({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return E[this.modelName]}},ei="gemini-1.5-flash-001",ul="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",De=w(C,R).parse({name:ei,description:ul,maxInputTokens:1e6,maxOutputTokens:8192,roles:G,modalities:O,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:E[ei]}),gl=F,hl=class extends I{constructor(e){super(De,e);}},ti="gemini-1.5-flash-002",fl="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",$e=w(C,R).parse({name:ti,description:fl,maxInputTokens:1e6,maxOutputTokens:8192,roles:G,modalities:O,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:E[ti]}),yl=F,bl=class extends I{constructor(e){super($e,e);}},ii="gemini-1.5-flash-latest",Pl="Google's latest multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",Be=w(C,R).parse({name:ii,description:Pl,maxInputTokens:1e6,maxOutputTokens:8192,roles:G,modalities:O,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:E[ii]}),Tl=F,vl=class extends I{constructor(e){super(Be,e);}},oi="gemini-1.5-flash",Ml="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",Ae=w(C,R).parse({name:oi,description:Ml,maxInputTokens:1e6,maxOutputTokens:8192,roles:G,modalities:O,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:E[oi]}),kl=F,_l=class extends I{constructor(e){super(Ae,e);}},ni="gemini-1.5-pro-001",xl="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",qe=w(C,R).parse({name:ni,description:xl,maxInputTokens:2e6,maxOutputTokens:8192,roles:G,modalities:O,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:E[ni]}),Sl=F,wl=class extends I{constructor(e){super(qe,e);}},ai="gemini-1.5-pro-002",El="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",ze=w(C,R).parse({name:ai,description:El,maxInputTokens:2e6,maxOutputTokens:8192,roles:G,modalities:O,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:E[ai]}),Cl=F,Gl=class extends I{constructor(e){super(ze,e);}},si="gemini-1.5-pro-latest",Ol="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",He=w(C,R).parse({name:si,description:Ol,maxInputTokens:2e6,maxOutputTokens:8192,roles:G,modalities:O,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:E[si]}),Rl=F,Il=class extends I{constructor(e){super(He,e);}},ri="gemini-1.5-pro",Fl="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",Ve=w(C,R).parse({name:ri,description:Fl,maxInputTokens:2e6,maxOutputTokens:8192,roles:G,modalities:O,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:E[ri]}),Ll=F,jl=class extends I{constructor(e){super(Ve,e);}},Rn="gemini-2.0-flash-exp",Nl="Google's experimental multimodal model with enhanced capabilities. Designed for cutting-edge performance across complex and high-frequency tasks.",ea=w(C,R).parse({name:Rn,description:Nl,maxInputTokens:1e6,maxOutputTokens:8192,roles:G,modalities:O,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:E[Rn]});var li="gemini-2.0-flash",Ul="Google's Gemini 2.0 Flash model optimized for low-latency, high-performance tasks. Supports multimodal inputs including text, images, video, and audio with enhanced speed and efficiency.",Ke=w(C,R).parse({name:li,description:Ul,maxInputTokens:1048576,maxOutputTokens:8192,roles:G,modalities:O,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:E[li]}),Dl=F,$l=class extends I{constructor(e){super(Ke,e);}},mi="gemini-2.0-flash-lite",Bl="Google's lightweight Gemini 2.0 Flash Lite model for high-throughput, low-cost text generation and classification workloads.",Ye=w(C,R).parse({name:mi,description:Bl,maxInputTokens:1048576,maxOutputTokens:8192,roles:G,modalities:O,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:E[mi]}),Al=F,ql=class extends I{constructor(e){super(Ye,e);}},di="gemini-2.5-flash-lite",zl="Google's most cost-efficient and fastest model in the 2.5 series. Optimized for high-volume, latency-sensitive tasks like translation and classification with enhanced reasoning capabilities.",Je=w(C,R).parse({name:di,description:zl,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:O,config:{def:f.responseSchema(2,1,65536,4,.95).def,schema:f.responseSchema(2,1,65536,4,.95).schema},price:E[di]}),Hl=F,Vl=class extends I{constructor(e){super(Je,e);}},ci="gemini-2.5-flash-lite-preview-09-2025",Kl="Google's preview Flash Lite variant in the Gemini 2.5 family, optimized for low-latency, high-volume tasks.",We=w(C,R).parse({name:ci,description:Kl,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:O,config:{def:f.responseSchema(2,1,65536,4,.95).def,schema:f.responseSchema(2,1,65536,4,.95).schema},price:E[ci]}),Yl=F,Jl=class extends I{constructor(e){super(We,e);}},pi="gemini-2.5-flash-preview-04-17",Wl="Google's best model in Gemini 2.5 family in terms of price-performance, offering well-rounded capabilities.",Ze=w(C,R).parse({name:pi,description:Wl,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:O,config:{def:f.reasoning(2,1,65536,4,.95,1,24576).def,schema:f.reasoning(2,1,65536,4,.95,1,24576).schema},price:E[pi]}),Zl=F,Xl=class extends I{constructor(e){super(Ze,e);}},ui="gemini-2.5-flash",Ql="Google's Gemini 2.5 Flash model for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",Xe=w(C,R).parse({name:ui,description:Ql,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:O,config:{def:f.reasoning(2,1,65536,4,.95,1,24576).def,schema:f.reasoning(2,1,65536,4,.95,1,24576).schema},price:E[ui]}),em=F,tm=class extends I{constructor(e){super(Xe,e);}},gi="gemini-2.5-pro-preview-03-25",im="Google's preview model in Gemini 2.5 family for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",Qe=w(C,R).parse({name:gi,description:im,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:O,config:{def:f.reasoning(2,1,65536,4,.95,1,65536).def,schema:f.reasoning(2,1,65536,4,.95,1,65536).schema},price:E[gi]}),om=F,nm=class extends I{constructor(e){super(Qe,e);}},hi="gemini-2.5-pro",am="Google's Gemini 2.5 Pro model for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",et=w(C,R).parse({name:hi,description:am,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:O,config:{def:f.reasoning(2,1,65536,4,.95,1,65536).def,schema:f.reasoning(2,1,65536,4,.95,1,65536).schema},price:E[hi]}),sm=F,rm=class extends I{constructor(e){super(et,e);}},fi="gemini-3.1-pro-preview-customtools",lm="Google's Gemini 3.1 Pro Preview variant optimized for the custom tools endpoint in the Gemini API.",ta=w(C,R).parse({name:fi,description:lm,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:O,config:{def:f.reasoning(2,1,65536,4,.95,1,65536).def,schema:f.reasoning(2,1,65536,4,.95,1,65536).schema},price:E[fi]}),mm=F,dm=class extends I{constructor(e){super(ta,e);}},yi="gemini-3.1-pro-preview",cm="Google's Gemini 3.1 Pro Preview model for improved reliability and nuanced understanding in complex reasoning and multimodal tasks.",ia=w(C,R).parse({name:yi,description:cm,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:O,config:{def:f.reasoning(2,1,65536,4,.95,1,65536).def,schema:f.reasoning(2,1,65536,4,.95,1,65536).schema},price:E[yi]}),pm=F,um=class extends I{constructor(e){super(ia,e);}},bi="gemini-3-flash-preview",gm="Google's Gemini 3 Flash Preview model - a lightweight and efficient AI model with enhanced multimodal understanding, reasoning, and advanced coding capabilities. Optimized for speed and cost-effectiveness. Supports Text, Image, Video, Audio, and PDF inputs. Knowledge cutoff: January 2025.",tt=w(C,R).parse({name:bi,description:gm,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:O,config:{def:f.reasoning(2,1,65536,4,.95,1,65536).def,schema:f.reasoning(2,1,65536,4,.95,1,65536).schema},price:E[bi]}),hm=F,fm=class extends I{constructor(e){super(tt,e);}},Pi="gemini-3-pro-preview",ym="Google's latest Gemini 3 Pro Preview model with enhanced multimodal understanding, reasoning, and thinking capabilities. Supports Text, Image, Video, Audio, and PDF inputs. Knowledge cutoff: January 2025.",it=w(C,R).parse({name:Pi,description:ym,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:O,config:{def:f.reasoning(2,1,65536,4,.95,1,65536).def,schema:f.reasoning(2,1,65536,4,.95,1,65536).schema},price:E[Pi]}),bm=F,Pm=class extends I{constructor(e){super(it,e);}},oa=[A],na=zod.z.enum([A]),Tm=zod.z.object({embeddings:zod.z.array(zod.z.object({values:zod.z.array(zod.z.number())}))}),vm=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)})}),Mm=zod.z.object({model:zod.z.string().min(1).optional(),requests:zod.z.array(vm).min(1),outputDimensionality:zod.z.number().int().min(1).optional()}),vi=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),getEmbeddingsUrl:zod.z.string().url().optional()}),aa=class{constructor(e,t){this.version="v1";let o=vi.parse(t);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=xe(o.baseUrl||Ti.baseUrl),this.getEmbeddingsUrl=xe(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(e,t){var o;let n=0,s=r=>{let l=r.match(/^(\d+(?:\.\d+)?)s$/);return l?Math.ceil(parseFloat(l[1])*1e3):0};if(t&&typeof t=="object"){let r=t;if((o=r.error)!=null&&o.details&&Array.isArray(r.error.details)){let l=r.error.details.find(m=>m["@type"]==="type.googleapis.com/google.rpc.RetryInfo");l!=null&&l.retryDelay&&(n=s(l.retryDelay));}}return {shouldRetry:!0,delayMs:n}}getTokenCount(e){return e.requests.reduce((t,o)=>t+o.length,0)}transformModelRequest(e){let t=Mm.safeParse(e);if(!t.success)throw new ae({info:"Invalid model request",cause:t.error});let o=t.data,n=o.model,s={outputDimensionality:o.outputDimensionality},r=Ee().parse(Oe(s)),l={modality:A,requests:o.requests.reduce((m,d)=>(m.push(...d.content.parts.map(c=>c.text)),m),[])};return {modelName:n,config:r,embeddingRequests:l}}transformConfig(e,t){let o=this.modelSchema.config.schema.safeParse(e);if(!o.success)throw new V({info:`Invalid config for model : '${this.modelName}'`,cause:o.error});let n=o.data;return Object.keys(n).forEach(s=>{if(!this.modelSchema.config.def[s])throw new V({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${s}',
|
|
16
|
+
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(n).reduce((s,r)=>{let l=this.modelSchema.config.def[r].param,m=n[r];return s[l]=m,s},{})}transformEmbeddingRequests(e){let t=Le().safeParse(e);if(!t.success)throw new de({info:"Invalid embedding requests",cause:t.error});if(e.modality!==A)throw new de({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Only '${A}' modality is supported for model : '${this.modelName}'`)});return {requests:t.data.requests.map(o=>({model:`models/${this.modelName}`,content:{parts:[{text:o}]}}))}}getGetEmbeddingsUrl(e,t){return $(this,null,function*(){return new Promise(o=>{o(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(e,t){return $(this,null,function*(){return new Promise(o=>{o(this.getDefaultHeaders());})})}getGetEmbeddingsData(e,t){return $(this,null,function*(){return new Promise(o=>{let n=this.transformConfig(e),s=this.transformEmbeddingRequests(t);if(t.requests.length===0)throw new de({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error("requests cannot be empty")});n.outputDimensionality&&(s.requests.forEach(r=>{r.outputDimensionality=n.outputDimensionality;}),delete n.outputDimensionality),o(S(S(S({},this.getDefaultParams()),n),s));})})}transformGetEmbeddingsResponse(e){let t=Tm.safeParse(e);if(t.success){let o=t.data.embeddings.map((n,s)=>({index:s,embedding:n.values}));return {encodingFormat:Ce,embeddings:o}}throw new H({info:"Invalid response from model",cause:t.error})}},sa="text-embedding-001",km="text-embedding-001",ra=W(na).parse({name:sa,description:km,modalities:oa,maxInputTokens:2048,maxOutputTokens:768,config:{def:Ue.base(768).def,schema:Ue.base(768).schema}}),_m=vi,xm=class extends aa{constructor(e){super(ra,e);}},la="text-embedding-004",Sm="text-embedding-004",ma=W(na).parse({name:la,description:Sm,modalities:oa,maxInputTokens:2048,maxOutputTokens:768,config:{def:Ue.base(768).def,schema:Ue.base(768).schema}}),wm=vi,Em=class extends aa{constructor(e){super(ma,e);}};var Cm="vertex",fe=class{constructor(){this.version="v1";this.name=Cm;this.chatModelFactories={[Mi]:{model:ot,modelOptions:da,modelSchema:ki},[_i]:{model:nt,modelOptions:ca,modelSchema:xi},[Fi]:{model:mt,modelOptions:fa,modelSchema:Li},[Si]:{model:at,modelOptions:pa,modelSchema:wi},[Ei]:{model:st,modelOptions:ua,modelSchema:Ci},[Gi]:{model:rt,modelOptions:ga,modelSchema:Oi},[ji]:{model:dt,modelOptions:ya,modelSchema:Ni},[Ri]:{model:lt,modelOptions:ha,modelSchema:Ii},[Ui]:{model:ct,modelOptions:ba,modelSchema:Di},[$i]:{model:pt,modelOptions:Pa,modelSchema:Bi},[Ai]:{model:ut,modelOptions:Ta,modelSchema:qi},[zi]:{model:gt,modelOptions:va,modelSchema:Hi},[Vi]:{model:ht,modelOptions:Ma,modelSchema:Ki},[Yi]:{model:ft,modelOptions:ka,modelSchema:Ji},[Xi]:{model:bt,modelOptions:xa,modelSchema:Qi},[Wi]:{model:yt,modelOptions:_a,modelSchema:Zi},[eo]:{model:Pt,modelOptions:Sa,modelSchema:to},[oo]:{model:Mt,modelOptions:Ea,modelSchema:no},[Tt]:{model:vt,modelOptions:wa,modelSchema:io},[ao]:{model:kt,modelOptions:Ca,modelSchema:so}};this.embeddingModelFactories={[ro]:{model:_t,modelOptions:Ga,modelSchema:lo},[mo]:{model:xt,modelOptions:Oa,modelSchema:co},[go]:{model:wt,modelOptions:Ia,modelSchema:ho},[po]:{model:St,modelOptions:Ra,modelSchema:uo}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((t,o)=>(t[o]=this.chatModelFactories[o].modelSchema,t),{})}chatModel(t){let o=t.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:
|
|
17
17
|
${this.chatModelLiterals().join(", ")}`)});let n=this.chatModelFactories[o].model,s=this.chatModelFactories[o].modelOptions.parse(t);return new n(s)}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((t,o)=>(t[o]=this.embeddingModelFactories[o].modelSchema,t),{})}embeddingModel(t){let o=t.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:
|
|
18
|
-
${this.embeddingModelLiterals().join(", ")}`)});let n=this.embeddingModelFactories[o].model,s=this.embeddingModelFactories[o].modelOptions.parse(t);return new n(s)}};fe.baseUrl=(t,o,n="google")=>`https://${t}-aiplatform.googleapis.com/v1/projects/${o}/locations/${t}/publishers/${n}`;var b={"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}}}]},"gemini-2.0-flash":{modelName:"gemini-2.0-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-2.0-flash-lite":{modelName:"gemini-2.0-flash-lite",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}}]},"gemini-2.5-flash-lite":{modelName:"gemini-2.5-flash-lite",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.5-flash-lite-preview-09-2025":{modelName:"gemini-2.5-flash-lite-preview-09-2025",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-1.5-flash-latest":{modelName:"gemini-1.5-flash-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.01875,outputPricePerMillion:.075}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.0375,outputPricePerMillion:.15}}}]},"gemini-1.5-pro-latest":{modelName:"gemini-1.5-pro-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.3125,outputPricePerMillion:1.25}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.625,outputPricePerMillion:2.5}}}]},"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:.5,outputPricePerMillion:2}}}]},"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-2.5-flash":{modelName:"gemini-2.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.3,outputPricePerMillion:2.5}}}]},"gemini-2.5-pro":{modelName:"gemini-2.5-pro",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-3-pro-preview":{modelName:"gemini-3-pro-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:2e5,prices:{base:{inputPricePerMillion:2,outputPricePerMillion:12}}},{minTokens:200001,maxTokens:null,prices:{base:{inputPricePerMillion:4,outputPricePerMillion:18}}}]},"gemini-3.1-pro-preview":{modelName:"gemini-3.1-pro-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:2e5,prices:{base:{inputPricePerMillion:2,outputPricePerMillion:8}}},{minTokens:200001,maxTokens:null,prices:{base:{inputPricePerMillion:3.5,outputPricePerMillion:12}}}]},"gemini-3-flash-preview":{modelName:"gemini-3-flash-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:3}}}]}};var M=zod.z.discriminatedUnion("authType",[zod.z.object({authType:zod.z.literal("accessToken"),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()}),zod.z.object({authType:zod.z.literal("serviceAccount"),serviceAccount:zod.z.object({client_email:zod.z.string().email(),private_key:zod.z.string(),type:zod.z.string().optional(),project_id:zod.z.string().optional(),private_key_id:zod.z.string().optional(),client_id:zod.z.string().optional(),auth_uri:zod.z.string().url().optional(),token_uri:zod.z.string().url().optional(),auth_provider_x509_cert_url:zod.z.string().url().optional(),client_x509_cert_url:zod.z.string().url().optional(),universe_domain:zod.z.string().optional()}),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(),tokenLifetimeHours:zod.z.number().min(.1).max(24).default(1)})]),T=class extends L{constructor(o,n){let s=M.parse(n),r;if(s.baseUrl)r=s.baseUrl;else if(s.location&&s.projectId)r=fe.baseUrl(s.location,s.projectId,s.publisher);else throw new _e({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:s.modelName,apiKey:"random-api-key",completeChatUrl:`${r}/models/${s.modelName}:generateContent`,streamChatUrl:`${r}/models/${s.modelName}:streamGenerateContent`});this.version="v1";this.accessToken=null;this.tokenExpiry=null;this.modelSchema=o,this.modelName=s.modelName,this.authOptions=s,this.location=s.location,this.projectId=s.projectId,this.publisher=s.publisher,s.authType==="accessToken"&&(this.accessToken=s.accessToken);}getAccessToken(){return X(this,null,function*(){if(this.accessToken&&this.tokenExpiry&&Date.now()<this.tokenExpiry)return this.accessToken;if(this.authOptions.authType==="serviceAccount")try{let o=this.authOptions.serviceAccount,n=Math.floor(Date.now()/1e3),s=yield new jose.SignJWT({scope:"https://www.googleapis.com/auth/cloud-platform",aud:"https://oauth2.googleapis.com/token"}).setProtectedHeader({alg:"RS256",typ:"JWT"}).setIssuedAt(n).setExpirationTime(n+this.authOptions.tokenLifetimeHours*3600).setIssuer(o.client_email).setSubject(o.client_email).sign(yield this.importPrivateKey(o.private_key)),r=yield fetch("https://oauth2.googleapis.com/token",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:jwt-bearer",assertion:s})});if(!r.ok){let m=yield r.text();throw new Error(`Token exchange failed: ${r.status} ${m}`)}let l=yield r.json();if(!l.access_token)throw new Error(`No access token received from Google OAuth: ${l.error||"Unknown error"}`);return this.tokenExpiry=Date.now()+this.authOptions.tokenLifetimeHours*3600*1e3-5*60*1e3,this.accessToken=l.access_token,this.accessToken}catch(o){throw new _e({info:`Failed to generate service account token: ${o instanceof Error?o.message:String(o)}`,cause:o instanceof Error?o:new Error(String(o))})}if(this.accessToken)return this.accessToken;throw new _e({info:"No valid access token available",cause:new Error("No valid access token available")})})}importPrivateKey(o){return X(this,null,function*(){let n=o.replace(/-----BEGIN PRIVATE KEY-----/,"").replace(/-----END PRIVATE KEY-----/,"").replace(/\s/g,""),s=atob(n),r=new Uint8Array(s.length);for(let l=0;l<s.length;l++)r[l]=s.charCodeAt(l);return yield crypto.subtle.importKey("pkcs8",r,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["sign"])})}ensureToken(){return X(this,null,function*(){this.authOptions.authType==="serviceAccount"&&(yield this.getAccessToken());})}getDefaultHeaders(){return _(y({},super.getDefaultHeaders()),{Authorization:`Bearer ${this.accessToken}`})}getCompleteChatHeaders(o,n,s){return X(this,null,function*(){return yield this.ensureToken(),this.getDefaultHeaders()})}getStreamChatHeaders(o,n,s){return X(this,null,function*(){return yield this.ensureToken(),this.getDefaultHeaders()})}getModelPricing(){if(!(this.modelName in b))throw new H({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return b[this.modelName]}};var Pi="gemini-1.5-flash-001",vi=_(y({},De),{price:b[Pi]}),sa=M,ot=class extends T{constructor(t){super(vi,t);}};var Mi="gemini-1.5-flash-002",_i=_(y({},$e),{price:b[Mi]}),ra=M,nt=class extends T{constructor(t){super(_i,t);}};var ki="gemini-1.5-flash",Si=_(y({},Ae),{price:b[ki]}),la=M,at=class extends T{constructor(t){super(Si,t);}};var xi="gemini-1.5-pro-001",Ei=_(y({},qe),{price:b[xi]}),ma=M,st=class extends T{constructor(t){super(Ei,t);}};var Ci="gemini-1.5-pro-002",wi=_(y({},ze),{price:b[Ci]}),da=M,rt=class extends T{constructor(t){super(wi,t);}};var Gi="gemini-1.5-pro",Oi=_(y({},Ve),{price:b[Gi]}),ca=M,lt=class extends T{constructor(t){super(Oi,t);}};var Ri="gemini-1.5-flash-latest",Fi=_(y({},Be),{price:b[Ri]}),pa=M,mt=class extends T{constructor(t){super(Fi,t);}};var Ii="gemini-1.5-pro-latest",Li=_(y({},He),{price:b[Ii]}),ua=M,dt=class extends T{constructor(t){super(Li,t);}};var ji="gemini-2.0-flash-exp",Ni=_(y({},Xn),{price:b[ji]}),ga=M,ct=class extends T{constructor(t){super(Ni,t);}};var Ui="gemini-2.0-flash",Di=_(y({},Ke),{price:b[Ui]}),ha=M,pt=class extends T{constructor(t){super(Di,t);}};var $i="gemini-2.0-flash-lite",Bi=_(y({},Ye),{price:b[$i]}),fa=M,ut=class extends T{constructor(t){super(Bi,t);}};var Ai="gemini-2.5-flash-lite",qi=_(y({},Je),{price:b[Ai]}),ya=M,gt=class extends T{constructor(t){super(qi,t);}};var zi="gemini-2.5-flash-lite-preview-09-2025",Hi=_(y({},We),{price:b[zi]}),ba=M,ht=class extends T{constructor(t){super(Hi,t);}};var Vi="gemini-2.5-flash-preview-04-17",Ki=_(y({},Ze),{price:b[Vi]}),Ta=M,ft=class extends T{constructor(t){super(Ki,t);}};var Yi="gemini-2.5-flash",Ji=_(y({},Xe),{price:b[Yi]}),Pa=M,yt=class extends T{constructor(t){super(Ji,t);}};var Wi="gemini-2.5-pro-preview-03-25",Zi=_(y({},Qe),{price:b[Wi]}),va=M,bt=class extends T{constructor(t){super(Zi,t);}};var Xi="gemini-2.5-pro",Qi=_(y({},et),{price:b[Xi]}),Ma=M,Tt=class extends T{constructor(t){super(Qi,t);}};var Pt="gemini-3.1-pro-preview",Mm="Google's Gemini 3.1 Pro Preview model on Vertex AI with improved reasoning and multimodal performance for complex agentic tasks.",eo=E(w,R).parse({name:Pt,description:Mm,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:O,config:{def:v.reasoning(2,1,65536,4,.95,1,65536).def,schema:v.reasoning(2,1,65536,4,.95,1,65536).schema},price:b[Pt]}),_a=M,vt=class extends T{constructor(t){super(eo,t);}};var to="gemini-3-flash-preview",io=_(y({},tt),{price:b[to]}),ka=M,Mt=class extends T{constructor(t){super(io,t);}};var oo="gemini-3-pro-preview",no=_(y({},it),{price:b[oo]}),Sa=M,_t=class extends T{constructor(t){super(no,t);}};var pe=[A],ue=zod.z.enum([A]);var Ga=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 Oa=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 re=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()}),ie=class{constructor(t,o){this.version="v1";let n=re.parse(o);this.modelSchema=t,this.modelName=n.modelName,this.accessToken=n.accessToken;let s;if(n.baseUrl)s=n.baseUrl;else if(n.location&&n.projectId)s=fe.baseUrl(n.location,n.projectId,n.publisher);else throw new _e({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=s,this.getEmbeddingsUrl=`${this.baseUrl}/models/${n.modelName}:predict`,this.location=n.location,this.projectId=n.projectId;}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"Content-Type":"application/json",Authorization:`Bearer ${this.accessToken}`}}getDefaultParams(){return {}}getRetryDelay(t,o){var l;let s=0,r=m=>{let d=m.match(/^(\d+(?:\.\d+)?)s$/);return d?Math.ceil(parseFloat(d[1])*1e3):0};if(o&&typeof o=="object"){let m=o;if((l=m.error)!=null&&l.details&&Array.isArray(m.error.details)){let d=m.error.details.find(c=>c["@type"]==="type.googleapis.com/google.rpc.RetryInfo");d!=null&&d.retryDelay&&(s=r(d.retryDelay));}}return {shouldRetry:!0,delayMs:s}}getTokenCount(t){return t.requests.reduce((o,n)=>o+n.length,0)}transformModelRequest(t){var d,c,g,P;let o=Oa.safeParse(t);if(!o.success)throw new ae({info:"Invalid model request",cause:o.error});let n=o.data,s=n.model,r={autoTruncate:((d=n.parameters)==null?void 0:d.auto_truncate)||((c=n.parameters)==null?void 0:c.autoTruncate),dimensions:((g=n.parameters)==null?void 0:g.output_dimensionality)||((P=n.parameters)==null?void 0:P.outputDimensionality)},l=Ce().parse(Oe(r)),m={modality:A,requests:n.instances.map(u=>u.content)};return {modelName:s,config:l,embeddingRequests:m}}transformConfig(t,o){let n=this.modelSchema.config.schema.safeParse(t);if(!n.success)throw new V({info:`Invalid config for model : '${this.modelName}'`,cause:n.error});let s=n.data;return Object.keys(s).forEach(l=>{if(!this.modelSchema.config.def[l])throw new V({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${l}',
|
|
19
|
-
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),{parameters:Object.keys(s).reduce((l,m)=>{let c=this.modelSchema.config.def[m].param,g=s[m];return l[c]=g,l},{})}}transformEmbeddingRequests(t){let o=Le().safeParse(t);if(!o.success)throw new de({info:"Invalid embedding requests",cause:o.error});if(t.modality!==A)throw new de({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Only '${A}' modality is supported for model : '${this.modelName}'`)});return {instances:o.data.requests.map(s=>({content:s}))}}getGetEmbeddingsUrl(t,o){return X(this,null,function*(){return new Promise(n=>{n(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(t,o){return X(this,null,function*(){return new Promise(n=>{n(this.getDefaultHeaders());})})}getGetEmbeddingsData(t,o){return X(this,null,function*(){return new Promise(n=>{if(o.requests.length===0)throw new de({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error("requests cannot be empty")});n(
|
|
18
|
+
${this.embeddingModelLiterals().join(", ")}`)});let n=this.embeddingModelFactories[o].model,s=this.embeddingModelFactories[o].modelOptions.parse(t);return new n(s)}};fe.baseUrl=(t,o,n="google")=>`https://${t}-aiplatform.googleapis.com/v1/projects/${o}/locations/${t}/publishers/${n}`;var P={"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}}}]},"gemini-2.0-flash":{modelName:"gemini-2.0-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-2.0-flash-lite":{modelName:"gemini-2.0-flash-lite",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}}]},"gemini-2.5-flash-lite":{modelName:"gemini-2.5-flash-lite",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.5-flash-lite-preview-09-2025":{modelName:"gemini-2.5-flash-lite-preview-09-2025",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-1.5-flash-latest":{modelName:"gemini-1.5-flash-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.01875,outputPricePerMillion:.075}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.0375,outputPricePerMillion:.15}}}]},"gemini-1.5-pro-latest":{modelName:"gemini-1.5-pro-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.3125,outputPricePerMillion:1.25}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.625,outputPricePerMillion:2.5}}}]},"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:.5,outputPricePerMillion:2}}}]},"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-2.5-flash":{modelName:"gemini-2.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.3,outputPricePerMillion:2.5}}}]},"gemini-2.5-pro":{modelName:"gemini-2.5-pro",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-3-pro-preview":{modelName:"gemini-3-pro-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:2e5,prices:{base:{inputPricePerMillion:2,outputPricePerMillion:12}}},{minTokens:200001,maxTokens:null,prices:{base:{inputPricePerMillion:4,outputPricePerMillion:18}}}]},"gemini-3.1-pro-preview":{modelName:"gemini-3.1-pro-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:2e5,prices:{base:{inputPricePerMillion:2,outputPricePerMillion:8}}},{minTokens:200001,maxTokens:null,prices:{base:{inputPricePerMillion:3.5,outputPricePerMillion:12}}}]},"gemini-3-flash-preview":{modelName:"gemini-3-flash-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:3}}}]}};var M=zod.z.discriminatedUnion("authType",[zod.z.object({authType:zod.z.literal("accessToken"),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()}),zod.z.object({authType:zod.z.literal("serviceAccount"),serviceAccount:zod.z.object({client_email:zod.z.string().email(),private_key:zod.z.string(),type:zod.z.string().optional(),project_id:zod.z.string().optional(),private_key_id:zod.z.string().optional(),client_id:zod.z.string().optional(),auth_uri:zod.z.string().url().optional(),token_uri:zod.z.string().url().optional(),auth_provider_x509_cert_url:zod.z.string().url().optional(),client_x509_cert_url:zod.z.string().url().optional(),universe_domain:zod.z.string().optional()}),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(),tokenLifetimeHours:zod.z.number().min(.1).max(24).default(1)})]),T=class extends I{constructor(o,n){let s=M.parse(n),r;if(s.baseUrl)r=s.baseUrl;else if(s.location&&s.projectId)r=fe.baseUrl(s.location,s.projectId,s.publisher);else throw new ke({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:s.modelName,apiKey:"random-api-key",completeChatUrl:`${r}/models/${s.modelName}:generateContent`,streamChatUrl:`${r}/models/${s.modelName}:streamGenerateContent`});this.version="v1";this.accessToken=null;this.tokenExpiry=null;this.modelSchema=o,this.modelName=s.modelName,this.authOptions=s,this.location=s.location,this.projectId=s.projectId,this.publisher=s.publisher,s.authType==="accessToken"&&(this.accessToken=s.accessToken);}getAccessToken(){return X(this,null,function*(){if(this.accessToken&&this.tokenExpiry&&Date.now()<this.tokenExpiry)return this.accessToken;if(this.authOptions.authType==="serviceAccount")try{let o=this.authOptions.serviceAccount,n=Math.floor(Date.now()/1e3),s=yield new jose.SignJWT({scope:"https://www.googleapis.com/auth/cloud-platform",aud:"https://oauth2.googleapis.com/token"}).setProtectedHeader({alg:"RS256",typ:"JWT"}).setIssuedAt(n).setExpirationTime(n+this.authOptions.tokenLifetimeHours*3600).setIssuer(o.client_email).setSubject(o.client_email).sign(yield this.importPrivateKey(o.private_key)),r=yield fetch("https://oauth2.googleapis.com/token",{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:jwt-bearer",assertion:s})});if(!r.ok){let m=yield r.text();throw new Error(`Token exchange failed: ${r.status} ${m}`)}let l=yield r.json();if(!l.access_token)throw new Error(`No access token received from Google OAuth: ${l.error||"Unknown error"}`);return this.tokenExpiry=Date.now()+this.authOptions.tokenLifetimeHours*3600*1e3-5*60*1e3,this.accessToken=l.access_token,this.accessToken}catch(o){throw new ke({info:`Failed to generate service account token: ${o instanceof Error?o.message:String(o)}`,cause:o instanceof Error?o:new Error(String(o))})}if(this.accessToken)return this.accessToken;throw new ke({info:"No valid access token available",cause:new Error("No valid access token available")})})}importPrivateKey(o){return X(this,null,function*(){let n=o.replace(/-----BEGIN PRIVATE KEY-----/,"").replace(/-----END PRIVATE KEY-----/,"").replace(/\s/g,""),s=atob(n),r=new Uint8Array(s.length);for(let l=0;l<s.length;l++)r[l]=s.charCodeAt(l);return yield crypto.subtle.importKey("pkcs8",r,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!1,["sign"])})}ensureToken(){return X(this,null,function*(){this.authOptions.authType==="serviceAccount"&&(yield this.getAccessToken());})}getDefaultHeaders(){return k(b({},super.getDefaultHeaders()),{Authorization:`Bearer ${this.accessToken}`})}getCompleteChatHeaders(o,n,s){return X(this,null,function*(){return yield this.ensureToken(),this.getDefaultHeaders()})}getStreamChatHeaders(o,n,s){return X(this,null,function*(){return yield this.ensureToken(),this.getDefaultHeaders()})}getModelPricing(){if(!(this.modelName in P))throw new H({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return P[this.modelName]}};var Mi="gemini-1.5-flash-001",ki=k(b({},De),{price:P[Mi]}),da=M,ot=class extends T{constructor(t){super(ki,t);}};var _i="gemini-1.5-flash-002",xi=k(b({},$e),{price:P[_i]}),ca=M,nt=class extends T{constructor(t){super(xi,t);}};var Si="gemini-1.5-flash",wi=k(b({},Ae),{price:P[Si]}),pa=M,at=class extends T{constructor(t){super(wi,t);}};var Ei="gemini-1.5-pro-001",Ci=k(b({},qe),{price:P[Ei]}),ua=M,st=class extends T{constructor(t){super(Ci,t);}};var Gi="gemini-1.5-pro-002",Oi=k(b({},ze),{price:P[Gi]}),ga=M,rt=class extends T{constructor(t){super(Oi,t);}};var Ri="gemini-1.5-pro",Ii=k(b({},Ve),{price:P[Ri]}),ha=M,lt=class extends T{constructor(t){super(Ii,t);}};var Fi="gemini-1.5-flash-latest",Li=k(b({},Be),{price:P[Fi]}),fa=M,mt=class extends T{constructor(t){super(Li,t);}};var ji="gemini-1.5-pro-latest",Ni=k(b({},He),{price:P[ji]}),ya=M,dt=class extends T{constructor(t){super(Ni,t);}};var Ui="gemini-2.0-flash-exp",Di=k(b({},ea),{price:P[Ui]}),ba=M,ct=class extends T{constructor(t){super(Di,t);}};var $i="gemini-2.0-flash",Bi=k(b({},Ke),{price:P[$i]}),Pa=M,pt=class extends T{constructor(t){super(Bi,t);}};var Ai="gemini-2.0-flash-lite",qi=k(b({},Ye),{price:P[Ai]}),Ta=M,ut=class extends T{constructor(t){super(qi,t);}};var zi="gemini-2.5-flash-lite",Hi=k(b({},Je),{price:P[zi]}),va=M,gt=class extends T{constructor(t){super(Hi,t);}};var Vi="gemini-2.5-flash-lite-preview-09-2025",Ki=k(b({},We),{price:P[Vi]}),Ma=M,ht=class extends T{constructor(t){super(Ki,t);}};var Yi="gemini-2.5-flash-preview-04-17",Ji=k(b({},Ze),{price:P[Yi]}),ka=M,ft=class extends T{constructor(t){super(Ji,t);}};var Wi="gemini-2.5-flash",Zi=k(b({},Xe),{price:P[Wi]}),_a=M,yt=class extends T{constructor(t){super(Zi,t);}};var Xi="gemini-2.5-pro-preview-03-25",Qi=k(b({},Qe),{price:P[Xi]}),xa=M,bt=class extends T{constructor(t){super(Qi,t);}};var eo="gemini-2.5-pro",to=k(b({},et),{price:P[eo]}),Sa=M,Pt=class extends T{constructor(t){super(to,t);}};var Tt="gemini-3.1-pro-preview",Rm="Google's Gemini 3.1 Pro Preview model on Vertex AI with improved reasoning and multimodal performance for complex agentic tasks.",io=w(C,R).parse({name:Tt,description:Rm,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:O,config:{def:f.reasoning(2,1,65536,4,.95,1,65536).def,schema:f.reasoning(2,1,65536,4,.95,1,65536).schema},price:P[Tt]}),wa=M,vt=class extends T{constructor(t){super(io,t);}};var oo="gemini-3-flash-preview",no=k(b({},tt),{price:P[oo]}),Ea=M,Mt=class extends T{constructor(t){super(no,t);}};var ao="gemini-3-pro-preview",so=k(b({},it),{price:P[ao]}),Ca=M,kt=class extends T{constructor(t){super(so,t);}};var pe=[A],ue=zod.z.enum([A]);var Fa=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 La=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 re=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()}),ie=class{constructor(t,o){this.version="v1";let n=re.parse(o);this.modelSchema=t,this.modelName=n.modelName,this.accessToken=n.accessToken;let s;if(n.baseUrl)s=n.baseUrl;else if(n.location&&n.projectId)s=fe.baseUrl(n.location,n.projectId,n.publisher);else throw new ke({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=s,this.getEmbeddingsUrl=`${this.baseUrl}/models/${n.modelName}:predict`,this.location=n.location,this.projectId=n.projectId;}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"Content-Type":"application/json",Authorization:`Bearer ${this.accessToken}`}}getDefaultParams(){return {}}getRetryDelay(t,o){var l;let s=0,r=m=>{let d=m.match(/^(\d+(?:\.\d+)?)s$/);return d?Math.ceil(parseFloat(d[1])*1e3):0};if(o&&typeof o=="object"){let m=o;if((l=m.error)!=null&&l.details&&Array.isArray(m.error.details)){let d=m.error.details.find(c=>c["@type"]==="type.googleapis.com/google.rpc.RetryInfo");d!=null&&d.retryDelay&&(s=r(d.retryDelay));}}return {shouldRetry:!0,delayMs:s}}getTokenCount(t){return t.requests.reduce((o,n)=>o+n.length,0)}transformModelRequest(t){var d,c,g,v;let o=La.safeParse(t);if(!o.success)throw new ae({info:"Invalid model request",cause:o.error});let n=o.data,s=n.model,r={autoTruncate:((d=n.parameters)==null?void 0:d.auto_truncate)||((c=n.parameters)==null?void 0:c.autoTruncate),dimensions:((g=n.parameters)==null?void 0:g.output_dimensionality)||((v=n.parameters)==null?void 0:v.outputDimensionality)},l=Ee().parse(Oe(r)),m={modality:A,requests:n.instances.map(u=>u.content)};return {modelName:s,config:l,embeddingRequests:m}}transformConfig(t,o){let n=this.modelSchema.config.schema.safeParse(t);if(!n.success)throw new V({info:`Invalid config for model : '${this.modelName}'`,cause:n.error});let s=n.data;return Object.keys(s).forEach(l=>{if(!this.modelSchema.config.def[l])throw new V({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${l}',
|
|
19
|
+
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),{parameters:Object.keys(s).reduce((l,m)=>{let c=this.modelSchema.config.def[m].param,g=s[m];return l[c]=g,l},{})}}transformEmbeddingRequests(t){let o=Le().safeParse(t);if(!o.success)throw new de({info:"Invalid embedding requests",cause:o.error});if(t.modality!==A)throw new de({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Only '${A}' modality is supported for model : '${this.modelName}'`)});return {instances:o.data.requests.map(s=>({content:s}))}}getGetEmbeddingsUrl(t,o){return X(this,null,function*(){return new Promise(n=>{n(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(t,o){return X(this,null,function*(){return new Promise(n=>{n(this.getDefaultHeaders());})})}getGetEmbeddingsData(t,o){return X(this,null,function*(){return new Promise(n=>{if(o.requests.length===0)throw new de({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error("requests cannot be empty")});n(b(b(b({},this.getDefaultParams()),this.transformConfig(t)),this.transformEmbeddingRequests(o)));})})}transformGetEmbeddingsResponse(t){let o=Fa.safeParse(t);if(o.success){let s=o.data.predictions.map((r,l)=>({index:l,embedding:r.embeddings.values}));return {encodingFormat:Ce,embeddings:s}}throw new H({info:"Invalid response from model",cause:o.error})}};var fo=e=>J({param:"output_dimensionality",title:_e.DIMENSIONS.title,description:_e.DIMENSIONS.description,min:1,max:e,step:1,default:e}),yo=Ge({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 ja=e=>zod.z.object({dimensions:fo(e).schema,autoTruncate:yo.schema}),Na=e=>({dimensions:fo(e).def,autoTruncate:yo.def});var K={base:e=>({def:Na(e),schema:ja(e)})};var ro="text-embedding-004",Lm="text-embedding-004",lo=W(ue).parse({name:ro,description:Lm,modalities:pe,maxInputTokens:2048,maxOutputTokens:768,config:{def:K.base(768).def,schema:K.base(768).schema}}),Ga=re,_t=class extends ie{constructor(t){super(lo,t);}};var mo="text-multilingual-embedding-002",jm="text-multilingual-embedding-002",co=W(ue).parse({name:mo,description:jm,modalities:pe,maxInputTokens:2048,maxOutputTokens:768,config:{def:K.base(768).def,schema:K.base(768).schema}}),Oa=re,xt=class extends ie{constructor(t){super(co,t);}};var po="textembedding-gecko-multilingual@001",Nm="textembedding-gecko-multilingual@001",uo=W(ue).parse({name:po,description:Nm,modalities:pe,maxInputTokens:2048,maxOutputTokens:768,config:{def:K.base(768).def,schema:K.base(768).schema}}),Ra=re,St=class extends ie{constructor(t){super(uo,t);}};var go="textembedding-gecko@003",Um="textembedding-gecko@003",ho=W(ue).parse({name:go,description:Um,modalities:pe,maxInputTokens:2048,maxOutputTokens:768,config:{def:K.base(768).def,schema:K.base(768).schema}}),Ia=re,wt=class extends ie{constructor(t){super(ho,t);}};
|
|
20
20
|
|
|
21
21
|
exports.BaseChatModelOptions = M;
|
|
22
22
|
exports.BaseChatModelVertex = T;
|
|
@@ -24,100 +24,100 @@ exports.BaseEmbeddingModel = ie;
|
|
|
24
24
|
exports.BaseEmbeddingModelOptions = re;
|
|
25
25
|
exports.Gemini1_5Flash = at;
|
|
26
26
|
exports.Gemini1_5Flash001 = ot;
|
|
27
|
-
exports.Gemini1_5Flash001Literal =
|
|
28
|
-
exports.Gemini1_5Flash001Options =
|
|
29
|
-
exports.Gemini1_5Flash001Schema =
|
|
27
|
+
exports.Gemini1_5Flash001Literal = Mi;
|
|
28
|
+
exports.Gemini1_5Flash001Options = da;
|
|
29
|
+
exports.Gemini1_5Flash001Schema = ki;
|
|
30
30
|
exports.Gemini1_5Flash002 = nt;
|
|
31
|
-
exports.Gemini1_5Flash002Literal =
|
|
32
|
-
exports.Gemini1_5Flash002Options =
|
|
33
|
-
exports.Gemini1_5Flash002Schema =
|
|
31
|
+
exports.Gemini1_5Flash002Literal = _i;
|
|
32
|
+
exports.Gemini1_5Flash002Options = ca;
|
|
33
|
+
exports.Gemini1_5Flash002Schema = xi;
|
|
34
34
|
exports.Gemini1_5FlashLatest = mt;
|
|
35
|
-
exports.Gemini1_5FlashLatestLiteral =
|
|
36
|
-
exports.Gemini1_5FlashLatestOptions =
|
|
37
|
-
exports.Gemini1_5FlashLatestSchema =
|
|
38
|
-
exports.Gemini1_5FlashLiteral =
|
|
39
|
-
exports.Gemini1_5FlashOptions =
|
|
40
|
-
exports.Gemini1_5FlashSchema =
|
|
35
|
+
exports.Gemini1_5FlashLatestLiteral = Fi;
|
|
36
|
+
exports.Gemini1_5FlashLatestOptions = fa;
|
|
37
|
+
exports.Gemini1_5FlashLatestSchema = Li;
|
|
38
|
+
exports.Gemini1_5FlashLiteral = Si;
|
|
39
|
+
exports.Gemini1_5FlashOptions = pa;
|
|
40
|
+
exports.Gemini1_5FlashSchema = wi;
|
|
41
41
|
exports.Gemini1_5Pro = lt;
|
|
42
42
|
exports.Gemini1_5Pro001 = st;
|
|
43
|
-
exports.Gemini1_5Pro001Literal =
|
|
44
|
-
exports.Gemini1_5Pro001Options =
|
|
45
|
-
exports.Gemini1_5Pro001Schema =
|
|
43
|
+
exports.Gemini1_5Pro001Literal = Ei;
|
|
44
|
+
exports.Gemini1_5Pro001Options = ua;
|
|
45
|
+
exports.Gemini1_5Pro001Schema = Ci;
|
|
46
46
|
exports.Gemini1_5Pro002 = rt;
|
|
47
|
-
exports.Gemini1_5Pro002Literal =
|
|
48
|
-
exports.Gemini1_5Pro002Options =
|
|
49
|
-
exports.Gemini1_5Pro002Schema =
|
|
47
|
+
exports.Gemini1_5Pro002Literal = Gi;
|
|
48
|
+
exports.Gemini1_5Pro002Options = ga;
|
|
49
|
+
exports.Gemini1_5Pro002Schema = Oi;
|
|
50
50
|
exports.Gemini1_5ProLatest = dt;
|
|
51
|
-
exports.Gemini1_5ProLatestLiteral =
|
|
52
|
-
exports.Gemini1_5ProLatestOptions =
|
|
53
|
-
exports.Gemini1_5ProLatestSchema =
|
|
54
|
-
exports.Gemini1_5ProLiteral =
|
|
55
|
-
exports.Gemini1_5ProOptions =
|
|
56
|
-
exports.Gemini1_5ProSchema =
|
|
51
|
+
exports.Gemini1_5ProLatestLiteral = ji;
|
|
52
|
+
exports.Gemini1_5ProLatestOptions = ya;
|
|
53
|
+
exports.Gemini1_5ProLatestSchema = Ni;
|
|
54
|
+
exports.Gemini1_5ProLiteral = Ri;
|
|
55
|
+
exports.Gemini1_5ProOptions = ha;
|
|
56
|
+
exports.Gemini1_5ProSchema = Ii;
|
|
57
57
|
exports.Gemini2_0Flash = pt;
|
|
58
58
|
exports.Gemini2_0FlashExp = ct;
|
|
59
|
-
exports.Gemini2_0FlashExpLiteral =
|
|
60
|
-
exports.Gemini2_0FlashExpOptions =
|
|
61
|
-
exports.Gemini2_0FlashExpSchema =
|
|
59
|
+
exports.Gemini2_0FlashExpLiteral = Ui;
|
|
60
|
+
exports.Gemini2_0FlashExpOptions = ba;
|
|
61
|
+
exports.Gemini2_0FlashExpSchema = Di;
|
|
62
62
|
exports.Gemini2_0FlashLite = ut;
|
|
63
|
-
exports.Gemini2_0FlashLiteLiteral =
|
|
64
|
-
exports.Gemini2_0FlashLiteOptions =
|
|
65
|
-
exports.Gemini2_0FlashLiteSchema =
|
|
66
|
-
exports.Gemini2_0FlashLiteral =
|
|
67
|
-
exports.Gemini2_0FlashOptions =
|
|
68
|
-
exports.Gemini2_0FlashSchema =
|
|
63
|
+
exports.Gemini2_0FlashLiteLiteral = Ai;
|
|
64
|
+
exports.Gemini2_0FlashLiteOptions = Ta;
|
|
65
|
+
exports.Gemini2_0FlashLiteSchema = qi;
|
|
66
|
+
exports.Gemini2_0FlashLiteral = $i;
|
|
67
|
+
exports.Gemini2_0FlashOptions = Pa;
|
|
68
|
+
exports.Gemini2_0FlashSchema = Bi;
|
|
69
69
|
exports.Gemini2_5Flash = yt;
|
|
70
70
|
exports.Gemini2_5FlashLite = gt;
|
|
71
|
-
exports.Gemini2_5FlashLiteLiteral =
|
|
72
|
-
exports.Gemini2_5FlashLiteOptions =
|
|
71
|
+
exports.Gemini2_5FlashLiteLiteral = zi;
|
|
72
|
+
exports.Gemini2_5FlashLiteOptions = va;
|
|
73
73
|
exports.Gemini2_5FlashLitePreview092025 = ht;
|
|
74
|
-
exports.Gemini2_5FlashLitePreview092025Literal =
|
|
75
|
-
exports.Gemini2_5FlashLitePreview092025Options =
|
|
76
|
-
exports.Gemini2_5FlashLitePreview092025Schema =
|
|
77
|
-
exports.Gemini2_5FlashLiteSchema =
|
|
78
|
-
exports.Gemini2_5FlashLiteral =
|
|
79
|
-
exports.Gemini2_5FlashOptions =
|
|
74
|
+
exports.Gemini2_5FlashLitePreview092025Literal = Vi;
|
|
75
|
+
exports.Gemini2_5FlashLitePreview092025Options = Ma;
|
|
76
|
+
exports.Gemini2_5FlashLitePreview092025Schema = Ki;
|
|
77
|
+
exports.Gemini2_5FlashLiteSchema = Hi;
|
|
78
|
+
exports.Gemini2_5FlashLiteral = Wi;
|
|
79
|
+
exports.Gemini2_5FlashOptions = _a;
|
|
80
80
|
exports.Gemini2_5FlashPreview0417 = ft;
|
|
81
|
-
exports.Gemini2_5FlashPreview0417Literal =
|
|
82
|
-
exports.Gemini2_5FlashPreview0417Options =
|
|
83
|
-
exports.Gemini2_5FlashPreview0417Schema =
|
|
84
|
-
exports.Gemini2_5FlashSchema =
|
|
85
|
-
exports.Gemini2_5Pro =
|
|
86
|
-
exports.Gemini2_5ProLiteral =
|
|
87
|
-
exports.Gemini2_5ProOptions =
|
|
81
|
+
exports.Gemini2_5FlashPreview0417Literal = Yi;
|
|
82
|
+
exports.Gemini2_5FlashPreview0417Options = ka;
|
|
83
|
+
exports.Gemini2_5FlashPreview0417Schema = Ji;
|
|
84
|
+
exports.Gemini2_5FlashSchema = Zi;
|
|
85
|
+
exports.Gemini2_5Pro = Pt;
|
|
86
|
+
exports.Gemini2_5ProLiteral = eo;
|
|
87
|
+
exports.Gemini2_5ProOptions = Sa;
|
|
88
88
|
exports.Gemini2_5ProPreview0325 = bt;
|
|
89
|
-
exports.Gemini2_5ProPreview0325Literal =
|
|
90
|
-
exports.Gemini2_5ProPreview0325Options =
|
|
91
|
-
exports.Gemini2_5ProPreview0325Schema =
|
|
92
|
-
exports.Gemini2_5ProSchema =
|
|
89
|
+
exports.Gemini2_5ProPreview0325Literal = Xi;
|
|
90
|
+
exports.Gemini2_5ProPreview0325Options = xa;
|
|
91
|
+
exports.Gemini2_5ProPreview0325Schema = Qi;
|
|
92
|
+
exports.Gemini2_5ProSchema = to;
|
|
93
93
|
exports.Gemini3FlashPreview = Mt;
|
|
94
|
-
exports.Gemini3FlashPreviewLiteral =
|
|
95
|
-
exports.Gemini3FlashPreviewOptions =
|
|
96
|
-
exports.Gemini3FlashPreviewSchema =
|
|
97
|
-
exports.Gemini3ProPreview =
|
|
98
|
-
exports.Gemini3ProPreviewLiteral =
|
|
99
|
-
exports.Gemini3ProPreviewOptions =
|
|
100
|
-
exports.Gemini3ProPreviewSchema =
|
|
94
|
+
exports.Gemini3FlashPreviewLiteral = oo;
|
|
95
|
+
exports.Gemini3FlashPreviewOptions = Ea;
|
|
96
|
+
exports.Gemini3FlashPreviewSchema = no;
|
|
97
|
+
exports.Gemini3ProPreview = kt;
|
|
98
|
+
exports.Gemini3ProPreviewLiteral = ao;
|
|
99
|
+
exports.Gemini3ProPreviewOptions = Ca;
|
|
100
|
+
exports.Gemini3ProPreviewSchema = so;
|
|
101
101
|
exports.Gemini3_1ProPreview = vt;
|
|
102
|
-
exports.Gemini3_1ProPreviewLiteral =
|
|
103
|
-
exports.Gemini3_1ProPreviewOptions =
|
|
104
|
-
exports.Gemini3_1ProPreviewSchema =
|
|
105
|
-
exports.Text_Embedding_004 =
|
|
106
|
-
exports.Text_Embedding_004Literal =
|
|
107
|
-
exports.Text_Embedding_004Options =
|
|
108
|
-
exports.Text_Embedding_004Schema =
|
|
109
|
-
exports.Text_Embedding_Gecko_003 =
|
|
110
|
-
exports.Text_Embedding_Gecko_003Literal =
|
|
111
|
-
exports.Text_Embedding_Gecko_003Options =
|
|
112
|
-
exports.Text_Embedding_Gecko_003Schema =
|
|
113
|
-
exports.Text_Embedding_Gecko_Multilingual_001 =
|
|
114
|
-
exports.Text_Embedding_Gecko_Multilingual_001Literal =
|
|
115
|
-
exports.Text_Embedding_Gecko_Multilingual_001Options =
|
|
116
|
-
exports.Text_Embedding_Gecko_Multilingual_001Schema =
|
|
117
|
-
exports.Text_Multilingual_Embedding_002 =
|
|
118
|
-
exports.Text_Multilingual_Embedding_002Literal =
|
|
119
|
-
exports.Text_Multilingual_Embedding_002Options =
|
|
120
|
-
exports.Text_Multilingual_Embedding_002Schema =
|
|
102
|
+
exports.Gemini3_1ProPreviewLiteral = Tt;
|
|
103
|
+
exports.Gemini3_1ProPreviewOptions = wa;
|
|
104
|
+
exports.Gemini3_1ProPreviewSchema = io;
|
|
105
|
+
exports.Text_Embedding_004 = _t;
|
|
106
|
+
exports.Text_Embedding_004Literal = ro;
|
|
107
|
+
exports.Text_Embedding_004Options = Ga;
|
|
108
|
+
exports.Text_Embedding_004Schema = lo;
|
|
109
|
+
exports.Text_Embedding_Gecko_003 = wt;
|
|
110
|
+
exports.Text_Embedding_Gecko_003Literal = go;
|
|
111
|
+
exports.Text_Embedding_Gecko_003Options = Ia;
|
|
112
|
+
exports.Text_Embedding_Gecko_003Schema = ho;
|
|
113
|
+
exports.Text_Embedding_Gecko_Multilingual_001 = St;
|
|
114
|
+
exports.Text_Embedding_Gecko_Multilingual_001Literal = po;
|
|
115
|
+
exports.Text_Embedding_Gecko_Multilingual_001Options = Ra;
|
|
116
|
+
exports.Text_Embedding_Gecko_Multilingual_001Schema = uo;
|
|
117
|
+
exports.Text_Multilingual_Embedding_002 = xt;
|
|
118
|
+
exports.Text_Multilingual_Embedding_002Literal = mo;
|
|
119
|
+
exports.Text_Multilingual_Embedding_002Options = Oa;
|
|
120
|
+
exports.Text_Multilingual_Embedding_002Schema = co;
|
|
121
121
|
exports.Vertex = fe;
|
|
122
122
|
//# sourceMappingURL=index.js.map
|
|
123
123
|
//# sourceMappingURL=index.js.map
|