@adaline/anthropic 0.26.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,18 +1,16 @@
1
1
  import { z as z$1 } from 'zod';
2
2
 
3
- var Jo=Object.defineProperty,Wo=Object.defineProperties;var Zo=Object.getOwnPropertyDescriptors;var At=Object.getOwnPropertySymbols;var Yo=Object.prototype.hasOwnProperty,Qo=Object.prototype.propertyIsEnumerable;var ae=(a,e)=>(e=Symbol[a])?e:Symbol.for("Symbol."+a),Xo=a=>{throw TypeError(a)};var kt=(a,e,o)=>e in a?Jo(a,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):a[e]=o,C=(a,e)=>{for(var o in e||(e={}))Yo.call(e,o)&&kt(a,o,e[o]);if(At)for(var o of At(e))Qo.call(e,o)&&kt(a,o,e[o]);return a},Re=(a,e)=>Wo(a,Zo(e));var k=(a,e,o)=>new Promise((n,i)=>{var r=d=>{try{s(o.next(d));}catch(c){i(c);}},p=d=>{try{s(o.throw(d));}catch(c){i(c);}},s=d=>d.done?n(d.value):Promise.resolve(d.value).then(r,p);s((o=o.apply(a,e)).next());}),_t=function(a,e){this[0]=a,this[1]=e;},ve=(a,e,o)=>{var n=(p,s,d,c)=>{try{var g=o[p](s),A=(s=g.value)instanceof _t,q=g.done;Promise.resolve(A?s[0]:s).then(O=>A?n(p==="return"?p:"next",s[1]?{done:O.done,value:O.value}:O,d,c):d({value:O,done:q})).catch(O=>n("throw",O,d,c));}catch(O){c(O);}},i=p=>r[p]=s=>new Promise((d,c)=>n(p,s,d,c)),r={};return o=o.apply(a,e),r[ae("asyncIterator")]=()=>r,i("next"),i("throw"),i("return"),r},wt=a=>{var e=a[ae("asyncIterator")],o=!1,n,i={};return e==null?(e=a[ae("iterator")](),n=r=>i[r]=p=>e[r](p)):(e=e.call(a),n=r=>i[r]=p=>{if(o){if(o=!1,r==="throw")throw p;return p}return o=!0,{done:!1,value:new _t(new Promise(s=>{var d=e[r](p);d instanceof Object||Xo("Object expected"),s(d);}),1)}}),i[ae("iterator")]=()=>i,n("next"),"throw"in e?n("throw"):i.throw=r=>{throw r},"return"in e&&n("return"),i};var en=a=>{let e=new WeakSet;return JSON.stringify(a,(o,n)=>{if(typeof n=="object"&&n!==null){if(e.has(n))return;e.add(n);}return n})},tn=a=>a==null?"unknown error":typeof a=="string"?a:a instanceof Error?a.message:en(a),Oe="GatewayBaseError",F=class Lt extends Error{constructor({info:e,cause:o},n){super(`[${n!=null?n:Oe}]: ${e}
4
- Message: ${tn(o)}`),this.name=Oe,this.info=e,this.cause=o,this.name=n!=null?n:Oe,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(e){return e instanceof Lt}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},Z="system",z="user",P="assistant",Q="tool",on=[Z,z,P,Q],xe=z$1.enum(on),nn=[P],an=z$1.enum(nn),H="image",Ae="base64",sn=["png","jpeg","webp","gif"],rn=z$1.object({type:z$1.literal(Ae),base64:z$1.string(),media_type:z$1.enum(sn)}),ln="url",dn=z$1.object({type:z$1.literal(ln),url:z$1.string()}),pn=z$1.discriminatedUnion("type",[rn,dn]),mn=["low","medium","high","auto"],cn=z$1.enum(mn),un=(a=z$1.undefined())=>z$1.object({modality:z$1.literal(H),detail:cn,value:pn,metadata:a}),x="text",jt=(a=z$1.undefined())=>z$1.object({modality:z$1.literal(x),value:z$1.string(),metadata:a}),ke="partial-text",Bt=(a=z$1.undefined())=>z$1.object({modality:z$1.literal(ke),value:z$1.string(),metadata:a}),V="tool-call",Ut=(a=z$1.undefined())=>z$1.object({modality:z$1.literal(V),index:z$1.number().int().nonnegative(),id:z$1.string().min(1),name:z$1.string().min(1),arguments:z$1.string(),metadata:a}),_e="partial-tool-call",Vt=(a=z$1.undefined())=>z$1.object({modality:z$1.literal(_e),index:z$1.number().int().nonnegative(),id:z$1.string().optional(),name:z$1.string().optional(),arguments:z$1.string().optional(),metadata:a}),D="tool-response",hn=(a=z$1.undefined())=>z$1.object({modality:z$1.literal(D),index:z$1.number().int().nonnegative(),id:z$1.string().min(1),name:z$1.string().min(1),data:z$1.string(),metadata:a}),gn=[x,H,V,D],Nt=z$1.enum(gn),yn=(a=z$1.undefined(),e=z$1.undefined(),o=z$1.undefined(),n=z$1.undefined())=>z$1.discriminatedUnion("modality",[jt(a),un(e),Ut(o),hn(n)]),fn=[ke,_e];z$1.enum(fn);var bn=(a=z$1.undefined(),e=z$1.undefined())=>z$1.discriminatedUnion("modality",[Bt(a),Vt(e)]);var we=(a=xe,e=z$1.undefined(),o=z$1.undefined(),n=z$1.undefined(),i=z$1.undefined(),r=z$1.undefined())=>z$1.object({role:a,content:z$1.array(yn(e,o,n,i)),metadata:r}),qe=(a=an,e=z$1.undefined(),o=z$1.undefined(),n=z$1.undefined())=>z$1.object({role:a,partialContent:bn(e,o),metadata:n}),zt=a=>jt().parse({modality:x,value:a}),$t=(a,e,o,n)=>Ut().parse({modality:V,index:a,id:e,name:o,arguments:n});var Pe=(a,e)=>qe().parse({role:a,partialContent:Bt().parse({modality:ke,value:e})}),Ie=(a,e,o,n,i)=>qe().parse({role:a,partialContent:Vt().parse({modality:_e,index:e,id:o,name:n,arguments:i})});var se=(a=z$1.record(z$1.string(),z$1.any()).optional())=>a,Cn=["object","array","number","string","boolean","enum"],qt=z$1.enum(Cn),Tn=z$1.object({anyOf:z$1.array(z$1.any()).optional(),type:z$1.union([qt,z$1.array(z$1.union([qt,z$1.literal("null")]))]).optional(),default:z$1.any().optional(),title:z$1.string().optional(),description:z$1.string().max(4096).optional(),properties:z$1.record(z$1.any()).optional(),required:z$1.array(z$1.string()).optional(),minItems:z$1.number().int().min(0).optional(),maxItems:z$1.number().int().optional(),items:z$1.record(z$1.any()).optional(),enum:z$1.array(z$1.union([z$1.string(),z$1.number(),z$1.boolean(),z$1.null()])).optional(),minimum:z$1.number().optional(),maximum:z$1.number().optional(),minLength:z$1.number().int().min(0).optional(),maxLength:z$1.number().int().optional(),$ref:z$1.string().optional()}),Mn=z$1.object({type:z$1.enum(["object"]),required:z$1.array(z$1.string()),$defs:z$1.record(z$1.any()).optional(),properties:z$1.record(Tn),additionalProperties:z$1.literal(!1)});z$1.object({name:z$1.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:z$1.string().max(4096),strict:z$1.boolean().optional(),schema:Mn}).optional();var En="function";var Sn=z$1.enum(["object","array","number","string","boolean","null"]),Rn=z$1.object({anyOf:z$1.array(z$1.any()).optional(),type:Sn.optional(),default:z$1.any().optional(),title:z$1.string().optional(),description:z$1.string().max(4096).optional(),properties:z$1.record(z$1.any()).optional(),required:z$1.array(z$1.string()).optional(),minItems:z$1.number().int().min(0).optional(),maxItems:z$1.number().int().optional(),items:z$1.record(z$1.any()).optional(),enum:z$1.array(z$1.union([z$1.string(),z$1.number(),z$1.boolean(),z$1.null()])).optional(),minimum:z$1.number().optional(),maximum:z$1.number().optional(),minLength:z$1.number().int().min(0).optional(),maxLength:z$1.number().int().optional()});z$1.object({type:z$1.enum(["object"]),title:z$1.string().optional(),$defs:z$1.record(z$1.any()).optional(),properties:z$1.record(Rn).optional(),required:z$1.array(z$1.string()).optional()});var vn=z$1.object({name:z$1.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:z$1.string().max(4096),parameters:z$1.any(),strict:z$1.boolean().optional()});var On=z$1.enum(["function"]),xn=z$1.object({type:On,definition:z$1.object({schema:vn})}),An=[En];z$1.enum(An);var Ft=(a=z$1.undefined())=>z$1.discriminatedUnion("type",[xn.extend({metadata:a})]),K="text",Ht="token",kn=[K,Ht],Dt=z$1.enum(kn),_n=z$1.array(z$1.string().min(1)),wn=z$1.array(z$1.array(z$1.number().int().nonnegative())),Kt=(a=z$1.undefined())=>z$1.discriminatedUnion("modality",[z$1.object({modality:z$1.literal(K),metadata:a,requests:_n}),z$1.object({modality:z$1.literal(Ht),metadata:a,requests:wn})]),Le="float",qn=z$1.object({index:z$1.number().int().nonnegative(),embedding:z$1.array(z$1.number())}),je="base64",Pn=z$1.object({index:z$1.number().int().nonnegative(),embedding:z$1.string().base64()}),Pt=z$1.object({totalTokens:z$1.number().int().nonnegative()});z$1.discriminatedUnion("encodingFormat",[z$1.object({encodingFormat:z$1.literal(Le),embeddings:z$1.array(qn),usage:Pt.optional()}),z$1.object({encodingFormat:z$1.literal(je),embeddings:z$1.array(Pn),usage:Pt.optional()})]);var Gt=z$1.object({promptTokens:z$1.number().nonnegative(),completionTokens:z$1.number().nonnegative(),totalTokens:z$1.number().nonnegative()}),It=z$1.object({token:z$1.string(),logProb:z$1.number(),bytes:z$1.array(z$1.number().int()).nullable()}),In=It.extend({topLogProbs:z$1.array(It)}),Jt=z$1.array(In);z$1.object({messages:z$1.array(we()),usage:Gt.optional(),logProbs:Jt.optional()});z$1.object({partialMessages:z$1.array(qe()),usage:Gt.optional(),logProbs:Jt.optional()});var Ln=Object.defineProperty,Wt=Object.getOwnPropertySymbols,jn=Object.prototype.hasOwnProperty,Bn=Object.prototype.propertyIsEnumerable,Zt=(a,e,o)=>e in a?Ln(a,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):a[e]=o,ie=(a,e)=>{for(var o in e||(e={}))jn.call(e,o)&&Zt(a,o,e[o]);if(Wt)for(var o of Wt(e))Bn.call(e,o)&&Zt(a,o,e[o]);return a},Yt="ProviderError",Be=class ao extends F{constructor({info:e,cause:o}){super({info:e,cause:o},Yt),this.name=Yt,this.info=e,this.cause=o;}static isProviderError(e){return e instanceof ao}};var Qt="ModelResponseError",$=class so extends F{constructor({info:e,cause:o}){super({info:e,cause:o},Qt),this.name=Qt,this.cause=o,this.info=e;}static isModelResponseError(e){return e instanceof so}},Xt="InvalidModelRequestError",X=class io extends F{constructor({info:e,cause:o}){super({info:e,cause:o},Xt),this.name=Xt,this.cause=o,this.info=e,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(e){return e instanceof io}},eo="InvalidConfigError",G=class ro extends F{constructor({info:e,cause:o}){super({info:e,cause:o},eo),this.name=eo,this.cause=o,this.info=e,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(e){return e instanceof ro}},to="InvalidMessagesError",_=class lo extends F{constructor({info:e,cause:o}){super({info:e,cause:o},to),this.name=to,this.cause=o,this.info=e,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(e){return e instanceof lo}},oo="InvalidToolsError",Ue=class po extends F{constructor({info:e,cause:o}){super({info:e,cause:o},oo),this.name=oo,this.cause=o,this.info=e,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(e){return e instanceof po}},no="InvalidEmbeddingRequestsError",Ve=class mo extends F{constructor({info:e,cause:o}){super({info:e,cause:o},no),this.name=no,this.info=e,this.cause=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(e){return e instanceof mo}},Ne="multi-string",co=z$1.object({type:z$1.literal(Ne),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),max:z$1.number().int().positive()}),Un=a=>z$1.array(z$1.string()).max(a).default([]).optional(),uo=a=>({def:co.parse(ie({type:Ne},a)),schema:Un(a.max)}),ho="object-schema",Vn=z$1.object({type:z$1.literal(ho),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),objectSchema:z$1.any()});var ze="range",go=z$1.object({type:z$1.literal(ze),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),min:z$1.number().int(),max:z$1.number().int(),step:z$1.number().positive(),default:z$1.number()}),Nn=(a,e,o,n)=>z$1.number().min(a).max(e).step(o).default(n).optional(),ee=a=>({def:go.parse(ie({type:ze},a)),schema:Nn(a.min,a.max,a.step,a.default)}),$e="select-boolean",yo=z$1.object({type:z$1.literal($e),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),default:z$1.boolean().nullable()}),zn=a=>z$1.boolean().nullable().default(a).optional(),fo=a=>({def:yo.parse(ie({type:$e},a)),schema:zn(a.default)}),Fe="select-string",bo=z$1.object({type:z$1.literal(Fe),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),default:z$1.string(),choices:z$1.array(z$1.string())}),$n=(a,e)=>z$1.enum(e).nullable().default(a).optional(),te=a=>({def:bo.parse(ie({type:Fe},a)),schema:$n(a.default,a.choices)}),Fn=[ze,Ne,Fe,ho,$e];z$1.enum(Fn);var Co=z$1.discriminatedUnion("type",[go,co,bo,yo,Vn]),M=(a=xe,e=Nt)=>z$1.object({name:z$1.string().min(1),description:z$1.string().min(1),roles:z$1.record(a,z$1.string().min(1).optional()),modalities:z$1.array(e).nonempty(),maxInputTokens:z$1.number().int().positive().min(1),maxOutputTokens:z$1.number().int().positive().min(1),config:z$1.object({def:z$1.record(z$1.string().min(1),Co),schema:z$1.instanceof(z$1.ZodObject)}).refine(o=>{var n,i;let r=Object.keys(o.def),p=Object.keys((i=(n=o.schema)==null?void 0:n.shape)!=null?i:{});return r.every(s=>p.includes(s))&&p.every(s=>r.includes(s))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})}),L=(a=Dt)=>z$1.object({name:z$1.string().min(1),description:z$1.string().min(1),modalities:z$1.array(a).nonempty(),maxInputTokens:z$1.number().int().positive().min(1),maxOutputTokens:z$1.number().int().positive().min(1),config:z$1.object({def:z$1.record(z$1.string().min(1),Co),schema:z$1.instanceof(z$1.ZodObject)}).refine(e=>{var o,n;let i=Object.keys(e.def),r=Object.keys((n=(o=e.schema)==null?void 0:o.shape)!=null?n:{});return i.every(p=>r.includes(p))&&r.every(p=>i.includes(p))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})});z$1.record(z$1.string());z$1.record(z$1.union([z$1.boolean(),z$1.string(),z$1.number(),z$1.object({}),z$1.array(z$1.any()),z$1.null(),z$1.undefined()]));z$1.string().url();var Hn={type:"range",title:"Temperature",description:"Adjusts the model's creativity level. With a setting of 0, the model strictly picks the most probable next word. For endeavors that benefit from a dash of inventiveness, consider dialing it up to 0.7 or higher, enabling the model to produce text that's unexpectedly fresh."},Dn={type:"range",title:"Max tokens",description:"Specify the total tokens for generation, where one token approximates four English characters. Setting this to 0 defaults to the model's maximum capacity."},Kn=a=>({type:"multi",title:"Stop sequence",description:`Enter up to ${a} sequences that will halt additional text output. The generated text will exclude these sequences.`}),Gn={type:"range",title:"Top A",description:"Considers only the top tokens that have 'sufficiently high' probabilities relative to the most likely token, functioning like a dynamic Top-P. A lower Top-A value narrows down the token choices based on the highest probability token, while a higher Top-A value refines the filtering without necessarily impacting the creativity of the output."},Jn={type:"range",title:"Top P",description:"Selects a subset of likely tokens for generation, restricting choices to the top-P fraction of possibilities, such as the top 10% when P=0.1. This approach can limit the variety of the output. By default, it's set to 1, indicating no restriction. It's advised to adjust this parameter or temperature to modulate output diversity, but not to modify both simultaneously."},Wn={type:"range",title:"Top K",description:"Select only from the highest K probabilities for each following word, effectively eliminating the less likely 'long tail' options."},Zn={type:"range",title:"Min P",description:"Specifies the minimum probability a token must have to be considered, in relation to the probability of the most likely token. (This value varies based on the confidence level of the top token.) For example, if Min-P is set to 0.1, only tokens with at least 1/10th the probability of the highest-ranked token will be considered."},Yn={type:"range",title:"Frequency penalty",description:"Minimize redundancy. By assigning a penalty to frequently used tokens within the text, the likelihood of repeating identical phrases is reduced. The default setting for this penalty is zero."},Qn={type:"range",title:"Presence penalty",description:"Enhance the introduction of novel subjects by reducing the preference for tokens that have already appeared in the text, thus boosting the chances of exploring fresh topics. The standard setting for this is zero."},Xn={type:"range",title:"Seed",description:"When seed is fixed to a specific value, the model makes a best effort to provide the same response for repeated requests. Deterministic output isn't guaranteed. Also, changing the model or parameter settings, such as the temperature, can cause variations in the response even when you use the same seed value. By default, a random seed value is used."},ea={type:"range",title:"Repetition penalty",description:"Reduces the likelihood of repeating tokens from the input. Increasing this value makes the model less prone to repetition, but setting it too high may lead to less coherent output, often resulting in run-on sentences missing smaller words. The token penalty is scaled according to the original token's probability."},ta={type:"boolean",title:"Log probs",description:"Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned."},oa={type:"range",title:"Top log probs",description:"The number of most likely tokens to return at each token position, each with an associated log probability. 'logprobs' must be set to true if this parameter is used."},na={type:"boolean",title:"Echo",description:"If true, the response will contain the prompt."},aa={type:"select",title:"Response format",description:"Choose the response format of your model. For JSON, you must include the string 'JSON' in some form within your system / user prompt."},sa={type:"select",title:"Response format",description:"Choose the response format of your model. 'json_object' colloquially known as JSON mode, instructs the model to respond with a valid JSON (must include the term 'json' in prompt). 'json_schema' colloquially known as structured outputs, allows you to specify a strict response schema that the model will adhere to."},ia={type:"object",title:"Response schema",description:"When response format is set to 'json_schema', the model will return a JSON object of the specified schema."},N={TEMPERATURE:Hn,MAX_TOKENS:Dn,STOP:Kn,TOP_A:Gn,TOP_P:Jn,TOP_K:Wn,MIN_P:Zn,FREQUENCY_PENALTY:Yn,PRESENCE_PENALTY:Qn,REPETITION_PENALTY:ea,SEED:Xn,LOG_PROBS:ta,TOP_LOG_PROBS:oa,ECHO:na,RESPONSE_FORMAT:aa,RESPONSE_FORMAT_WITH_SCHEMA:sa,RESPONSE_SCHEMA:ia};var re=a=>Object.fromEntries(Object.entries(a).filter(([e,o])=>o!=null));var Y=a=>a==null?void 0:a.replace(/\/$/,"");var He=ee({param:"temperature",title:N.TEMPERATURE.title,description:N.TEMPERATURE.description,min:0,max:1,step:.01,default:1}),De=a=>ee({param:"max_tokens",title:N.MAX_TOKENS.title,description:N.MAX_TOKENS.description,min:0,max:a,step:1,default:0}),Ke=a=>uo({param:"stop_sequences",title:N.STOP(a).title,description:N.STOP(a).description,max:a}),Ge=ee({param:"top_p",title:N.TOP_P.title,description:N.TOP_P.description,min:0,max:1,step:.01,default:1}),Je=ee({param:"top_k",title:N.TOP_K.title,description:N.TOP_K.description,min:0,max:1,step:.01,default:1}),We=te({param:"tool_choice",title:"Tool choice",description:"Controls which (if any) tool is called by the model. 'any' means the model will call any of the provided tools. 'auto' means the model can pick between generating a message or calling a tool.",default:"auto",choices:["auto","any"]});var To=(a,e)=>z$1.object({temperature:He.schema,maxTokens:De(a).schema,stop:Ke(e).schema,topP:Ge.schema,topK:Je.schema,toolChoice:We.schema}),Mo=(a,e)=>({temperature:He.def,maxTokens:De(a).def,stop:Ke(e).def,topP:Ge.def,topK:Je.def,toolChoice:We.def});var Ze=te({param:"encoding_format",title:"Encoding format",description:"Select the encoding format for the word embedding.",default:"",choices:["base64",""]}),Ye=te({param:"input_type",title:"Input type",description:"Select the input type for the word embedding.",default:"",choices:["query","document",""]}),Qe=fo({param:"truncation",title:"Truncation",description:"Select the truncation for the word embedding.",default:!0});var Eo=()=>z$1.object({encodingFormat:Ze.schema,inputType:Ye.schema,truncation:Qe.schema}),So=()=>({encodingFormat:Ze.def,inputType:Ye.def,truncation:Qe.def});var h={base:(a,e)=>({def:Mo(a,e),schema:To(a,e)})},f={base:()=>({def:So(),schema:Eo()})};var da="anthropic",J=class{constructor(){this.version="v1";this.name=da;this.chatModelFactories={[st]:{model:me,modelOptions:xo,modelSchema:it},[ut]:{model:ge,modelOptions:wo,modelSchema:ht},[mt]:{model:he,modelOptions:_o,modelSchema:ct},[Xe]:{model:le,modelOptions:Ro,modelSchema:et},[tt]:{model:de,modelOptions:vo,modelSchema:ot},[rt]:{model:ce,modelOptions:Ao,modelSchema:lt},[nt]:{model:pe,modelOptions:Oo,modelSchema:at},[dt]:{model:ue,modelOptions:ko,modelSchema:pt}};this.embeddingModelFactories={[vt]:{model:Me,modelOptions:Bo,modelSchema:Ot},[St]:{model:Te,modelOptions:jo,modelSchema:Rt},[gt]:{model:ye,modelOptions:qo,modelSchema:yt},[ft]:{model:fe,modelOptions:Po,modelSchema:bt},[Ct]:{model:be,modelOptions:Io,modelSchema:Tt},[Mt]:{model:Ce,modelOptions:Lo,modelSchema:Et}};}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 Be({info:`Anthropic chat model: ${o} not found`,cause:new Error(`Anthropic chat model: ${o} not found, available chat models:
5
- ${this.chatModelLiterals().join(", ")}`)});let n=this.chatModelFactories[o].model,i=this.chatModelFactories[o].modelOptions.parse(e);return new n(i)}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 Be({info:`Anthropic embedding model: ${o} not found`,cause:new Error(`Anthropic embedding model: ${o} not found, available embedding models:
6
- ${this.embeddingModelLiterals().join(", ")}`)});let n=this.embeddingModelFactories[o].model,i=this.embeddingModelFactories[o].modelOptions.parse(e);return new n(i)}};J.chatBaseUrl="https://api.anthropic.com/v1",J.embeddingBaseUrl="https://api.voyageai.com/v1";var E=z$1.enum([Z,z,P,Q]),S={system:Z,user:z,assistant:P,tool:z};var R=[x,H,V,D],v=z$1.enum([x,H,V,D]);var ca=z$1.object({type:z$1.literal("text"),text:z$1.string()}),ua=z$1.object({type:z$1.literal("tool_use"),id:z$1.string(),name:z$1.string(),input:z$1.record(z$1.any())}),Uo=z$1.object({content:z$1.array(z$1.discriminatedUnion("type",[ca,ua])),id:z$1.string(),model:z$1.string(),role:z$1.string(),stop_reason:z$1.string(),stop_sequence:z$1.null(),type:z$1.literal("message"),usage:z$1.object({input_tokens:z$1.number(),output_tokens:z$1.number(),cache_creation_input_tokens:z$1.number().nullish(),cache_read_input_tokens:z$1.number().nullish()})}),Vo=z$1.object({type:z$1.literal("message_start"),message:z$1.object({id:z$1.string(),type:z$1.literal("message"),role:z$1.string(),model:z$1.string(),stop_reason:z$1.string().nullable(),stop_sequence:z$1.string().nullable(),content:z$1.array(z$1.any()),usage:z$1.object({input_tokens:z$1.number(),output_tokens:z$1.number()})})}),No=z$1.object({type:z$1.literal("message_delta"),delta:z$1.object({stop_reason:z$1.string().nullable(),stop_sequence:z$1.string().nullable()}),usage:z$1.object({output_tokens:z$1.number()})}),ha=z$1.object({type:z$1.literal("text"),text:z$1.string()}),ga=z$1.object({type:z$1.literal("tool_use"),id:z$1.string(),name:z$1.string(),input:z$1.object({})}),zo=z$1.object({type:z$1.literal("content_block_start"),index:z$1.number(),content_block:z$1.discriminatedUnion("type",[ha,ga])}),ya=z$1.object({type:z$1.literal("text_delta"),text:z$1.string()}),fa=z$1.object({type:z$1.literal("input_json_delta"),partial_json:z$1.string()}),$o=z$1.object({type:z$1.literal("content_block_delta"),index:z$1.number(),delta:z$1.discriminatedUnion("type",[ya,fa])});var ba=z$1.object({name:z$1.string().min(1),description:z$1.string().min(1).optional(),input_schema:z$1.any()}),Ca=z$1.object({type:z$1.enum(["auto","any"])}),Ta=z$1.object({type:z$1.literal("tool"),name:z$1.string().min(1)}),xt=z$1.object({text:z$1.string().min(1),type:z$1.literal("text")}),Fo=z$1.object({type:z$1.literal("image"),source:z$1.object({type:z$1.literal("base64"),media_type:z$1.enum(["image/jpeg","image/png","image/gif","image/webp"]),data:z$1.string().base64()})}),Ps=z$1.object({id:z$1.string().min(1),type:z$1.literal("tool_use"),name:z$1.string().min(1),input:z$1.record(z$1.any())}),Ho=z$1.object({type:z$1.literal("tool_result"),tool_use_id:z$1.string().min(1),content:z$1.string().min(1).or(z$1.array(z$1.union([xt,Fo])).min(1))}),Ma=z$1.object({role:z$1.literal("user"),content:z$1.string().min(1).or(z$1.array(z$1.union([xt,Fo,Ho])).min(1))}),Ea=z$1.object({role:z$1.literal("assistant"),content:z$1.string().min(1).or(z$1.array(z$1.union([xt,Ho])).min(1))}),Sa=z$1.union([Ma,Ea]),Do=z$1.object({model:z$1.string().min(1).optional(),messages:z$1.array(Sa).min(1),system:z$1.string().min(1).optional(),max_tokens:z$1.number().min(0).optional(),stop_sequences:z$1.array(z$1.string().min(1)).optional(),temperature:z$1.number().min(0).max(1).optional(),tool_choice:z$1.union([Ca,Ta]).optional(),tools:z$1.array(ba).min(1).optional(),top_p:z$1.number().min(0).max(1).optional(),top_k:z$1.number().min(0).optional()});var T=z$1.object({modelName:z$1.string(),apiKey:z$1.string(),completeChatUrl:z$1.string().url().optional(),streamChatUrl:z$1.string().url().optional()}),b=class{constructor(e,o){this.version="v1";let n=T.parse(o);this.modelSchema=e,this.modelName=n.modelName,this.apiKey=n.apiKey,this.baseUrl=Y(J.chatBaseUrl),this.completeChatUrl=Y(n.completeChatUrl||`${this.baseUrl}/messages`),this.streamChatUrl=Y(n.streamChatUrl||`${this.baseUrl}/messages`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"x-api-key":`${this.apiKey}`,"anthropic-version":"2023-06-01","content-type":"application/json","anthropic-dangerous-direct-browser-access":"true"}}getDefaultParams(){return {model:this.modelName}}getRetryDelay(e){let o=0,n=!0;return e["x-should-retry"]&&(n=e["x-should-retry"].toLowerCase()!=="false"),e["retry-after"]&&(o=parseInt(e["retry-after"])*1e3),{shouldRetry:n,delayMs:o}}getTokenCount(e){return e.reduce((o,n)=>o+n.content.map(i=>i.modality==="text"?i.value:"").join(" ").length,0)}transformModelRequest(e){let o=Do.safeParse(e);if(!o.success)throw new X({info:"Invalid model request",cause:o.error});let n=o.data,i=n.model;if(n.tool_choice&&(!n.tools||n.tools.length===0))throw new X({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let r={};n.tool_choice&&(n.tool_choice.type==="tool"?r.toolChoice=n.tool_choice.name:r.toolChoice=n.tool_choice.type),r.maxTokens=n.max_tokens,r.temperature=n.temperature,r.topP=n.top_p,r.topK=n.top_k,r.stop=n.stop_sequences;let p=se().parse(re(r)),s=[],d={};n.system&&s.push({role:Z,content:[{modality:x,value:n.system}]}),n.messages.forEach(g=>{let A=g.role;switch(A){case"user":{let q=g.content;if(typeof q=="string")s.push({role:A,content:[{modality:x,value:q}]});else {let O=q.map(y=>{if(y.type==="text")return {modality:x,value:y.text};if(y.type==="image"){let Se="auto",ne=y.source.media_type.split("/")[1];return {modality:H,detail:Se,value:{type:Ae,media_type:ne,base64:y.source.data}}}else return {modality:D,id:y.tool_use_id,index:d[y.tool_use_id].index,name:d[y.tool_use_id].name,data:typeof y.content=="string"?y.content:JSON.stringify(y.content)}});s.push({role:A,content:O});}}break;case"assistant":{let q=g.content;if(typeof q=="string")s.push({role:A,content:[{modality:x,value:q}]});else {let O=q.map((y,Se)=>{if(y.type==="text")return {modality:x,value:y.text};{let ne={modality:V,id:y.id,index:Se,name:y.name,arguments:JSON.stringify(y.input)};return d[y.id]=ne,ne}});s.push({role:A,content:O});}}break}});let c=[];return n.tools&&n.tools.forEach(g=>{c.push({type:"function",definition:{schema:{name:g.name,description:g.description||"",parameters:g.input_schema}}});}),{modelName:i,config:p,messages:s,tools:c.length>0?c:void 0}}transformConfig(e,o,n){let i=e.toolChoice,r=C({},e);delete r.toolChoice;let p=this.modelSchema.config.schema.safeParse(r);if(!p.success)throw new G({info:`Invalid config for model : '${this.modelName}'`,cause:p.error});let s=p.data;i!==void 0&&(s.toolChoice=i),Object.keys(s).forEach(c=>{if(!(c in this.modelSchema.config.def))throw new G({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${c}',
7
- available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let d=Object.keys(s).reduce((c,g)=>{let A=this.modelSchema.config.def[g],q=A.param,O=s[g];return q==="max_tokens"&&A.type==="range"&&O===0?c[q]=A.max:c[q]=O,c},{});if(!d.max_tokens){let c=this.modelSchema.config.def.maxTokens;d.max_tokens=c.max;}if("tool_choice"in d&&d.tool_choice!==void 0){let c=d.tool_choice;if(!n||n&&n.length===0)throw new G({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(n&&n.length>0){let g=this.modelSchema.config.def.toolChoice;if(g.choices.includes(c))d.tool_choice={type:c};else if(n.map(A=>A.definition.schema.name).includes(c))d.tool_choice={type:"tool",name:c};else throw new G({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`toolChoice : '${c}' is not part of provided 'tools' names or
8
- one of [${g.choices.join(", ")}]`)})}}return d}transformMessages(e){if(!e||e&&e.length===0)return {messages:[]};let o=s=>{let d=s.match(/^data:image\/[a-zA-Z]+;base64,/);return d?s.substring(d[0].length):s},n=e.map(s=>{let d=we().safeParse(s);if(!d.success)throw new _({info:"Invalid messages",cause:d.error});return d.data});n.forEach(s=>{s.content.forEach(d=>{if(!this.modelSchema.modalities.includes(d.modality))throw new _({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${d.modality}',
9
- available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),n.forEach(s=>{if(!Object.keys(this.modelSchema.roles).includes(s.role))throw new _({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${s.role}',
10
- available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})});let i="",r=[];if(n.forEach(s=>{switch(s.role){case Z:{s.content.forEach(d=>{if(d.modality===x)i+=d.value;else throw new _({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${d.modality}'`)})});break}case P:{let d=[];s.content.forEach(c=>{if(c.modality===x)d.push({type:"text",text:c.value});else if(c.modality===V)d.push({type:"tool_use",id:c.id,name:c.name,input:JSON.parse(c.arguments)});else throw new _({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${c.modality}'`)})}),r.push({role:this.modelSchema.roles[s.role],content:d});break}case z:{let d=[];s.content.forEach(c=>{if(c.modality===x)d.push({type:"text",text:c.value});else if(c.modality===H){if(c.value.type==="base64"){let g=c.value.base64;g=o(g),d.push({type:"image",source:{type:"base64",media_type:`image/${c.value.media_type}`,data:g}});}else if(c.value.type==="url")throw new _({info:`Invalid message 'modality' for model : ${this.modelName}`,cause:new Error(`model: '${this.modelName}' does not support image content type: '${c.value.type}'`)})}else throw new _({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${c.modality}'`)})}),r.push({role:this.modelSchema.roles[s.role],content:d});break}case Q:{let d=[];s.content.forEach(c=>{if(c.modality===D)d.push({type:"tool_result",tool_use_id:c.id,content:c.data});else throw new _({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${c.modality}'`)})}),r.push({role:this.modelSchema.roles[s.role],content:d});break}default:throw new _({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' is not supported,
11
- available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}}),r[0].role!==this.modelSchema.roles[z])throw new _({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires first message to be from user`)});let p=s=>s===this.modelSchema.roles[z]?this.modelSchema.roles[P]:this.modelSchema.roles[z];for(let s=1;s<r.length;s++)if(r[s].role!==p(r[s-1].role))throw new _({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires messages to alternate between user and assistant`)});return {system:i,messages:r}}transformTools(e){if(!this.modelSchema.modalities.includes(V))throw new Ue({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${V}'`)});return !e||e&&e.length===0?{tools:[]}:{tools:e.map(i=>{let r=Ft().safeParse(i);if(!r.success)throw new Ue({info:"Invalid tools",cause:r.error});return r.data}).map(i=>({name:i.definition.schema.name,description:i.definition.schema.description,input_schema:i.definition.schema.parameters}))}}getCompleteChatUrl(e,o,n){return k(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getCompleteChatHeaders(e,o,n){return k(this,null,function*(){let i=this.getDefaultHeaders();return n&&n.length>0&&(i=Re(C({},i),{"anthropic-beta":"tools-2024-05-16"})),new Promise(r=>{r(i);})})}getCompleteChatData(e,o,n){return k(this,null,function*(){let i=this.transformConfig(e,o,n),r=this.transformMessages(o);if(r.messages&&r.messages.length===0)throw new _({info:"Messages are required",cause:new Error("Messages are required")});let p=n?this.transformTools(n):{};return new Promise(s=>{s(C(C(C(C({},this.getDefaultParams()),i),r),p));})})}transformCompleteChatResponse(e){let o=Uo.safeParse(e);if(o.success){let n=o.data,r=n.content.map((d,c)=>{if(d.type==="text")return zt(d.text);if(d.type==="tool_use")return $t(c,d.id,d.name,JSON.stringify(d.input))}),p=[{role:P,content:r}],s={promptTokens:n.usage.input_tokens,completionTokens:n.usage.output_tokens,totalTokens:n.usage.input_tokens+n.usage.output_tokens};return {messages:p,usage:s,logProbs:[]}}throw new $({info:"Invalid response from model",cause:o.error})}getStreamChatUrl(e,o,n){return k(this,null,function*(){return new Promise(i=>{i(this.streamChatUrl);})})}getStreamChatHeaders(e,o,n){let i=this.getDefaultHeaders();return n&&n.length>0&&(i=Re(C({},i),{"anthropic-beta":"tools-2024-05-16"})),new Promise(r=>{r(i);})}getStreamChatData(e,o,n){return k(this,null,function*(){let i=this.transformConfig(e,o,n),r=this.transformMessages(o);if(r.messages&&r.messages.length===0)throw new _({info:"Messages are required",cause:new Error("Messages are required")});let p=n?this.transformTools(n):{};return new Promise(s=>{s(C(C(C(C({stream:!0},this.getDefaultParams()),i),r),p));})})}transformStreamChatResponseChunk(e,o){return ve(this,null,function*(){let n=(o+e).split(`
12
- `).filter(i=>i.trim()!=="");for(let i of n)if(i.startsWith("data: {")&&i.endsWith("}")){let r;try{r=JSON.parse(i.substring(6));}catch(p){throw new $({info:`Malformed JSON received in stream : ${r}`,cause:p})}if("type"in r){if(r.type==="message_stop")return;if(r.type==="message_start"){let p=Vo.safeParse(r);if(p.success){let s=p.data;yield {partialResponse:{partialMessages:[],usage:{promptTokens:s.message.usage.input_tokens,completionTokens:s.message.usage.output_tokens,totalTokens:s.message.usage.input_tokens+s.message.usage.output_tokens}},buffer:o};}else throw new $({info:"Invalid response from model",cause:p.error})}else if(r.type==="message_delta"){let p=No.safeParse(r);if(p.success){let s=p.data;yield {partialResponse:{partialMessages:[],usage:{promptTokens:0,completionTokens:s.usage.output_tokens,totalTokens:s.usage.output_tokens}},buffer:o};}else throw new $({info:"Invalid response from model",cause:p.error})}else if(r.type==="content_block_start"){let p=zo.safeParse(r);if(p.success){let s=p.data,d=[];s.content_block.type==="text"?d.push(Pe(P,s.content_block.text)):s.content_block.type==="tool_use"&&d.push(Ie(P,s.index,s.content_block.id,s.content_block.name,"")),yield {partialResponse:{partialMessages:d},buffer:o};}else throw new $({info:"Invalid response from model",cause:p.error})}else if(r.type==="content_block_delta"){let p=$o.safeParse(r);if(p.success){let s=p.data,d=[];s.delta.type==="text_delta"?d.push(Pe(P,s.delta.text)):s.delta.type==="input_json_delta"&&d.push(Ie(P,s.index,"","",s.delta.partial_json)),yield {partialResponse:{partialMessages:d},buffer:o};}else throw new $({info:"Invalid response from model",cause:p.error})}}else throw new $({info:"Invalid JSON received in stream",cause:new Error(`Invalid JSON received in stream, expected 'type' property,
13
- received : ${JSON.stringify(r)}`)})}})}transformProxyStreamChatResponseChunk(e,o,n,i,r){return ve(this,null,function*(){yield*wt(this.transformStreamChatResponseChunk(e,o));})}getProxyStreamChatUrl(e,o,n){return k(this,null,function*(){return new Promise(i=>{i(this.streamChatUrl);})})}getProxyCompleteChatUrl(e,o,n){return k(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getProxyCompleteChatHeaders(e,o,n){return k(this,null,function*(){if(!o)return {};let i=C({},o);return delete i.host,delete i["content-length"],i})}getProxyStreamChatHeaders(e,o,n){return k(this,null,function*(){return yield this.getProxyCompleteChatHeaders(e,o,n)})}};var Xe="claude-3-5-sonnet-20240620",Ra="Most intelligent model. Highest level of intelligence and capability.",et=M(E,v).parse({name:Xe,description:Ra,maxInputTokens:2e5,maxOutputTokens:8192,roles:S,modalities:R,config:{def:h.base(8192,4).def,schema:h.base(8192,4).schema}}),Ro=T,le=class extends b{constructor(e){super(et,e);}};var tt="claude-3-5-sonnet-20241022",va="Most intelligent model. Highest level of intelligence and capability.",ot=M(E,v).parse({name:tt,description:va,maxInputTokens:2e5,maxOutputTokens:8192,roles:S,modalities:R,config:{def:h.base(8192,4).def,schema:h.base(8192,4).schema}}),vo=T,de=class extends b{constructor(e){super(ot,e);}};var nt="claude-3-5-sonnet-latest",Oa="Most intelligent model. Highest level of intelligence and capability.",at=M(E,v).parse({name:nt,description:Oa,maxInputTokens:2e5,maxOutputTokens:8192,roles:S,modalities:R,config:{def:h.base(8192,4).def,schema:h.base(8192,4).schema}}),Oo=T,pe=class extends b{constructor(e){super(at,e);}};var st="claude-3-haiku-20240307",xa="Fastest and most compact model for near-instant responsiveness. Quick and accurate targeted performance.",it=M(E,v).parse({name:st,description:xa,maxInputTokens:2e5,maxOutputTokens:4096,roles:S,modalities:R,config:{def:h.base(4096,4).def,schema:h.base(4096,4).schema}}),xo=T,me=class extends b{constructor(e){super(it,e);}};var rt="claude-3-5-haiku-20241022",Aa="Our fastest model with intelligence at blazing speeds.",lt=M(E,v).parse({name:rt,description:Aa,maxInputTokens:2e5,maxOutputTokens:8192,roles:S,modalities:R,config:{def:h.base(8192,4).def,schema:h.base(8192,4).schema}}),Ao=T,ce=class extends b{constructor(e){super(lt,e);}};var dt="claude-3-5-haiku-latest",ka="Our fastest model with intelligence at blazing speeds.",pt=M(E,v).parse({name:dt,description:ka,maxInputTokens:2e5,maxOutputTokens:8192,roles:S,modalities:R,config:{def:h.base(8192,4).def,schema:h.base(8192,4).schema}}),ko=T,ue=class extends b{constructor(e){super(pt,e);}};var mt="claude-3-opus-20240229",_a="Powerful model for highly complex tasks. Top-level performance, intelligence, fluency, and understanding.",ct=M(E,v).parse({name:mt,description:_a,maxInputTokens:2e5,maxOutputTokens:4096,roles:S,modalities:R,config:{def:h.base(4096,4).def,schema:h.base(4096,4).schema}}),_o=T,he=class extends b{constructor(e){super(ct,e);}};var ut="claude-3-sonnet-20240229",wa="Balance of intelligence and speed. Strong utility, balanced for scaled deployments.",ht=M(E,v).parse({name:ut,description:wa,maxInputTokens:2e5,maxOutputTokens:4096,roles:S,modalities:R,config:{def:h.base(4096,4).def,schema:h.base(4096,4).schema}}),wo=T,ge=class extends b{constructor(e){super(ht,e);}};var j=[K],B=z$1.enum([K]);var Ko=z$1.object({object:z$1.literal("list"),model:z$1.string(),data:z$1.array(z$1.object({index:z$1.number(),object:z$1.literal("embedding"),embedding:z$1.array(z$1.number()).or(z$1.string().base64())})),usage:z$1.object({total_tokens:z$1.number()})});var Pa=z$1.string().min(1).or(z$1.array(z$1.string().min(1)).min(1)),Go=z$1.object({model:z$1.string().min(1).optional(),input:Pa,encoding_format:z$1.enum(["base64"]).nullable().optional(),input_type:z$1.enum(["query","document"]).nullable().optional(),truncation:z$1.boolean().optional()});var I=z$1.object({modelName:z$1.string(),apiKey:z$1.string(),getEmbeddingsUrl:z$1.string().url().optional()}),w=class{constructor(e,o){this.version="v1";let n=I.parse(o);this.modelSchema=e,this.modelName=n.modelName,this.apiKey=n.apiKey,this.baseUrl=Y(J.embeddingBaseUrl),this.getEmbeddingsUrl=Y(n.getEmbeddingsUrl||`${this.baseUrl}/embeddings`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"}}getDefaultParams(){return {model:this.modelName}}getTokenCount(e){return e.requests.reduce((o,n)=>o+n.length,0)}getRetryDelay(e){return {shouldRetry:!0,delayMs:0}}transformModelRequest(e){let o=Go.safeParse(e);if(!o.success)throw new X({info:"Invalid model request",cause:o.error});let n=o.data,i=n.model,r={encodingFormat:n.encoding_format,inputType:n.input_type,truncation:n.truncation},p=se().parse(re(r)),s;return typeof n.input=="string"?s={modality:K,requests:[n.input]}:s={modality:K,requests:n.input},{modelName:i,config:p,embeddingRequests:s}}transformConfig(e,o){"inputType"in e&&e.inputType===""&&delete e.inputType,"encodingFormat"in e&&e.encodingFormat===""&&delete e.encodingFormat;let n=this.modelSchema.config.schema.safeParse(e);if(!n.success)throw new G({info:`Invalid config for model : '${this.modelName}'`,cause:n.error});let i=n.data;return Object.keys(i).forEach(p=>{if(!this.modelSchema.config.def[p])throw new G({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${p}',
14
- available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(i).reduce((p,s)=>{let c=this.modelSchema.config.def[s].param,g=i[s];return p[c]=g,p},{})}transformEmbeddingRequests(e){let o=Kt().safeParse(e);if(!o.success)throw new Ve({info:"Invalid embedding requests",cause:o.error});if(o.data.requests.length>128)throw new Ve({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Max requests for model : '${this.modelName}' is 128`)});return {input:o.data.requests}}getGetEmbeddingsUrl(e,o){return k(this,null,function*(){return new Promise(n=>{n(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(e,o){return k(this,null,function*(){return new Promise(n=>{n(this.getDefaultHeaders());})})}getGetEmbeddingsData(e,o){return k(this,null,function*(){return new Promise(n=>{n(C(C(C({},this.getDefaultParams()),this.transformConfig(e,o)),this.transformEmbeddingRequests(o)));})})}transformGetEmbeddingsResponse(e){let o,n=Ko.safeParse(e);if(n.success){let i=n.data;o=typeof i.data[0].embedding=="string"?je:Le;let r=i.data.map(p=>typeof p.embedding=="string"?{index:p.index,embedding:p.embedding}:{index:p.index,embedding:p.embedding});return {encodingFormat:o,embeddings:r,usage:{totalTokens:i.usage.total_tokens}}}throw new $({info:"Invalid response from model",cause:n.error})}};var gt="voyage-code-2",Ia="Optimized for code retrieval.",yt=L(B).parse({name:gt,description:Ia,modalities:j,maxInputTokens:16e3,maxOutputTokens:16e3,config:{def:f.base().def,schema:f.base().schema}}),qo=I,ye=class extends w{constructor(e){super(yt,e);}};var ft="voyage-law-2",La="Optimized for legal and long-context retrieval and RAG. Also improved performance across all domains.",bt=L(B).parse({name:ft,description:La,modalities:j,maxInputTokens:16e3,maxOutputTokens:16e3,config:{def:f.base().def,schema:f.base().schema}}),Po=I,fe=class extends w{constructor(e){super(bt,e);}};var Ct="voyage-multilingual-2",ja="Optimized for multilingual retrieval and RAG.",Tt=L(B).parse({name:Ct,description:ja,modalities:j,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:f.base().def,schema:f.base().schema}}),Io=I,be=class extends w{constructor(e){super(Tt,e);}};var Mt="voyage-finance-2",Ba="Optimized for finance retrieval and RAG.",Et=L(B).parse({name:Mt,description:Ba,modalities:j,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:f.base().def,schema:f.base().schema}}),Lo=I,Ce=class extends w{constructor(e){super(Et,e);}};var St="voyage-3-lite",Ua="Optimized for latency and cost.",Rt=L(B).parse({name:St,description:Ua,modalities:j,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:f.base().def,schema:f.base().schema}}),jo=I,Te=class extends w{constructor(e){super(Rt,e);}};var vt="voyage-3",Va="Optimized for quality.",Ot=L(B).parse({name:vt,description:Va,modalities:j,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:f.base().def,schema:f.base().schema}}),Bo=I,Me=class extends w{constructor(e){super(Ot,e);}};
3
+ var bn=Object.defineProperty,Cn=Object.defineProperties;var Mn=Object.getOwnPropertyDescriptors;var Ht=Object.getOwnPropertySymbols;var kn=Object.prototype.hasOwnProperty,Rn=Object.prototype.propertyIsEnumerable;var le=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n),Sn=n=>{throw TypeError(n)};var Ft=(n,e,o)=>e in n?bn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[e]=o,b=(n,e)=>{for(var o in e||(e={}))kn.call(e,o)&&Ft(n,o,e[o]);if(Ht)for(var o of Ht(e))Rn.call(e,o)&&Ft(n,o,e[o]);return n},de=(n,e)=>Cn(n,Mn(e));var _=(n,e,o)=>new Promise((a,i)=>{var l=m=>{try{r(o.next(m));}catch(h){i(h);}},s=m=>{try{r(o.throw(m));}catch(h){i(h);}},r=m=>m.done?a(m.value):Promise.resolve(m.value).then(l,s);r((o=o.apply(n,e)).next());}),Kt=function(n,e){this[0]=n,this[1]=e;},Ve=(n,e,o)=>{var a=(s,r,m,h)=>{try{var f=o[s](r),V=(r=f.value)instanceof Kt,L=f.done;Promise.resolve(V?r[0]:r).then(u=>V?a(s==="return"?s:"next",r[1]?{done:u.done,value:u.value}:u,m,h):m({value:u,done:L})).catch(u=>a("throw",u,m,h));}catch(u){h(u);}},i=s=>l[s]=r=>new Promise((m,h)=>a(s,r,m,h)),l={};return o=o.apply(n,e),l[le("asyncIterator")]=()=>l,i("next"),i("throw"),i("return"),l},Gt=n=>{var e=n[le("asyncIterator")],o=!1,a,i={};return e==null?(e=n[le("iterator")](),a=l=>i[l]=s=>e[l](s)):(e=e.call(n),a=l=>i[l]=s=>{if(o){if(o=!1,l==="throw")throw s;return s}return o=!0,{done:!1,value:new Kt(new Promise(r=>{var m=e[l](s);m instanceof Object||Sn("Object expected"),r(m);}),1)}}),i[le("iterator")]=()=>i,a("next"),"throw"in e?a("throw"):i.throw=l=>{throw l},"return"in e&&a("return"),i};var ee="system",W="user",E="assistant",ne="tool",xn=[ee,W,E,ne],He=z$1.enum(xn),En=[E],vn=z$1.enum(En),z="image",Fe="base64",On=["png","jpeg","webp","gif"],An=z$1.object({type:z$1.literal(Fe),base64:z$1.string(),media_type:z$1.enum(On)}),_n="url",Pn=z$1.object({type:z$1.literal(_n),url:z$1.string()}),wn=z$1.discriminatedUnion("type",[An,Pn]),qn=["low","medium","high","auto"],In=z$1.enum(qn),jn=(n=z$1.undefined())=>z$1.object({modality:z$1.literal(z),detail:In,value:wn,metadata:n}),H="reasoning",pe="partial-reasoning",me="thinking",Ke="redacted",ze=z$1.object({type:z$1.literal(me),thinking:z$1.string(),signature:z$1.string()}),Xt=z$1.object({type:z$1.literal(Ke),data:z$1.string()}),Ln=z$1.discriminatedUnion("type",[ze,Xt]),Ge=(n=z$1.undefined())=>z$1.object({modality:z$1.literal(H),value:Ln,metadata:n}),Bn=z$1.object({type:z$1.literal(me),thinking:ze.shape.thinking.optional(),signature:ze.shape.signature.optional()}),Nn=z$1.discriminatedUnion("type",[Bn,Xt]),Je=(n=z$1.undefined())=>z$1.object({modality:z$1.literal(pe),value:Nn,metadata:n}),x="text",Yt=(n=z$1.undefined())=>z$1.object({modality:z$1.literal(x),value:z$1.string(),metadata:n}),We="partial-text",Qt=(n=z$1.undefined())=>z$1.object({modality:z$1.literal(We),value:z$1.string(),metadata:n}),q="tool-call",eo=(n=z$1.undefined())=>z$1.object({modality:z$1.literal(q),index:z$1.number().int().nonnegative(),id:z$1.string().min(1),name:z$1.string().min(1),arguments:z$1.string(),metadata:n}),Ze="partial-tool-call",to=(n=z$1.undefined())=>z$1.object({modality:z$1.literal(Ze),index:z$1.number().int().nonnegative(),id:z$1.string().optional(),name:z$1.string().optional(),arguments:z$1.string().optional(),metadata:n}),F="tool-response",Un=(n=z$1.undefined())=>z$1.object({modality:z$1.literal(F),index:z$1.number().int().nonnegative(),id:z$1.string().min(1),name:z$1.string().min(1),data:z$1.string(),metadata:n}),Dn=[x,z,q,F,H],oo=z$1.enum(Dn),Vn=(n=z$1.undefined(),e=z$1.undefined(),o=z$1.undefined(),a=z$1.undefined(),i=z$1.undefined())=>z$1.discriminatedUnion("modality",[Yt(n),jn(e),eo(o),Un(a),Ge(i)]),$n=[We,Ze,pe];z$1.enum($n);var zn=(n=z$1.undefined(),e=z$1.undefined(),o=z$1.undefined())=>z$1.discriminatedUnion("modality",[Qt(n),to(e),Je(o)]);var Xe=(n=He,e=z$1.undefined(),o=z$1.undefined(),a=z$1.undefined(),i=z$1.undefined(),l=z$1.undefined(),s=z$1.undefined())=>z$1.object({role:n,content:z$1.array(Vn(e,o,a,i,s)),metadata:l}),ae=(n=vn,e=z$1.undefined(),o=z$1.undefined(),a=z$1.undefined(),i=z$1.undefined())=>z$1.object({role:n,partialContent:zn(e,o,a),metadata:i}),Hn=z$1.object({promptTokens:z$1.number().nonnegative(),completionTokens:z$1.number().nonnegative(),totalTokens:z$1.number().nonnegative()}),Jt=z$1.object({token:z$1.string(),logProb:z$1.number(),bytes:z$1.array(z$1.number().int()).nullable()}),Fn=Jt.extend({topLogProbs:z$1.array(Jt)}),no=z$1.array(Fn);z$1.object({messages:z$1.array(Xe()),usage:Hn.optional(),logProbs:no.optional()});var Kn=z$1.object({promptTokens:z$1.number().nonnegative().optional(),completionTokens:z$1.number().nonnegative().optional(),totalTokens:z$1.number().nonnegative().optional()});z$1.object({partialMessages:z$1.array(ae()),usage:Kn.optional(),logProbs:no.optional()});var ce=(n=z$1.record(z$1.string(),z$1.any()).optional())=>n,Gn=["object","array","number","string","boolean","enum"],Wt=z$1.enum(Gn),Jn=z$1.object({anyOf:z$1.array(z$1.any()).optional(),type:z$1.union([Wt,z$1.array(z$1.union([Wt,z$1.literal("null")]))]).optional(),default:z$1.any().optional(),title:z$1.string().optional(),description:z$1.string().max(4096).optional(),properties:z$1.record(z$1.any()).optional(),required:z$1.array(z$1.string()).optional(),minItems:z$1.number().int().min(0).optional(),maxItems:z$1.number().int().optional(),items:z$1.record(z$1.any()).optional(),enum:z$1.array(z$1.union([z$1.string(),z$1.number(),z$1.boolean(),z$1.null()])).optional(),minimum:z$1.number().optional(),maximum:z$1.number().optional(),minLength:z$1.number().int().min(0).optional(),maxLength:z$1.number().int().optional(),$ref:z$1.string().optional()}),Wn=z$1.object({type:z$1.enum(["object"]),required:z$1.array(z$1.string()),$defs:z$1.record(z$1.any()).optional(),properties:z$1.record(Jn),additionalProperties:z$1.literal(!1)});z$1.object({name:z$1.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:z$1.string().max(4096),strict:z$1.boolean().optional(),schema:Wn}).optional();var Z="text",ao="token",Zn=[Z,ao],io=z$1.enum(Zn),Xn=z$1.array(z$1.string().min(1)),Yn=z$1.array(z$1.array(z$1.number().int().nonnegative())),so=(n=z$1.undefined())=>z$1.discriminatedUnion("modality",[z$1.object({modality:z$1.literal(Z),metadata:n,requests:Xn}),z$1.object({modality:z$1.literal(ao),metadata:n,requests:Yn})]),Ye="float",Qn=z$1.object({index:z$1.number().int().nonnegative(),embedding:z$1.array(z$1.number())}),Qe="base64",ea=z$1.object({index:z$1.number().int().nonnegative(),embedding:z$1.string().base64()}),Zt=z$1.object({totalTokens:z$1.number().int().nonnegative()});z$1.discriminatedUnion("encodingFormat",[z$1.object({encodingFormat:z$1.literal(Ye),embeddings:z$1.array(Qn),usage:Zt.optional()}),z$1.object({encodingFormat:z$1.literal(Qe),embeddings:z$1.array(ea),usage:Zt.optional()})]);var ta=n=>{let e=new WeakSet;return JSON.stringify(n,(o,a)=>{if(typeof a=="object"&&a!==null){if(e.has(a))return;e.add(a);}return a})},oa=n=>n==null?"unknown error":typeof n=="string"?n:n instanceof Error?n.message:ta(n),$e="GatewayBaseError",X=class ro extends Error{constructor({info:e,cause:o},a){super(`[${a!=null?a:$e}]: ${e}
4
+ Message: ${oa(o)}`),this.name=$e,this.info=e,this.cause=o,this.name=a!=null?a:$e,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(e){return e instanceof ro}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},na=z$1.object({inputPricePerMillion:z$1.number().nonnegative().describe("Price per 1M input tokens"),outputPricePerMillion:z$1.number().nonnegative().describe("Price per 1M output tokens")}).describe("Input/output price pair (per 1M tokens) for a specific category within a ChatModel pricing tier."),aa=z$1.object({base:na.describe("Base (uncached, non\u2011reasoning) rates")}).describe("Holds the `ChatModelTokenPairPrice` for different categories (e.g., base) within a single pricing tier."),ia=z$1.object({minTokens:z$1.number().int().nonnegative().describe("Inclusive lower token bound for this tier."),maxTokens:z$1.number().int().nullable().optional().describe("Exclusive upper token bound; `null` means \u221E."),prices:aa.describe("Price categories and rates for this specific token range.")}).refine(n=>n.maxTokens===null||typeof n.maxTokens=="number"&&n.maxTokens>n.minTokens,{message:"maxTokens must be > minTokens (or null for infinite).",path:["maxTokens"]}).describe("A single pricing tier defined by a token range and associated prices.");z$1.object({modelName:z$1.string().describe("Model name this schedule applies to."),currency:z$1.string().default("USD").describe("Currency code (e.g., USD)."),tokenRanges:z$1.array(ia).min(1).describe("Pricing tiers (`ChatModelTokenRangePrice`) schedule, sorted by minTokens.")}).superRefine((n,e)=>{let{tokenRanges:o}=n;o[0].minTokens!==0&&e.addIssue({code:z$1.ZodIssueCode.custom,path:["tokenRanges",0,"minTokens"],message:"The first tier must have minTokens = 0."});for(let i=1;i<o.length;i++){let l=o[i-1],s=o[i];if(l.maxTokens===null){e.addIssue({code:z$1.ZodIssueCode.custom,path:["tokenRanges",i-1,"maxTokens"],message:"Cannot define any tokenRanges after an infinite tier (maxTokens = null)."});break}s.minTokens!==l.maxTokens&&e.addIssue({code:z$1.ZodIssueCode.custom,path:["tokenRanges",i,"minTokens"],message:`Tier ${i} minTokens (${s.minTokens}) must equal previous tier's maxTokens (${l.maxTokens}) for contiguity.`}),s.minTokens<l.minTokens&&e.addIssue({code:z$1.ZodIssueCode.custom,path:["tokenRanges",i,"minTokens"],message:`tokenRanges must be sorted by ascending minTokens. Tier ${i} (${s.minTokens}) starts before Tier ${i-1} (${l.minTokens}).`});}let a=o[o.length-1];o.every(i=>i.maxTokens!==null||i===a)&&a.maxTokens!==null&&e.addIssue({code:z$1.ZodIssueCode.custom,path:["tokenRanges",o.length-1,"maxTokens"],message:"The final tier must have maxTokens = null (representing infinity)."});}).describe("Complete pricing schedule for a single chat model, including all its token-based tiers.");var sa="function";var ra=z$1.enum(["object","array","number","string","boolean","null"]),la=z$1.object({anyOf:z$1.array(z$1.any()).optional(),type:ra.optional(),default:z$1.any().optional(),title:z$1.string().optional(),description:z$1.string().max(4096).optional(),properties:z$1.record(z$1.any()).optional(),required:z$1.array(z$1.string()).optional(),minItems:z$1.number().int().min(0).optional(),maxItems:z$1.number().int().optional(),items:z$1.record(z$1.any()).optional(),enum:z$1.array(z$1.union([z$1.string(),z$1.number(),z$1.boolean(),z$1.null()])).optional(),minimum:z$1.number().optional(),maximum:z$1.number().optional(),minLength:z$1.number().int().min(0).optional(),maxLength:z$1.number().int().optional()});z$1.object({type:z$1.enum(["object"]),title:z$1.string().optional(),$defs:z$1.record(z$1.any()).optional(),properties:z$1.record(la).optional(),required:z$1.array(z$1.string()).optional()});var da=z$1.object({name:z$1.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:z$1.string().max(4096),parameters:z$1.any(),strict:z$1.boolean().optional()});var pa=z$1.enum(["function"]),ma=z$1.object({type:pa,definition:z$1.object({schema:da})}),ca=[sa];z$1.enum(ca);var lo=(n=z$1.undefined())=>z$1.discriminatedUnion("type",[ma.extend({metadata:n})]),po=n=>Yt().parse({modality:x,value:n}),mo=(n,e,o,a)=>eo().parse({modality:q,index:n,id:e,name:o,arguments:a});var et=(n,e)=>ae().parse({role:n,partialContent:Qt().parse({modality:We,value:e})}),tt=(n,e,o,a,i)=>ae().parse({role:n,partialContent:to().parse({modality:Ze,index:e,id:o,name:a,arguments:i})}),co=(n,e)=>Ge().parse({modality:H,value:{type:me,thinking:n,signature:e}});var uo=n=>Ge().parse({modality:H,value:{type:Ke,data:n}});var ue=(n,e,o)=>ae().parse({role:n,partialContent:Je().parse({modality:pe,value:{type:me,thinking:e,signature:o}})}),go=(n,e)=>ae().parse({role:n,partialContent:Je().parse({modality:pe,value:{type:Ke,data:e}})});var ua=Object.defineProperty,ho=Object.getOwnPropertySymbols,ga=Object.prototype.hasOwnProperty,ha=Object.prototype.propertyIsEnumerable,yo=(n,e,o)=>e in n?ua(n,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[e]=o,ge=(n,e)=>{for(var o in e||(e={}))ga.call(e,o)&&yo(n,o,e[o]);if(ho)for(var o of ho(e))ha.call(e,o)&&yo(n,o,e[o]);return n},fo="ProviderError",ot=class So extends X{constructor({info:e,cause:o}){super({info:e,cause:o},fo),this.name=fo,this.info=e,this.cause=o;}static isProviderError(e){return e instanceof So}};var To="ModelResponseError",$=class xo extends X{constructor({info:e,cause:o}){super({info:e,cause:o},To),this.name=To,this.cause=o,this.info=e;}static isModelResponseError(e){return e instanceof xo}},bo="InvalidModelRequestError",ie=class Eo extends X{constructor({info:e,cause:o}){super({info:e,cause:o},bo),this.name=bo,this.cause=o,this.info=e,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(e){return e instanceof Eo}},Co="InvalidConfigError",K=class vo extends X{constructor({info:e,cause:o}){super({info:e,cause:o},Co),this.name=Co,this.cause=o,this.info=e,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(e){return e instanceof vo}},Mo="InvalidMessagesError",I=class Oo extends X{constructor({info:e,cause:o}){super({info:e,cause:o},Mo),this.name=Mo,this.cause=o,this.info=e,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(e){return e instanceof Oo}},ko="InvalidToolsError",nt=class Ao extends X{constructor({info:e,cause:o}){super({info:e,cause:o},ko),this.name=ko,this.cause=o,this.info=e,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(e){return e instanceof Ao}},Ro="InvalidEmbeddingRequestsError",at=class _o extends X{constructor({info:e,cause:o}){super({info:e,cause:o},Ro),this.name=Ro,this.info=e,this.cause=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(e){return e instanceof _o}},it="multi-string",Po=z$1.object({type:z$1.literal(it),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),max:z$1.number().int().positive()}),ya=n=>z$1.array(z$1.string()).max(n).default([]).optional(),wo=n=>({def:Po.parse(ge({type:it},n)),schema:ya(n.max)}),qo="object-schema",fa=z$1.object({type:z$1.literal(qo),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),objectSchema:z$1.any()});var st="range",Io=z$1.object({type:z$1.literal(st),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),min:z$1.number().int(),max:z$1.number().int(),step:z$1.number().positive(),default:z$1.number()}),Ta=(n,e,o,a)=>z$1.number().min(n).max(e).step(o).default(a).optional(),te=n=>({def:Io.parse(ge({type:st},n)),schema:Ta(n.min,n.max,n.step,n.default)}),rt="select-boolean",jo=z$1.object({type:z$1.literal(rt),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),default:z$1.boolean().nullable()}),ba=n=>z$1.boolean().nullable().default(n).optional(),he=n=>({def:jo.parse(ge({type:rt},n)),schema:ba(n.default)}),lt="select-string",Lo=z$1.object({type:z$1.literal(lt),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),default:z$1.string(),choices:z$1.array(z$1.string())}),Ca=(n,e)=>z$1.enum(e).nullable().default(n).optional(),se=n=>({def:Lo.parse(ge({type:lt},n)),schema:Ca(n.default,n.choices)}),Ma=[st,it,lt,qo,rt];z$1.enum(Ma);var Bo=z$1.discriminatedUnion("type",[Io,Po,Lo,jo,fa]),M=(n=He,e=oo)=>z$1.object({name:z$1.string().min(1),description:z$1.string().min(1),roles:z$1.record(n,z$1.string().min(1).optional()),modalities:z$1.array(e).nonempty(),maxInputTokens:z$1.number().int().positive().min(1),maxOutputTokens:z$1.number().int().positive().min(1),maxReasoningTokens:z$1.number().int().positive().min(1).optional(),config:z$1.object({def:z$1.record(z$1.string().min(1),Bo),schema:z$1.instanceof(z$1.ZodObject)}).refine(o=>{var a,i;let l=Object.keys(o.def),s=Object.keys((i=(a=o.schema)==null?void 0:a.shape)!=null?i:{});return l.every(r=>s.includes(r))&&s.every(r=>l.includes(r))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"}),price:z$1.custom()}),B=(n=io)=>z$1.object({name:z$1.string().min(1),description:z$1.string().min(1),modalities:z$1.array(n).nonempty(),maxInputTokens:z$1.number().int().positive().min(1),maxOutputTokens:z$1.number().int().positive().min(1),config:z$1.object({def:z$1.record(z$1.string().min(1),Bo),schema:z$1.instanceof(z$1.ZodObject)}).refine(e=>{var o,a;let i=Object.keys(e.def),l=Object.keys((a=(o=e.schema)==null?void 0:o.shape)!=null?a:{});return i.every(s=>l.includes(s))&&l.every(s=>i.includes(s))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})});z$1.record(z$1.string());z$1.record(z$1.union([z$1.boolean(),z$1.string(),z$1.number(),z$1.object({}),z$1.array(z$1.any()),z$1.null(),z$1.undefined()]));z$1.string().url();var ka={type:"range",title:"Temperature",description:"Adjusts the model's creativity level. With a setting of 0, the model strictly picks the most probable next word. For endeavors that benefit from a dash of inventiveness, consider dialing it up to 0.7 or higher, enabling the model to produce text that's unexpectedly fresh."},Ra={type:"range",title:"Max tokens",description:"Specify the total tokens for generation, where one token approximates four English characters. Setting this to 0 defaults to the model's maximum capacity."},Sa={type:"range",title:"Max reasoning tokens",description:"Specify the total tokens for reasoning, where one token approximates four English characters."},xa=n=>({type:"multi",title:"Stop sequence",description:`Enter up to ${n} sequences that will halt additional text output. The generated text will exclude these sequences.`}),Ea={type:"range",title:"Top A",description:"Considers only the top tokens that have 'sufficiently high' probabilities relative to the most likely token, functioning like a dynamic Top-P. A lower Top-A value narrows down the token choices based on the highest probability token, while a higher Top-A value refines the filtering without necessarily impacting the creativity of the output."},va={type:"range",title:"Top P",description:"Selects a subset of likely tokens for generation, restricting choices to the top-P fraction of possibilities, such as the top 10% when P=0.1. This approach can limit the variety of the output. By default, it's set to 1, indicating no restriction. It's advised to adjust this parameter or temperature to modulate output diversity, but not to modify both simultaneously."},Oa={type:"range",title:"Top K",description:"Select only from the highest K probabilities for each following word, effectively eliminating the less likely 'long tail' options."},Aa={type:"range",title:"Min P",description:"Specifies the minimum probability a token must have to be considered, in relation to the probability of the most likely token. (This value varies based on the confidence level of the top token.) For example, if Min-P is set to 0.1, only tokens with at least 1/10th the probability of the highest-ranked token will be considered."},_a={type:"range",title:"Frequency penalty",description:"Minimize redundancy. By assigning a penalty to frequently used tokens within the text, the likelihood of repeating identical phrases is reduced. The default setting for this penalty is zero."},Pa={type:"range",title:"Presence penalty",description:"Enhance the introduction of novel subjects by reducing the preference for tokens that have already appeared in the text, thus boosting the chances of exploring fresh topics. The standard setting for this is zero."},wa={type:"range",title:"Seed",description:"When seed is fixed to a specific value, the model makes a best effort to provide the same response for repeated requests. Deterministic output isn't guaranteed. Also, changing the model or parameter settings, such as the temperature, can cause variations in the response even when you use the same seed value. By default, a random seed value is used."},qa={type:"range",title:"Repetition penalty",description:"Reduces the likelihood of repeating tokens from the input. Increasing this value makes the model less prone to repetition, but setting it too high may lead to less coherent output, often resulting in run-on sentences missing smaller words. The token penalty is scaled according to the original token's probability."},Ia={type:"boolean",title:"Log probs",description:"Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned."},ja={type:"range",title:"Top log probs",description:"The number of most likely tokens to return at each token position, each with an associated log probability. 'logprobs' must be set to true if this parameter is used."},La={type:"boolean",title:"Echo",description:"If true, the response will contain the prompt."},Ba={type:"select",title:"Response format",description:"Choose the response format of your model. For JSON, you must include the string 'JSON' in some form within your system / user prompt."},Na={type:"select",title:"Response format",description:"Choose the response format of your model. 'json_object' colloquially known as JSON mode, instructs the model to respond with a valid JSON (must include the term 'json' in prompt). 'json_schema' colloquially known as structured outputs, allows you to specify a strict response schema that the model will adhere to."},Ua={type:"object",title:"Response schema",description:"When response format is set to 'json_schema', the model will return a JSON object of the specified schema."},P={TEMPERATURE:ka,MAX_TOKENS:Ra,STOP:xa,TOP_A:Ea,TOP_P:va,TOP_K:Oa,MIN_P:Aa,FREQUENCY_PENALTY:_a,PRESENCE_PENALTY:Pa,REPETITION_PENALTY:qa,SEED:wa,LOG_PROBS:Ia,TOP_LOG_PROBS:ja,ECHO:La,RESPONSE_FORMAT:Ba,RESPONSE_FORMAT_WITH_SCHEMA:Na,RESPONSE_SCHEMA:Ua,MAX_REASONING_TOKENS:Sa};var ye=n=>Object.fromEntries(Object.entries(n).filter(([e,o])=>o!=null));var oe=n=>n==null?void 0:n.replace(/\/$/,"");var dt=te({param:"temperature",title:P.TEMPERATURE.title,description:P.TEMPERATURE.description,min:0,max:1,step:.01,default:1}),pt=n=>te({param:"max_tokens",title:P.MAX_TOKENS.title,description:P.MAX_TOKENS.description,min:0,max:n,step:1,default:0}),mt=n=>wo({param:"stop_sequences",title:P.STOP(n).title,description:P.STOP(n).description,max:n}),ct=te({param:"top_p",title:P.TOP_P.title,description:P.TOP_P.description,min:0,max:1,step:.01,default:1}),ut=te({param:"top_k",title:P.TOP_K.title,description:P.TOP_K.description,min:0,max:1,step:.01,default:1}),gt=se({param:"tool_choice",title:"Tool choice",description:"Controls which (if any) tool is called by the model. 'any' means the model will call any of the provided tools. 'auto' means the model can pick between generating a message or calling a tool.",default:"auto",choices:["auto","any"]});var fe=(n,e)=>z$1.object({temperature:dt.schema,maxTokens:pt(n).schema,stop:mt(e).schema,topP:ct.schema,topK:ut.schema,toolChoice:gt.schema}),Te=(n,e)=>({temperature:dt.def,maxTokens:pt(n).def,stop:mt(e).def,topP:ct.def,topK:ut.def,toolChoice:gt.def});var No=(n,e)=>te({param:"max_reasoning_tokens",title:P.MAX_REASONING_TOKENS.title,description:P.MAX_REASONING_TOKENS.description,min:n,max:e,step:1,default:0}),Uo=he({param:"reasoning_enabled",title:"Reasoning Enabled",description:`Controls whether the model is allowed to think for a longer period of time before generating a response.
5
+ This can be useful for complex tasks that require more time to think.`,default:!1}),Do=(n,e,o,a)=>de(b({},Te(n,e)),{reasoningEnabled:Uo.def,maxReasoningTokens:No(o,a).def}),Vo=(n,e,o,a)=>fe(n,e).extend({reasoningEnabled:Uo.schema,maxReasoningTokens:No(o,a).schema});var ht=se({param:"encoding_format",title:"Encoding format",description:"Select the encoding format for the word embedding.",default:"",choices:["base64",""]}),yt=se({param:"input_type",title:"Input type",description:"Select the input type for the word embedding.",default:"",choices:["query","document",""]}),ft=he({param:"truncation",title:"Truncation",description:"Select the truncation for the word embedding.",default:!0});var $o=()=>z$1.object({encodingFormat:ht.schema,inputType:yt.schema,truncation:ft.schema}),zo=()=>({encodingFormat:ht.def,inputType:yt.def,truncation:ft.def});var g={base:(n,e)=>({def:Te(n,e),schema:fe(n,e)}),extendedThinking:(n,e,o,a)=>({def:Do(n,e,o,a),schema:Vo(n,e,o,a)})},k={base:()=>({def:zo(),schema:$o()})};var $a="anthropic",Y=class{constructor(){this.version="v1";this.name=$a;this.chatModelFactories={[kt]:{model:ve,modelOptions:Jo,modelSchema:Rt},[Ot]:{model:qe,modelOptions:Yo,modelSchema:At},[Et]:{model:we,modelOptions:Xo,modelSchema:vt},[be]:{model:Ce,modelOptions:Ho,modelSchema:Tt},[Me]:{model:ke,modelOptions:Fo,modelSchema:bt},[Oe]:{model:Ae,modelOptions:Wo,modelSchema:St},[Re]:{model:Se,modelOptions:Ko,modelSchema:Ct},[_e]:{model:Pe,modelOptions:Zo,modelSchema:xt},[xe]:{model:Ee,modelOptions:Go,modelSchema:Mt}};this.embeddingModelFactories={[Dt]:{model:Ue,modelOptions:an,modelSchema:Vt},[Nt]:{model:Ne,modelOptions:nn,modelSchema:Ut},[_t]:{model:Ie,modelOptions:Qo,modelSchema:Pt},[wt]:{model:je,modelOptions:en,modelSchema:qt},[It]:{model:Le,modelOptions:tn,modelSchema:jt},[Lt]:{model:Be,modelOptions:on,modelSchema:Bt}};}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 ot({info:`Anthropic chat model: ${o} not found`,cause:new Error(`Anthropic chat model: ${o} not found, available chat models:
6
+ ${this.chatModelLiterals().join(", ")}`)});let a=this.chatModelFactories[o].model,i=this.chatModelFactories[o].modelOptions.parse(e);return new a(i)}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 ot({info:`Anthropic embedding model: ${o} not found`,cause:new Error(`Anthropic embedding model: ${o} not found, available embedding models:
7
+ ${this.embeddingModelLiterals().join(", ")}`)});let a=this.embeddingModelFactories[o].model,i=this.embeddingModelFactories[o].modelOptions.parse(e);return new a(i)}};Y.chatBaseUrl="https://api.anthropic.com/v1",Y.embeddingBaseUrl="https://api.voyageai.com/v1";var A={"claude-3-opus-20240229":{modelName:"claude-3-opus-20240229",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:15,outputPricePerMillion:75}}}]},"claude-3-sonnet-20240229":{modelName:"claude-3-sonnet-20240229",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"claude-3-5-sonnet-20240620":{modelName:"claude-3-5-sonnet-20240620",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"claude-3-5-sonnet-20241022":{modelName:"claude-3-5-sonnet-20241022",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"claude-3-5-sonnet-latest":{modelName:"claude-3-5-sonnet-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"claude-3-7-sonnet-20250219":{modelName:"claude-3-7-sonnet-20250219",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:15}}}]},"claude-3-haiku-20240307":{modelName:"claude-3-haiku-20240307",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.25,outputPricePerMillion:1.25}}}]},"claude-3-haiku-20241022":{modelName:"claude-3-haiku-20241022",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.25,outputPricePerMillion:1.25}}}]},"claude-3-haiku-latest":{modelName:"claude-3-haiku-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.25,outputPricePerMillion:1.25}}}]},"claude-3-5-haiku-20241022":{modelName:"claude-3-5-haiku-20241022",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.8,outputPricePerMillion:4}}}]},"claude-3-5-haiku-latest":{modelName:"claude-3-5-haiku-20241022",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.8,outputPricePerMillion:4}}}]}};var R=z$1.enum([ee,W,E,ne]),S={system:ee,user:W,assistant:E,tool:W};var v=[x,z,q,F],O=z$1.enum([x,z,q,F]),rn=[x,z,q,F,H],ln=z$1.enum([x,z,q,F,H]);var Fa=z$1.object({type:z$1.literal("text"),text:z$1.string()}),Ka=z$1.object({type:z$1.literal("tool_use"),id:z$1.string(),name:z$1.string(),input:z$1.record(z$1.any())}),Ga=z$1.object({type:z$1.literal("thinking"),thinking:z$1.string(),signature:z$1.string()}),Ja=z$1.object({type:z$1.literal("redacted_thinking"),data:z$1.string()}),dn=z$1.object({content:z$1.array(z$1.discriminatedUnion("type",[Fa,Ka,Ga,Ja])),id:z$1.string(),model:z$1.string(),role:z$1.string(),stop_reason:z$1.string(),stop_sequence:z$1.null(),type:z$1.literal("message"),usage:z$1.object({input_tokens:z$1.number(),output_tokens:z$1.number(),cache_creation_input_tokens:z$1.number().nullish(),cache_read_input_tokens:z$1.number().nullish()})}),pn=z$1.object({type:z$1.literal("message_start"),message:z$1.object({id:z$1.string(),type:z$1.literal("message"),role:z$1.string(),model:z$1.string(),stop_reason:z$1.string().nullable(),stop_sequence:z$1.string().nullable(),content:z$1.array(z$1.any()),usage:z$1.object({input_tokens:z$1.number(),output_tokens:z$1.number()})})}),mn=z$1.object({type:z$1.literal("message_delta"),delta:z$1.object({stop_reason:z$1.string().nullable(),stop_sequence:z$1.string().nullable()}),usage:z$1.object({output_tokens:z$1.number()})}),Wa=z$1.object({type:z$1.literal("text"),text:z$1.string()}),Za=z$1.object({type:z$1.literal("tool_use"),id:z$1.string(),name:z$1.string(),input:z$1.object({})}),Xa=z$1.object({type:z$1.literal("thinking"),thinking:z$1.string()}),Ya=z$1.object({type:z$1.literal("redacted_thinking"),data:z$1.string()}),cn=z$1.object({type:z$1.literal("content_block_start"),index:z$1.number(),content_block:z$1.discriminatedUnion("type",[Wa,Za,Xa,Ya])}),Qa=z$1.object({type:z$1.literal("text_delta"),text:z$1.string()}),ei=z$1.object({type:z$1.literal("input_json_delta"),partial_json:z$1.string()}),ti=z$1.object({type:z$1.literal("thinking_delta"),thinking:z$1.string()}),oi=z$1.object({type:z$1.literal("signature_delta"),signature:z$1.string()}),un=z$1.object({type:z$1.literal("content_block_delta"),index:z$1.number(),delta:z$1.discriminatedUnion("type",[Qa,ei,ti,oi])});var ni=z$1.object({type:z$1.literal("thinking"),thinking:z$1.string().optional(),signature:z$1.string().optional()}),ai=z$1.object({type:z$1.literal("redacted_thinking"),data:z$1.string()}),ii=z$1.object({name:z$1.string().min(1),description:z$1.string().min(1).optional(),input_schema:z$1.any()}),si=z$1.object({type:z$1.enum(["auto","any"])}),ri=z$1.object({type:z$1.literal("tool"),name:z$1.string().min(1)}),$t=z$1.object({text:z$1.string().min(1),type:z$1.literal("text")}),gn=z$1.object({type:z$1.literal("image"),source:z$1.object({type:z$1.literal("base64"),media_type:z$1.enum(["image/jpeg","image/png","image/gif","image/webp"]),data:z$1.string().base64()})}),Os=z$1.object({id:z$1.string().min(1),type:z$1.literal("tool_use"),name:z$1.string().min(1),input:z$1.record(z$1.any())}),hn=z$1.object({type:z$1.literal("tool_result"),tool_use_id:z$1.string().min(1),content:z$1.string().min(1).or(z$1.array(z$1.union([$t,gn])).min(1))}),li=z$1.object({role:z$1.literal("user"),content:z$1.string().min(1).or(z$1.array(z$1.union([$t,gn,hn])).min(1))}),di=z$1.object({role:z$1.literal("assistant"),content:z$1.string().min(1).or(z$1.array(z$1.union([$t,hn,ni,ai])).min(1))}),pi=z$1.union([li,di]),yn=z$1.object({model:z$1.string().min(1).optional(),messages:z$1.array(pi).min(1),system:z$1.string().min(1).optional(),max_tokens:z$1.number().min(0).optional(),stop_sequences:z$1.array(z$1.string().min(1)).optional(),temperature:z$1.number().min(0).max(1).optional(),tool_choice:z$1.union([si,ri]).optional(),tools:z$1.array(ii).min(1).optional(),top_p:z$1.number().min(0).max(1).optional(),top_k:z$1.number().min(0).optional()});var C=z$1.object({modelName:z$1.string(),apiKey:z$1.string(),completeChatUrl:z$1.string().url().optional(),streamChatUrl:z$1.string().url().optional()}),T=class{constructor(e,o){this.version="v1";let a=C.parse(o);this.modelSchema=e,this.modelName=a.modelName,this.apiKey=a.apiKey,this.baseUrl=oe(Y.chatBaseUrl),this.completeChatUrl=oe(a.completeChatUrl||`${this.baseUrl}/messages`),this.streamChatUrl=oe(a.streamChatUrl||`${this.baseUrl}/messages`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"x-api-key":`${this.apiKey}`,"anthropic-version":"2023-06-01","content-type":"application/json","anthropic-dangerous-direct-browser-access":"true"}}getDefaultParams(){return {model:this.modelName}}getRetryDelay(e){let o=0,a=!0;return e["x-should-retry"]&&(a=e["x-should-retry"].toLowerCase()!=="false"),e["retry-after"]&&(o=parseInt(e["retry-after"])*1e3),{shouldRetry:a,delayMs:o}}getTokenCount(e){return e.reduce((o,a)=>o+a.content.map(i=>i.modality==="text"?i.value:"").join(" ").length,0)}transformModelRequest(e){let o=yn.safeParse(e);if(!o.success)throw new ie({info:"Invalid model request",cause:o.error});let a=o.data,i=a.model;if(a.tool_choice&&(!a.tools||a.tools.length===0))throw new ie({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let l={};a.tool_choice&&(a.tool_choice.type==="tool"?l.toolChoice=a.tool_choice.name:l.toolChoice=a.tool_choice.type),l.maxTokens=a.max_tokens,l.temperature=a.temperature,l.topP=a.top_p,l.topK=a.top_k,l.stop=a.stop_sequences;let s=ce().parse(ye(l)),r=[],m={};a.system&&r.push({role:ee,content:[{modality:x,value:a.system}]}),a.messages.forEach(f=>{let V=f.role;switch(V){case"user":{let L=f.content;if(typeof L=="string")r.push({role:V,content:[{modality:x,value:L}]});else {let u=L.map(y=>{if(y.type==="text")return {modality:x,value:y.text};if(y.type==="image"){let G="auto",J=y.source.media_type.split("/")[1];return {modality:z,detail:G,value:{type:Fe,media_type:J,base64:y.source.data}}}else return {modality:F,id:y.tool_use_id,index:m[y.tool_use_id].index,name:m[y.tool_use_id].name,data:typeof y.content=="string"?y.content:JSON.stringify(y.content)}});r.push({role:V,content:u});}}break;case"assistant":{let L=f.content;if(typeof L=="string")r.push({role:V,content:[{modality:x,value:L}]});else {let u=L.map((y,G)=>{if(y.type==="text")return {modality:x,value:y.text};{let J={modality:q,id:y.id,index:G,name:y.name,arguments:JSON.stringify(y.input)};return m[y.id]=J,J}});r.push({role:V,content:u});}}break}});let h=[];return a.tools&&a.tools.forEach(f=>{h.push({type:"function",definition:{schema:{name:f.name,description:f.description||"",parameters:f.input_schema}}});}),{modelName:i,config:s,messages:r,tools:h.length>0?h:void 0}}transformConfig(e,o,a){let i=e.toolChoice,l=e.reasoningEnabled,s=e.maxReasoningTokens,r=b({},e);delete r.toolChoice,delete r.reasoningEnabled,delete r.maxReasoningTokens;let m=this.modelSchema.config.schema.safeParse(r);if(!m.success)throw new K({info:`Invalid config for model : '${this.modelName}'`,cause:m.error});let h=m.data;i!==void 0&&(h.toolChoice=i),Object.keys(h).forEach(u=>{if(!(u in this.modelSchema.config.def))throw new K({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${u}',
8
+ available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let f=Object.keys(h).reduce((u,y)=>{let G=this.modelSchema.config.def[y],J=G.param,zt=h[y];return J==="max_tokens"&&G.type==="range"&&zt===0?u[J]=G.max:u[J]=zt,u},{});if(!f.max_tokens){let u=this.modelSchema.config.def.maxTokens;f.max_tokens=u.max;}if("tool_choice"in f&&f.tool_choice!==void 0){let u=f.tool_choice;if(!a||a&&a.length===0)throw new K({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(a&&a.length>0){let y=this.modelSchema.config.def.toolChoice;if(y.choices.includes(u))f.tool_choice={type:u};else if(a.map(G=>G.definition.schema.name).includes(u))f.tool_choice={type:"tool",name:u};else throw new K({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`toolChoice : '${u}' is not part of provided 'tools' names or
9
+ one of [${y.choices.join(", ")}]`)})}}let V=l!==void 0,L=s!==void 0;if(V!==L)throw new K({info:`Invalid extended thinking config for model: '${this.modelName}'`,cause:new Error("Both 'reasoningEnabled' and 'maxReasoningTokens' must be defined together.")});if(V&&L){let u=f.max_tokens;if(l)if(s<u)f.thinking={type:"enabled",budget_tokens:s};else throw new K({info:`Invalid extended thinking token budget for model: '${this.modelName}'`,cause:new Error(`maxReasoningTokens (${s}) must be less than max_tokens (${u})`)})}return f}transformMessages(e){if(!e||e&&e.length===0)return {messages:[]};let o=s=>{let r=s.match(/^data:image\/[a-zA-Z]+;base64,/);return r?s.substring(r[0].length):s},a=e.map(s=>{let r=Xe().safeParse(s);if(!r.success)throw new I({info:"Invalid messages",cause:r.error});return r.data});a.forEach(s=>{s.content.forEach(r=>{if(!this.modelSchema.modalities.includes(r.modality))throw new I({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${r.modality}', available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),a.forEach(s=>{if(!Object.keys(this.modelSchema.roles).includes(s.role))throw new I({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${s.role}', available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})});let i="",l=[];if(a.forEach(s=>{switch(s.role){case ee:{s.content.forEach(r=>{if(r.modality===x)i+=r.value;else throw new I({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${r.modality}'`)})});break}case E:{let r=[];s.content.forEach(m=>{if(m.modality===x)r.push({type:"text",text:m.value});else if(m.modality===q)r.push({type:"tool_use",id:m.id,name:m.name,input:JSON.parse(m.arguments)});else if(m.modality===H&&m.value.type==="thinking")r.push({type:"thinking",thinking:m.value.thinking,signature:m.value.signature});else if(m.modality===H&&m.value.type==="redacted")r.push({type:"redacted_thinking",data:m.value.data});else throw new I({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${m.modality}'`)})}),l.push({role:this.modelSchema.roles[s.role],content:r});break}case W:{let r=[];s.content.forEach(m=>{if(m.modality===x)r.push({type:"text",text:m.value});else if(m.modality===z){if(m.value.type==="base64"){let h=m.value.base64;h=o(h),r.push({type:"image",source:{type:"base64",media_type:`image/${m.value.media_type}`,data:h}});}else if(m.value.type==="url")throw new I({info:`Invalid message 'modality' for model : ${this.modelName}`,cause:new Error(`model: '${this.modelName}' does not support image content type: '${m.value.type}'`)})}else throw new I({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${m.modality}'`)})}),l.push({role:this.modelSchema.roles[s.role],content:r});break}case ne:{let r=[];s.content.forEach(m=>{if(m.modality===F)r.push({type:"tool_result",tool_use_id:m.id,content:m.data});else throw new I({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${m.modality}'`)})}),l.push({role:this.modelSchema.roles[s.role],content:r});break}default:throw new I({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' is not supported,
10
+ available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}}),l[0].role!==this.modelSchema.roles[W])throw new I({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires first message to be from user`)});return {system:i,messages:l}}transformTools(e){if(!this.modelSchema.modalities.includes(q))throw new nt({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${q}'`)});return !e||e&&e.length===0?{tools:[]}:{tools:e.map(i=>{let l=lo().safeParse(i);if(!l.success)throw new nt({info:"Invalid tools",cause:l.error});return l.data}).map(i=>({name:i.definition.schema.name,description:i.definition.schema.description,input_schema:i.definition.schema.parameters}))}}getCompleteChatUrl(e,o,a){return _(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getCompleteChatHeaders(e,o,a){return _(this,null,function*(){let i=this.getDefaultHeaders();return new Promise(l=>{l(i);})})}getCompleteChatData(e,o,a){return _(this,null,function*(){let i=this.transformConfig(e,o,a),l=this.transformMessages(o);if(l.messages&&l.messages.length===0)throw new I({info:"Messages are required",cause:new Error("Messages are required")});let s=a?this.transformTools(a):{};return new Promise(r=>{r(b(b(b(b({},this.getDefaultParams()),i),l),s));})})}transformCompleteChatResponse(e){let o=dn.safeParse(e);if(o.success){let a=o.data,l=a.content.map((m,h)=>{if(m.type==="text")return po(m.text);if(m.type==="tool_use")return mo(h,m.id,m.name,JSON.stringify(m.input));if(m.type==="thinking")return co(m.thinking,m.signature);if(m.type==="redacted_thinking")return uo(m.data)}),s=[{role:E,content:l}],r={promptTokens:a.usage.input_tokens,completionTokens:a.usage.output_tokens,totalTokens:a.usage.input_tokens+a.usage.output_tokens};return {messages:s,usage:r,logProbs:[]}}throw new $({info:"Invalid response from model",cause:o.error})}getStreamChatUrl(e,o,a){return _(this,null,function*(){return new Promise(i=>{i(this.streamChatUrl);})})}getStreamChatHeaders(e,o,a){let i=this.getDefaultHeaders();return new Promise(l=>{l(i);})}getStreamChatData(e,o,a){return _(this,null,function*(){let i=this.transformConfig(e,o,a),l=this.transformMessages(o);if(l.messages&&l.messages.length===0)throw new I({info:"Messages are required",cause:new Error("Messages are required")});let s=a?this.transformTools(a):{};return new Promise(r=>{r(b(b(b(b({stream:!0},this.getDefaultParams()),i),l),s));})})}transformStreamChatResponseChunk(e,o){return Ve(this,null,function*(){let a=(o+e).split(`
11
+ `).filter(i=>i.trim()!=="");for(let i of a)if(i.startsWith("data: {")&&i.endsWith("}")){let l;try{l=JSON.parse(i.substring(6));}catch(s){throw new $({info:`Malformed JSON received in stream : ${l}`,cause:s})}if("type"in l){if(l.type==="message_stop")return;if(l.type==="message_start"){let s=pn.safeParse(l);if(s.success){let r=s.data;yield {partialResponse:{partialMessages:[],usage:{promptTokens:r.message.usage.input_tokens,completionTokens:r.message.usage.output_tokens,totalTokens:r.message.usage.input_tokens+r.message.usage.output_tokens}},buffer:o};}else throw new $({info:"Invalid response from model",cause:s.error})}else if(l.type==="message_delta"){let s=mn.safeParse(l);if(s.success){let r=s.data;yield {partialResponse:{partialMessages:[],usage:{promptTokens:void 0,completionTokens:r.usage.output_tokens,totalTokens:r.usage.output_tokens}},buffer:o};}else throw new $({info:"Invalid response from model",cause:s.error})}else if(l.type==="content_block_start"){let s=cn.safeParse(l);if(s.success){let r=s.data,m=[];r.content_block.type==="text"?m.push(et(E,r.content_block.text)):r.content_block.type==="tool_use"?m.push(tt(E,r.index,r.content_block.id,r.content_block.name,"")):r.content_block.type==="thinking"?m.push(ue(E,r.content_block.thinking)):r.content_block.type==="redacted_thinking"&&m.push(go(E,r.content_block.data)),yield {partialResponse:{partialMessages:m},buffer:o};}else throw new $({info:"Invalid response from model",cause:s.error})}else if(l.type==="content_block_delta"){let s=un.safeParse(l);if(s.success){let r=s.data,m=[];r.delta.type==="text_delta"?m.push(et(E,r.delta.text)):r.delta.type==="input_json_delta"?m.push(tt(E,r.index,"","",r.delta.partial_json)):r.delta.type==="thinking_delta"?m.push(ue(E,r.delta.thinking)):r.delta.type==="signature_delta"&&m.push(ue(E,void 0,r.delta.signature)),yield {partialResponse:{partialMessages:m},buffer:o};}else throw new $({info:"Invalid response from model",cause:s.error})}}else throw new $({info:"Invalid JSON received in stream",cause:new Error(`Invalid JSON received in stream, expected 'type' property, received: ${JSON.stringify(l)}`)})}})}transformProxyStreamChatResponseChunk(e,o,a,i,l){return Ve(this,null,function*(){yield*Gt(this.transformStreamChatResponseChunk(e,o));})}getProxyStreamChatUrl(e,o,a){return _(this,null,function*(){return new Promise(i=>{i(this.streamChatUrl);})})}getProxyCompleteChatUrl(e,o,a){return _(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getProxyCompleteChatHeaders(e,o,a){return _(this,null,function*(){if(!o)return {};let i=b({},o);return delete i.host,delete i["content-length"],i})}getProxyStreamChatHeaders(e,o,a){return _(this,null,function*(){return yield this.getProxyCompleteChatHeaders(e,o,a)})}getModelPricing(){if(!(this.modelName in A))throw new $({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return A[this.modelName]}};var be="claude-3-5-sonnet-20240620",mi="Most intelligent model. Highest level of intelligence and capability.",Tt=M(R,O).parse({name:be,description:mi,maxInputTokens:2e5,maxOutputTokens:8192,roles:S,modalities:v,config:{def:g.base(8192,4).def,schema:g.base(8192,4).schema},price:A[be]}),Ho=C,Ce=class extends T{constructor(e){super(Tt,e);}};var Me="claude-3-5-sonnet-20241022",ci="Most intelligent model. Highest level of intelligence and capability.",bt=M(R,O).parse({name:Me,description:ci,maxInputTokens:2e5,maxOutputTokens:8192,roles:S,modalities:v,config:{def:g.base(8192,4).def,schema:g.base(8192,4).schema},price:A[Me]}),Fo=C,ke=class extends T{constructor(e){super(bt,e);}};var Re="claude-3-5-sonnet-latest",ui="Most intelligent model. Highest level of intelligence and capability.",Ct=M(R,O).parse({name:Re,description:ui,maxInputTokens:2e5,maxOutputTokens:8192,roles:S,modalities:v,config:{def:g.base(8192,4).def,schema:g.base(8192,4).schema},price:A[Re]}),Ko=C,Se=class extends T{constructor(e){super(Ct,e);}};var xe="claude-3-7-sonnet-20250219",gi="Most intelligent model. Highest level of intelligence and capability.",Mt=M(R,ln).parse({name:xe,description:gi,maxInputTokens:2e5,maxOutputTokens:128e3,maxReasoningTokens:64e3,roles:S,modalities:rn,config:{def:g.extendedThinking(128e3,4,1024,64e3).def,schema:g.extendedThinking(128e3,4,1024,64e3).schema},price:A[xe]}),Go=C,Ee=class extends T{constructor(e){super(Mt,e);}getDefaultHeaders(){let e=super.getDefaultHeaders();return e=de(b({},e),{"anthropic-beta":"output-128k-2025-02-19"}),e}};var kt="claude-3-haiku-20240307",hi="Fastest and most compact model for near-instant responsiveness. Quick and accurate targeted performance.",Rt=M(R,O).parse({name:kt,description:hi,maxInputTokens:2e5,maxOutputTokens:4096,roles:S,modalities:v,config:{def:g.base(4096,4).def,schema:g.base(4096,4).schema}}),Jo=C,ve=class extends T{constructor(e){super(Rt,e);}};var Oe="claude-3-5-haiku-20241022",yi="Our fastest model with intelligence at blazing speeds.",St=M(R,O).parse({name:Oe,description:yi,maxInputTokens:2e5,maxOutputTokens:8192,roles:S,modalities:v,config:{def:g.base(8192,4).def,schema:g.base(8192,4).schema},price:A[Oe]}),Wo=C,Ae=class extends T{constructor(e){super(St,e);}};var _e="claude-3-5-haiku-latest",fi="Our fastest model with intelligence at blazing speeds.",xt=M(R,O).parse({name:_e,description:fi,maxInputTokens:2e5,maxOutputTokens:8192,roles:S,modalities:v,config:{def:g.base(8192,4).def,schema:g.base(8192,4).schema},price:A[_e]}),Zo=C,Pe=class extends T{constructor(e){super(xt,e);}};var Et="claude-3-opus-20240229",Ti="Powerful model for highly complex tasks. Top-level performance, intelligence, fluency, and understanding.",vt=M(R,O).parse({name:Et,description:Ti,maxInputTokens:2e5,maxOutputTokens:4096,roles:S,modalities:v,config:{def:g.base(4096,4).def,schema:g.base(4096,4).schema}}),Xo=C,we=class extends T{constructor(e){super(vt,e);}};var Ot="claude-3-sonnet-20240229",bi="Balance of intelligence and speed. Strong utility, balanced for scaled deployments.",At=M(R,O).parse({name:Ot,description:bi,maxInputTokens:2e5,maxOutputTokens:4096,roles:S,modalities:v,config:{def:g.base(4096,4).def,schema:g.base(4096,4).schema}}),Yo=C,qe=class extends T{constructor(e){super(At,e);}};var N=[Z],U=z$1.enum([Z]);var fn=z$1.object({object:z$1.literal("list"),model:z$1.string(),data:z$1.array(z$1.object({index:z$1.number(),object:z$1.literal("embedding"),embedding:z$1.array(z$1.number()).or(z$1.string().base64())})),usage:z$1.object({total_tokens:z$1.number()})});var Mi=z$1.string().min(1).or(z$1.array(z$1.string().min(1)).min(1)),Tn=z$1.object({model:z$1.string().min(1).optional(),input:Mi,encoding_format:z$1.enum(["base64"]).nullable().optional(),input_type:z$1.enum(["query","document"]).nullable().optional(),truncation:z$1.boolean().optional()});var j=z$1.object({modelName:z$1.string(),apiKey:z$1.string(),getEmbeddingsUrl:z$1.string().url().optional()}),w=class{constructor(e,o){this.version="v1";let a=j.parse(o);this.modelSchema=e,this.modelName=a.modelName,this.apiKey=a.apiKey,this.baseUrl=oe(Y.embeddingBaseUrl),this.getEmbeddingsUrl=oe(a.getEmbeddingsUrl||`${this.baseUrl}/embeddings`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"}}getDefaultParams(){return {model:this.modelName}}getTokenCount(e){return e.requests.reduce((o,a)=>o+a.length,0)}getRetryDelay(e){return {shouldRetry:!0,delayMs:0}}transformModelRequest(e){let o=Tn.safeParse(e);if(!o.success)throw new ie({info:"Invalid model request",cause:o.error});let a=o.data,i=a.model,l={encodingFormat:a.encoding_format,inputType:a.input_type,truncation:a.truncation},s=ce().parse(ye(l)),r;return typeof a.input=="string"?r={modality:Z,requests:[a.input]}:r={modality:Z,requests:a.input},{modelName:i,config:s,embeddingRequests:r}}transformConfig(e,o){"inputType"in e&&e.inputType===""&&delete e.inputType,"encodingFormat"in e&&e.encodingFormat===""&&delete e.encodingFormat;let a=this.modelSchema.config.schema.safeParse(e);if(!a.success)throw new K({info:`Invalid config for model : '${this.modelName}'`,cause:a.error});let i=a.data;return Object.keys(i).forEach(s=>{if(!this.modelSchema.config.def[s])throw new K({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${s}',
12
+ available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(i).reduce((s,r)=>{let h=this.modelSchema.config.def[r].param,f=i[r];return s[h]=f,s},{})}transformEmbeddingRequests(e){let o=so().safeParse(e);if(!o.success)throw new at({info:"Invalid embedding requests",cause:o.error});if(o.data.requests.length>128)throw new at({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Max requests for model : '${this.modelName}' is 128`)});return {input:o.data.requests}}getGetEmbeddingsUrl(e,o){return _(this,null,function*(){return new Promise(a=>{a(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(e,o){return _(this,null,function*(){return new Promise(a=>{a(this.getDefaultHeaders());})})}getGetEmbeddingsData(e,o){return _(this,null,function*(){return new Promise(a=>{a(b(b(b({},this.getDefaultParams()),this.transformConfig(e,o)),this.transformEmbeddingRequests(o)));})})}transformGetEmbeddingsResponse(e){let o,a=fn.safeParse(e);if(a.success){let i=a.data;o=typeof i.data[0].embedding=="string"?Qe:Ye;let l=i.data.map(s=>typeof s.embedding=="string"?{index:s.index,embedding:s.embedding}:{index:s.index,embedding:s.embedding});return {encodingFormat:o,embeddings:l,usage:{totalTokens:i.usage.total_tokens}}}throw new $({info:"Invalid response from model",cause:a.error})}};var _t="voyage-code-2",ki="Optimized for code retrieval.",Pt=B(U).parse({name:_t,description:ki,modalities:N,maxInputTokens:16e3,maxOutputTokens:16e3,config:{def:k.base().def,schema:k.base().schema}}),Qo=j,Ie=class extends w{constructor(e){super(Pt,e);}};var wt="voyage-law-2",Ri="Optimized for legal and long-context retrieval and RAG. Also improved performance across all domains.",qt=B(U).parse({name:wt,description:Ri,modalities:N,maxInputTokens:16e3,maxOutputTokens:16e3,config:{def:k.base().def,schema:k.base().schema}}),en=j,je=class extends w{constructor(e){super(qt,e);}};var It="voyage-multilingual-2",Si="Optimized for multilingual retrieval and RAG.",jt=B(U).parse({name:It,description:Si,modalities:N,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:k.base().def,schema:k.base().schema}}),tn=j,Le=class extends w{constructor(e){super(jt,e);}};var Lt="voyage-finance-2",xi="Optimized for finance retrieval and RAG.",Bt=B(U).parse({name:Lt,description:xi,modalities:N,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:k.base().def,schema:k.base().schema}}),on=j,Be=class extends w{constructor(e){super(Bt,e);}};var Nt="voyage-3-lite",Ei="Optimized for latency and cost.",Ut=B(U).parse({name:Nt,description:Ei,modalities:N,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:k.base().def,schema:k.base().schema}}),nn=j,Ne=class extends w{constructor(e){super(Ut,e);}};var Dt="voyage-3",vi="Optimized for quality.",Vt=B(U).parse({name:Dt,description:vi,modalities:N,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:k.base().def,schema:k.base().schema}}),an=j,Ue=class extends w{constructor(e){super(Vt,e);}};
15
13
 
16
- export { J as Anthropic, h as AnthropicChatModelConfigs, R as AnthropicChatModelModalities, v as AnthropicChatModelModalitiesEnum, E as AnthropicChatModelRoles, S as AnthropicChatModelRolesMap, Uo as AnthropicCompleteChatResponse, f as AnthropicEmbeddingModelConfigs, j as AnthropicEmbeddingModelModalities, B as AnthropicEmbeddingModelModalitiesEnum, Go as AnthropicEmbeddingRequest, Pa as AnthropicEmbeddingRequestInput, Ko as AnthropicGetEmbeddingsResponse, Do as AnthropicRequest, Ea as AnthropicRequestAssistantMessage, Fo as AnthropicRequestImageContent, Sa as AnthropicRequestMessage, xt as AnthropicRequestTextContent, ba as AnthropicRequestTool, Ps as AnthropicRequestToolCallContent, Ca as AnthropicRequestToolChoiceEnum, Ta as AnthropicRequestToolChoiceTool, Ho as AnthropicRequestToolResponseContent, Ma as AnthropicRequestUserMessage, $o as AnthropicStreamChatContentBlockDeltaResponse, zo as AnthropicStreamChatContentBlockStartResponse, No as AnthropicStreamChatMessageDeltaResponse, Vo as AnthropicStreamChatMessageStartResponse, b as BaseChatModel, T as BaseChatModelOptions, w as BaseEmbeddingModel, I as BaseEmbeddingModelOptions, Mo as ChatModelBaseConfigDef, To as ChatModelBaseConfigSchema, me as Claude3Haiku20240307, st as Claude3Haiku20240307Literal, xo as Claude3Haiku20240307Options, it as Claude3Haiku20240307Schema, he as Claude3Opus20240229, mt as Claude3Opus20240229Literal, _o as Claude3Opus20240229Options, ct as Claude3Opus20240229Schema, ge as Claude3Sonnet20240229, ut as Claude3Sonnet20240229Literal, wo as Claude3Sonnet20240229Options, ht as Claude3Sonnet20240229Schema, ce as Claude3_5Haiku20241022, rt as Claude3_5Haiku20241022Literal, Ao as Claude3_5Haiku20241022Options, lt as Claude3_5Haiku20241022Schema, ue as Claude3_5HaikuLatest, dt as Claude3_5HaikuLatestLiteral, ko as Claude3_5HaikuLatestOptions, pt as Claude3_5HaikuLatestSchema, le as Claude3_5Sonnet20240620, Xe as Claude3_5Sonnet20240620Literal, Ro as Claude3_5Sonnet20240620Options, et as Claude3_5Sonnet20240620Schema, de as Claude3_5Sonnet20241022, tt as Claude3_5Sonnet20241022Literal, vo as Claude3_5Sonnet20241022Options, ot as Claude3_5Sonnet20241022Schema, pe as Claude3_5SonnetLatest, nt as Claude3_5SonnetLatestLiteral, Oo as Claude3_5SonnetLatestOptions, at as Claude3_5SonnetLatestSchema, So as EmbeddingModelBaseConfigDef, Eo as EmbeddingModelBaseConfigSchema, da as ProviderLiteral, Me as Voyage3, Te as Voyage3Lite, St as Voyage3LiteLiteral, jo as Voyage3LiteOptions, Rt as Voyage3LiteSchema, vt as Voyage3Literal, Bo as Voyage3Options, Ot as Voyage3Schema, ye as VoyageCode2, gt as VoyageCode2Literal, qo as VoyageCode2Options, yt as VoyageCode2Schema, Ce as VoyageFinance2, Mt as VoyageFinance2Literal, Lo as VoyageFinance2Options, Et as VoyageFinance2Schema, fe as VoyageLaw2, ft as VoyageLaw2Literal, Po as VoyageLaw2Options, bt as VoyageLaw2Schema, be as VoyageMultilingual2, Ct as VoyageMultilingual2Literal, Io as VoyageMultilingual2Options, Tt as VoyageMultilingual2Schema, Ze as encodingFormat, Ye as inputType, De as maxTokens, Ke as stop, He as temperature, We as toolChoice, Je as topK, Ge as topP, Qe as truncation };
14
+ export { Y as Anthropic, g as AnthropicChatModelConfigs, v as AnthropicChatModelModalities, O as AnthropicChatModelModalitiesEnum, R as AnthropicChatModelRoles, S as AnthropicChatModelRolesMap, dn as AnthropicCompleteChatResponse, k as AnthropicEmbeddingModelConfigs, N as AnthropicEmbeddingModelModalities, U as AnthropicEmbeddingModelModalitiesEnum, Tn as AnthropicEmbeddingRequest, Mi as AnthropicEmbeddingRequestInput, fn as AnthropicGetEmbeddingsResponse, yn as AnthropicRequest, di as AnthropicRequestAssistantMessage, gn as AnthropicRequestImageContent, pi as AnthropicRequestMessage, ai as AnthropicRequestRedactedThinkingContent, $t as AnthropicRequestTextContent, ni as AnthropicRequestThinkingContent, ii as AnthropicRequestTool, Os as AnthropicRequestToolCallContent, si as AnthropicRequestToolChoiceEnum, ri as AnthropicRequestToolChoiceTool, hn as AnthropicRequestToolResponseContent, li as AnthropicRequestUserMessage, un as AnthropicStreamChatContentBlockDeltaResponse, cn as AnthropicStreamChatContentBlockStartResponse, mn as AnthropicStreamChatMessageDeltaResponse, pn as AnthropicStreamChatMessageStartResponse, rn as AnthropicThinkingChatModelModalities, ln as AnthropicThinkingChatModelModalitiesEnum, T as BaseChatModel, C as BaseChatModelOptions, w as BaseEmbeddingModel, j as BaseEmbeddingModelOptions, Te as ChatModelBaseConfigDef, fe as ChatModelBaseConfigSchema, Do as ChatModelReasoningConfigDef, Vo as ChatModelReasoningConfigSchema, ve as Claude3Haiku20240307, kt as Claude3Haiku20240307Literal, Jo as Claude3Haiku20240307Options, Rt as Claude3Haiku20240307Schema, we as Claude3Opus20240229, Et as Claude3Opus20240229Literal, Xo as Claude3Opus20240229Options, vt as Claude3Opus20240229Schema, qe as Claude3Sonnet20240229, Ot as Claude3Sonnet20240229Literal, Yo as Claude3Sonnet20240229Options, At as Claude3Sonnet20240229Schema, Ae as Claude3_5Haiku20241022, Oe as Claude3_5Haiku20241022Literal, Wo as Claude3_5Haiku20241022Options, St as Claude3_5Haiku20241022Schema, Pe as Claude3_5HaikuLatest, _e as Claude3_5HaikuLatestLiteral, Zo as Claude3_5HaikuLatestOptions, xt as Claude3_5HaikuLatestSchema, Ce as Claude3_5Sonnet20240620, be as Claude3_5Sonnet20240620Literal, Ho as Claude3_5Sonnet20240620Options, Tt as Claude3_5Sonnet20240620Schema, ke as Claude3_5Sonnet20241022, Me as Claude3_5Sonnet20241022Literal, Fo as Claude3_5Sonnet20241022Options, bt as Claude3_5Sonnet20241022Schema, Se as Claude3_5SonnetLatest, Re as Claude3_5SonnetLatestLiteral, Ko as Claude3_5SonnetLatestOptions, Ct as Claude3_5SonnetLatestSchema, Ee as Claude3_7Sonnet20250219, xe as Claude3_7Sonnet20250219Literal, Go as Claude3_7Sonnet20250219Options, Mt as Claude3_7Sonnet20250219Schema, zo as EmbeddingModelBaseConfigDef, $o as EmbeddingModelBaseConfigSchema, $a as ProviderLiteral, Ue as Voyage3, Ne as Voyage3Lite, Nt as Voyage3LiteLiteral, nn as Voyage3LiteOptions, Ut as Voyage3LiteSchema, Dt as Voyage3Literal, an as Voyage3Options, Vt as Voyage3Schema, Ie as VoyageCode2, _t as VoyageCode2Literal, Qo as VoyageCode2Options, Pt as VoyageCode2Schema, Be as VoyageFinance2, Lt as VoyageFinance2Literal, on as VoyageFinance2Options, Bt as VoyageFinance2Schema, je as VoyageLaw2, wt as VoyageLaw2Literal, en as VoyageLaw2Options, qt as VoyageLaw2Schema, Le as VoyageMultilingual2, It as VoyageMultilingual2Literal, tn as VoyageMultilingual2Options, jt as VoyageMultilingual2Schema, ht as encodingFormat, yt as inputType, pt as maxTokens, mt as stop, dt as temperature, gt as toolChoice, ut as topK, ct as topP, ft as truncation };
17
15
  //# sourceMappingURL=index.mjs.map
18
16
  //# sourceMappingURL=index.mjs.map