@adaline/google 1.17.0 → 1.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +437 -1
- package/dist/index.d.ts +437 -1
- package/dist/index.js +159 -143
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,169 +4,185 @@ var zod = require('zod');
|
|
|
4
4
|
var provider = require('@adaline/provider');
|
|
5
5
|
var types = require('@adaline/types');
|
|
6
6
|
|
|
7
|
-
var
|
|
8
|
-
[${this.chatModelLiterals().join(", ")}]`)});let t=this.chatModelFactories[o].model,
|
|
9
|
-
[${this.embeddingModelLiterals().join(", ")}]`)});let t=this.embeddingModelFactories[o].model,a=this.embeddingModelFactories[o].modelOptions.parse(e);return new t(a)}};B.baseUrl="https://generativelanguage.googleapis.com/v1beta";var C={"base-gemini-1-chat-model":{modelName:"base-gemini-1-chat-model",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"gemini-1.0-pro-001":{modelName:"gemini-1.0-pro-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro-latest":{modelName:"gemini-1.0-pro-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro-vision":{modelName:"gemini-1.0-pro-vision",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro":{modelName:"gemini-1.0-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.5-flash-001":{modelName:"gemini-1.5-flash-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-flash-002":{modelName:"gemini-1.5-flash-002",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.0375,outputPricePerMillion:.15}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}}]},"gemini-1.5-flash-latest":{modelName:"gemini-1.5-flash-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-flash":{modelName:"gemini-1.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-pro-001":{modelName:"gemini-1.5-pro-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro-002":{modelName:"gemini-1.5-pro-002",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro-latest":{modelName:"gemini-1.5-pro-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro":{modelName:"gemini-1.5-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-2.0-flash-exp":{modelName:"gemini-2.0-flash-exp",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.5-flash-preview-04-17":{modelName:"gemini-2.5-flash-preview-04-17",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-2.5-pro-preview-03-25":{modelName:"gemini-2.5-pro-preview-03-25",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:2e5,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}},{minTokens:200001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:15}}}]},"gemini-pro-vision":{modelName:"gemini-pro-vision",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-pro":{modelName:"gemini-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-2.5-pro":{modelName:"gemini-2.5-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gemini-3-pro-preview":{modelName:"gemini-3-pro-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gemini-2.5-flash":{modelName:"gemini-2.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.3,outputPricePerMillion:2.5}}}]},"gemini-2.0-flash":{modelName:"gemini-2.0-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.5-flash-lite":{modelName:"gemini-2.5-flash-lite",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-3-flash-preview":{modelName:"gemini-3-flash-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:3}}}]}};var b=zod.z.enum([types.SystemRoleLiteral,types.UserRoleLiteral,types.AssistantRoleLiteral,types.ToolRoleLiteral]),yn="model",Cn="function",P={system:types.UserRoleLiteral,user:types.UserRoleLiteral,assistant:yn,tool:Cn};var _=[types.TextModalityLiteral,types.ImageModalityLiteral,types.PdfModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral,types.ReasoningModalityLiteral,types.SearchResultModalityLiteral,types.ErrorModalityLiteral],S=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral,types.PdfModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral,types.ReasoningModalityLiteral,types.SearchResultModalityLiteral,types.ErrorModalityLiteral]),Es=[types.TextModalityLiteral],ws=zod.z.enum([types.TextModalityLiteral]),Os=[types.TextModalityLiteral,types.ImageModalityLiteral],ks=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral]),Rs=[types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],xs=zod.z.enum([types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]);var Tn=zod.z.object({renderedContent:zod.z.string().optional()}),Mn=zod.z.object({uri:zod.z.string().optional(),title:zod.z.string().optional()}),Gn=zod.z.object({web:Mn.optional()}),bn=zod.z.object({startIndex:zod.z.number().optional(),endIndex:zod.z.number().optional(),text:zod.z.string().optional()}),Pn=zod.z.object({segment:bn.optional(),groundingChunkIndices:zod.z.array(zod.z.number()).optional(),confidenceScores:zod.z.array(zod.z.number()).optional()}),yt=zod.z.object({searchEntryPoint:Tn.optional(),groundingChunks:zod.z.array(Gn).optional(),groundingSupports:zod.z.array(Pn).optional(),webSearchQueries:zod.z.array(zod.z.string()).optional()}),_n=zod.z.object({text:zod.z.string(),thought:zod.z.boolean().optional()}),Sn=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())}),thoughtSignature:zod.z.string().optional()}),Ct=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([_n,Sn]))}).optional(),finishReason:zod.z.string(),index:zod.z.number().optional(),safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string(),blocked:zod.z.boolean().optional()}))),groundingMetadata:yt.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()}),En=zod.z.object({text:zod.z.string(),thought:zod.z.boolean().optional()}),wn=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())}),thoughtSignature:zod.z.string().optional()}),ko=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([En,wn]))}).optional(),finishReason:zod.z.string().optional(),index:zod.z.number().optional(),safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string(),blocked:zod.z.boolean().optional()}))),groundingMetadata:yt.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 _t=zod.z.object({text:zod.z.string().min(1)}),On=zod.z.object({inline_data:zod.z.object({mime_type:zod.z.string().min(1),data:zod.z.string().base64()})}),kn=zod.z.object({file_data:zod.z.object({mime_type:zod.z.string().min(1),file_uri:zod.z.string().min(1)})}),Rn=zod.z.object({function_call:zod.z.object({name:zod.z.string().min(1),args:zod.z.record(zod.z.string().min(1))}),thought_signature:zod.z.string().optional()}),xn=zod.z.object({function_response:zod.z.object({name:zod.z.string().min(1),response:zod.z.record(zod.z.string().min(1))})}),Tt=zod.z.object({text:zod.z.string(),thought:zod.z.literal(!0),thought_signature:zod.z.string().min(1)}),vn=zod.z.object({role:zod.z.enum(["user","model","function"]),parts:zod.z.array(zod.z.union([_t,On,kn,Rn,xn,Tt,Tt]))}),Mt=zod.z.object({parts:zod.z.array(_t)}),Fn=zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),parameters:zod.z.any()}),In=zod.z.object({timeRangeFilter:zod.z.object({startTime:zod.z.string().datetime().optional(),endTime:zod.z.string().datetime().optional()}).optional()}),Gt=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()})}),Ln=zod.z.object({thinkingBudget:zod.z.number().optional(),includeThoughts:zod.z.boolean().optional(),thinkingLevel:zod.z.enum(["LOW","HIGH"]).optional()}),bt=zod.z.object({stopSequences:zod.z.array(zod.z.string()).optional(),maxOutputTokens:zod.z.number().optional(),temperature:zod.z.number().optional(),topP:zod.z.number().optional(),topK:zod.z.number().optional(),presencePenalty:zod.z.number().optional(),frequencyPenalty:zod.z.number().optional(),seed:zod.z.number().optional(),thinkingConfig:Ln.optional()}),Pt=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"])}),St=zod.z.object({model:zod.z.string().min(1).optional(),contents:zod.z.array(vn),systemInstruction:Mt.optional(),system_instruction:Mt.optional(),generationConfig:bt.optional(),generation_config:bt.optional(),safetySettings:zod.z.array(Pt).optional(),safety_settings:zod.z.array(Pt).optional(),tools:zod.z.object({function_declarations:zod.z.array(Fn),google_search:In.optional()}).optional(),toolConfig:Gt.optional(),tool_config:Gt.optional()});var G=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()}),M=class{constructor(e,o){this.version="v1";var a;let t=G.parse(o);this.modelSchema=e,this.modelName=t.modelName,this.apiKey=t.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash((a=t.baseUrl)!=null?a:B.baseUrl),this.completeChatUrl=provider.urlWithoutTrailingSlash(t.completeChatUrl||`${this.baseUrl}/models/${this.modelName}:generateContent?key=${this.apiKey}`),this.streamChatUrl=provider.urlWithoutTrailingSlash(t.streamChatUrl||`${this.baseUrl}/models/${this.modelName}:streamGenerateContent?key=${this.apiKey}`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"Content-Type":"application/json"}}getDefaultParams(){return {}}getRetryDelay(e,o){var l;let a=0,d=n=>{let i=n.match(/^(\d+(?:\.\d+)?)s$/);return i?Math.ceil(parseFloat(i[1])*1e3):0};if(o&&typeof o=="object"){let n=o;if((l=n.error)!=null&&l.details&&Array.isArray(n.error.details)){let i=n.error.details.find(s=>s["@type"]==="type.googleapis.com/google.rpc.RetryInfo");i!=null&&i.retryDelay&&(a=d(i.retryDelay));}}return {shouldRetry:!0,delayMs:a}}getTokenCount(e){return e.reduce((o,t)=>o+t.content.map(a=>a.modality==="text"?a.value:"").join(" ").length,0)}transformPdfMessages(e){return R(this,null,function*(){let o=n=>R(this,null,function*(){let i={};provider.isRunningInBrowser()||(i["User-Agent"]="Mozilla/5.0 (compatible; GoogleFilesAPI/1.0)");let s=yield fetch(n,{headers:i});if(!s.ok)throw new provider.InvalidMessagesError({info:`Failed to download PDF from URL: ${n}`,cause:new Error(`HTTP ${s.status}: ${s.statusText}`)});let c=yield s.arrayBuffer();return new Uint8Array(c)}),t=n=>R(this,null,function*(){try{let i=yield fetch(`https://generativelanguage.googleapis.com/v1beta/files?key=${this.apiKey}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!i.ok)return null;let h=((yield i.json()).files||[]).find(T=>T.displayName===n);return h?h.uri:null}catch(i){return null}}),a=(n,i)=>R(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:i}})});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 c=s.headers.get("x-goog-upload-url");if(!c)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 T=yield fetch(c,{method:"POST",headers:h,body:n});if(!T.ok)throw new provider.InvalidMessagesError({info:"Failed to upload PDF content to Google Files API",cause:new Error(`HTTP ${T.status}: ${T.statusText}`)});return (yield T.json()).file.uri}),d=n=>R(this,null,function*(){let i=yield t(n.file.id);if(i)return i;let s;if(n.value.type==="url")s=yield o(n.value.url);else {let c=n.value.base64,h="data:application/pdf;base64,";c=c.startsWith(h)?c.substring(h.length):c,s=provider.convertBase64ToUint8Array(c);}return yield a(s,n.file.id)}),l=[];for(let n of e){let i=[];for(let s of n.content)if(s.modality===types.PdfModalityLiteral){let c=yield d(s);i.push(D(E({},s),{value:{type:"url",url:c}}));}else i.push(s);l.push(D(E({},n),{content:i}));}return l})}transformModelRequest(e){let o=St.safeParse(e);if(!o.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:o.error});let t=o.data,a=t.model;if(t.system_instruction&&t.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(t.generation_config&&t.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(t.tool_config&&t.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 d=t.system_instruction||t.systemInstruction,l=t.generation_config||t.generationConfig,n=t.safety_settings||t.safetySettings,i=t.tool_config||t.toolConfig;if(i&&(!t.tools||t.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={};i&&(i.function_calling_config.mode==="ANY"&&i.function_calling_config.allowed_function_names&&i.function_calling_config.allowed_function_names.length===1?s.toolChoice=i.function_calling_config.allowed_function_names[0]:s.toolChoice=i.function_calling_config.mode.toLowerCase()),s.seed=l==null?void 0:l.seed,s.maxTokens=l==null?void 0:l.maxOutputTokens,s.temperature=l==null?void 0:l.temperature,s.topP=l==null?void 0:l.topP,s.presencePenalty=l==null?void 0:l.presencePenalty,s.frequencyPenalty=l==null?void 0:l.frequencyPenalty,s.stop=l==null?void 0:l.stopSequences,s.safetySettings=n;let c=types.Config().parse(provider.removeUndefinedEntries(s)),h=[];d&&d.parts.forEach(p=>{h.push({role:types.SystemRoleLiteral,content:[{modality:types.TextModalityLiteral,value:p.text}]});}),t.contents.forEach(p=>{let f=p.role;switch(f){case"user":{let O=p.parts.map(w=>"text"in w?{modality:types.TextModalityLiteral,value:w.text}:{modality:types.ImageModalityLiteral,detail:"auto",value:{type:types.Base64ImageContentTypeLiteral,base64:w.inline_data.data,mediaType:w.inline_data.mime_type.split("/")[1]}});h.push({role:f,content:O});}break;case"model":{let O=p.parts.map((w,k)=>"text"in w?{modality:types.TextModalityLiteral,value:w.text}:{modality:types.ToolCallModalityLiteral,id:k.toString(),index:k,name:w.function_call.name,arguments:JSON.stringify(w.function_call.args)});h.push({role:types.AssistantRoleLiteral,content:O});}break;case"function":{let O=p.parts.map((w,k)=>({modality:types.ToolResponseModalityLiteral,id:k.toString(),index:k,name:w.function_response.name,data:JSON.stringify(w.function_response.response)}));h.push({role:types.ToolRoleLiteral,content:O});}break;default:throw new provider.InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${p.role}' is not supported for model : ${this.modelName}`)})}});let T=[];return t.tools&&t.tools.function_declarations.forEach(p=>{T.push({type:"function",definition:{schema:{name:p.name,description:p.description,parameters:p.parameters}}});}),{modelName:a,config:c,messages:h,tools:T.length>0?T:void 0}}transformConfig(e,o,t){let a=e.toolChoice;delete e.toolChoice;let d=this.modelSchema.config.schema.safeParse(e);if(!d.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:d.error});let l=d.data;Object.keys(l).forEach(c=>{if(!(c in this.modelSchema.config.def))throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${c}',
|
|
10
|
-
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let
|
|
11
|
-
one of [${h.choices.join(", ")}]`)})}}if("response_format"in
|
|
12
|
-
available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),t.forEach(
|
|
13
|
-
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}),t.forEach(
|
|
14
|
-
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}}),
|
|
15
|
-
`,s);if(p===-1){i=l.substring(s);break}else {let f=l.substring(s,p).trim();f&&n.push(f),s=p+1;}}for(let p of n){if(p==="data: [DONE]")return;if(p.startsWith("data: ")){let f=p.substring(6);try{let y=JSON.parse(f),O=ko.safeParse(y);if(O.success){let w={partialMessages:[]},k=O.data;if(k.candidates.length>0){let N=k.candidates[0].content;N&&"parts"in N&&N.parts.length>0&&N.parts.forEach((L,x)=>{if("text"in L&&L.text!==void 0&&(L.thought===!0?w.partialMessages.push(types.createPartialReasoningMessage(types.AssistantRoleLiteral,L.text,"")):w.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,L.text))),"functionCall"in L&&L.functionCall!==void 0){let $=L.functionCall;w.partialMessages.push(types.createPartialToolCallMessage(types.AssistantRoleLiteral,x,`${$.name}_${x}`,$.name,JSON.stringify($.args),void 0,L.thoughtSignature));}});}if(k.usageMetadata&&k.usageMetadata.totalTokenCount&&k.usageMetadata.promptTokenCount&&k.usageMetadata.candidatesTokenCount&&(w.usage={promptTokens:k.usageMetadata.promptTokenCount,completionTokens:k.usageMetadata.candidatesTokenCount,totalTokens:k.usageMetadata.totalTokenCount}),k.candidates.length>0){let N=k.candidates[0];N.groundingMetadata&&w.partialMessages.push(types.createPartialSearchResultGoogleMessage(types.AssistantRoleLiteral,((c=N.groundingMetadata.webSearchQueries)==null?void 0:c[0])||"",((h=N.groundingMetadata.groundingChunks)==null?void 0:h.map(x=>{var $,W;return {source:x.web?"web":"",url:(($=x.web)==null?void 0:$.uri)||"",title:((W=x.web)==null?void 0:W.title)||""}}))||[],((T=N.groundingMetadata.groundingSupports)==null?void 0:T.map(x=>{var $,W,Fo;return {text:(($=x.segment)==null?void 0:$.text)||"",responseIndices:x.groundingChunkIndices||[],startIndex:((W=x.segment)==null?void 0:W.startIndex)||void 0,endIndex:((Fo=x.segment)==null?void 0:Fo.endIndex)||void 0,confidenceScores:x.confidenceScores||void 0}}))||[]));let L=N.safetyRatings;L&&L.length>0&&L.forEach(x=>{x.blocked&&w.partialMessages.push(types.createPartialSafetyErrorMessage(types.AssistantRoleLiteral,x.category,x.probability,x.blocked,`Blocked content for category: ${x.category} with probability: ${x.probability}`));});}yield {partialResponse:w,buffer:o};}else throw new provider.ModelResponseError({info:"Invalid response from model",cause:O.error})}catch(y){throw new provider.ModelResponseError({info:`Malformed JSON received in stream: ${f}`,cause:y})}}}yield {partialResponse:{partialMessages:[]},buffer:i};})}getProxyCompleteChatUrl(e,o,t){return R(this,null,function*(){return new Promise(a=>{a(this.completeChatUrl);})})}getProxyStreamChatUrl(e,o,t){return R(this,null,function*(){return new Promise(a=>{if(!t||Object.keys(t).length===0){a(this.streamChatUrl);return}let d=new URL(this.streamChatUrl);Object.entries(t).forEach(([l,n])=>{n!=null&&d.searchParams.set(l,n);}),a(d.toString());})})}getProxyCompleteChatHeaders(e,o,t){return R(this,null,function*(){if(!o)return {};let a=E({},o);return delete a.host,delete a["content-length"],a})}getProxyStreamChatHeaders(e,o,t){return R(this,null,function*(){return yield this.getProxyCompleteChatHeaders(e,o,t)})}getModelPricing(){if(!(this.modelName in C))throw new provider.ModelResponseError({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return C[this.modelName]}};var le="gemini-1.5-flash-001",Yn="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",ro=provider.ChatModelSchema(b,S).parse({name:le,description:Yn,maxInputTokens:1e6,maxOutputTokens:8192,roles:P,modalities:_,config:{def:u.responseSchema(2,1,8192,4,.95).def,schema:u.responseSchema(2,1,8192,4,.95).schema},price:C[le]}),Wo=G,me=class extends M{constructor(e){super(ro,e);}};var de="gemini-1.5-flash-002",Wn="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",lo=provider.ChatModelSchema(b,S).parse({name:de,description:Wn,maxInputTokens:1e6,maxOutputTokens:8192,roles:P,modalities:_,config:{def:u.responseSchema(2,1,8192,4,.95).def,schema:u.responseSchema(2,1,8192,4,.95).schema},price:C[de]}),Jo=G,pe=class extends M{constructor(e){super(lo,e);}};var ce="gemini-1.5-flash-latest",Xn="Google's latest multimodal model with great performance for high-frequency tasks. Optimized for fast and versatile performance across a diverse variety of tasks",mo=provider.ChatModelSchema(b,S).parse({name:ce,description:Xn,maxInputTokens:1e6,maxOutputTokens:8192,roles:P,modalities:_,config:{def:u.responseSchema(2,1,8192,4,.95).def,schema:u.responseSchema(2,1,8192,4,.95).schema},price:C[ce]}),Xo=G,ge=class extends M{constructor(e){super(mo,e);}};var he="gemini-1.5-flash",Zn="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",po=provider.ChatModelSchema(b,S).parse({name:he,description:Zn,maxInputTokens:1e6,maxOutputTokens:8192,roles:P,modalities:_,config:{def:u.responseSchema(2,1,8192,4,.95).def,schema:u.responseSchema(2,1,8192,4,.95).schema},price:C[he]}),Qo=G,fe=class extends M{constructor(e){super(po,e);}};var ue="gemini-1.5-pro-001",oi="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",co=provider.ChatModelSchema(b,S).parse({name:ue,description:oi,maxInputTokens:2e6,maxOutputTokens:8192,roles:P,modalities:_,config:{def:u.responseSchema(2,1,8192,4,.95).def,schema:u.responseSchema(2,1,8192,4,.95).schema},price:C[ue]}),Zo=G,ye=class extends M{constructor(e){super(co,e);}};var Ce="gemini-1.5-pro-002",ni="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",go=provider.ChatModelSchema(b,S).parse({name:Ce,description:ni,maxInputTokens:2e6,maxOutputTokens:8192,roles:P,modalities:_,config:{def:u.responseSchema(2,1,8192,4,.95).def,schema:u.responseSchema(2,1,8192,4,.95).schema},price:C[Ce]}),et=G,Te=class extends M{constructor(e){super(go,e);}};var Me="gemini-1.5-pro-latest",si="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",ho=provider.ChatModelSchema(b,S).parse({name:Me,description:si,maxInputTokens:2e6,maxOutputTokens:8192,roles:P,modalities:_,config:{def:u.responseSchema(2,1,8192,4,.95).def,schema:u.responseSchema(2,1,8192,4,.95).schema},price:C[Me]}),ot=G,Ge=class extends M{constructor(e){super(ho,e);}};var be="gemini-1.5-pro",ri="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",fo=provider.ChatModelSchema(b,S).parse({name:be,description:ri,maxInputTokens:2e6,maxOutputTokens:8192,roles:P,modalities:_,config:{def:u.responseSchema(2,1,8192,4,.95).def,schema:u.responseSchema(2,1,8192,4,.95).schema},price:C[be]}),tt=G,Pe=class extends M{constructor(e){super(fo,e);}};var $t="gemini-2.0-flash-exp",mi="Google's experimental multimodal model with enhanced capabilities. Designed for cutting-edge performance across complex and high-frequency tasks.",di=provider.ChatModelSchema(b,S).parse({name:$t,description:mi,maxInputTokens:1e6,maxOutputTokens:8192,roles:P,modalities:_,config:{def:u.responseSchema(2,1,8192,4,.95).def,schema:u.responseSchema(2,1,8192,4,.95).schema},price:C[$t]}),yr=G,At=class extends M{constructor(e){super(di,e);}};var _e="gemini-2.0-flash",ci="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.",uo=provider.ChatModelSchema(b,S).parse({name:_e,description:ci,maxInputTokens:1048576,maxOutputTokens:8192,roles:P,modalities:_,config:{def:u.responseSchema(2,1,8192,4,.95).def,schema:u.responseSchema(2,1,8192,4,.95).schema},price:C[_e]}),nt=G,Se=class extends M{constructor(e){super(uo,e);}};var Ee="gemini-2.5-flash-lite",hi="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.",yo=provider.ChatModelSchema(b,S).parse({name:Ee,description:hi,maxInputTokens:1048576,maxOutputTokens:65536,roles:P,modalities:_,config:{def:u.responseSchema(2,1,65536,4,.95).def,schema:u.responseSchema(2,1,65536,4,.95).schema},price:C[Ee]}),it=G,we=class extends M{constructor(e){super(yo,e);}};var Oe="gemini-2.5-flash-preview-04-17",ui="Google's best model in Gemini 2.5 family in terms of price-performance, offering well-rounded capabilities.",Co=provider.ChatModelSchema(b,S).parse({name:Oe,description:ui,maxInputTokens:1048576,maxOutputTokens:65536,roles:P,modalities:_,config:{def:u.reasoning(2,1,65536,4,.95,1,24576).def,schema:u.reasoning(2,1,65536,4,.95,1,24576).schema},price:C[Oe]}),st=G,ke=class extends M{constructor(e){super(Co,e);}};var Re="gemini-2.5-flash",Ci="Google's Gemini 2.5 Flash model for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",To=provider.ChatModelSchema(b,S).parse({name:Re,description:Ci,maxInputTokens:1048576,maxOutputTokens:65536,roles:P,modalities:_,config:{def:u.reasoning(2,1,65536,4,.95,1,24576).def,schema:u.reasoning(2,1,65536,4,.95,1,24576).schema},price:C[Re]}),at=G,xe=class extends M{constructor(e){super(To,e);}};var ve="gemini-2.5-pro-preview-03-25",Mi="Google's preview model in Gemini 2.5 family for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",Mo=provider.ChatModelSchema(b,S).parse({name:ve,description:Mi,maxInputTokens:1048576,maxOutputTokens:65536,roles:P,modalities:_,config:{def:u.reasoning(2,1,65536,4,.95,1,65536).def,schema:u.reasoning(2,1,65536,4,.95,1,65536).schema},price:C[ve]}),rt=G,Fe=class extends M{constructor(e){super(Mo,e);}};var Ie="gemini-2.5-pro",bi="Google's Gemini 2.5 Pro model for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",Go=provider.ChatModelSchema(b,S).parse({name:Ie,description:bi,maxInputTokens:1048576,maxOutputTokens:65536,roles:P,modalities:_,config:{def:u.reasoning(2,1,65536,4,.95,1,65536).def,schema:u.reasoning(2,1,65536,4,.95,1,65536).schema},price:C[Ie]}),lt=G,Le=class extends M{constructor(e){super(Go,e);}};var Ne="gemini-3-flash-preview",_i="Google's Gemini 3 Flash Preview model - a lightweight and efficient AI model with enhanced multimodal understanding, reasoning, and advanced coding capabilities. Optimized for speed and cost-effectiveness. Supports Text, Image, Video, Audio, and PDF inputs. Knowledge cutoff: January 2025.",bo=provider.ChatModelSchema(b,S).parse({name:Ne,description:_i,maxInputTokens:1048576,maxOutputTokens:65536,roles:P,modalities:_,config:{def:u.reasoning(2,1,65536,4,.95,1,65536).def,schema:u.reasoning(2,1,65536,4,.95,1,65536).schema},price:C[Ne]}),mt=G,De=class extends M{constructor(e){super(bo,e);}};var Ue="gemini-3-pro-preview",Ei="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.",Po=provider.ChatModelSchema(b,S).parse({name:Ue,description:Ei,maxInputTokens:1048576,maxOutputTokens:65536,roles:P,modalities:_,config:{def:u.reasoning(2,1,65536,4,.95,1,65536).def,schema:u.reasoning(2,1,65536,4,.95,1,65536).schema},price:C[Ue]}),dt=G,$e=class extends M{constructor(e){super(Po,e);}};var Ye=[types.EmbeddingTextModalityLiteral],Ve=zod.z.enum([types.EmbeddingTextModalityLiteral]);var Bt=zod.z.object({embeddings:zod.z.array(zod.z.object({values:zod.z.array(zod.z.number())}))});var Oi=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)})}),zt=zod.z.object({model:zod.z.string().min(1).optional(),requests:zod.z.array(Oi).min(1),outputDimensionality:zod.z.number().int().min(1).optional()});var oe=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),getEmbeddingsUrl:zod.z.string().url().optional()}),V=class{constructor(e,o){this.version="v1";let t=oe.parse(o);this.modelSchema=e,this.modelName=t.modelName,this.apiKey=t.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash(t.baseUrl||B.baseUrl),this.getEmbeddingsUrl=provider.urlWithoutTrailingSlash(t.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,o){var l;let a=0,d=n=>{let i=n.match(/^(\d+(?:\.\d+)?)s$/);return i?Math.ceil(parseFloat(i[1])*1e3):0};if(o&&typeof o=="object"){let n=o;if((l=n.error)!=null&&l.details&&Array.isArray(n.error.details)){let i=n.error.details.find(s=>s["@type"]==="type.googleapis.com/google.rpc.RetryInfo");i!=null&&i.retryDelay&&(a=d(i.retryDelay));}}return {shouldRetry:!0,delayMs:a}}getTokenCount(e){return e.requests.reduce((o,t)=>o+t.length,0)}transformModelRequest(e){let o=zt.safeParse(e);if(!o.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:o.error});let t=o.data,a=t.model,d={outputDimensionality:t.outputDimensionality},l=types.Config().parse(provider.removeUndefinedEntries(d)),n={modality:types.EmbeddingTextModalityLiteral,requests:t.requests.reduce((i,s)=>(i.push(...s.content.parts.map(c=>c.text)),i),[])};return {modelName:a,config:l,embeddingRequests:n}}transformConfig(e,o){let t=this.modelSchema.config.schema.safeParse(e);if(!t.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:t.error});let a=t.data;return Object.keys(a).forEach(l=>{if(!this.modelSchema.config.def[l])throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${l}',
|
|
16
|
-
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(
|
|
7
|
+
var li=Object.defineProperty,mi=Object.defineProperties;var di=Object.getOwnPropertyDescriptors;var Ko=Object.getOwnPropertySymbols;var pi=Object.prototype.hasOwnProperty,ci=Object.prototype.propertyIsEnumerable;var te=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),gi=r=>{throw TypeError(r)};var Yo=(r,e,o)=>e in r?li(r,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[e]=o,w=(r,e)=>{for(var o in e||(e={}))pi.call(e,o)&&Yo(r,o,e[o]);if(Ko)for(var o of Ko(e))ci.call(e,o)&&Yo(r,o,e[o]);return r},N=(r,e)=>mi(r,di(e));var R=(r,e,o)=>new Promise((t,s)=>{var c=i=>{try{m(o.next(i));}catch(n){s(n);}},a=i=>{try{m(o.throw(i));}catch(n){s(n);}},m=i=>i.done?t(i.value):Promise.resolve(i.value).then(c,a);m((o=o.apply(r,e)).next());}),Vo=function(r,e){this[0]=r,this[1]=e;},io=(r,e,o)=>{var t=(a,m,i,n)=>{try{var l=o[a](m),h=(m=l.value)instanceof Vo,S=l.done;Promise.resolve(h?m[0]:m).then(p=>h?t(a==="return"?a:"next",m[1]?{done:p.done,value:p.value}:p,i,n):i({value:p,done:S})).catch(p=>t("throw",p,i,n));}catch(p){n(p);}},s=a=>c[a]=m=>new Promise((i,n)=>t(a,m,i,n)),c={};return o=o.apply(r,e),c[te("asyncIterator")]=()=>c,s("next"),s("throw"),s("return"),c},Wo=r=>{var e=r[te("asyncIterator")],o=!1,t,s={};return e==null?(e=r[te("iterator")](),t=c=>s[c]=a=>e[c](a)):(e=e.call(r),t=c=>s[c]=a=>{if(o){if(o=!1,c==="throw")throw a;return a}return o=!0,{done:!1,value:new Vo(new Promise(m=>{var i=e[c](a);i instanceof Object||gi("Object expected"),m(i);}),1)}}),s[te("iterator")]=()=>s,t("next"),"throw"in e?t("throw"):s.throw=c=>{throw c},"return"in e&&t("return"),s};var ui=["HARM_CATEGORY_HARASSMENT","HARM_CATEGORY_HATE_SPEECH","HARM_CATEGORY_SEXUALLY_EXPLICIT","HARM_CATEGORY_DANGEROUS_CONTENT","HARM_CATEGORY_CIVIC_INTEGRITY"],yi=["HARM_BLOCK_THRESHOLD_UNSPECIFIED","BLOCK_LOW_AND_ABOVE","BLOCK_MEDIUM_AND_ABOVE","BLOCK_ONLY_HIGH","BLOCK_NONE","OFF"],Qo=(r,e)=>r.replace(e,"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,o=>o.toUpperCase()),Ci=ui.map(r=>({value:r,label:Qo(r,"HARM_CATEGORY_")})),Mi=yi.map(r=>({value:r,label:Qo(r,"HARM_BLOCK_THRESHOLD_")})),no=(r,e)=>provider.RangeConfigItem({param:"temperature",title:provider.CHAT_CONFIG.TEMPERATURE.title,description:provider.CHAT_CONFIG.TEMPERATURE.description,min:0,max:r,step:.01,default:e}),so=r=>provider.RangeConfigItem({param:"maxOutputTokens",title:provider.CHAT_CONFIG.MAX_TOKENS.title,description:provider.CHAT_CONFIG.MAX_TOKENS.description,min:0,max:r,step:1,default:0}),ao=r=>provider.MultiStringConfigItem({param:"stopSequences",title:provider.CHAT_CONFIG.STOP(r).title,description:provider.CHAT_CONFIG.STOP(r).description,max:r}),ro=r=>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:r}),ps=r=>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:r}),cs=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}),gs=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}),hs=provider.RangeConfigItem({param:"seed",title:provider.CHAT_CONFIG.SEED.title,description:provider.CHAT_CONFIG.SEED.description,min:0,max:1e6,step:1,default:0}),lo=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"]}),mo=provider.PairedSelectConfigItem({param:"safetySettings",title:"Safety settings",description:"The safety rating contains the category of harm and the harm probability level in that category for a piece of content.",fields:[{key:"category",label:"Category",choices:Ci},{key:"threshold",label:"Threshold",choices:Mi}],uniqueByField:"category"}),po=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}),co=(r,e)=>provider.RangeConfigItem({param:"thinkingBudget",title:"Thinking budget",description:"Specify the total tokens for thinking (or reasoning), where one token approximates four English characters.",min:r,max:e,step:1,default:0}),go=provider.SelectStringConfigItem({param:"thinkingLevel",title:"Thinking Level",description:"Controls the depth of the model's reasoning process. Higher levels may result in more thorough reasoning but use more tokens.",default:"LOW",choices:["LOW","HIGH"]}),ho=provider.SelectBooleanConfigItem({param:"googleSearch",title:"Google Search Tool",description:"Controls whether the model is allowed to use the Google Search tool. Powered by Google.",default:!1});var ie=(r,e,o,t,s)=>zod.z.object({temperature:no(r,e).schema,maxTokens:so(o).schema,stop:ao(t).schema,topP:ro(s).schema,toolChoice:lo.schema,safetySettings:mo.schema,googleSearchTool:ho.schema}),ne=(r,e,o,t,s)=>({temperature:no(r,e).def,maxTokens:so(o).def,stop:ao(t).def,topP:ro(s).def,toolChoice:lo.def,safetySettings:mo.def,googleSearchTool:ho.def});var Zo=provider.ObjectSchemaConfigItem({param:"response_schema",title:provider.CHAT_CONFIG.RESPONSE_SCHEMA.title,description:provider.CHAT_CONFIG.RESPONSE_SCHEMA.description,objectSchema:types.ResponseSchema}),et=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"]}),ae=(r,e,o,t,s)=>N(w({},ne(r,e,o,t,s)),{responseFormat:et.def,responseSchema:Zo.def}),re=(r,e,o,t,s)=>ie(r,e,o,t,s).extend({responseFormat:et.schema,responseSchema:Zo.schema});var ot=(r,e,o,t,s,c,a)=>re(r,e,o,t,s).extend({reasoningEnabled:po.schema,maxReasoningTokens:co(c,a).schema,reasoningEffort:go.schema}),tt=(r,e,o,t,s,c,a)=>N(w({},ae(r,e,o,t,s)),{reasoningEnabled:po.def,maxReasoningTokens:co(c,a).def,reasoningEffort:go.def});var fo=r=>provider.RangeConfigItem({param:"outputDimensionality",title:provider.EMBEDDING_CONFIG.DIMENSIONS.title,description:provider.EMBEDDING_CONFIG.DIMENSIONS.description,min:1,max:r,step:1,default:r});var nt=r=>zod.z.object({dimensions:fo(r).schema}),st=r=>({dimensions:fo(r).def});var f={base:(r,e,o,t,s)=>({def:ne(r,e,o,t,s),schema:ie(r,e,o,t,s)}),responseSchema:(r,e,o,t,s)=>({def:ae(r,e,o,t,s),schema:re(r,e,o,t,s)}),reasoning:(r,e,o,t,s,c,a)=>({def:tt(r,e,o,t,s,c,a),schema:ot(r,e,o,t,s,c,a)})},H={base:r=>({def:st(r),schema:nt(r)})};var wi="google",A=class{constructor(){this.version="v1";this.name=wi;this.chatModelFactories={[le]:{model:me,modelOptions:rt,modelSchema:uo},[de]:{model:pe,modelOptions:lt,modelSchema:yo},[ce]:{model:ge,modelOptions:mt,modelSchema:Co},[he]:{model:fe,modelOptions:dt,modelSchema:Mo},[ue]:{model:ye,modelOptions:pt,modelSchema:To},[Ce]:{model:Me,modelOptions:ct,modelSchema:Go},[Te]:{model:Ge,modelOptions:gt,modelSchema:bo},[be]:{model:Pe,modelOptions:ht,modelSchema:Po},[_e]:{model:Se,modelOptions:ft,modelSchema:_o},[we]:{model:Oe,modelOptions:ut,modelSchema:So},[ve]:{model:Fe,modelOptions:Mt,modelSchema:Eo},[Ne]:{model:De,modelOptions:Gt,modelSchema:Ro},[Le]:{model:Ie,modelOptions:Tt,modelSchema:ko},[Ue]:{model:Be,modelOptions:bt,modelSchema:xo},[qe]:{model:He,modelOptions:St,modelSchema:Lo},[Ae]:{model:je,modelOptions:_t,modelSchema:Fo},[$e]:{model:ze,modelOptions:Pt,modelSchema:vo},[Ke]:{model:Ye,modelOptions:wt,modelSchema:Io},[Ee]:{model:ke,modelOptions:yt,modelSchema:wo},[Re]:{model:xe,modelOptions:Ct,modelSchema:Oo}};this.embeddingModelFactories={[No]:{model:Ve,modelOptions:Ot,modelSchema:Do},[Uo]:{model:We,modelOptions:Et,modelSchema:Bo}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((e,o)=>(e[o]=this.chatModelFactories[o].modelSchema,e),{})}chatModel(e){let o=e.modelName;if(!(o in this.chatModelFactories))throw new provider.ProviderError({info:`Google chat model: ${o} not found`,cause:new Error(`Google chat model: ${o} not found, available chat models:
|
|
8
|
+
[${this.chatModelLiterals().join(", ")}]`)});let t=this.chatModelFactories[o].model,s=this.chatModelFactories[o].modelOptions.parse(e);return new t(s)}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((e,o)=>(e[o]=this.embeddingModelFactories[o].modelSchema,e),{})}embeddingModel(e){let o=e.modelName;if(!(o in this.embeddingModelFactories))throw new provider.ProviderError({info:`Google embedding model: ${o} not found`,cause:new Error(`Google embedding model: ${o} not found, available embedding models:
|
|
9
|
+
[${this.embeddingModelLiterals().join(", ")}]`)});let t=this.embeddingModelFactories[o].model,s=this.embeddingModelFactories[o].modelOptions.parse(e);return new t(s)}};A.baseUrl="https://generativelanguage.googleapis.com/v1beta";var y={"base-gemini-1-chat-model":{modelName:"base-gemini-1-chat-model",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"gemini-1.0-pro-001":{modelName:"gemini-1.0-pro-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro-latest":{modelName:"gemini-1.0-pro-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro-vision":{modelName:"gemini-1.0-pro-vision",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.0-pro":{modelName:"gemini-1.0-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-1.5-flash-001":{modelName:"gemini-1.5-flash-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-flash-002":{modelName:"gemini-1.5-flash-002",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.0375,outputPricePerMillion:.15}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}}]},"gemini-1.5-flash-latest":{modelName:"gemini-1.5-flash-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-flash":{modelName:"gemini-1.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-1.5-pro-001":{modelName:"gemini-1.5-pro-001",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro-002":{modelName:"gemini-1.5-pro-002",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro-latest":{modelName:"gemini-1.5-pro-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-1.5-pro":{modelName:"gemini-1.5-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:128e3,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:5}}},{minTokens:128001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gemini-2.0-flash-exp":{modelName:"gemini-2.0-flash-exp",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.5-flash-preview-04-17":{modelName:"gemini-2.5-flash-preview-04-17",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.15,outputPricePerMillion:.6}}}]},"gemini-2.5-pro-preview-03-25":{modelName:"gemini-2.5-pro-preview-03-25",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:2e5,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}},{minTokens:200001,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:15}}}]},"gemini-pro-vision":{modelName:"gemini-pro-vision",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-pro":{modelName:"gemini-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gemini-2.5-pro":{modelName:"gemini-2.5-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gemini-3-pro-preview":{modelName:"gemini-3-pro-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gemini-3.1-pro-preview":{modelName:"gemini-3.1-pro-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:2e5,prices:{base:{inputPricePerMillion:2,outputPricePerMillion:12}}},{minTokens:200001,maxTokens:null,prices:{base:{inputPricePerMillion:4,outputPricePerMillion:18}}}]},"gemini-3.1-pro-preview-customtools":{modelName:"gemini-3.1-pro-preview-customtools",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:2e5,prices:{base:{inputPricePerMillion:2,outputPricePerMillion:12}}},{minTokens:200001,maxTokens:null,prices:{base:{inputPricePerMillion:4,outputPricePerMillion:18}}}]},"gemini-2.5-flash":{modelName:"gemini-2.5-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.3,outputPricePerMillion:2.5}}}]},"gemini-2.0-flash":{modelName:"gemini-2.0-flash",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.0-flash-lite":{modelName:"gemini-2.0-flash-lite",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.075,outputPricePerMillion:.3}}}]},"gemini-2.5-flash-lite":{modelName:"gemini-2.5-flash-lite",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-2.5-flash-lite-preview-09-2025":{modelName:"gemini-2.5-flash-lite-preview-09-2025",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gemini-3-flash-preview":{modelName:"gemini-3-flash-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:3}}}]}};var T=zod.z.enum([types.SystemRoleLiteral,types.UserRoleLiteral,types.AssistantRoleLiteral,types.ToolRoleLiteral]),vi="model",Fi="function",G={system:types.UserRoleLiteral,user:types.UserRoleLiteral,assistant:vi,tool:Fi};var b=[types.TextModalityLiteral,types.ImageModalityLiteral,types.PdfModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral,types.ReasoningModalityLiteral,types.SearchResultModalityLiteral,types.ErrorModalityLiteral],P=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral,types.PdfModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral,types.ReasoningModalityLiteral,types.SearchResultModalityLiteral,types.ErrorModalityLiteral]),Js=[types.TextModalityLiteral],Xs=zod.z.enum([types.TextModalityLiteral]),Qs=[types.TextModalityLiteral,types.ImageModalityLiteral],Zs=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral]),ea=[types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],oa=zod.z.enum([types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]);var Li=zod.z.object({renderedContent:zod.z.string().optional()}),Ii=zod.z.object({uri:zod.z.string().optional(),title:zod.z.string().optional()}),Ni=zod.z.object({web:Ii.optional()}),Di=zod.z.object({startIndex:zod.z.number().optional(),endIndex:zod.z.number().optional(),text:zod.z.string().optional()}),Ui=zod.z.object({segment:Di.optional(),groundingChunkIndices:zod.z.array(zod.z.number()).optional(),confidenceScores:zod.z.array(zod.z.number()).optional()}),Ft=zod.z.object({searchEntryPoint:Li.optional(),groundingChunks:zod.z.array(Ni).optional(),groundingSupports:zod.z.array(Ui).optional(),webSearchQueries:zod.z.array(zod.z.string()).optional()}),Bi=zod.z.object({text:zod.z.string(),thought:zod.z.boolean().optional()}),$i=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())}),thoughtSignature:zod.z.string().optional()}),Lt=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([Bi,$i]))}).optional(),finishReason:zod.z.string(),index:zod.z.number().optional(),safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string(),blocked:zod.z.boolean().optional()}))),groundingMetadata:Ft.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()}),zi=zod.z.object({text:zod.z.string(),thought:zod.z.boolean().optional()}),Ai=zod.z.object({functionCall:zod.z.object({name:zod.z.string(),args:zod.z.record(zod.z.any())}),thoughtSignature:zod.z.string().optional()}),zo=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([zi,Ai]))}).optional(),finishReason:zod.z.string().optional(),index:zod.z.number().optional(),safetyRatings:zod.z.optional(zod.z.array(zod.z.object({category:zod.z.string(),probability:zod.z.string(),blocked:zod.z.boolean().optional()}))),groundingMetadata:Ft.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 $t=zod.z.object({text:zod.z.string().min(1)}),ji=zod.z.object({inline_data:zod.z.object({mime_type:zod.z.string().min(1),data:zod.z.string().base64()})}),qi=zod.z.object({file_data:zod.z.object({mime_type:zod.z.string().min(1),file_uri:zod.z.string().min(1)})}),Hi=zod.z.object({function_call:zod.z.object({name:zod.z.string().min(1),args:zod.z.record(zod.z.string().min(1))}),thought_signature:zod.z.string().optional()}),Ki=zod.z.object({function_response:zod.z.object({name:zod.z.string().min(1),response:zod.z.record(zod.z.string().min(1))})}),It=zod.z.object({text:zod.z.string(),thought:zod.z.literal(!0),thought_signature:zod.z.string().min(1)}),Yi=zod.z.object({role:zod.z.enum(["user","model","function"]),parts:zod.z.array(zod.z.union([$t,ji,qi,Hi,Ki,It,It]))}),Nt=zod.z.object({parts:zod.z.array($t)}),Vi=zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),parameters:zod.z.any()}),Wi=zod.z.object({timeRangeFilter:zod.z.object({startTime:zod.z.string().datetime().optional(),endTime:zod.z.string().datetime().optional()}).optional()}),Dt=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()})}),Ji=zod.z.object({thinkingBudget:zod.z.number().optional(),includeThoughts:zod.z.boolean().optional(),thinkingLevel:zod.z.enum(["LOW","HIGH"]).optional()}),Ut=zod.z.object({stopSequences:zod.z.array(zod.z.string()).optional(),maxOutputTokens:zod.z.number().optional(),temperature:zod.z.number().optional(),topP:zod.z.number().optional(),topK:zod.z.number().optional(),presencePenalty:zod.z.number().optional(),frequencyPenalty:zod.z.number().optional(),seed:zod.z.number().optional(),thinkingConfig:Ji.optional()}),Bt=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"])}),zt=zod.z.object({model:zod.z.string().min(1).optional(),contents:zod.z.array(Yi),systemInstruction:Nt.optional(),system_instruction:Nt.optional(),generationConfig:Ut.optional(),generation_config:Ut.optional(),safetySettings:zod.z.array(Bt).optional(),safety_settings:zod.z.array(Bt).optional(),tools:zod.z.object({function_declarations:zod.z.array(Vi),google_search:Wi.optional()}).optional(),toolConfig:Dt.optional(),tool_config:Dt.optional()});var M=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()}),C=class{constructor(e,o){this.version="v1";var s;let t=M.parse(o);this.modelSchema=e,this.modelName=t.modelName,this.apiKey=t.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash((s=t.baseUrl)!=null?s:A.baseUrl),this.completeChatUrl=provider.urlWithoutTrailingSlash(t.completeChatUrl||`${this.baseUrl}/models/${this.modelName}:generateContent?key=${this.apiKey}`),this.streamChatUrl=provider.urlWithoutTrailingSlash(t.streamChatUrl||`${this.baseUrl}/models/${this.modelName}:streamGenerateContent?key=${this.apiKey}`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"Content-Type":"application/json"}}getDefaultParams(){return {}}getRetryDelay(e,o){var a;let s=0,c=m=>{let i=m.match(/^(\d+(?:\.\d+)?)s$/);return i?Math.ceil(parseFloat(i[1])*1e3):0};if(o&&typeof o=="object"){let m=o;if((a=m.error)!=null&&a.details&&Array.isArray(m.error.details)){let i=m.error.details.find(n=>n["@type"]==="type.googleapis.com/google.rpc.RetryInfo");i!=null&&i.retryDelay&&(s=c(i.retryDelay));}}return {shouldRetry:!0,delayMs:s}}getTokenCount(e){return e.reduce((o,t)=>o+t.content.map(s=>s.modality==="text"?s.value:"").join(" ").length,0)}transformPdfMessages(e){return R(this,null,function*(){let o=m=>R(this,null,function*(){let i={};provider.isRunningInBrowser()||(i["User-Agent"]="Mozilla/5.0 (compatible; GoogleFilesAPI/1.0)");let n=yield fetch(m,{headers:i});if(!n.ok)throw new provider.InvalidMessagesError({info:`Failed to download PDF from URL: ${m}`,cause:new Error(`HTTP ${n.status}: ${n.statusText}`)});let l=yield n.arrayBuffer();return new Uint8Array(l)}),t=m=>R(this,null,function*(){try{let i=yield fetch(`https://generativelanguage.googleapis.com/v1beta/files?key=${this.apiKey}`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!i.ok)return null;let h=((yield i.json()).files||[]).find(S=>S.displayName===m);return h?h.uri:null}catch(i){return null}}),s=(m,i)=>R(this,null,function*(){let n=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":m.length.toString(),"X-Goog-Upload-Header-Content-Type":"application/pdf","Content-Type":"application/json"},body:JSON.stringify({file:{display_name:i}})});if(!n.ok)throw new provider.InvalidMessagesError({info:"Failed to start PDF upload to Google Files API",cause:new Error(`HTTP ${n.status}: ${n.statusText}`)});let l=n.headers.get("x-goog-upload-url");if(!l)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"]=m.length.toString());let S=yield fetch(l,{method:"POST",headers:h,body:m});if(!S.ok)throw new provider.InvalidMessagesError({info:"Failed to upload PDF content to Google Files API",cause:new Error(`HTTP ${S.status}: ${S.statusText}`)});return (yield S.json()).file.uri}),c=m=>R(this,null,function*(){let i=yield t(m.file.id);if(i)return i;let n;if(m.value.type==="url")n=yield o(m.value.url);else {let l=m.value.base64,h="data:application/pdf;base64,";l=l.startsWith(h)?l.substring(h.length):l,n=provider.convertBase64ToUint8Array(l);}return yield s(n,m.file.id)}),a=[];for(let m of e){let i=[];for(let n of m.content)if(n.modality===types.PdfModalityLiteral){let l=yield c(n);i.push(N(w({},n),{value:{type:"url",url:l}}));}else i.push(n);a.push(N(w({},m),{content:i}));}return a})}transformModelRequest(e){let o=zt.safeParse(e);if(!o.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:o.error});let t=o.data,s=t.model;if(t.system_instruction&&t.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(t.generation_config&&t.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(t.tool_config&&t.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 c=t.system_instruction||t.systemInstruction,a=t.generation_config||t.generationConfig,m=t.safety_settings||t.safetySettings,i=t.tool_config||t.toolConfig;if(i&&(!t.tools||t.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 n={};i&&(i.function_calling_config.mode==="ANY"&&i.function_calling_config.allowed_function_names&&i.function_calling_config.allowed_function_names.length===1?n.toolChoice=i.function_calling_config.allowed_function_names[0]:n.toolChoice=i.function_calling_config.mode.toLowerCase()),n.seed=a==null?void 0:a.seed,n.maxTokens=a==null?void 0:a.maxOutputTokens,n.temperature=a==null?void 0:a.temperature,n.topP=a==null?void 0:a.topP,n.presencePenalty=a==null?void 0:a.presencePenalty,n.frequencyPenalty=a==null?void 0:a.frequencyPenalty,n.stop=a==null?void 0:a.stopSequences,n.safetySettings=m;let l=types.Config().parse(provider.removeUndefinedEntries(n)),h=[];c&&c.parts.forEach(p=>{h.push({role:types.SystemRoleLiteral,content:[{modality:types.TextModalityLiteral,value:p.text}]});}),t.contents.forEach(p=>{let u=p.role;switch(u){case"user":{let E=p.parts.map(O=>"text"in O?{modality:types.TextModalityLiteral,value:O.text}:{modality:types.ImageModalityLiteral,detail:"auto",value:{type:types.Base64ImageContentTypeLiteral,base64:O.inline_data.data,mediaType:O.inline_data.mime_type.split("/")[1]}});h.push({role:u,content:E});}break;case"model":{let E=p.parts.map((O,k)=>"text"in O?{modality:types.TextModalityLiteral,value:O.text}:{modality:types.ToolCallModalityLiteral,id:k.toString(),index:k,name:O.function_call.name,arguments:JSON.stringify(O.function_call.args)});h.push({role:types.AssistantRoleLiteral,content:E});}break;case"function":{let E=p.parts.map((O,k)=>({modality:types.ToolResponseModalityLiteral,id:k.toString(),index:k,name:O.function_response.name,data:JSON.stringify(O.function_response.response)}));h.push({role:types.ToolRoleLiteral,content:E});}break;default:throw new provider.InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${p.role}' is not supported for model : ${this.modelName}`)})}});let S=[];return t.tools&&t.tools.function_declarations.forEach(p=>{S.push({type:"function",definition:{schema:{name:p.name,description:p.description,parameters:p.parameters}}});}),{modelName:s,config:l,messages:h,tools:S.length>0?S:void 0}}transformConfig(e,o,t){let s=e.toolChoice;delete e.toolChoice;let c=this.modelSchema.config.schema.safeParse(e);if(!c.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:c.error});let a=c.data;Object.keys(a).forEach(l=>{if(!(l in this.modelSchema.config.def))throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${l}',
|
|
10
|
+
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let m=Object.keys(a).reduce((l,h)=>{let S=this.modelSchema.config.def[h],p=S.param,u=a[h];return h==="reasoningEnabled"?l.thinkingConfig=l.thinkingConfig&&typeof l.thinkingConfig=="object"?N(w({},l.thinkingConfig),{includeThoughts:u}):{includeThoughts:u}:h==="maxReasoningTokens"?l.thinkingConfig=l.thinkingConfig&&typeof l.thinkingConfig=="object"?N(w({},l.thinkingConfig),{thinkingBudget:u}):{thinkingBudget:u}:h==="reasoningEffort"?l.thinkingConfig=l.thinkingConfig&&typeof l.thinkingConfig=="object"?N(w({},l.thinkingConfig),{thinkingLevel:u}):{thinkingLevel:u}:p==="maxOutputTokens"&&S.type==="range"&&u===0?l[p]=S.max:l[p]=u,l},{});if(m.thinkingConfig&&typeof m.thinkingConfig=="object"&&"thinkingBudget"in m.thinkingConfig&&"thinkingLevel"in m.thinkingConfig&&m.thinkingConfig.thinkingBudget!==void 0&&m.thinkingConfig.thinkingBudget!==0&&m.thinkingConfig.thinkingLevel!==void 0)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("Only one of 'thinkingBudget' or 'thinkingLevel' can be set, not both.")});let i=m.safetySettings;delete m.safetySettings,delete m.googleSearch;let n;if(s!==void 0){let l=s;if(!t||t&&t.length===0)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(t&&t.length>0){let h=this.modelSchema.config.def.toolChoice;if(h.choices.includes(l))l==="any"?n={function_calling_config:{mode:"ANY",allowed_function_names:t.map(S=>S.definition.schema.name)}}:n={function_calling_config:{mode:l.toUpperCase()}};else if(t.map(S=>S.definition.schema.name).includes(l))n={function_calling_config:{mode:"ANY",allowed_function_names:[l]}};else throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`toolChoice : '${l}' is not part of provided 'tools' names or
|
|
11
|
+
one of [${h.choices.join(", ")}]`)})}}if("response_format"in m&&m.response_format!==void 0){let l=m.response_format;if(l==="json_schema"){let h=m.response_schema;if(!("response_schema"in m)||!m.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'")});m.responseSchema=this.stripAdditionalProperties(h.schema),m.responseMimeType="application/json",delete m.response_format,delete m.response_schema;}else l==="json_object"?(m.responseSchema={type:"object"},delete m.response_format):l==="text"&&delete m.response_format;}return w(w({generation_config:m},n?{tool_config:n}:{}),i?{safety_settings:i}:{})}transformMessages(e){if(!e||e&&e.length===0)return {messages:[]};let o=i=>{let n=i.match(/^data:(image\/[a-zA-Z]+|application\/pdf);base64,/);return n?i.substring(n[0].length):i},t=e.map(i=>{let n=types.Message().safeParse(i);if(!n.success)throw new provider.InvalidMessagesError({info:"Invalid messages",cause:n.error});return n.data});t.forEach(i=>{i.content.forEach(n=>{if(!this.modelSchema.modalities.includes(n.modality))throw new provider.InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${n.modality}',
|
|
12
|
+
available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),t.forEach(i=>{if(!Object.keys(this.modelSchema.roles).includes(i.role))throw new provider.InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${i.role}',
|
|
13
|
+
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}),t.forEach(i=>{i.content=i.content.filter(n=>n.modality!=="error"&&n.modality!=="search-result");});let s=[];for(let i of t){let n=s[s.length-1];if(i.role===types.ToolRoleLiteral&&(n==null?void 0:n.role)===types.ToolRoleLiteral){s[s.length-1]=N(w({},n),{content:[...n.content,...i.content]});continue}s.push(i);}let c={parts:[]},a=[];if(s.forEach(i=>{switch(i.role){case types.SystemRoleLiteral:i.content.forEach(n=>{if(n.modality===types.TextModalityLiteral)c.parts.push({text:n.value});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${i.role}' cannot have content with modality : '${n.modality}'`)})});break;case types.AssistantRoleLiteral:{let n=[];i.content.forEach(l=>{if(l.modality===types.TextModalityLiteral)n.push({text:l.value});else if(l.modality===types.ToolCallModalityLiteral)n.push(w({function_call:{name:l.name,args:JSON.parse(l.arguments)}},l.thoughtSignature?{thought_signature:l.thoughtSignature}:{}));else if(l.modality===types.ReasoningModalityLiteral)l.value.type==="thinking"&&l.value.thinking&&n.push({text:l.value.thinking,thought:!0,thought_signature:l.value.signature});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${i.role}' cannot have content with modality : '${l.modality}'`)})}),a.push({role:this.modelSchema.roles[i.role],parts:n});}break;case types.UserRoleLiteral:{let n=[];i.content.forEach(l=>{if(l.modality===types.TextModalityLiteral)n.push({text:l.value});else if(l.modality===types.ImageModalityLiteral){if(l.value.type==="base64"){let h=l.value.base64;h=o(h),n.push({inline_data:{mime_type:`image/${l.value.mediaType}`,data:h}});}else if(l.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: '${l.value.type}'`)})}else if(l.modality===types.PdfModalityLiteral)if(l.value.type==="base64"){let h=l.value.base64;h=o(h),n.push({inline_data:{mime_type:"application/pdf",data:h}});}else l.value.type==="url"&&n.push({file_data:{mime_type:"application/pdf",file_uri:l.value.url}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${i.role}' cannot have content with modality : '${l.modality}'`)})}),a.push({role:this.modelSchema.roles[i.role],parts:n});}break;case types.ToolRoleLiteral:{let n=[];i.content.forEach(l=>{if(l.modality===types.ToolResponseModalityLiteral)n.push({function_response:{name:l.name,response:JSON.parse(l.data)}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${i.role}' cannot have content with modality : '${l.modality}'`)})}),a.push({role:this.modelSchema.roles[i.role],parts:n});}break;default:throw new provider.InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${i.role}' is not supported,
|
|
14
|
+
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}}),a[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=i=>i===this.modelSchema.roles[types.UserRoleLiteral]||i===this.modelSchema.roles[types.ToolRoleLiteral]?[this.modelSchema.roles[types.AssistantRoleLiteral]]:[this.modelSchema.roles[types.UserRoleLiteral],this.modelSchema.roles[types.ToolRoleLiteral]];for(let i=1;i<a.length;i++)if(!m(a[i-1].role).includes(a[i].role))throw new provider.InvalidMessagesError({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' cannot have message with role : '${a[i].role}' after message with role : '${a[i-1].role}'`)});if(a[a.length-1].role!==this.modelSchema.roles[types.UserRoleLiteral]&&a[a.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 w({contents:a},c.parts.length>0?{system_instruction:c}:{})}stripAdditionalProperties(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(t=>this.stripAdditionalProperties(t));let o={};for(let[t,s]of Object.entries(e))t!=="additionalProperties"&&(o[t]=this.stripAdditionalProperties(s));return o}transformTools(e,o){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}'`)});if((!e||e.length===0)&&!(o!=null&&o.googleSearchTool))return {tools:[]};let s=(e!=null?e:[]).map(c=>{let a=types.Tool().safeParse(c);if(!a.success)throw new provider.InvalidToolsError({info:"Invalid tools",cause:a.error});return a.data}).map(c=>({name:c.definition.schema.name,description:c.definition.schema.description,parameters:this.stripAdditionalProperties(c.definition.schema.parameters)}));return {tools:[w(w({},s.length>0?{function_declarations:s}:{}),o!=null&&o.googleSearchTool?{google_search:{}}:{})]}}getCompleteChatUrl(e,o,t){return R(this,null,function*(){return new Promise(s=>{s(this.completeChatUrl);})})}getCompleteChatHeaders(e,o,t){return R(this,null,function*(){return new Promise(s=>{s(this.getDefaultHeaders());})})}getCompleteChatData(e,o,t){return R(this,null,function*(){let s=this.transformConfig(e,o,t),c=yield this.transformPdfMessages(o),a=this.transformMessages(c);if(a.messages&&a.messages.length===0)throw new provider.InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let m=this.transformTools(t||[],e);return w(w(w(w({},this.getDefaultParams()),s),a),m)})}transformCompleteChatResponse(e){var t,s,c,a,m,i;let o=Lt.safeParse(e);if(o.success){if(o.data.candidates.length===0)throw new provider.ModelResponseError({info:"Invalid response from model",cause:new Error(`No choices in response : ${JSON.stringify(o.data)}`)});let n={messages:[],usage:void 0,logProbs:void 0},l=o.data;l.usageMetadata&&(n.usage={promptTokens:l.usageMetadata.promptTokenCount,totalTokens:l.usageMetadata.totalTokenCount,completionTokens:l.usageMetadata.candidatesTokenCount||0});let h=l.candidates[0];if(h.content){let p=h.content.parts.map((u,_)=>{if("text"in u&&u.text!==void 0)return u.thought===!0?types.createReasoningContent(u.text,""):types.createTextContent(u.text);if("functionCall"in u&&u.functionCall!==void 0)return types.createToolCallContent(_,`${u.functionCall.name}_${_}`,u.functionCall.name,JSON.stringify(u.functionCall.args),void 0,u.thoughtSignature)});n.messages.push({role:types.AssistantRoleLiteral,content:p});}h.groundingMetadata&&(n.messages.length===0?n.messages.push({role:types.AssistantRoleLiteral,content:[types.createSearchResultGoogleContent(((t=h.groundingMetadata.webSearchQueries)==null?void 0:t[0])||"",((s=h.groundingMetadata.groundingChunks)==null?void 0:s.map(p=>{var u,_;return {source:p.web?"web":"",url:((u=p.web)==null?void 0:u.uri)||"",title:((_=p.web)==null?void 0:_.title)||""}}))||[],((c=h.groundingMetadata.groundingSupports)==null?void 0:c.map(p=>{var u,_,E;return {text:((u=p.segment)==null?void 0:u.text)||"",responseIndices:p.groundingChunkIndices||[],startIndex:((_=p.segment)==null?void 0:_.startIndex)||void 0,endIndex:((E=p.segment)==null?void 0:E.endIndex)||void 0,confidenceScores:p.confidenceScores||void 0}}))||[])]}):n.messages[0].content.push(types.createSearchResultGoogleContent(((a=h.groundingMetadata.webSearchQueries)==null?void 0:a[0])||"",((m=h.groundingMetadata.groundingChunks)==null?void 0:m.map(p=>{var u,_;return {source:p.web?"web":"",url:((u=p.web)==null?void 0:u.uri)||"",title:((_=p.web)==null?void 0:_.title)||""}}))||[],((i=h.groundingMetadata.groundingSupports)==null?void 0:i.map(p=>{var u,_,E;return {text:((u=p.segment)==null?void 0:u.text)||"",responseIndices:p.groundingChunkIndices||[],startIndex:((_=p.segment)==null?void 0:_.startIndex)||void 0,endIndex:((E=p.segment)==null?void 0:E.endIndex)||void 0,confidenceScores:p.confidenceScores||void 0}}))||[])));let S=h.safetyRatings;if(S&&S.length>0&&S.forEach(p=>{p.blocked&&(n.messages.length===0?n.messages.push({role:types.AssistantRoleLiteral,content:[types.createSafetyErrorContent(p.category,p.probability,p.blocked,`Blocked content for category: ${p.category} with probability: ${p.probability}`)]}):n.messages[0].content.push(types.createSafetyErrorContent(p.category,p.probability,p.blocked,`Blocked content for category: ${p.category} with probability: ${p.probability}`)));}),n.messages.length>0)return n;if(n.messages.length===0&&h.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:o.error})}getStreamChatUrl(e,o,t){return R(this,null,function*(){return new Promise(s=>{s(this.streamChatUrl);})})}getStreamChatHeaders(e,o,t){return R(this,null,function*(){return new Promise(s=>{s(this.getDefaultHeaders());})})}getStreamChatData(e,o,t){return R(this,null,function*(){let s=this.transformConfig(e,o,t),c=yield this.transformPdfMessages(o),a=this.transformMessages(c);if(a.messages&&a.messages.length===0)throw new provider.InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let m=this.transformTools(t||[],e);return w(w(w(w({},this.getDefaultParams()),s),a),m)})}transformStreamChatResponseChunk(e,o){return io(this,null,function*(){var s,c,a;let t=(o+e).split(",\r").filter(m=>m.trim()!=="");for(let m of t){let i=m;if(i=i.replace(/\n/g,""),i.startsWith("[")||i.startsWith(",{"))i=i.slice(1);else if(i.endsWith("]")){if(i==="]")return;i=i.slice(0,-1);}let n;try{n=JSON.parse(i);}catch(h){if(h instanceof SyntaxError){o=i;continue}else throw h}o="";let l=zo.safeParse(n);if(l.success){let h={partialMessages:[]},S=l.data;if(S.candidates.length>0){let p=S.candidates[0].content;p&&"parts"in p&&p.parts.length>0&&p.parts.forEach((u,_)=>{if("text"in u&&u.text!==void 0&&(u.thought===!0?h.partialMessages.push(types.createPartialReasoningMessage(types.AssistantRoleLiteral,u.text,"")):h.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,u.text))),"functionCall"in u&&u.functionCall!==void 0){let E=u.functionCall;h.partialMessages.push(types.createPartialToolCallMessage(types.AssistantRoleLiteral,_,`${E.name}_${_}`,E.name,JSON.stringify(E.args),void 0,u.thoughtSignature));}});}if(S.usageMetadata&&(h.usage={promptTokens:S.usageMetadata.promptTokenCount,completionTokens:S.usageMetadata.candidatesTokenCount,totalTokens:S.usageMetadata.totalTokenCount}),S.candidates.length>0){let p=S.candidates[0];p.groundingMetadata&&h.partialMessages.push(types.createPartialSearchResultGoogleMessage(types.AssistantRoleLiteral,((s=p.groundingMetadata.webSearchQueries)==null?void 0:s[0])||"",((c=p.groundingMetadata.groundingChunks)==null?void 0:c.map(_=>{var E,O;return {source:_.web?"web":"",url:((E=_.web)==null?void 0:E.uri)||"",title:((O=_.web)==null?void 0:O.title)||""}}))||[],((a=p.groundingMetadata.groundingSupports)==null?void 0:a.map(_=>{var E,O,k;return {text:((E=_.segment)==null?void 0:E.text)||"",responseIndices:_.groundingChunkIndices||[],startIndex:((O=_.segment)==null?void 0:O.startIndex)||void 0,endIndex:((k=_.segment)==null?void 0:k.endIndex)||void 0,confidenceScores:_.confidenceScores||void 0}}))||[]));let u=p.safetyRatings;u&&u.length>0&&u.forEach(_=>{_.blocked&&h.partialMessages.push(types.createPartialSafetyErrorMessage(types.AssistantRoleLiteral,_.category,_.probability,_.blocked,`Blocked content for category: ${_.category} with probability: ${_.probability}`));});}yield {partialResponse:h,buffer:o};}else throw new provider.ModelResponseError({info:"Invalid response from model",cause:l.error})}yield {partialResponse:{partialMessages:[]},buffer:o};})}transformProxyStreamChatResponseChunk(e,o,t,s,c){return io(this,null,function*(){var l,h,S;if((c==null?void 0:c.alt)!=="sse"){yield*Wo(this.transformStreamChatResponseChunk(e,o));return}let a=o+e,m=[],i="",n=0;for(;n<a.length;){let p=a.indexOf(`
|
|
15
|
+
`,n);if(p===-1){i=a.substring(n);break}else {let u=a.substring(n,p).trim();u&&m.push(u),n=p+1;}}for(let p of m){if(p==="data: [DONE]")return;if(p.startsWith("data: ")){let u=p.substring(6);try{let _=JSON.parse(u),E=zo.safeParse(_);if(E.success){let O={partialMessages:[]},k=E.data;if(k.candidates.length>0){let D=k.candidates[0].content;D&&"parts"in D&&D.parts.length>0&&D.parts.forEach((I,x)=>{if("text"in I&&I.text!==void 0&&(I.thought===!0?O.partialMessages.push(types.createPartialReasoningMessage(types.AssistantRoleLiteral,I.text,"")):O.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,I.text))),"functionCall"in I&&I.functionCall!==void 0){let B=I.functionCall;O.partialMessages.push(types.createPartialToolCallMessage(types.AssistantRoleLiteral,x,`${B.name}_${x}`,B.name,JSON.stringify(B.args),void 0,I.thoughtSignature));}});}if(k.usageMetadata&&k.usageMetadata.totalTokenCount&&k.usageMetadata.promptTokenCount&&k.usageMetadata.candidatesTokenCount&&(O.usage={promptTokens:k.usageMetadata.promptTokenCount,completionTokens:k.usageMetadata.candidatesTokenCount,totalTokens:k.usageMetadata.totalTokenCount}),k.candidates.length>0){let D=k.candidates[0];D.groundingMetadata&&O.partialMessages.push(types.createPartialSearchResultGoogleMessage(types.AssistantRoleLiteral,((l=D.groundingMetadata.webSearchQueries)==null?void 0:l[0])||"",((h=D.groundingMetadata.groundingChunks)==null?void 0:h.map(x=>{var B,J;return {source:x.web?"web":"",url:((B=x.web)==null?void 0:B.uri)||"",title:((J=x.web)==null?void 0:J.title)||""}}))||[],((S=D.groundingMetadata.groundingSupports)==null?void 0:S.map(x=>{var B,J,Ho;return {text:((B=x.segment)==null?void 0:B.text)||"",responseIndices:x.groundingChunkIndices||[],startIndex:((J=x.segment)==null?void 0:J.startIndex)||void 0,endIndex:((Ho=x.segment)==null?void 0:Ho.endIndex)||void 0,confidenceScores:x.confidenceScores||void 0}}))||[]));let I=D.safetyRatings;I&&I.length>0&&I.forEach(x=>{x.blocked&&O.partialMessages.push(types.createPartialSafetyErrorMessage(types.AssistantRoleLiteral,x.category,x.probability,x.blocked,`Blocked content for category: ${x.category} with probability: ${x.probability}`));});}yield {partialResponse:O,buffer:o};}else throw new provider.ModelResponseError({info:"Invalid response from model",cause:E.error})}catch(_){throw new provider.ModelResponseError({info:`Malformed JSON received in stream: ${u}`,cause:_})}}}yield {partialResponse:{partialMessages:[]},buffer:i};})}getProxyCompleteChatUrl(e,o,t){return R(this,null,function*(){return new Promise(s=>{s(this.completeChatUrl);})})}getProxyStreamChatUrl(e,o,t){return R(this,null,function*(){return new Promise(s=>{if(!t||Object.keys(t).length===0){s(this.streamChatUrl);return}let c=new URL(this.streamChatUrl);Object.entries(t).forEach(([a,m])=>{m!=null&&c.searchParams.set(a,m);}),s(c.toString());})})}getProxyCompleteChatHeaders(e,o,t){return R(this,null,function*(){if(!o)return {};let s=w({},o);return delete s.host,delete s["content-length"],s})}getProxyStreamChatHeaders(e,o,t){return R(this,null,function*(){return yield this.getProxyCompleteChatHeaders(e,o,t)})}getModelPricing(){if(!(this.modelName in y))throw new provider.ModelResponseError({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return y[this.modelName]}};var le="gemini-1.5-flash-001",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",uo=provider.ChatModelSchema(T,P).parse({name:le,description:mn,maxInputTokens:1e6,maxOutputTokens:8192,roles:G,modalities:b,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:y[le]}),rt=M,me=class extends C{constructor(e){super(uo,e);}};var de="gemini-1.5-flash-002",pn="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",yo=provider.ChatModelSchema(T,P).parse({name:de,description:pn,maxInputTokens:1e6,maxOutputTokens:8192,roles:G,modalities:b,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:y[de]}),lt=M,pe=class extends C{constructor(e){super(yo,e);}};var ce="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",Co=provider.ChatModelSchema(T,P).parse({name:ce,description:gn,maxInputTokens:1e6,maxOutputTokens:8192,roles:G,modalities:b,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:y[ce]}),mt=M,ge=class extends C{constructor(e){super(Co,e);}};var he="gemini-1.5-flash",fn="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",Mo=provider.ChatModelSchema(T,P).parse({name:he,description:fn,maxInputTokens:1e6,maxOutputTokens:8192,roles:G,modalities:b,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:y[he]}),dt=M,fe=class extends C{constructor(e){super(Mo,e);}};var ue="gemini-1.5-pro-001",yn="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",To=provider.ChatModelSchema(T,P).parse({name:ue,description:yn,maxInputTokens:2e6,maxOutputTokens:8192,roles:G,modalities:b,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:y[ue]}),pt=M,ye=class extends C{constructor(e){super(To,e);}};var Ce="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",Go=provider.ChatModelSchema(T,P).parse({name:Ce,description:Mn,maxInputTokens:2e6,maxOutputTokens:8192,roles:G,modalities:b,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:y[Ce]}),ct=M,Me=class extends C{constructor(e){super(Go,e);}};var Te="gemini-1.5-pro-latest",Gn="Google's best performing multimodal model with features for a wide variety of reasoning tasks. Optimized for complex reasoning tasks requiring more intelligence",bo=provider.ChatModelSchema(T,P).parse({name:Te,description:Gn,maxInputTokens:2e6,maxOutputTokens:8192,roles:G,modalities:b,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:y[Te]}),gt=M,Ge=class extends C{constructor(e){super(bo,e);}};var be="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",Po=provider.ChatModelSchema(T,P).parse({name:be,description:Pn,maxInputTokens:2e6,maxOutputTokens:8192,roles:G,modalities:b,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:y[be]}),ht=M,Pe=class extends C{constructor(e){super(Po,e);}};var oi="gemini-2.0-flash-exp",Sn="Google's experimental multimodal model with enhanced capabilities. Designed for cutting-edge performance across complex and high-frequency tasks.",wn=provider.ChatModelSchema(T,P).parse({name:oi,description:Sn,maxInputTokens:1e6,maxOutputTokens:8192,roles:G,modalities:b,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:y[oi]}),zr=M,ti=class extends C{constructor(e){super(wn,e);}};var _e="gemini-2.0-flash",En="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.",_o=provider.ChatModelSchema(T,P).parse({name:_e,description:En,maxInputTokens:1048576,maxOutputTokens:8192,roles:G,modalities:b,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:y[_e]}),ft=M,Se=class extends C{constructor(e){super(_o,e);}};var we="gemini-2.0-flash-lite",Rn="Google's lightweight Gemini 2.0 Flash Lite model for high-throughput, low-cost text generation and classification workloads.",So=provider.ChatModelSchema(T,P).parse({name:we,description:Rn,maxInputTokens:1048576,maxOutputTokens:8192,roles:G,modalities:b,config:{def:f.responseSchema(2,1,8192,4,.95).def,schema:f.responseSchema(2,1,8192,4,.95).schema},price:y[we]}),ut=M,Oe=class extends C{constructor(e){super(So,e);}};var Ee="gemini-2.5-flash-lite",vn="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.",wo=provider.ChatModelSchema(T,P).parse({name:Ee,description:vn,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:b,config:{def:f.responseSchema(2,1,65536,4,.95).def,schema:f.responseSchema(2,1,65536,4,.95).schema},price:y[Ee]}),yt=M,ke=class extends C{constructor(e){super(wo,e);}};var Re="gemini-2.5-flash-lite-preview-09-2025",Ln="Google's preview Flash Lite variant in the Gemini 2.5 family, optimized for low-latency, high-volume tasks.",Oo=provider.ChatModelSchema(T,P).parse({name:Re,description:Ln,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:b,config:{def:f.responseSchema(2,1,65536,4,.95).def,schema:f.responseSchema(2,1,65536,4,.95).schema},price:y[Re]}),Ct=M,xe=class extends C{constructor(e){super(Oo,e);}};var ve="gemini-2.5-flash-preview-04-17",Nn="Google's best model in Gemini 2.5 family in terms of price-performance, offering well-rounded capabilities.",Eo=provider.ChatModelSchema(T,P).parse({name:ve,description:Nn,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:b,config:{def:f.reasoning(2,1,65536,4,.95,1,24576).def,schema:f.reasoning(2,1,65536,4,.95,1,24576).schema},price:y[ve]}),Mt=M,Fe=class extends C{constructor(e){super(Eo,e);}};var Le="gemini-2.5-flash",Un="Google's Gemini 2.5 Flash model for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",ko=provider.ChatModelSchema(T,P).parse({name:Le,description:Un,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:b,config:{def:f.reasoning(2,1,65536,4,.95,1,24576).def,schema:f.reasoning(2,1,65536,4,.95,1,24576).schema},price:y[Le]}),Tt=M,Ie=class extends C{constructor(e){super(ko,e);}};var Ne="gemini-2.5-pro-preview-03-25",$n="Google's preview model in Gemini 2.5 family for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",Ro=provider.ChatModelSchema(T,P).parse({name:Ne,description:$n,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:b,config:{def:f.reasoning(2,1,65536,4,.95,1,65536).def,schema:f.reasoning(2,1,65536,4,.95,1,65536).schema},price:y[Ne]}),Gt=M,De=class extends C{constructor(e){super(Ro,e);}};var Ue="gemini-2.5-pro",An="Google's Gemini 2.5 Pro model for enhanced thinking, reasoning, multimodal understanding, and advanced coding.",xo=provider.ChatModelSchema(T,P).parse({name:Ue,description:An,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:b,config:{def:f.reasoning(2,1,65536,4,.95,1,65536).def,schema:f.reasoning(2,1,65536,4,.95,1,65536).schema},price:y[Ue]}),bt=M,Be=class extends C{constructor(e){super(xo,e);}};var $e="gemini-3.1-pro-preview-customtools",qn="Google's Gemini 3.1 Pro Preview variant optimized for the custom tools endpoint in the Gemini API.",vo=provider.ChatModelSchema(T,P).parse({name:$e,description:qn,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:b,config:{def:f.reasoning(2,1,65536,4,.95,1,65536).def,schema:f.reasoning(2,1,65536,4,.95,1,65536).schema},price:y[$e]}),Pt=M,ze=class extends C{constructor(e){super(vo,e);}};var Ae="gemini-3.1-pro-preview",Kn="Google's Gemini 3.1 Pro Preview model for improved reliability and nuanced understanding in complex reasoning and multimodal tasks.",Fo=provider.ChatModelSchema(T,P).parse({name:Ae,description:Kn,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:b,config:{def:f.reasoning(2,1,65536,4,.95,1,65536).def,schema:f.reasoning(2,1,65536,4,.95,1,65536).schema},price:y[Ae]}),_t=M,je=class extends C{constructor(e){super(Fo,e);}};var qe="gemini-3-flash-preview",Vn="Google's Gemini 3 Flash Preview model - a lightweight and efficient AI model with enhanced multimodal understanding, reasoning, and advanced coding capabilities. Optimized for speed and cost-effectiveness. Supports Text, Image, Video, Audio, and PDF inputs. Knowledge cutoff: January 2025.",Lo=provider.ChatModelSchema(T,P).parse({name:qe,description:Vn,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:b,config:{def:f.reasoning(2,1,65536,4,.95,1,65536).def,schema:f.reasoning(2,1,65536,4,.95,1,65536).schema},price:y[qe]}),St=M,He=class extends C{constructor(e){super(Lo,e);}};var Ke="gemini-3-pro-preview",Jn="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.",Io=provider.ChatModelSchema(T,P).parse({name:Ke,description:Jn,maxInputTokens:1048576,maxOutputTokens:65536,roles:G,modalities:b,config:{def:f.reasoning(2,1,65536,4,.95,1,65536).def,schema:f.reasoning(2,1,65536,4,.95,1,65536).schema},price:y[Ke]}),wt=M,Ye=class extends C{constructor(e){super(Io,e);}};var oo=[types.EmbeddingTextModalityLiteral],to=zod.z.enum([types.EmbeddingTextModalityLiteral]);var ni=zod.z.object({embeddings:zod.z.array(zod.z.object({values:zod.z.array(zod.z.number())}))});var Qn=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)})}),si=zod.z.object({model:zod.z.string().min(1).optional(),requests:zod.z.array(Qn).min(1),outputDimensionality:zod.z.number().int().min(1).optional()});var oe=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),getEmbeddingsUrl:zod.z.string().url().optional()}),W=class{constructor(e,o){this.version="v1";let t=oe.parse(o);this.modelSchema=e,this.modelName=t.modelName,this.apiKey=t.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash(t.baseUrl||A.baseUrl),this.getEmbeddingsUrl=provider.urlWithoutTrailingSlash(t.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,o){var a;let s=0,c=m=>{let i=m.match(/^(\d+(?:\.\d+)?)s$/);return i?Math.ceil(parseFloat(i[1])*1e3):0};if(o&&typeof o=="object"){let m=o;if((a=m.error)!=null&&a.details&&Array.isArray(m.error.details)){let i=m.error.details.find(n=>n["@type"]==="type.googleapis.com/google.rpc.RetryInfo");i!=null&&i.retryDelay&&(s=c(i.retryDelay));}}return {shouldRetry:!0,delayMs:s}}getTokenCount(e){return e.requests.reduce((o,t)=>o+t.length,0)}transformModelRequest(e){let o=si.safeParse(e);if(!o.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:o.error});let t=o.data,s=t.model,c={outputDimensionality:t.outputDimensionality},a=types.Config().parse(provider.removeUndefinedEntries(c)),m={modality:types.EmbeddingTextModalityLiteral,requests:t.requests.reduce((i,n)=>(i.push(...n.content.parts.map(l=>l.text)),i),[])};return {modelName:s,config:a,embeddingRequests:m}}transformConfig(e,o){let t=this.modelSchema.config.schema.safeParse(e);if(!t.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:t.error});let s=t.data;return Object.keys(s).forEach(a=>{if(!this.modelSchema.config.def[a])throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${a}',
|
|
16
|
+
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(s).reduce((a,m)=>{let n=this.modelSchema.config.def[m].param,l=s[m];return a[n]=l,a},{})}transformEmbeddingRequests(e){let o=types.EmbeddingRequests().safeParse(e);if(!o.success)throw new provider.InvalidEmbeddingRequestsError({info:"Invalid embedding requests",cause:o.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:o.data.requests.map(s=>({model:`models/${this.modelName}`,content:{parts:[{text:s}]}}))}}getGetEmbeddingsUrl(e,o){return R(this,null,function*(){return new Promise(t=>{t(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(e,o){return R(this,null,function*(){return new Promise(t=>{t(this.getDefaultHeaders());})})}getGetEmbeddingsData(e,o){return R(this,null,function*(){return new Promise(t=>{let s=this.transformConfig(e),c=this.transformEmbeddingRequests(o);if(o.requests.length===0)throw new provider.InvalidEmbeddingRequestsError({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error("requests cannot be empty")});s.outputDimensionality&&(c.requests.forEach(a=>{a.outputDimensionality=s.outputDimensionality;}),delete s.outputDimensionality),t(w(w(w({},this.getDefaultParams()),s),c));})})}transformGetEmbeddingsResponse(e){let o=ni.safeParse(e);if(o.success){let s=o.data.embeddings.map((c,a)=>({index:a,embedding:c.values}));return {encodingFormat:types.FloatEmbeddingLiteral,embeddings:s}}throw new provider.ModelResponseError({info:"Invalid response from model",cause:o.error})}};var No="text-embedding-001",as="text-embedding-001",Do=provider.EmbeddingModelSchema(to).parse({name:No,description:as,modalities:oo,maxInputTokens:2048,maxOutputTokens:768,config:{def:H.base(768).def,schema:H.base(768).schema}}),Ot=oe,Ve=class extends W{constructor(e){super(Do,e);}};var Uo="text-embedding-004",ls="text-embedding-004",Bo=provider.EmbeddingModelSchema(to).parse({name:Uo,description:ls,modalities:oo,maxInputTokens:2048,maxOutputTokens:768,config:{def:H.base(768).def,schema:H.base(768).schema}}),Et=oe,We=class extends W{constructor(e){super(Bo,e);}};
|
|
17
17
|
|
|
18
|
-
exports.BaseChatModel =
|
|
19
|
-
exports.BaseChatModelOptions =
|
|
20
|
-
exports.BaseEmbeddingModel =
|
|
18
|
+
exports.BaseChatModel = C;
|
|
19
|
+
exports.BaseChatModelOptions = M;
|
|
20
|
+
exports.BaseEmbeddingModel = W;
|
|
21
21
|
exports.BaseEmbeddingModelOptions = oe;
|
|
22
|
-
exports.ChatModelBaseConfigDef =
|
|
23
|
-
exports.ChatModelBaseConfigSchema =
|
|
24
|
-
exports.ChatModelReasoningConfigDef =
|
|
25
|
-
exports.ChatModelReasoningConfigSchema =
|
|
26
|
-
exports.EmbeddingModelBaseConfigDef =
|
|
27
|
-
exports.EmbeddingModelBaseConfigSchema =
|
|
28
|
-
exports.GOOGLE_SAFETY_CATEGORIES =
|
|
29
|
-
exports.GOOGLE_SAFETY_CATEGORY_OPTIONS =
|
|
30
|
-
exports.GOOGLE_SAFETY_THRESHOLDS =
|
|
31
|
-
exports.GOOGLE_SAFETY_THRESHOLD_OPTIONS =
|
|
22
|
+
exports.ChatModelBaseConfigDef = ne;
|
|
23
|
+
exports.ChatModelBaseConfigSchema = ie;
|
|
24
|
+
exports.ChatModelReasoningConfigDef = tt;
|
|
25
|
+
exports.ChatModelReasoningConfigSchema = ot;
|
|
26
|
+
exports.EmbeddingModelBaseConfigDef = st;
|
|
27
|
+
exports.EmbeddingModelBaseConfigSchema = nt;
|
|
28
|
+
exports.GOOGLE_SAFETY_CATEGORIES = ui;
|
|
29
|
+
exports.GOOGLE_SAFETY_CATEGORY_OPTIONS = Ci;
|
|
30
|
+
exports.GOOGLE_SAFETY_THRESHOLDS = yi;
|
|
31
|
+
exports.GOOGLE_SAFETY_THRESHOLD_OPTIONS = Mi;
|
|
32
32
|
exports.Gemini1_5Flash = fe;
|
|
33
33
|
exports.Gemini1_5Flash001 = me;
|
|
34
34
|
exports.Gemini1_5Flash001Literal = le;
|
|
35
|
-
exports.Gemini1_5Flash001Options =
|
|
36
|
-
exports.Gemini1_5Flash001Schema =
|
|
35
|
+
exports.Gemini1_5Flash001Options = rt;
|
|
36
|
+
exports.Gemini1_5Flash001Schema = uo;
|
|
37
37
|
exports.Gemini1_5Flash002 = pe;
|
|
38
38
|
exports.Gemini1_5Flash002Literal = de;
|
|
39
|
-
exports.Gemini1_5Flash002Options =
|
|
40
|
-
exports.Gemini1_5Flash002Schema =
|
|
39
|
+
exports.Gemini1_5Flash002Options = lt;
|
|
40
|
+
exports.Gemini1_5Flash002Schema = yo;
|
|
41
41
|
exports.Gemini1_5FlashLatest = ge;
|
|
42
42
|
exports.Gemini1_5FlashLatestLiteral = ce;
|
|
43
|
-
exports.Gemini1_5FlashLatestOptions =
|
|
44
|
-
exports.Gemini1_5FlashLatestSchema =
|
|
43
|
+
exports.Gemini1_5FlashLatestOptions = mt;
|
|
44
|
+
exports.Gemini1_5FlashLatestSchema = Co;
|
|
45
45
|
exports.Gemini1_5FlashLiteral = he;
|
|
46
|
-
exports.Gemini1_5FlashOptions =
|
|
47
|
-
exports.Gemini1_5FlashSchema =
|
|
46
|
+
exports.Gemini1_5FlashOptions = dt;
|
|
47
|
+
exports.Gemini1_5FlashSchema = Mo;
|
|
48
48
|
exports.Gemini1_5Pro = Pe;
|
|
49
49
|
exports.Gemini1_5Pro001 = ye;
|
|
50
50
|
exports.Gemini1_5Pro001Literal = ue;
|
|
51
|
-
exports.Gemini1_5Pro001Options =
|
|
52
|
-
exports.Gemini1_5Pro001Schema =
|
|
53
|
-
exports.Gemini1_5Pro002 =
|
|
51
|
+
exports.Gemini1_5Pro001Options = pt;
|
|
52
|
+
exports.Gemini1_5Pro001Schema = To;
|
|
53
|
+
exports.Gemini1_5Pro002 = Me;
|
|
54
54
|
exports.Gemini1_5Pro002Literal = Ce;
|
|
55
|
-
exports.Gemini1_5Pro002Options =
|
|
56
|
-
exports.Gemini1_5Pro002Schema =
|
|
55
|
+
exports.Gemini1_5Pro002Options = ct;
|
|
56
|
+
exports.Gemini1_5Pro002Schema = Go;
|
|
57
57
|
exports.Gemini1_5ProLatest = Ge;
|
|
58
|
-
exports.Gemini1_5ProLatestLiteral =
|
|
59
|
-
exports.Gemini1_5ProLatestOptions =
|
|
60
|
-
exports.Gemini1_5ProLatestSchema =
|
|
58
|
+
exports.Gemini1_5ProLatestLiteral = Te;
|
|
59
|
+
exports.Gemini1_5ProLatestOptions = gt;
|
|
60
|
+
exports.Gemini1_5ProLatestSchema = bo;
|
|
61
61
|
exports.Gemini1_5ProLiteral = be;
|
|
62
|
-
exports.Gemini1_5ProOptions =
|
|
63
|
-
exports.Gemini1_5ProSchema =
|
|
62
|
+
exports.Gemini1_5ProOptions = ht;
|
|
63
|
+
exports.Gemini1_5ProSchema = Po;
|
|
64
64
|
exports.Gemini2_0Flash = Se;
|
|
65
|
-
exports.Gemini2_0FlashExp =
|
|
66
|
-
exports.Gemini2_0FlashExpLiteral =
|
|
67
|
-
exports.Gemini2_0FlashExpOptions =
|
|
68
|
-
exports.Gemini2_0FlashExpSchema =
|
|
65
|
+
exports.Gemini2_0FlashExp = ti;
|
|
66
|
+
exports.Gemini2_0FlashExpLiteral = oi;
|
|
67
|
+
exports.Gemini2_0FlashExpOptions = zr;
|
|
68
|
+
exports.Gemini2_0FlashExpSchema = wn;
|
|
69
|
+
exports.Gemini2_0FlashLite = Oe;
|
|
70
|
+
exports.Gemini2_0FlashLiteLiteral = we;
|
|
71
|
+
exports.Gemini2_0FlashLiteOptions = ut;
|
|
72
|
+
exports.Gemini2_0FlashLiteSchema = So;
|
|
69
73
|
exports.Gemini2_0FlashLiteral = _e;
|
|
70
|
-
exports.Gemini2_0FlashOptions =
|
|
71
|
-
exports.Gemini2_0FlashSchema =
|
|
72
|
-
exports.Gemini2_5Flash =
|
|
73
|
-
exports.Gemini2_5FlashLite =
|
|
74
|
+
exports.Gemini2_0FlashOptions = ft;
|
|
75
|
+
exports.Gemini2_0FlashSchema = _o;
|
|
76
|
+
exports.Gemini2_5Flash = Ie;
|
|
77
|
+
exports.Gemini2_5FlashLite = ke;
|
|
74
78
|
exports.Gemini2_5FlashLiteLiteral = Ee;
|
|
75
|
-
exports.Gemini2_5FlashLiteOptions =
|
|
76
|
-
exports.
|
|
77
|
-
exports.
|
|
78
|
-
exports.
|
|
79
|
-
exports.
|
|
80
|
-
exports.
|
|
81
|
-
exports.
|
|
82
|
-
exports.
|
|
83
|
-
exports.
|
|
84
|
-
exports.
|
|
85
|
-
exports.
|
|
86
|
-
exports.
|
|
87
|
-
exports.
|
|
88
|
-
exports.
|
|
89
|
-
exports.
|
|
90
|
-
exports.
|
|
91
|
-
exports.
|
|
92
|
-
exports.
|
|
93
|
-
exports.
|
|
94
|
-
exports.
|
|
95
|
-
exports.
|
|
96
|
-
exports.
|
|
97
|
-
exports.
|
|
98
|
-
exports.
|
|
99
|
-
exports.
|
|
100
|
-
exports.
|
|
101
|
-
exports.
|
|
102
|
-
exports.
|
|
103
|
-
exports.
|
|
104
|
-
exports.
|
|
105
|
-
exports.
|
|
106
|
-
exports.
|
|
107
|
-
exports.
|
|
108
|
-
exports.
|
|
109
|
-
exports.
|
|
110
|
-
exports.
|
|
111
|
-
exports.
|
|
112
|
-
exports.
|
|
113
|
-
exports.
|
|
79
|
+
exports.Gemini2_5FlashLiteOptions = yt;
|
|
80
|
+
exports.Gemini2_5FlashLitePreview092025 = xe;
|
|
81
|
+
exports.Gemini2_5FlashLitePreview092025Literal = Re;
|
|
82
|
+
exports.Gemini2_5FlashLitePreview092025Options = Ct;
|
|
83
|
+
exports.Gemini2_5FlashLitePreview092025Schema = Oo;
|
|
84
|
+
exports.Gemini2_5FlashLiteSchema = wo;
|
|
85
|
+
exports.Gemini2_5FlashLiteral = Le;
|
|
86
|
+
exports.Gemini2_5FlashOptions = Tt;
|
|
87
|
+
exports.Gemini2_5FlashPreview0417 = Fe;
|
|
88
|
+
exports.Gemini2_5FlashPreview0417Literal = ve;
|
|
89
|
+
exports.Gemini2_5FlashPreview0417Options = Mt;
|
|
90
|
+
exports.Gemini2_5FlashPreview0417Schema = Eo;
|
|
91
|
+
exports.Gemini2_5FlashSchema = ko;
|
|
92
|
+
exports.Gemini2_5Pro = Be;
|
|
93
|
+
exports.Gemini2_5ProLiteral = Ue;
|
|
94
|
+
exports.Gemini2_5ProOptions = bt;
|
|
95
|
+
exports.Gemini2_5ProPreview0325 = De;
|
|
96
|
+
exports.Gemini2_5ProPreview0325Literal = Ne;
|
|
97
|
+
exports.Gemini2_5ProPreview0325Options = Gt;
|
|
98
|
+
exports.Gemini2_5ProPreview0325Schema = Ro;
|
|
99
|
+
exports.Gemini2_5ProSchema = xo;
|
|
100
|
+
exports.Gemini3FlashPreview = He;
|
|
101
|
+
exports.Gemini3FlashPreviewLiteral = qe;
|
|
102
|
+
exports.Gemini3FlashPreviewOptions = St;
|
|
103
|
+
exports.Gemini3FlashPreviewSchema = Lo;
|
|
104
|
+
exports.Gemini3ProPreview = Ye;
|
|
105
|
+
exports.Gemini3ProPreviewLiteral = Ke;
|
|
106
|
+
exports.Gemini3ProPreviewOptions = wt;
|
|
107
|
+
exports.Gemini3ProPreviewSchema = Io;
|
|
108
|
+
exports.Gemini3_1ProPreview = je;
|
|
109
|
+
exports.Gemini3_1ProPreviewCustomtools = ze;
|
|
110
|
+
exports.Gemini3_1ProPreviewCustomtoolsLiteral = $e;
|
|
111
|
+
exports.Gemini3_1ProPreviewCustomtoolsOptions = Pt;
|
|
112
|
+
exports.Gemini3_1ProPreviewCustomtoolsSchema = vo;
|
|
113
|
+
exports.Gemini3_1ProPreviewLiteral = Ae;
|
|
114
|
+
exports.Gemini3_1ProPreviewOptions = _t;
|
|
115
|
+
exports.Gemini3_1ProPreviewSchema = Fo;
|
|
116
|
+
exports.Google = A;
|
|
117
|
+
exports.GoogleChatAssistantRoleLiteral = vi;
|
|
118
|
+
exports.GoogleChatContent = Yi;
|
|
119
|
+
exports.GoogleChatContentPartFileData = qi;
|
|
120
|
+
exports.GoogleChatContentPartFunctionCall = Hi;
|
|
121
|
+
exports.GoogleChatContentPartFunctionResponse = Ki;
|
|
122
|
+
exports.GoogleChatContentPartInlineData = ji;
|
|
123
|
+
exports.GoogleChatContentPartText = $t;
|
|
124
|
+
exports.GoogleChatContentPartThinking = It;
|
|
125
|
+
exports.GoogleChatGenerationConfig = Ut;
|
|
126
|
+
exports.GoogleChatGoogleSearchTool = Wi;
|
|
127
|
+
exports.GoogleChatModelConfigs = f;
|
|
128
|
+
exports.GoogleChatModelModalities = b;
|
|
129
|
+
exports.GoogleChatModelModalitiesEnum = P;
|
|
114
130
|
exports.GoogleChatModelResponseSchemaConfigDef = ae;
|
|
115
131
|
exports.GoogleChatModelResponseSchemaConfigSchema = re;
|
|
116
|
-
exports.GoogleChatModelRoles =
|
|
117
|
-
exports.GoogleChatModelRolesMap =
|
|
118
|
-
exports.GoogleChatModelTextModalities =
|
|
119
|
-
exports.GoogleChatModelTextModalitiesEnum =
|
|
120
|
-
exports.GoogleChatModelTextToolModalities =
|
|
121
|
-
exports.GoogleChatModelTextToolModalitiesEnum =
|
|
122
|
-
exports.GoogleChatModelTextVisionModalities =
|
|
123
|
-
exports.GoogleChatModelTextVisionModalitiesEnum =
|
|
124
|
-
exports.GoogleChatRequest =
|
|
125
|
-
exports.GoogleChatSafetySettings =
|
|
126
|
-
exports.GoogleChatSystemInstruction =
|
|
127
|
-
exports.GoogleChatThinkingConfig =
|
|
128
|
-
exports.GoogleChatTool =
|
|
129
|
-
exports.GoogleChatToolConfig =
|
|
130
|
-
exports.GoogleChatToolRoleLiteral =
|
|
131
|
-
exports.GoogleCompleteChatResponse =
|
|
132
|
-
exports.GoogleCompleteChatTextResponse =
|
|
133
|
-
exports.GoogleCompleteChatToolResponse =
|
|
134
|
-
exports.GoogleEmbeddingModelConfigs =
|
|
135
|
-
exports.GoogleEmbeddingModelModalities =
|
|
136
|
-
exports.GoogleEmbeddingModelModalitiesEnum =
|
|
137
|
-
exports.GoogleEmbeddingRequest =
|
|
138
|
-
exports.GoogleEmbeddingRequestInput =
|
|
139
|
-
exports.GoogleGetEmbeddingsResponse =
|
|
140
|
-
exports.GoogleGroundingChunk =
|
|
141
|
-
exports.GoogleGroundingMetadata =
|
|
142
|
-
exports.GoogleGroundingSupport =
|
|
143
|
-
exports.GoogleSearchEntryPoint =
|
|
144
|
-
exports.GoogleStreamChatResponse =
|
|
145
|
-
exports.GoogleStreamChatTextResponse =
|
|
146
|
-
exports.GoogleStreamChatToolResponse =
|
|
147
|
-
exports.ProviderLiteral =
|
|
148
|
-
exports.Text_Embedding_001 =
|
|
149
|
-
exports.Text_Embedding_001Literal =
|
|
150
|
-
exports.Text_Embedding_001Options =
|
|
151
|
-
exports.Text_Embedding_001Schema =
|
|
152
|
-
exports.Text_Embedding_004 =
|
|
153
|
-
exports.Text_Embedding_004Literal =
|
|
154
|
-
exports.Text_Embedding_004Options =
|
|
155
|
-
exports.Text_Embedding_004Schema =
|
|
156
|
-
exports.dimensions =
|
|
157
|
-
exports.frequencyPenalty =
|
|
158
|
-
exports.googleSearchTool =
|
|
159
|
-
exports.maxReasoningTokens =
|
|
160
|
-
exports.maxTokens =
|
|
161
|
-
exports.presencePenalty =
|
|
162
|
-
exports.reasoningEffort =
|
|
163
|
-
exports.reasoningEnabled =
|
|
164
|
-
exports.safetySettings =
|
|
165
|
-
exports.seed =
|
|
166
|
-
exports.stop =
|
|
167
|
-
exports.temperature =
|
|
168
|
-
exports.toolChoice =
|
|
169
|
-
exports.topK =
|
|
170
|
-
exports.topP =
|
|
132
|
+
exports.GoogleChatModelRoles = T;
|
|
133
|
+
exports.GoogleChatModelRolesMap = G;
|
|
134
|
+
exports.GoogleChatModelTextModalities = Js;
|
|
135
|
+
exports.GoogleChatModelTextModalitiesEnum = Xs;
|
|
136
|
+
exports.GoogleChatModelTextToolModalities = ea;
|
|
137
|
+
exports.GoogleChatModelTextToolModalitiesEnum = oa;
|
|
138
|
+
exports.GoogleChatModelTextVisionModalities = Qs;
|
|
139
|
+
exports.GoogleChatModelTextVisionModalitiesEnum = Zs;
|
|
140
|
+
exports.GoogleChatRequest = zt;
|
|
141
|
+
exports.GoogleChatSafetySettings = Bt;
|
|
142
|
+
exports.GoogleChatSystemInstruction = Nt;
|
|
143
|
+
exports.GoogleChatThinkingConfig = Ji;
|
|
144
|
+
exports.GoogleChatTool = Vi;
|
|
145
|
+
exports.GoogleChatToolConfig = Dt;
|
|
146
|
+
exports.GoogleChatToolRoleLiteral = Fi;
|
|
147
|
+
exports.GoogleCompleteChatResponse = Lt;
|
|
148
|
+
exports.GoogleCompleteChatTextResponse = Bi;
|
|
149
|
+
exports.GoogleCompleteChatToolResponse = $i;
|
|
150
|
+
exports.GoogleEmbeddingModelConfigs = H;
|
|
151
|
+
exports.GoogleEmbeddingModelModalities = oo;
|
|
152
|
+
exports.GoogleEmbeddingModelModalitiesEnum = to;
|
|
153
|
+
exports.GoogleEmbeddingRequest = si;
|
|
154
|
+
exports.GoogleEmbeddingRequestInput = Qn;
|
|
155
|
+
exports.GoogleGetEmbeddingsResponse = ni;
|
|
156
|
+
exports.GoogleGroundingChunk = Ni;
|
|
157
|
+
exports.GoogleGroundingMetadata = Ft;
|
|
158
|
+
exports.GoogleGroundingSupport = Ui;
|
|
159
|
+
exports.GoogleSearchEntryPoint = Li;
|
|
160
|
+
exports.GoogleStreamChatResponse = zo;
|
|
161
|
+
exports.GoogleStreamChatTextResponse = zi;
|
|
162
|
+
exports.GoogleStreamChatToolResponse = Ai;
|
|
163
|
+
exports.ProviderLiteral = wi;
|
|
164
|
+
exports.Text_Embedding_001 = Ve;
|
|
165
|
+
exports.Text_Embedding_001Literal = No;
|
|
166
|
+
exports.Text_Embedding_001Options = Ot;
|
|
167
|
+
exports.Text_Embedding_001Schema = Do;
|
|
168
|
+
exports.Text_Embedding_004 = We;
|
|
169
|
+
exports.Text_Embedding_004Literal = Uo;
|
|
170
|
+
exports.Text_Embedding_004Options = Et;
|
|
171
|
+
exports.Text_Embedding_004Schema = Bo;
|
|
172
|
+
exports.dimensions = fo;
|
|
173
|
+
exports.frequencyPenalty = cs;
|
|
174
|
+
exports.googleSearchTool = ho;
|
|
175
|
+
exports.maxReasoningTokens = co;
|
|
176
|
+
exports.maxTokens = so;
|
|
177
|
+
exports.presencePenalty = gs;
|
|
178
|
+
exports.reasoningEffort = go;
|
|
179
|
+
exports.reasoningEnabled = po;
|
|
180
|
+
exports.safetySettings = mo;
|
|
181
|
+
exports.seed = hs;
|
|
182
|
+
exports.stop = ao;
|
|
183
|
+
exports.temperature = no;
|
|
184
|
+
exports.toolChoice = lo;
|
|
185
|
+
exports.topK = ps;
|
|
186
|
+
exports.topP = ro;
|
|
171
187
|
//# sourceMappingURL=index.js.map
|
|
172
188
|
//# sourceMappingURL=index.js.map
|