@adaline/google 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +89 -1
- package/dist/index.d.ts +89 -1
- package/dist/index.js +78 -72
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -4,28 +4,30 @@ var zod = require('zod');
|
|
|
4
4
|
var provider = require('@adaline/provider');
|
|
5
5
|
var types = require('@adaline/types');
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var bt=Object.defineProperty,Pt=Object.defineProperties;var _t=Object.getOwnPropertyDescriptors;var _o=Object.getOwnPropertySymbols;var St=Object.prototype.hasOwnProperty,Et=Object.prototype.propertyIsEnumerable;var W=(a,e)=>(e=Symbol[a])?e:Symbol.for("Symbol."+a),Ot=a=>{throw TypeError(a)};var So=(a,e,t)=>e in a?bt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,_=(a,e)=>{for(var t in e||(e={}))St.call(e,t)&&So(a,t,e[t]);if(_o)for(var t of _o(e))Et.call(e,t)&&So(a,t,e[t]);return a},N=(a,e)=>Pt(a,_t(e));var S=(a,e,t)=>new Promise((o,i)=>{var l=r=>{try{n(t.next(r));}catch(s){i(s);}},m=r=>{try{n(t.throw(r));}catch(s){i(s);}},n=r=>r.done?o(r.value):Promise.resolve(r.value).then(l,m);n((t=t.apply(a,e)).next());}),Eo=function(a,e){this[0]=a,this[1]=e;},qe=(a,e,t)=>{var o=(m,n,r,s)=>{try{var p=t[m](n),h=(n=p.value)instanceof Eo,P=p.done;Promise.resolve(h?n[0]:n).then(y=>h?o(m==="return"?m:"next",n[1]?{done:y.done,value:y.value}:y,r,s):r({value:y,done:P})).catch(y=>o("throw",y,r,s));}catch(y){s(y);}},i=m=>l[m]=n=>new Promise((r,s)=>o(m,n,r,s)),l={};return t=t.apply(a,e),l[W("asyncIterator")]=()=>l,i("next"),i("throw"),i("return"),l},Oo=a=>{var e=a[W("asyncIterator")],t=!1,o,i={};return e==null?(e=a[W("iterator")](),o=l=>i[l]=m=>e[l](m)):(e=e.call(a),o=l=>i[l]=m=>{if(t){if(t=!1,l==="throw")throw m;return m}return t=!0,{done:!1,value:new Eo(new Promise(n=>{var r=e[l](m);r instanceof Object||Ot("Object expected"),n(r);}),1)}}),i[W("iterator")]=()=>i,o("next"),"throw"in e?o("throw"):i.throw=l=>{throw l},"return"in e&&o("return"),i};var vt=["HARM_CATEGORY_UNSPECIFIED","HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT","HARM_CATEGORY_CIVIC_INTEGRITY"],Ft=["HARM_BLOCK_THRESHOLD_UNSPECIFIED","BLOCK_LOW_AND_ABOVE","BLOCK_MEDIUM_AND_ABOVE","BLOCK_ONLY_HIGH","BLOCK_NONE","OFF"],He=(a,e)=>provider.RangeConfigItem({param:"temperature",title:provider.CHAT_CONFIG.TEMPERATURE.title,description:provider.CHAT_CONFIG.TEMPERATURE.description,min:0,max:a,step:.01,default:e}),Ke=a=>provider.RangeConfigItem({param:"maxOutputTokens",title:provider.CHAT_CONFIG.MAX_TOKENS.title,description:provider.CHAT_CONFIG.MAX_TOKENS.description,min:0,max:a,step:1,default:0}),Ye=a=>provider.MultiStringConfigItem({param:"stopSequences",title:provider.CHAT_CONFIG.STOP(a).title,description:provider.CHAT_CONFIG.STOP(a).description,max:a}),Ve=a=>provider.RangeConfigItem({param:"topP",title:provider.CHAT_CONFIG.TOP_P.title,description:provider.CHAT_CONFIG.TOP_P.description,min:0,max:1,step:.01,default:a}),ri=a=>provider.RangeConfigItem({param:"topK",title:provider.CHAT_CONFIG.TOP_K.title,description:provider.CHAT_CONFIG.TOP_K.description,min:1,max:40,step:1,default:a}),li=provider.RangeConfigItem({param:"frequencyPenalty",title:provider.CHAT_CONFIG.FREQUENCY_PENALTY.title,description:provider.CHAT_CONFIG.FREQUENCY_PENALTY.description,min:-2,max:2,step:.01,default:0}),mi=provider.RangeConfigItem({param:"presencePenalty",title:provider.CHAT_CONFIG.PRESENCE_PENALTY.title,description:provider.CHAT_CONFIG.PRESENCE_PENALTY.description,min:-2,max:2,step:.01,default:0}),pi=provider.RangeConfigItem({param:"seed",title:provider.CHAT_CONFIG.SEED.title,description:provider.CHAT_CONFIG.SEED.description,min:0,max:1e6,step:1,default:0}),Je=provider.SelectStringConfigItem({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"]}),Xe=provider.ObjectSchemaConfigItem({param:"safetySettings",title:"Safety settings",description:"The safety rating contains the category of harm and the harm probability level in that category for a piece of content.",objectSchema:zod.z.array(zod.z.object({threshold:zod.z.enum(Ft),category:zod.z.enum(vt)}))}),We=provider.SelectBooleanConfigItem({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});var Q=(a,e,t,o,i)=>zod.z.object({temperature:He(a,e).schema,maxTokens:Ke(t).schema,stop:Ye(o).schema,topP:Ve(i).schema,toolChoice:Je.schema,safetySettings:Xe.schema}),ee=(a,e,t,o,i)=>({temperature:He(a,e).def,maxTokens:Ke(t).def,stop:Ye(o).def,topP:Ve(i).def,toolChoice:Je.def,safetySettings:Xe.def});var Ro=provider.ObjectSchemaConfigItem({param:"response_schema",title:provider.CHAT_CONFIG.RESPONSE_SCHEMA.title,description:provider.CHAT_CONFIG.RESPONSE_SCHEMA.description,objectSchema:types.ResponseSchema}),wo=provider.SelectStringConfigItem({param:"response_format",title:provider.CHAT_CONFIG.RESPONSE_FORMAT_WITH_SCHEMA.title,description:provider.CHAT_CONFIG.RESPONSE_FORMAT_WITH_SCHEMA.description,default:"text",choices:["text","json_schema"]}),te=(a,e,t,o,i)=>N(_({},ee(a,e,t,o,i)),{responseFormat:wo.def,responseSchema:Ro.def}),ne=(a,e,t,o,i)=>Q(a,e,t,o,i).extend({responseFormat:wo.schema,responseSchema:Ro.schema});var xo=(a,e,t,o,i)=>ne(a,e,t,o,i).extend({reasoningEnabled:We.schema}),ko=(a,e,t,o,i)=>N(_({},te(a,e,t,o,i)),{reasoningEnabled:We.def});var Ze=a=>provider.RangeConfigItem({param:"outputDimensionality",title:provider.EMBEDDING_CONFIG.DIMENSIONS.title,description:provider.EMBEDDING_CONFIG.DIMENSIONS.description,min:1,max:a,step:1,default:a});var Fo=a=>zod.z.object({dimensions:Ze(a).schema}),No=a=>({dimensions:Ze(a).def});var g={base:(a,e,t,o,i)=>({def:ee(a,e,t,o,i),schema:Q(a,e,t,o,i)}),responseSchema:(a,e,t,o,i)=>({def:te(a,e,t,o,i),schema:ne(a,e,t,o,i)}),reasoning:(a,e,t,o,i)=>({def:ko(a,e,t,o,i),schema:xo(a,e,t,o,i)})},j={base:a=>({def:No(a),schema:Fo(a)})};var jt="google",$=class{constructor(){this.version="v1";this.name=jt;this.chatModelFactories={[ie]:{model:se,modelOptions:Lo,modelSchema:Qe},[ae]:{model:re,modelOptions:Do,modelSchema:eo},[le]:{model:me,modelOptions:Uo,modelSchema:oo},[pe]:{model:de,modelOptions:$o,modelSchema:to},[ce]:{model:ge,modelOptions:jo,modelSchema:no},[he]:{model:fe,modelOptions:Bo,modelSchema:io},[ue]:{model:ye,modelOptions:zo,modelSchema:so},[Ce]:{model:Te,modelOptions:Ao,modelSchema:ao},[Me]:{model:Ge,modelOptions:qo,modelSchema:ro},[_e]:{model:Se,modelOptions:Ko,modelSchema:mo},[Re]:{model:we,modelOptions:Vo,modelSchema:co},[Ee]:{model:Oe,modelOptions:Yo,modelSchema:po},[xe]:{model:ke,modelOptions:Jo,modelSchema:go},[ve]:{model:Fe,modelOptions:Xo,modelSchema:ho},[be]:{model:Pe,modelOptions:Ho,modelSchema:lo}};this.embeddingModelFactories={[fo]:{model:Ne,modelOptions:Wo,modelSchema:uo},[yo]:{model:Ie,modelOptions:Zo,modelSchema:Co}};}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 provider.ProviderError({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,i=this.chatModelFactories[t].modelOptions.parse(e);return new o(i)}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 provider.ProviderError({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,i=this.embeddingModelFactories[t].modelOptions.parse(e);return new o(i)}};$.baseUrl="https://generativelanguage.googleapis.com/v1beta";var u={"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-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.5-flash-lite":{modelName:"gemini-2.5-flash-lite",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]}};var T=zod.z.enum([types.SystemRoleLiteral,types.UserRoleLiteral,types.AssistantRoleLiteral,types.ToolRoleLiteral]),qt="model",zt="function",M={system:types.UserRoleLiteral,user:types.UserRoleLiteral,assistant:qt,tool:zt};var G=[types.TextModalityLiteral,types.ImageModalityLiteral,types.PdfModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],b=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral,types.PdfModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]),$i=[types.TextModalityLiteral],ji=zod.z.enum([types.TextModalityLiteral]),Bi=[types.TextModalityLiteral,types.ImageModalityLiteral],qi=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral]),zi=[types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],Ai=zod.z.enum([types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]);var At=zod.z.object({text:zod.z.string()}),Ht=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())})}),et=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([At,Ht]))}).optional(),finishReason:zod.z.string(),index:zod.z.number().optional(),safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string(),blocked:zod.z.boolean().optional()})))})),promptFeedback:zod.z.optional(zod.z.object({safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string()})))})),usageMetadata:zod.z.object({promptTokenCount:zod.z.number(),cachedContentTokenCount:zod.z.number().optional(),candidatesTokenCount:zod.z.number().optional(),totalTokenCount:zod.z.number()}).optional()}),Kt=zod.z.object({text:zod.z.string()}),Yt=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())})}),Mo=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([Kt,Yt]))}).optional(),finishReason:zod.z.string().optional(),index:zod.z.number().optional(),safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string(),blocked:zod.z.boolean().optional()})))})),promptFeedback:zod.z.optional(zod.z.object({safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string()})))})),usageMetadata:zod.z.object({promptTokenCount:zod.z.number().optional(),cachedContentTokenCount:zod.z.number().optional(),candidatesTokenCount:zod.z.number().optional(),totalTokenCount:zod.z.number().optional()}).optional()});var st=zod.z.object({text:zod.z.string().min(1)}),Vt=zod.z.object({inline_data:zod.z.object({mime_type:zod.z.string().min(1),data:zod.z.string().base64()})}),Jt=zod.z.object({file_data:zod.z.object({mime_type:zod.z.string().min(1),file_uri:zod.z.string().min(1)})}),Xt=zod.z.object({function_call:zod.z.object({name:zod.z.string().min(1),args:zod.z.record(zod.z.string().min(1))})}),Wt=zod.z.object({function_response:zod.z.object({name:zod.z.string().min(1),response:zod.z.record(zod.z.string().min(1))})}),Zt=zod.z.object({role:zod.z.enum(["user","model","function"]),parts:zod.z.array(zod.z.union([st,Vt,Jt,Xt,Wt]))}),ot=zod.z.object({parts:zod.z.array(st)}),Qt=zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),parameters:zod.z.any()}),tt=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()})}),nt=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()}),it=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"])}),at=zod.z.object({model:zod.z.string().min(1).optional(),contents:zod.z.array(Zt),systemInstruction:ot.optional(),system_instruction:ot.optional(),generationConfig:nt.optional(),generation_config:nt.optional(),safetySettings:zod.z.array(it).optional(),safety_settings:zod.z.array(it).optional(),tools:zod.z.object({function_declarations:zod.z.array(Qt)}).optional(),toolConfig:tt.optional(),tool_config:tt.optional()});var C=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()}),y=class{constructor(e,t){this.version="v1";var i;let o=C.parse(t);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash((i=o.baseUrl)!=null?i:$.baseUrl),this.completeChatUrl=provider.urlWithoutTrailingSlash(o.completeChatUrl||`${this.baseUrl}/models/${this.modelName}:generateContent?key=${this.apiKey}`),this.streamChatUrl=provider.urlWithoutTrailingSlash(o.streamChatUrl||`${this.baseUrl}/models/${this.modelName}:streamGenerateContent?key=${this.apiKey}`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"Content-Type":"application/json"}}getDefaultParams(){return {}}getRetryDelay(e){return {shouldRetry:!1,delayMs:0}}getTokenCount(e){return e.reduce((t,o)=>t+o.content.map(i=>i.modality==="text"?i.value:"").join(" ").length,0)}transformPdfMessages(e){return S(this,null,function*(){let t=n=>S(this,null,function*(){let r={};provider.isRunningInBrowser()||(r["User-Agent"]="Mozilla/5.0 (compatible; GoogleFilesAPI/1.0)");let s=yield fetch(n,{headers:r});if(!s.ok)throw new provider.InvalidMessagesError({info:`Failed to download PDF from URL: ${n}`,cause:new Error(`HTTP ${s.status}: ${s.statusText}`)});let d=yield s.arrayBuffer();return new Uint8Array(d)}),o=n=>S(this,null,function*(){try{let r=yield fetch(`https://generativelanguage.googleapis.com/v1beta/files?key=${this.apiKey}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok)return null;let h=((yield r.json()).files||[]).find(_=>_.displayName===n);return h?h.uri:null}catch(r){return null}}),i=(n,r)=>S(this,null,function*(){let s=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":n.length.toString(),"X-Goog-Upload-Header-Content-Type":"application/pdf","Content-Type":"application/json"},body:JSON.stringify({file:{display_name:r}})});if(!s.ok)throw new provider.InvalidMessagesError({info:"Failed to start PDF upload to Google Files API",cause:new Error(`HTTP ${s.status}: ${s.statusText}`)});let d=s.headers.get("x-goog-upload-url");if(!d)throw new provider.InvalidMessagesError({info:"No upload URL received from Google Files API",cause:new Error("Missing x-goog-upload-url header")});let h={"X-Goog-Upload-Offset":"0","X-Goog-Upload-Command":"upload, finalize"};provider.isRunningInBrowser()||(h["Content-Length"]=n.length.toString());let _=yield fetch(d,{method:"POST",headers:h,body:n});if(!_.ok)throw new provider.InvalidMessagesError({info:"Failed to upload PDF content to Google Files API",cause:new Error(`HTTP ${_.status}: ${_.statusText}`)});return (yield _.json()).file.uri}),l=n=>S(this,null,function*(){let r=yield o(n.file.id);if(r)return r;let s;if(n.value.type==="url")s=yield t(n.value.url);else {let d=n.value.base64,h="data:application/pdf;base64,";d=d.startsWith(h)?d.substring(h.length):d,s=provider.convertBase64ToUint8Array(d);}return yield i(s,n.file.id)}),m=[];for(let n of e){let r=[];for(let s of n.content)if(s.modality===types.PdfModalityLiteral){let d=yield l(s);r.push(N(P({},s),{value:{type:"url",url:d}}));}else r.push(s);m.push(N(P({},n),{content:r}));}return m})}transformModelRequest(e){let t=at.safeParse(e);if(!t.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:t.error});let o=t.data,i=o.model;if(o.system_instruction&&o.systemInstruction)throw new provider.InvalidModelRequestError({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 provider.InvalidModelRequestError({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 provider.InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tool_config' and 'toolConfig' are not allowed at the same time")});let l=o.system_instruction||o.systemInstruction,m=o.generation_config||o.generationConfig,n=o.safety_settings||o.safetySettings,r=o.tool_config||o.toolConfig;if(r&&(!o.tools||o.tools.function_declarations.length===0))throw new provider.InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let s={};r&&(r.function_calling_config.mode==="ANY"&&r.function_calling_config.allowed_function_names&&r.function_calling_config.allowed_function_names.length===1?s.toolChoice=r.function_calling_config.allowed_function_names[0]:s.toolChoice=r.function_calling_config.mode.toLowerCase()),s.seed=m==null?void 0:m.seed,s.maxTokens=m==null?void 0:m.maxOutputTokens,s.temperature=m==null?void 0:m.temperature,s.topP=m==null?void 0:m.topP,s.presencePenalty=m==null?void 0:m.presencePenalty,s.frequencyPenalty=m==null?void 0:m.frequencyPenalty,s.stop=m==null?void 0:m.stopSequences,s.safetySettings=n;let d=types.Config().parse(provider.removeUndefinedEntries(s)),h=[];l&&l.parts.forEach(f=>{h.push({role:types.SystemRoleLiteral,content:[{modality:types.TextModalityLiteral,value:f.text}]});}),o.contents.forEach(f=>{let x=f.role;switch(x){case"user":{let k=f.parts.map(E=>"text"in E?{modality:types.TextModalityLiteral,value:E.text}:{modality:types.ImageModalityLiteral,detail:"auto",value:{type:types.Base64ImageContentTypeLiteral,base64:E.inline_data.data,mediaType:E.inline_data.mime_type.split("/")[1]}});h.push({role:x,content:k});}break;case"model":{let k=f.parts.map((E,v)=>"text"in E?{modality:types.TextModalityLiteral,value:E.text}:{modality:types.ToolCallModalityLiteral,id:v.toString(),index:v,name:E.function_call.name,arguments:JSON.stringify(E.function_call.args)});h.push({role:types.AssistantRoleLiteral,content:k});}break;case"function":{let k=f.parts.map((E,v)=>({modality:types.ToolResponseModalityLiteral,id:v.toString(),index:v,name:E.function_response.name,data:JSON.stringify(E.function_response.response)}));h.push({role:types.ToolRoleLiteral,content:k});}break;default:throw new provider.InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${f.role}' is not supported for model : ${this.modelName}`)})}});let _=[];return o.tools&&o.tools.function_declarations.forEach(f=>{_.push({type:"function",definition:{schema:{name:f.name,description:f.description,parameters:f.parameters}}});}),{modelName:i,config:d,messages:h,tools:_.length>0?_:void 0}}transformConfig(e,t,o){let i=e.toolChoice;delete e.toolChoice;let l=this.modelSchema.config.schema.safeParse(e);if(!l.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:l.error});let m=l.data;Object.keys(m).forEach(d=>{if(!(d in this.modelSchema.config.def))throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${d}',
|
|
10
|
-
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let n=Object.keys(m).reduce((
|
|
11
|
-
one of [${h.choices.join(", ")}]`)})}}if("response_format"in n&&n.response_format!==void 0){let
|
|
9
|
+
[${this.embeddingModelLiterals().join(", ")}]`)});let o=this.embeddingModelFactories[t].model,i=this.embeddingModelFactories[t].modelOptions.parse(e);return new o(i)}};$.baseUrl="https://generativelanguage.googleapis.com/v1beta";var f={"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.5-flash-lite":{modelName:"gemini-2.5-flash-lite",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]}};var T=zod.z.enum([types.SystemRoleLiteral,types.UserRoleLiteral,types.AssistantRoleLiteral,types.ToolRoleLiteral]),Kt="model",Yt="function",M={system:types.UserRoleLiteral,user:types.UserRoleLiteral,assistant:Kt,tool:Yt};var G=[types.TextModalityLiteral,types.ImageModalityLiteral,types.PdfModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],b=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral,types.PdfModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]),Ki=[types.TextModalityLiteral],Yi=zod.z.enum([types.TextModalityLiteral]),Vi=[types.TextModalityLiteral,types.ImageModalityLiteral],Ji=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral]),Xi=[types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],Wi=zod.z.enum([types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]);var Vt=zod.z.object({text:zod.z.string()}),Jt=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())})}),et=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([Vt,Jt]))}).optional(),finishReason:zod.z.string(),index:zod.z.number().optional(),safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string(),blocked:zod.z.boolean().optional()})))})),promptFeedback:zod.z.optional(zod.z.object({safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string()})))})),usageMetadata:zod.z.object({promptTokenCount:zod.z.number(),cachedContentTokenCount:zod.z.number().optional(),candidatesTokenCount:zod.z.number().optional(),totalTokenCount:zod.z.number()}).optional()}),Xt=zod.z.object({text:zod.z.string()}),Wt=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())})}),Mo=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([Xt,Wt]))}).optional(),finishReason:zod.z.string().optional(),index:zod.z.number().optional(),safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string(),blocked:zod.z.boolean().optional()})))})),promptFeedback:zod.z.optional(zod.z.object({safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string()})))})),usageMetadata:zod.z.object({promptTokenCount:zod.z.number().optional(),cachedContentTokenCount:zod.z.number().optional(),candidatesTokenCount:zod.z.number().optional(),totalTokenCount:zod.z.number().optional()}).optional()});var st=zod.z.object({text:zod.z.string().min(1)}),Zt=zod.z.object({inline_data:zod.z.object({mime_type:zod.z.string().min(1),data:zod.z.string().base64()})}),Qt=zod.z.object({file_data:zod.z.object({mime_type:zod.z.string().min(1),file_uri:zod.z.string().min(1)})}),en=zod.z.object({function_call:zod.z.object({name:zod.z.string().min(1),args:zod.z.record(zod.z.string().min(1))})}),on=zod.z.object({function_response:zod.z.object({name:zod.z.string().min(1),response:zod.z.record(zod.z.string().min(1))})}),tn=zod.z.object({role:zod.z.enum(["user","model","function"]),parts:zod.z.array(zod.z.union([st,Zt,Qt,en,on]))}),ot=zod.z.object({parts:zod.z.array(st)}),nn=zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),parameters:zod.z.any()}),tt=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()})}),nt=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()}),it=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"])}),at=zod.z.object({model:zod.z.string().min(1).optional(),contents:zod.z.array(tn),systemInstruction:ot.optional(),system_instruction:ot.optional(),generationConfig:nt.optional(),generation_config:nt.optional(),safetySettings:zod.z.array(it).optional(),safety_settings:zod.z.array(it).optional(),tools:zod.z.object({function_declarations:zod.z.array(nn)}).optional(),toolConfig:tt.optional(),tool_config:tt.optional()});var C=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()}),u=class{constructor(e,t){this.version="v1";var i;let o=C.parse(t);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash((i=o.baseUrl)!=null?i:$.baseUrl),this.completeChatUrl=provider.urlWithoutTrailingSlash(o.completeChatUrl||`${this.baseUrl}/models/${this.modelName}:generateContent?key=${this.apiKey}`),this.streamChatUrl=provider.urlWithoutTrailingSlash(o.streamChatUrl||`${this.baseUrl}/models/${this.modelName}:streamGenerateContent?key=${this.apiKey}`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"Content-Type":"application/json"}}getDefaultParams(){return {}}getRetryDelay(e){return {shouldRetry:!1,delayMs:0}}getTokenCount(e){return e.reduce((t,o)=>t+o.content.map(i=>i.modality==="text"?i.value:"").join(" ").length,0)}transformPdfMessages(e){return S(this,null,function*(){let t=n=>S(this,null,function*(){let r={};provider.isRunningInBrowser()||(r["User-Agent"]="Mozilla/5.0 (compatible; GoogleFilesAPI/1.0)");let s=yield fetch(n,{headers:r});if(!s.ok)throw new provider.InvalidMessagesError({info:`Failed to download PDF from URL: ${n}`,cause:new Error(`HTTP ${s.status}: ${s.statusText}`)});let p=yield s.arrayBuffer();return new Uint8Array(p)}),o=n=>S(this,null,function*(){try{let r=yield fetch(`https://generativelanguage.googleapis.com/v1beta/files?key=${this.apiKey}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!r.ok)return null;let h=((yield r.json()).files||[]).find(P=>P.displayName===n);return h?h.uri:null}catch(r){return null}}),i=(n,r)=>S(this,null,function*(){let s=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":n.length.toString(),"X-Goog-Upload-Header-Content-Type":"application/pdf","Content-Type":"application/json"},body:JSON.stringify({file:{display_name:r}})});if(!s.ok)throw new provider.InvalidMessagesError({info:"Failed to start PDF upload to Google Files API",cause:new Error(`HTTP ${s.status}: ${s.statusText}`)});let p=s.headers.get("x-goog-upload-url");if(!p)throw new provider.InvalidMessagesError({info:"No upload URL received from Google Files API",cause:new Error("Missing x-goog-upload-url header")});let h={"X-Goog-Upload-Offset":"0","X-Goog-Upload-Command":"upload, finalize"};provider.isRunningInBrowser()||(h["Content-Length"]=n.length.toString());let P=yield fetch(p,{method:"POST",headers:h,body:n});if(!P.ok)throw new provider.InvalidMessagesError({info:"Failed to upload PDF content to Google Files API",cause:new Error(`HTTP ${P.status}: ${P.statusText}`)});return (yield P.json()).file.uri}),l=n=>S(this,null,function*(){let r=yield o(n.file.id);if(r)return r;let s;if(n.value.type==="url")s=yield t(n.value.url);else {let p=n.value.base64,h="data:application/pdf;base64,";p=p.startsWith(h)?p.substring(h.length):p,s=provider.convertBase64ToUint8Array(p);}return yield i(s,n.file.id)}),m=[];for(let n of e){let r=[];for(let s of n.content)if(s.modality===types.PdfModalityLiteral){let p=yield l(s);r.push(N(_({},s),{value:{type:"url",url:p}}));}else r.push(s);m.push(N(_({},n),{content:r}));}return m})}transformModelRequest(e){let t=at.safeParse(e);if(!t.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:t.error});let o=t.data,i=o.model;if(o.system_instruction&&o.systemInstruction)throw new provider.InvalidModelRequestError({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 provider.InvalidModelRequestError({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 provider.InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tool_config' and 'toolConfig' are not allowed at the same time")});let l=o.system_instruction||o.systemInstruction,m=o.generation_config||o.generationConfig,n=o.safety_settings||o.safetySettings,r=o.tool_config||o.toolConfig;if(r&&(!o.tools||o.tools.function_declarations.length===0))throw new provider.InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let s={};r&&(r.function_calling_config.mode==="ANY"&&r.function_calling_config.allowed_function_names&&r.function_calling_config.allowed_function_names.length===1?s.toolChoice=r.function_calling_config.allowed_function_names[0]:s.toolChoice=r.function_calling_config.mode.toLowerCase()),s.seed=m==null?void 0:m.seed,s.maxTokens=m==null?void 0:m.maxOutputTokens,s.temperature=m==null?void 0:m.temperature,s.topP=m==null?void 0:m.topP,s.presencePenalty=m==null?void 0:m.presencePenalty,s.frequencyPenalty=m==null?void 0:m.frequencyPenalty,s.stop=m==null?void 0:m.stopSequences,s.safetySettings=n;let p=types.Config().parse(provider.removeUndefinedEntries(s)),h=[];l&&l.parts.forEach(y=>{h.push({role:types.SystemRoleLiteral,content:[{modality:types.TextModalityLiteral,value:y.text}]});}),o.contents.forEach(y=>{let w=y.role;switch(w){case"user":{let k=y.parts.map(E=>"text"in E?{modality:types.TextModalityLiteral,value:E.text}:{modality:types.ImageModalityLiteral,detail:"auto",value:{type:types.Base64ImageContentTypeLiteral,base64:E.inline_data.data,mediaType:E.inline_data.mime_type.split("/")[1]}});h.push({role:w,content:k});}break;case"model":{let k=y.parts.map((E,F)=>"text"in E?{modality:types.TextModalityLiteral,value:E.text}:{modality:types.ToolCallModalityLiteral,id:F.toString(),index:F,name:E.function_call.name,arguments:JSON.stringify(E.function_call.args)});h.push({role:types.AssistantRoleLiteral,content:k});}break;case"function":{let k=y.parts.map((E,F)=>({modality:types.ToolResponseModalityLiteral,id:F.toString(),index:F,name:E.function_response.name,data:JSON.stringify(E.function_response.response)}));h.push({role:types.ToolRoleLiteral,content:k});}break;default:throw new provider.InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${y.role}' is not supported for model : ${this.modelName}`)})}});let P=[];return o.tools&&o.tools.function_declarations.forEach(y=>{P.push({type:"function",definition:{schema:{name:y.name,description:y.description,parameters:y.parameters}}});}),{modelName:i,config:p,messages:h,tools:P.length>0?P:void 0}}transformConfig(e,t,o){let i=e.toolChoice;delete e.toolChoice;let l=this.modelSchema.config.schema.safeParse(e);if(!l.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:l.error});let m=l.data;Object.keys(m).forEach(p=>{if(!(p in this.modelSchema.config.def))throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${p}',
|
|
10
|
+
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let n=Object.keys(m).reduce((p,h)=>{let P=this.modelSchema.config.def[h],y=P.param,w=m[h];return h==="reasoningEnabled"?p.thinkingConfig={includeThoughts:w}:h==="maxReasoningTokens"?p.thinkingConfig=p.thinkingConfig&&typeof p.thinkingConfig=="object"?N(_({},p.thinkingConfig),{thinkingBudget:w}):{thinkingBudget:w}:y==="maxOutputTokens"&&P.type==="range"&&w===0?p[y]=P.max:p[y]=w,p},{}),r=n.safetySettings;delete n.safetySettings;let s;if(i!==void 0){let p=i;if(!o||o&&o.length===0)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(o&&o.length>0){let h=this.modelSchema.config.def.toolChoice;if(h.choices.includes(p))p==="any"?s={function_calling_config:{mode:"ANY",allowed_function_names:o.map(P=>P.definition.schema.name)}}:s={function_calling_config:{mode:p.toUpperCase()}};else if(o.map(P=>P.definition.schema.name).includes(p))s={function_calling_config:{mode:"ANY",allowed_function_names:[p]}};else throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`toolChoice : '${p}' is not part of provided 'tools' names or
|
|
11
|
+
one of [${h.choices.join(", ")}]`)})}}if("response_format"in n&&n.response_format!==void 0){let p=n.response_format;if(p==="json_schema"){let h=n.response_schema;if(!("response_schema"in n)||!n.response_schema||!(h!=null&&h.schema))throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'responseSchema' is required in config when 'responseFormat' is 'json_schema'")});n.responseSchema=h.schema,n.responseMimeType="application/json","additionalProperties"in h.schema&&delete n.responseSchema.additionalProperties,delete n.response_format,delete n.response_schema;}else p==="json_object"?(n.responseSchema={type:"object"},delete n.response_format):p==="text"&&delete n.response_format;}return _(_({generation_config:n},s?{tool_config:s}:{}),r?{safety_settings:r}:{})}transformMessages(e){if(!e||e&&e.length===0)return {messages:[]};let t=n=>{let r=n.match(/^data:(image\/[a-zA-Z]+|application\/pdf);base64,/);return r?n.substring(r[0].length):n},o=e.map(n=>{let r=types.Message().safeParse(n);if(!r.success)throw new provider.InvalidMessagesError({info:"Invalid messages",cause:r.error});return r.data});o.forEach(n=>{n.content.forEach(r=>{if(!this.modelSchema.modalities.includes(r.modality))throw new provider.InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${r.modality}',
|
|
12
12
|
available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),o.forEach(n=>{if(!Object.keys(this.modelSchema.roles).includes(n.role))throw new provider.InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${n.role}',
|
|
13
|
-
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})});let i={parts:[]},l=[];if(o.forEach(n=>{switch(n.role){case types.SystemRoleLiteral:n.content.forEach(r=>{if(r.modality===types.TextModalityLiteral)i.parts.push({text:r.value});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${r.modality}'`)})});break;case types.AssistantRoleLiteral:{let r=[];n.content.forEach(s=>{if(s.modality===types.TextModalityLiteral)r.push({text:s.value});else if(s.modality===types.ToolCallModalityLiteral)r.push({function_call:{name:s.name,args:JSON.parse(s.arguments)}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${s.modality}'`)})}),l.push({role:this.modelSchema.roles[n.role],parts:r});}break;case types.UserRoleLiteral:{let r=[];n.content.forEach(s=>{if(s.modality===types.TextModalityLiteral)r.push({text:s.value});else if(s.modality===types.ImageModalityLiteral){if(s.value.type==="base64"){let
|
|
14
|
-
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}}),l[0].role!==this.modelSchema.roles[types.UserRoleLiteral])throw new provider.InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires first message to be from user`)});let m=n=>n===this.modelSchema.roles[types.UserRoleLiteral]||n===this.modelSchema.roles[types.ToolRoleLiteral]?[this.modelSchema.roles[types.AssistantRoleLiteral]]:[this.modelSchema.roles[types.UserRoleLiteral],this.modelSchema.roles[types.ToolRoleLiteral]];for(let n=1;n<l.length;n++)if(!m(l[n-1].role).includes(l[n].role))throw new provider.InvalidMessagesError({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' cannot have message with role : '${l[n].role}' after message with role : '${l[n-1].role}'`)});if(l[l.length-1].role!==this.modelSchema.roles[types.UserRoleLiteral]&&l[l.length-1].role!==this.modelSchema.roles[types.ToolRoleLiteral])throw new provider.InvalidMessagesError({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires last message to be from user`)});return
|
|
15
|
-
`,s);if(d===-1){r=m.substring(s);break}else {let h=m.substring(s,d).trim();h&&n.push(h),s=d+1;}}for(let d of n){if(d==="data: [DONE]")return;if(d.startsWith("data: ")){let h=d.substring(6);try{let _=JSON.parse(h),f=Mo.safeParse(_);if(f.success){let x={partialMessages:[]},w=f.data;if(w.candidates.length>0){let k=w.candidates[0].content;k&&"parts"in k&&k.parts.length>0&&k.parts.forEach((E,v)=>{if("text"in E&&E.text!==void 0&&x.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,E.text)),"functionCall"in E&&E.functionCall!==void 0){let ze=E.functionCall;x.partialMessages.push(types.createPartialToolCallMessage(types.AssistantRoleLiteral,v,`${ze.name}_${v}`,ze.name,JSON.stringify(ze.args)));}});}w.usageMetadata&&w.usageMetadata.totalTokenCount&&w.usageMetadata.promptTokenCount&&w.usageMetadata.candidatesTokenCount&&(x.usage={promptTokens:w.usageMetadata.promptTokenCount,completionTokens:w.usageMetadata.candidatesTokenCount,totalTokens:w.usageMetadata.totalTokenCount}),yield {partialResponse:x,buffer:t};}else throw new provider.ModelResponseError({info:"Invalid response from model",cause:f.error})}catch(_){throw new provider.ModelResponseError({info:`Malformed JSON received in stream: ${h}`,cause:_})}}}yield {partialResponse:{partialMessages:[]},buffer:r};})}getProxyCompleteChatUrl(e,t,o){return S(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getProxyStreamChatUrl(e,t,o){return S(this,null,function*(){return new Promise(i=>{if(!o||Object.keys(o).length===0){i(this.streamChatUrl);return}let l=new URL(this.streamChatUrl);Object.entries(o).forEach(([m,n])=>{n!=null&&l.searchParams.set(m,n);}),i(l.toString());})})}getProxyCompleteChatHeaders(e,t,o){return S(this,null,function*(){if(!t)return {};let i=P({},t);return delete i.host,delete i["content-length"],i})}getProxyStreamChatHeaders(e,t,o){return S(this,null,function*(){return yield this.getProxyCompleteChatHeaders(e,t,o)})}getModelPricing(){if(!(this.modelName in u))throw new provider.ModelResponseError({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return u[this.modelName]}};var ie="gemini-1.5-flash-001",dn="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",Qe=provider.ChatModelSchema(T,b).parse({name:ie,description:dn,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:u[ie]}),Lo=C,se=class extends y{constructor(e){super(Qe,e);}};var ae="gemini-1.5-flash-002",cn="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",eo=provider.ChatModelSchema(T,b).parse({name:ae,description:cn,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:u[ae]}),Do=C,re=class extends y{constructor(e){super(eo,e);}};var le="gemini-1.5-flash-latest",gn="Google's latest multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",oo=provider.ChatModelSchema(T,b).parse({name:le,description:gn,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:u[le]}),Uo=C,me=class extends y{constructor(e){super(oo,e);}};var de="gemini-1.5-flash",un="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",to=provider.ChatModelSchema(T,b).parse({name:de,description:un,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:u[de]}),$o=C,pe=class extends y{constructor(e){super(to,e);}};var ce="gemini-1.5-pro-001",Cn="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",no=provider.ChatModelSchema(T,b).parse({name:ce,description:Cn,maxInputTokens:2e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:u[ce]}),jo=C,he=class extends y{constructor(e){super(no,e);}};var ge="gemini-1.5-pro-002",Mn="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",io=provider.ChatModelSchema(T,b).parse({name:ge,description:Mn,maxInputTokens:2e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:u[ge]}),Bo=C,fe=class extends y{constructor(e){super(io,e);}};var ue="gemini-1.5-pro-latest",bn="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",so=provider.ChatModelSchema(T,b).parse({name:ue,description:bn,maxInputTokens:2e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:u[ue]}),qo=C,ye=class extends y{constructor(e){super(so,e);}};var Ce="gemini-1.5-pro",Pn="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",ao=provider.ChatModelSchema(T,b).parse({name:Ce,description:Pn,maxInputTokens:2e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:u[Ce]}),zo=C,Te=class extends y{constructor(e){super(ao,e);}};var Me="gemini-2.0-flash-exp",En="Google's experimental multimodal model with enhanced capabilities. Designed for cutting-edge performance across complex and high-frequency tasks.",ro=provider.ChatModelSchema(T,b).parse({name:Me,description:En,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:u[Me]}),Ao=C,Ge=class extends y{constructor(e){super(ro,e);}};var be="gemini-2.0-flash",Rn="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.",lo=provider.ChatModelSchema(T,b).parse({name:be,description:Rn,maxInputTokens:1048576,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:u[be]}),Ho=C,_e=class extends y{constructor(e){super(lo,e);}};var Pe="gemini-2.5-flash-lite",wn="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.",mo=provider.ChatModelSchema(T,b).parse({name:Pe,description:wn,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.responseSchema(2,1,65536,4,.95).def,schema:g.responseSchema(2,1,65536,4,.95).schema},price:u[Pe]}),Ko=C,Se=class extends y{constructor(e){super(mo,e);}};var Ee="gemini-2.5-flash-preview-04-17",Fn="Google's best model in Gemini 2.5 family in terms of price-performance, offering well-rounded capabilities.",po=provider.ChatModelSchema(T,b).parse({name:Ee,description:Fn,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.responseSchema(2,1,65536,4,.95).def,schema:g.responseSchema(2,1,65536,4,.95).schema},price:u[Ee]}),Yo=C,Oe=class extends y{constructor(e){super(po,e);}};var Re="gemini-2.5-flash",Nn="Google's Gemini 2.5 Flash model for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",co=provider.ChatModelSchema(T,b).parse({name:Re,description:Nn,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.responseSchema(2,1,65536,4,.95).def,schema:g.responseSchema(2,1,65536,4,.95).schema},price:u[Re]}),Vo=C,xe=class extends y{constructor(e){super(co,e);}};var we="gemini-2.5-pro-preview-03-25",Ln="Google's preview model in Gemini 2.5 family for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",ho=provider.ChatModelSchema(T,b).parse({name:we,description:Ln,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.reasoning(2,1,65536,4,.95).def,schema:g.reasoning(2,1,65536,4,.95).schema},price:u[we]}),Jo=C,ke=class extends y{constructor(e){super(ho,e);}};var Fe="gemini-2.5-pro",Un="Google's Gemini 2.5 Pro model for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",go=provider.ChatModelSchema(T,b).parse({name:Fe,description:Un,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.reasoning(2,1,65536,4,.95).def,schema:g.reasoning(2,1,65536,4,.95).schema},price:u[Fe]}),Xo=C,ve=class extends y{constructor(e){super(go,e);}};var Be=[types.EmbeddingTextModalityLiteral],qe=zod.z.enum([types.EmbeddingTextModalityLiteral]);var ut=zod.z.object({embeddings:zod.z.array(zod.z.object({values:zod.z.array(zod.z.number())}))});var jn=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)})}),yt=zod.z.object({model:zod.z.string().min(1).optional(),requests:zod.z.array(jn).min(1),outputDimensionality:zod.z.number().int().min(1).optional()});var X=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),getEmbeddingsUrl:zod.z.string().url().optional()}),z=class{constructor(e,t){this.version="v1";let o=X.parse(t);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash(o.baseUrl||$.baseUrl),this.getEmbeddingsUrl=provider.urlWithoutTrailingSlash(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){return {shouldRetry:!1,delayMs:0}}getTokenCount(e){return e.requests.reduce((t,o)=>t+o.length,0)}transformModelRequest(e){let t=yt.safeParse(e);if(!t.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:t.error});let o=t.data,i=o.model,l={outputDimensionality:o.outputDimensionality},m=types.Config().parse(provider.removeUndefinedEntries(l)),n={modality:types.EmbeddingTextModalityLiteral,requests:o.requests.reduce((r,s)=>(r.push(...s.content.parts.map(d=>d.text)),r),[])};return {modelName:i,config:m,embeddingRequests:n}}transformConfig(e,t){let o=this.modelSchema.config.schema.safeParse(e);if(!o.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:o.error});let i=o.data;return Object.keys(i).forEach(m=>{if(!this.modelSchema.config.def[m])throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${m}',
|
|
16
|
-
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(i).reduce((m,n)=>{let s=this.modelSchema.config.def[n].param,
|
|
13
|
+
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})});let i={parts:[]},l=[];if(o.forEach(n=>{switch(n.role){case types.SystemRoleLiteral:n.content.forEach(r=>{if(r.modality===types.TextModalityLiteral)i.parts.push({text:r.value});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${r.modality}'`)})});break;case types.AssistantRoleLiteral:{let r=[];n.content.forEach(s=>{if(s.modality===types.TextModalityLiteral)r.push({text:s.value});else if(s.modality===types.ToolCallModalityLiteral)r.push({function_call:{name:s.name,args:JSON.parse(s.arguments)}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${s.modality}'`)})}),l.push({role:this.modelSchema.roles[n.role],parts:r});}break;case types.UserRoleLiteral:{let r=[];n.content.forEach(s=>{if(s.modality===types.TextModalityLiteral)r.push({text:s.value});else if(s.modality===types.ImageModalityLiteral){if(s.value.type==="base64"){let p=s.value.base64;p=t(p),r.push({inline_data:{mime_type:`image/${s.value.mediaType}`,data:p}});}else if(s.value.type==="url")throw new provider.InvalidMessagesError({info:`Invalid message 'modality' for model : ${this.modelName}`,cause:new Error(`model: '${this.modelName}' does not support image content type: '${s.value.type}'`)})}else if(s.modality===types.PdfModalityLiteral)if(s.value.type==="base64"){let p=s.value.base64;p=t(p),r.push({inline_data:{mime_type:"application/pdf",data:p}});}else s.value.type==="url"&&r.push({file_data:{mime_type:"application/pdf",file_uri:s.value.url}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${s.modality}'`)})}),l.push({role:this.modelSchema.roles[n.role],parts:r});}break;case types.ToolRoleLiteral:{let r=[];n.content.forEach(s=>{if(s.modality===types.ToolResponseModalityLiteral)r.push({function_response:{name:s.name,response:JSON.parse(s.data)}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${s.modality}'`)})}),l.push({role:this.modelSchema.roles[n.role],parts:r});}break;default:throw new provider.InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' is not supported,
|
|
14
|
+
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}}),l[0].role!==this.modelSchema.roles[types.UserRoleLiteral])throw new provider.InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires first message to be from user`)});let m=n=>n===this.modelSchema.roles[types.UserRoleLiteral]||n===this.modelSchema.roles[types.ToolRoleLiteral]?[this.modelSchema.roles[types.AssistantRoleLiteral]]:[this.modelSchema.roles[types.UserRoleLiteral],this.modelSchema.roles[types.ToolRoleLiteral]];for(let n=1;n<l.length;n++)if(!m(l[n-1].role).includes(l[n].role))throw new provider.InvalidMessagesError({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' cannot have message with role : '${l[n].role}' after message with role : '${l[n-1].role}'`)});if(l[l.length-1].role!==this.modelSchema.roles[types.UserRoleLiteral]&&l[l.length-1].role!==this.modelSchema.roles[types.ToolRoleLiteral])throw new provider.InvalidMessagesError({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires last message to be from user`)});return _({contents:l},i.parts.length>0?{system_instruction:i}:{})}transformTools(e){if(!this.modelSchema.modalities.includes(types.ToolCallModalityLiteral))throw new provider.InvalidToolsError({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${types.ToolCallModalityLiteral}'`)});return !e||e&&e.length===0?{tools:[]}:{tools:[{function_declarations:e.map(i=>{let l=types.Tool().safeParse(i);if(!l.success)throw new provider.InvalidToolsError({info:"Invalid tools",cause:l.error});return l.data}).map(i=>({name:i.definition.schema.name,description:i.definition.schema.description,parameters:i.definition.schema.parameters}))}]}}getCompleteChatUrl(e,t,o){return S(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getCompleteChatHeaders(e,t,o){return S(this,null,function*(){return new Promise(i=>{i(this.getDefaultHeaders());})})}getCompleteChatData(e,t,o){return S(this,null,function*(){let i=this.transformConfig(e,t,o),l=yield this.transformPdfMessages(t),m=this.transformMessages(l);if(m.messages&&m.messages.length===0)throw new provider.InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let n=o?this.transformTools(o):{};return _(_(_(_({},this.getDefaultParams()),i),m),n)})}transformCompleteChatResponse(e){let t=et.safeParse(e);if(t.success){if(t.data.candidates.length===0)throw new provider.ModelResponseError({info:"Invalid response from model",cause:new Error(`No choices in response : ${JSON.stringify(t.data)}`)});let o=t.data,i=[],l,m=o.candidates[0].content;if(m){let s=m.parts.map((p,h)=>{if("text"in p&&p.text!==void 0)return types.createTextContent(p.text);if("functionCall"in p&&p.functionCall!==void 0)return types.createToolCallContent(h,`${p.functionCall.name}_${h}`,p.functionCall.name,JSON.stringify(p.functionCall.args))});return i.push({role:types.AssistantRoleLiteral,content:s}),o.usageMetadata&&(l={promptTokens:o.usageMetadata.promptTokenCount,totalTokens:o.usageMetadata.totalTokenCount,completionTokens:o.usageMetadata.candidatesTokenCount||0}),{messages:i,usage:l,logProbs:void 0}}let n=o.candidates[0].safetyRatings;if(n&&n.length>0&&n.forEach(s=>{if(s.blocked)throw new provider.ModelResponseError({info:`Blocked content for category: ${s.category} with probability: ${s.probability}`,cause:new Error(`Blocked content for category: ${s.category} with probability: ${s.probability}`)})}),o.candidates[0].finishReason==="SAFETY")throw new provider.ModelResponseError({info:"Blocked content, model response finished with safety reason",cause:new Error("Blocked content, model response finished with safety reason")})}throw new provider.ModelResponseError({info:"Invalid response from model",cause:t.error})}getStreamChatUrl(e,t,o){return S(this,null,function*(){return new Promise(i=>{i(this.streamChatUrl);})})}getStreamChatHeaders(e,t,o){return S(this,null,function*(){return new Promise(i=>{i(this.getDefaultHeaders());})})}getStreamChatData(e,t,o){return S(this,null,function*(){let i=this.transformConfig(e,t,o),l=yield this.transformPdfMessages(t),m=this.transformMessages(l);if(m.messages&&m.messages.length===0)throw new provider.InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let n=o?this.transformTools(o):{};return _(_(_(_({},this.getDefaultParams()),i),m),n)})}transformStreamChatResponseChunk(e,t){return qe(this,null,function*(){let o=(t+e).split(",\r").filter(i=>i.trim()!=="");for(let i of o){let l=i;if(l=l.replace(/\n/g,""),l.startsWith("[")||l.startsWith(",{"))l=l.slice(1);else if(l.endsWith("]")){if(l==="]")return;l=l.slice(0,-1);}let m;try{m=JSON.parse(l);}catch(r){if(r instanceof SyntaxError){t=l;continue}else throw r}t="";let n=Mo.safeParse(m);if(n.success){let r={partialMessages:[]},s=n.data;if(s.candidates.length>0){let p=s.candidates[0].content;p&&"parts"in p&&p.parts.length>0&&p.parts.forEach((h,P)=>{if("text"in h&&h.text!==void 0&&r.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,h.text)),"functionCall"in h&&h.functionCall!==void 0){let y=h.functionCall;r.partialMessages.push(types.createPartialToolCallMessage(types.AssistantRoleLiteral,P,`${y.name}_${P}`,y.name,JSON.stringify(y.args)));}});}s.usageMetadata&&(r.usage={promptTokens:s.usageMetadata.promptTokenCount,completionTokens:s.usageMetadata.candidatesTokenCount,totalTokens:s.usageMetadata.totalTokenCount}),yield {partialResponse:r,buffer:t};}else throw new provider.ModelResponseError({info:"Invalid response from model",cause:n.error})}yield {partialResponse:{partialMessages:[]},buffer:t};})}transformProxyStreamChatResponseChunk(e,t,o,i,l){return qe(this,null,function*(){if((l==null?void 0:l.alt)!=="sse"){yield*Oo(this.transformStreamChatResponseChunk(e,t));return}let m=t+e,n=[],r="",s=0;for(;s<m.length;){let p=m.indexOf(`
|
|
15
|
+
`,s);if(p===-1){r=m.substring(s);break}else {let h=m.substring(s,p).trim();h&&n.push(h),s=p+1;}}for(let p of n){if(p==="data: [DONE]")return;if(p.startsWith("data: ")){let h=p.substring(6);try{let P=JSON.parse(h),y=Mo.safeParse(P);if(y.success){let w={partialMessages:[]},x=y.data;if(x.candidates.length>0){let k=x.candidates[0].content;k&&"parts"in k&&k.parts.length>0&&k.parts.forEach((E,F)=>{if("text"in E&&E.text!==void 0&&w.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,E.text)),"functionCall"in E&&E.functionCall!==void 0){let Ae=E.functionCall;w.partialMessages.push(types.createPartialToolCallMessage(types.AssistantRoleLiteral,F,`${Ae.name}_${F}`,Ae.name,JSON.stringify(Ae.args)));}});}x.usageMetadata&&x.usageMetadata.totalTokenCount&&x.usageMetadata.promptTokenCount&&x.usageMetadata.candidatesTokenCount&&(w.usage={promptTokens:x.usageMetadata.promptTokenCount,completionTokens:x.usageMetadata.candidatesTokenCount,totalTokens:x.usageMetadata.totalTokenCount}),yield {partialResponse:w,buffer:t};}else throw new provider.ModelResponseError({info:"Invalid response from model",cause:y.error})}catch(P){throw new provider.ModelResponseError({info:`Malformed JSON received in stream: ${h}`,cause:P})}}}yield {partialResponse:{partialMessages:[]},buffer:r};})}getProxyCompleteChatUrl(e,t,o){return S(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getProxyStreamChatUrl(e,t,o){return S(this,null,function*(){return new Promise(i=>{if(!o||Object.keys(o).length===0){i(this.streamChatUrl);return}let l=new URL(this.streamChatUrl);Object.entries(o).forEach(([m,n])=>{n!=null&&l.searchParams.set(m,n);}),i(l.toString());})})}getProxyCompleteChatHeaders(e,t,o){return S(this,null,function*(){if(!t)return {};let i=_({},t);return delete i.host,delete i["content-length"],i})}getProxyStreamChatHeaders(e,t,o){return S(this,null,function*(){return yield this.getProxyCompleteChatHeaders(e,t,o)})}getModelPricing(){if(!(this.modelName in f))throw new provider.ModelResponseError({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return f[this.modelName]}};var ie="gemini-1.5-flash-001",hn="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",Qe=provider.ChatModelSchema(T,b).parse({name:ie,description:hn,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[ie]}),Lo=C,se=class extends u{constructor(e){super(Qe,e);}};var ae="gemini-1.5-flash-002",un="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",eo=provider.ChatModelSchema(T,b).parse({name:ae,description:un,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[ae]}),Do=C,re=class extends u{constructor(e){super(eo,e);}};var le="gemini-1.5-flash-latest",Cn="Google's latest multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",oo=provider.ChatModelSchema(T,b).parse({name:le,description:Cn,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[le]}),Uo=C,me=class extends u{constructor(e){super(oo,e);}};var pe="gemini-1.5-flash",Mn="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",to=provider.ChatModelSchema(T,b).parse({name:pe,description:Mn,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[pe]}),$o=C,de=class extends u{constructor(e){super(to,e);}};var ce="gemini-1.5-pro-001",bn="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",no=provider.ChatModelSchema(T,b).parse({name:ce,description:bn,maxInputTokens:2e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[ce]}),jo=C,ge=class extends u{constructor(e){super(no,e);}};var he="gemini-1.5-pro-002",_n="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",io=provider.ChatModelSchema(T,b).parse({name:he,description:_n,maxInputTokens:2e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[he]}),Bo=C,fe=class extends u{constructor(e){super(io,e);}};var ue="gemini-1.5-pro-latest",En="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",so=provider.ChatModelSchema(T,b).parse({name:ue,description:En,maxInputTokens:2e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[ue]}),zo=C,ye=class extends u{constructor(e){super(so,e);}};var Ce="gemini-1.5-pro",Rn="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",ao=provider.ChatModelSchema(T,b).parse({name:Ce,description:Rn,maxInputTokens:2e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[Ce]}),Ao=C,Te=class extends u{constructor(e){super(ao,e);}};var ft="gemini-2.0-flash-exp",xn="Google's experimental multimodal model with enhanced capabilities. Designed for cutting-edge performance across complex and high-frequency tasks.",kn=provider.ChatModelSchema(T,b).parse({name:ft,description:xn,maxInputTokens:1e6,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[ft]}),Ua=C,ut=class extends u{constructor(e){super(kn,e);}};var Me="gemini-2.0-flash",Fn="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.",ro=provider.ChatModelSchema(T,b).parse({name:Me,description:Fn,maxInputTokens:1048576,maxOutputTokens:8192,roles:M,modalities:G,config:{def:g.responseSchema(2,1,8192,4,.95).def,schema:g.responseSchema(2,1,8192,4,.95).schema},price:f[Me]}),qo=C,Ge=class extends u{constructor(e){super(ro,e);}};var be="gemini-2.5-flash-lite",In="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.",lo=provider.ChatModelSchema(T,b).parse({name:be,description:In,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.responseSchema(2,1,65536,4,.95).def,schema:g.responseSchema(2,1,65536,4,.95).schema},price:f[be]}),Ho=C,Pe=class extends u{constructor(e){super(lo,e);}};var _e="gemini-2.5-flash-preview-04-17",Dn="Google's best model in Gemini 2.5 family in terms of price-performance, offering well-rounded capabilities.",mo=provider.ChatModelSchema(T,b).parse({name:_e,description:Dn,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.responseSchema(2,1,65536,4,.95).def,schema:g.responseSchema(2,1,65536,4,.95).schema},price:f[_e]}),Ko=C,Se=class extends u{constructor(e){super(mo,e);}};var Ee="gemini-2.5-flash",$n="Google's Gemini 2.5 Flash model for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",po=provider.ChatModelSchema(T,b).parse({name:Ee,description:$n,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.responseSchema(2,1,65536,4,.95).def,schema:g.responseSchema(2,1,65536,4,.95).schema},price:f[Ee]}),Yo=C,Oe=class extends u{constructor(e){super(po,e);}};var Re="gemini-2.5-pro-preview-03-25",Bn="Google's preview model in Gemini 2.5 family for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",co=provider.ChatModelSchema(T,b).parse({name:Re,description:Bn,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.reasoning(2,1,65536,4,.95).def,schema:g.reasoning(2,1,65536,4,.95).schema},price:f[Re]}),Vo=C,we=class extends u{constructor(e){super(co,e);}};var xe="gemini-2.5-pro",An="Google's Gemini 2.5 Pro model for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",go=provider.ChatModelSchema(T,b).parse({name:xe,description:An,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.reasoning(2,1,65536,4,.95).def,schema:g.reasoning(2,1,65536,4,.95).schema},price:f[xe]}),Jo=C,ke=class extends u{constructor(e){super(go,e);}};var ve="gemini-3-pro-preview",Hn="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.",ho=provider.ChatModelSchema(T,b).parse({name:ve,description:Hn,maxInputTokens:1048576,maxOutputTokens:65536,roles:M,modalities:G,config:{def:g.reasoning(2,1,65536,4,.95).def,schema:g.reasoning(2,1,65536,4,.95).schema},price:f[ve]}),Xo=C,Fe=class extends u{constructor(e){super(ho,e);}};var Be=[types.EmbeddingTextModalityLiteral],ze=zod.z.enum([types.EmbeddingTextModalityLiteral]);var Ct=zod.z.object({embeddings:zod.z.array(zod.z.object({values:zod.z.array(zod.z.number())}))});var Yn=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)})}),Tt=zod.z.object({model:zod.z.string().min(1).optional(),requests:zod.z.array(Yn).min(1),outputDimensionality:zod.z.number().int().min(1).optional()});var X=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),getEmbeddingsUrl:zod.z.string().url().optional()}),A=class{constructor(e,t){this.version="v1";let o=X.parse(t);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash(o.baseUrl||$.baseUrl),this.getEmbeddingsUrl=provider.urlWithoutTrailingSlash(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){return {shouldRetry:!1,delayMs:0}}getTokenCount(e){return e.requests.reduce((t,o)=>t+o.length,0)}transformModelRequest(e){let t=Tt.safeParse(e);if(!t.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:t.error});let o=t.data,i=o.model,l={outputDimensionality:o.outputDimensionality},m=types.Config().parse(provider.removeUndefinedEntries(l)),n={modality:types.EmbeddingTextModalityLiteral,requests:o.requests.reduce((r,s)=>(r.push(...s.content.parts.map(p=>p.text)),r),[])};return {modelName:i,config:m,embeddingRequests:n}}transformConfig(e,t){let o=this.modelSchema.config.schema.safeParse(e);if(!o.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:o.error});let i=o.data;return Object.keys(i).forEach(m=>{if(!this.modelSchema.config.def[m])throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${m}',
|
|
16
|
+
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(i).reduce((m,n)=>{let s=this.modelSchema.config.def[n].param,p=i[n];return m[s]=p,m},{})}transformEmbeddingRequests(e){let t=types.EmbeddingRequests().safeParse(e);if(!t.success)throw new provider.InvalidEmbeddingRequestsError({info:"Invalid embedding requests",cause:t.error});if(e.modality!==types.EmbeddingTextModalityLiteral)throw new provider.InvalidEmbeddingRequestsError({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Only '${types.EmbeddingTextModalityLiteral}' modality is supported for model : '${this.modelName}'`)});return {requests:t.data.requests.map(i=>({model:`models/${this.modelName}`,content:{parts:[{text:i}]}}))}}getGetEmbeddingsUrl(e,t){return S(this,null,function*(){return new Promise(o=>{o(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(e,t){return S(this,null,function*(){return new Promise(o=>{o(this.getDefaultHeaders());})})}getGetEmbeddingsData(e,t){return S(this,null,function*(){return new Promise(o=>{let i=this.transformConfig(e),l=this.transformEmbeddingRequests(t);if(t.requests.length===0)throw new provider.InvalidEmbeddingRequestsError({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error("requests cannot be empty")});i.outputDimensionality&&(l.requests.forEach(m=>{m.outputDimensionality=i.outputDimensionality;}),delete i.outputDimensionality),o(_(_(_({},this.getDefaultParams()),i),l));})})}transformGetEmbeddingsResponse(e){let t=Ct.safeParse(e);if(t.success){let i=t.data.embeddings.map((l,m)=>({index:m,embedding:l.values}));return {encodingFormat:types.FloatEmbeddingLiteral,embeddings:i}}throw new provider.ModelResponseError({info:"Invalid response from model",cause:t.error})}};var fo="text-embedding-001",oi="text-embedding-001",uo=provider.EmbeddingModelSchema(ze).parse({name:fo,description:oi,modalities:Be,maxInputTokens:2048,maxOutputTokens:768,config:{def:j.base(768).def,schema:j.base(768).schema}}),Wo=X,Ne=class extends A{constructor(e){super(uo,e);}};var yo="text-embedding-004",ni="text-embedding-004",Co=provider.EmbeddingModelSchema(ze).parse({name:yo,description:ni,modalities:Be,maxInputTokens:2048,maxOutputTokens:768,config:{def:j.base(768).def,schema:j.base(768).schema}}),Zo=X,Ie=class extends A{constructor(e){super(Co,e);}};
|
|
17
17
|
|
|
18
|
-
exports.BaseChatModel =
|
|
18
|
+
exports.BaseChatModel = u;
|
|
19
19
|
exports.BaseChatModelOptions = C;
|
|
20
|
-
exports.BaseEmbeddingModel =
|
|
20
|
+
exports.BaseEmbeddingModel = A;
|
|
21
21
|
exports.BaseEmbeddingModelOptions = X;
|
|
22
22
|
exports.ChatModelBaseConfigDef = ee;
|
|
23
23
|
exports.ChatModelBaseConfigSchema = Q;
|
|
24
24
|
exports.ChatModelReasoningConfigDef = ko;
|
|
25
|
-
exports.ChatModelReasoningConfigSchema =
|
|
25
|
+
exports.ChatModelReasoningConfigSchema = xo;
|
|
26
26
|
exports.EmbeddingModelBaseConfigDef = No;
|
|
27
|
-
exports.EmbeddingModelBaseConfigSchema =
|
|
28
|
-
exports.
|
|
27
|
+
exports.EmbeddingModelBaseConfigSchema = Fo;
|
|
28
|
+
exports.GOOGLE_SAFETY_CATEGORIES = vt;
|
|
29
|
+
exports.GOOGLE_SAFETY_THRESHOLDS = Ft;
|
|
30
|
+
exports.Gemini1_5Flash = de;
|
|
29
31
|
exports.Gemini1_5Flash001 = se;
|
|
30
32
|
exports.Gemini1_5Flash001Literal = ie;
|
|
31
33
|
exports.Gemini1_5Flash001Options = Lo;
|
|
@@ -38,60 +40,64 @@ exports.Gemini1_5FlashLatest = me;
|
|
|
38
40
|
exports.Gemini1_5FlashLatestLiteral = le;
|
|
39
41
|
exports.Gemini1_5FlashLatestOptions = Uo;
|
|
40
42
|
exports.Gemini1_5FlashLatestSchema = oo;
|
|
41
|
-
exports.Gemini1_5FlashLiteral =
|
|
43
|
+
exports.Gemini1_5FlashLiteral = pe;
|
|
42
44
|
exports.Gemini1_5FlashOptions = $o;
|
|
43
45
|
exports.Gemini1_5FlashSchema = to;
|
|
44
46
|
exports.Gemini1_5Pro = Te;
|
|
45
|
-
exports.Gemini1_5Pro001 =
|
|
47
|
+
exports.Gemini1_5Pro001 = ge;
|
|
46
48
|
exports.Gemini1_5Pro001Literal = ce;
|
|
47
49
|
exports.Gemini1_5Pro001Options = jo;
|
|
48
50
|
exports.Gemini1_5Pro001Schema = no;
|
|
49
51
|
exports.Gemini1_5Pro002 = fe;
|
|
50
|
-
exports.Gemini1_5Pro002Literal =
|
|
52
|
+
exports.Gemini1_5Pro002Literal = he;
|
|
51
53
|
exports.Gemini1_5Pro002Options = Bo;
|
|
52
54
|
exports.Gemini1_5Pro002Schema = io;
|
|
53
55
|
exports.Gemini1_5ProLatest = ye;
|
|
54
56
|
exports.Gemini1_5ProLatestLiteral = ue;
|
|
55
|
-
exports.Gemini1_5ProLatestOptions =
|
|
57
|
+
exports.Gemini1_5ProLatestOptions = zo;
|
|
56
58
|
exports.Gemini1_5ProLatestSchema = so;
|
|
57
59
|
exports.Gemini1_5ProLiteral = Ce;
|
|
58
|
-
exports.Gemini1_5ProOptions =
|
|
60
|
+
exports.Gemini1_5ProOptions = Ao;
|
|
59
61
|
exports.Gemini1_5ProSchema = ao;
|
|
60
|
-
exports.Gemini2_0Flash =
|
|
61
|
-
exports.Gemini2_0FlashExp =
|
|
62
|
-
exports.Gemini2_0FlashExpLiteral =
|
|
63
|
-
exports.Gemini2_0FlashExpOptions =
|
|
64
|
-
exports.Gemini2_0FlashExpSchema =
|
|
65
|
-
exports.Gemini2_0FlashLiteral =
|
|
66
|
-
exports.Gemini2_0FlashOptions =
|
|
67
|
-
exports.Gemini2_0FlashSchema =
|
|
68
|
-
exports.Gemini2_5Flash =
|
|
69
|
-
exports.Gemini2_5FlashLite =
|
|
70
|
-
exports.Gemini2_5FlashLiteLiteral =
|
|
71
|
-
exports.Gemini2_5FlashLiteOptions =
|
|
72
|
-
exports.Gemini2_5FlashLiteSchema =
|
|
73
|
-
exports.Gemini2_5FlashLiteral =
|
|
74
|
-
exports.Gemini2_5FlashOptions =
|
|
75
|
-
exports.Gemini2_5FlashPreview0417 =
|
|
76
|
-
exports.Gemini2_5FlashPreview0417Literal =
|
|
77
|
-
exports.Gemini2_5FlashPreview0417Options =
|
|
78
|
-
exports.Gemini2_5FlashPreview0417Schema =
|
|
79
|
-
exports.Gemini2_5FlashSchema =
|
|
80
|
-
exports.Gemini2_5Pro =
|
|
81
|
-
exports.Gemini2_5ProLiteral =
|
|
82
|
-
exports.Gemini2_5ProOptions =
|
|
83
|
-
exports.Gemini2_5ProPreview0325 =
|
|
84
|
-
exports.Gemini2_5ProPreview0325Literal =
|
|
85
|
-
exports.Gemini2_5ProPreview0325Options =
|
|
86
|
-
exports.Gemini2_5ProPreview0325Schema =
|
|
62
|
+
exports.Gemini2_0Flash = Ge;
|
|
63
|
+
exports.Gemini2_0FlashExp = ut;
|
|
64
|
+
exports.Gemini2_0FlashExpLiteral = ft;
|
|
65
|
+
exports.Gemini2_0FlashExpOptions = Ua;
|
|
66
|
+
exports.Gemini2_0FlashExpSchema = kn;
|
|
67
|
+
exports.Gemini2_0FlashLiteral = Me;
|
|
68
|
+
exports.Gemini2_0FlashOptions = qo;
|
|
69
|
+
exports.Gemini2_0FlashSchema = ro;
|
|
70
|
+
exports.Gemini2_5Flash = Oe;
|
|
71
|
+
exports.Gemini2_5FlashLite = Pe;
|
|
72
|
+
exports.Gemini2_5FlashLiteLiteral = be;
|
|
73
|
+
exports.Gemini2_5FlashLiteOptions = Ho;
|
|
74
|
+
exports.Gemini2_5FlashLiteSchema = lo;
|
|
75
|
+
exports.Gemini2_5FlashLiteral = Ee;
|
|
76
|
+
exports.Gemini2_5FlashOptions = Yo;
|
|
77
|
+
exports.Gemini2_5FlashPreview0417 = Se;
|
|
78
|
+
exports.Gemini2_5FlashPreview0417Literal = _e;
|
|
79
|
+
exports.Gemini2_5FlashPreview0417Options = Ko;
|
|
80
|
+
exports.Gemini2_5FlashPreview0417Schema = mo;
|
|
81
|
+
exports.Gemini2_5FlashSchema = po;
|
|
82
|
+
exports.Gemini2_5Pro = ke;
|
|
83
|
+
exports.Gemini2_5ProLiteral = xe;
|
|
84
|
+
exports.Gemini2_5ProOptions = Jo;
|
|
85
|
+
exports.Gemini2_5ProPreview0325 = we;
|
|
86
|
+
exports.Gemini2_5ProPreview0325Literal = Re;
|
|
87
|
+
exports.Gemini2_5ProPreview0325Options = Vo;
|
|
88
|
+
exports.Gemini2_5ProPreview0325Schema = co;
|
|
87
89
|
exports.Gemini2_5ProSchema = go;
|
|
90
|
+
exports.Gemini3ProPreview = Fe;
|
|
91
|
+
exports.Gemini3ProPreviewLiteral = ve;
|
|
92
|
+
exports.Gemini3ProPreviewOptions = Xo;
|
|
93
|
+
exports.Gemini3ProPreviewSchema = ho;
|
|
88
94
|
exports.Google = $;
|
|
89
|
-
exports.GoogleChatAssistantRoleLiteral =
|
|
90
|
-
exports.GoogleChatContent =
|
|
91
|
-
exports.GoogleChatContentPartFileData =
|
|
92
|
-
exports.GoogleChatContentPartFunctionCall =
|
|
93
|
-
exports.GoogleChatContentPartFunctionResponse =
|
|
94
|
-
exports.GoogleChatContentPartInlineData =
|
|
95
|
+
exports.GoogleChatAssistantRoleLiteral = Kt;
|
|
96
|
+
exports.GoogleChatContent = tn;
|
|
97
|
+
exports.GoogleChatContentPartFileData = Qt;
|
|
98
|
+
exports.GoogleChatContentPartFunctionCall = en;
|
|
99
|
+
exports.GoogleChatContentPartFunctionResponse = on;
|
|
100
|
+
exports.GoogleChatContentPartInlineData = Zt;
|
|
95
101
|
exports.GoogleChatContentPartText = st;
|
|
96
102
|
exports.GoogleChatGenerationConfig = nt;
|
|
97
103
|
exports.GoogleChatModelConfigs = g;
|
|
@@ -101,31 +107,31 @@ exports.GoogleChatModelResponseSchemaConfigDef = te;
|
|
|
101
107
|
exports.GoogleChatModelResponseSchemaConfigSchema = ne;
|
|
102
108
|
exports.GoogleChatModelRoles = T;
|
|
103
109
|
exports.GoogleChatModelRolesMap = M;
|
|
104
|
-
exports.GoogleChatModelTextModalities =
|
|
105
|
-
exports.GoogleChatModelTextModalitiesEnum =
|
|
106
|
-
exports.GoogleChatModelTextToolModalities =
|
|
107
|
-
exports.GoogleChatModelTextToolModalitiesEnum =
|
|
108
|
-
exports.GoogleChatModelTextVisionModalities =
|
|
109
|
-
exports.GoogleChatModelTextVisionModalitiesEnum =
|
|
110
|
+
exports.GoogleChatModelTextModalities = Ki;
|
|
111
|
+
exports.GoogleChatModelTextModalitiesEnum = Yi;
|
|
112
|
+
exports.GoogleChatModelTextToolModalities = Xi;
|
|
113
|
+
exports.GoogleChatModelTextToolModalitiesEnum = Wi;
|
|
114
|
+
exports.GoogleChatModelTextVisionModalities = Vi;
|
|
115
|
+
exports.GoogleChatModelTextVisionModalitiesEnum = Ji;
|
|
110
116
|
exports.GoogleChatRequest = at;
|
|
111
117
|
exports.GoogleChatSafetySettings = it;
|
|
112
118
|
exports.GoogleChatSystemInstruction = ot;
|
|
113
|
-
exports.GoogleChatTool =
|
|
119
|
+
exports.GoogleChatTool = nn;
|
|
114
120
|
exports.GoogleChatToolConfig = tt;
|
|
115
|
-
exports.GoogleChatToolRoleLiteral =
|
|
121
|
+
exports.GoogleChatToolRoleLiteral = Yt;
|
|
116
122
|
exports.GoogleCompleteChatResponse = et;
|
|
117
|
-
exports.GoogleCompleteChatTextResponse =
|
|
118
|
-
exports.GoogleCompleteChatToolResponse =
|
|
123
|
+
exports.GoogleCompleteChatTextResponse = Vt;
|
|
124
|
+
exports.GoogleCompleteChatToolResponse = Jt;
|
|
119
125
|
exports.GoogleEmbeddingModelConfigs = j;
|
|
120
126
|
exports.GoogleEmbeddingModelModalities = Be;
|
|
121
|
-
exports.GoogleEmbeddingModelModalitiesEnum =
|
|
122
|
-
exports.GoogleEmbeddingRequest =
|
|
123
|
-
exports.GoogleEmbeddingRequestInput =
|
|
124
|
-
exports.GoogleGetEmbeddingsResponse =
|
|
127
|
+
exports.GoogleEmbeddingModelModalitiesEnum = ze;
|
|
128
|
+
exports.GoogleEmbeddingRequest = Tt;
|
|
129
|
+
exports.GoogleEmbeddingRequestInput = Yn;
|
|
130
|
+
exports.GoogleGetEmbeddingsResponse = Ct;
|
|
125
131
|
exports.GoogleStreamChatResponse = Mo;
|
|
126
|
-
exports.GoogleStreamChatTextResponse =
|
|
127
|
-
exports.GoogleStreamChatToolResponse =
|
|
128
|
-
exports.ProviderLiteral =
|
|
132
|
+
exports.GoogleStreamChatTextResponse = Xt;
|
|
133
|
+
exports.GoogleStreamChatToolResponse = Wt;
|
|
134
|
+
exports.ProviderLiteral = jt;
|
|
129
135
|
exports.Text_Embedding_001 = Ne;
|
|
130
136
|
exports.Text_Embedding_001Literal = fo;
|
|
131
137
|
exports.Text_Embedding_001Options = Wo;
|
|
@@ -135,16 +141,16 @@ exports.Text_Embedding_004Literal = yo;
|
|
|
135
141
|
exports.Text_Embedding_004Options = Zo;
|
|
136
142
|
exports.Text_Embedding_004Schema = Co;
|
|
137
143
|
exports.dimensions = Ze;
|
|
138
|
-
exports.frequencyPenalty =
|
|
144
|
+
exports.frequencyPenalty = li;
|
|
139
145
|
exports.maxTokens = Ke;
|
|
140
|
-
exports.presencePenalty =
|
|
146
|
+
exports.presencePenalty = mi;
|
|
141
147
|
exports.reasoningEnabled = We;
|
|
142
148
|
exports.safetySettings = Xe;
|
|
143
|
-
exports.seed =
|
|
149
|
+
exports.seed = pi;
|
|
144
150
|
exports.stop = Ye;
|
|
145
151
|
exports.temperature = He;
|
|
146
152
|
exports.toolChoice = Je;
|
|
147
|
-
exports.topK =
|
|
153
|
+
exports.topK = ri;
|
|
148
154
|
exports.topP = Ve;
|
|
149
155
|
//# sourceMappingURL=index.js.map
|
|
150
156
|
//# sourceMappingURL=index.js.map
|