@adaline/openai 0.20.0 → 0.21.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.js CHANGED
@@ -4,24 +4,24 @@ var zod = require('zod');
4
4
  var provider = require('@adaline/provider');
5
5
  var types = require('@adaline/types');
6
6
 
7
- var Nt=Object.defineProperty,$t=Object.defineProperties;var Ut=Object.getOwnPropertyDescriptors;var No=Object.getOwnPropertySymbols;var Ht=Object.prototype.hasOwnProperty,Vt=Object.prototype.propertyIsEnumerable;var Kt=(s,e)=>(e=Symbol[s])?e:Symbol.for("Symbol."+s);var $o=(s,e,t)=>e in s?Nt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,M=(s,e)=>{for(var t in e||(e={}))Ht.call(e,t)&&$o(s,t,e[t]);if(No)for(var t of No(e))Vt.call(e,t)&&$o(s,t,e[t]);return s},G=(s,e)=>$t(s,Ut(e));var S=(s,e,t)=>new Promise((o,n)=>{var a=l=>{try{i(t.next(l));}catch(h){n(h);}},m=l=>{try{i(t.throw(l));}catch(h){n(h);}},i=l=>l.done?o(l.value):Promise.resolve(l.value).then(a,m);i((t=t.apply(s,e)).next());}),Jt=function(s,e){this[0]=s,this[1]=e;},Y=(s,e,t)=>{var o=(m,i,l,h)=>{try{var d=t[m](i),T=(i=d.value)instanceof Jt,_=d.done;Promise.resolve(T?i[0]:i).then(C=>T?o(m==="return"?m:"next",i[1]?{done:C.done,value:C.value}:C,l,h):l({value:C,done:_})).catch(C=>o("throw",C,l,h));}catch(C){h(C);}},n=m=>a[m]=i=>new Promise((l,h)=>o(m,i,l,h)),a={};return t=t.apply(s,e),a[Kt("asyncIterator")]=()=>a,n("next"),n("throw"),n("return"),a};var Le=provider.RangeConfigItem({param:"temperature",title:provider.CHAT_CONFIG.TEMPERATURE.title,description:provider.CHAT_CONFIG.TEMPERATURE.description,min:0,max:2,step:.01,default:1}),je=s=>provider.RangeConfigItem({param:"max_tokens",title:provider.CHAT_CONFIG.MAX_TOKENS.title,description:provider.CHAT_CONFIG.MAX_TOKENS.description,min:0,max:s,step:1,default:0}),ze=s=>provider.MultiStringConfigItem({param:"stop",title:provider.CHAT_CONFIG.STOP(s).title,description:provider.CHAT_CONFIG.STOP(s).description,max:s}),Be=provider.RangeConfigItem({param:"top_p",title:provider.CHAT_CONFIG.TOP_P.title,description:provider.CHAT_CONFIG.TOP_P.description,min:0,max:1,step:.01,default:1}),Fe=provider.RangeConfigItem({param:"frequency_penalty",title:provider.CHAT_CONFIG.FREQUENCY_PENALTY.title,description:provider.CHAT_CONFIG.FREQUENCY_PENALTY.description,min:-2,max:2,step:.01,default:0}),De=provider.RangeConfigItem({param:"presence_penalty",title:provider.CHAT_CONFIG.PRESENCE_PENALTY.title,description:provider.CHAT_CONFIG.PRESENCE_PENALTY.description,min:-2,max:2,step:.01,default:0}),Ne=provider.RangeConfigItem({param:"seed",title:provider.CHAT_CONFIG.SEED.title,description:provider.CHAT_CONFIG.SEED.description,min:0,max:1e6,step:1,default:0}),$e=provider.SelectBooleanConfigItem({param:"logprobs",title:provider.CHAT_CONFIG.LOG_PROBS.title,description:provider.CHAT_CONFIG.LOG_PROBS.description,default:!1}),Ue=provider.RangeConfigItem({param:"top_logprobs",title:provider.CHAT_CONFIG.TOP_LOG_PROBS.title,description:provider.CHAT_CONFIG.TOP_LOG_PROBS.description,min:0,max:20,step:1,default:0}),He=provider.SelectStringConfigItem({param:"tool_choice",title:"Tool choice",description:"Controls which (if any) tool is called by the model. 'none' means the model will not call a function. 'auto' means the model can pick between generating a message or calling a tool.",default:"auto",choices:["auto","required","none"]});var D=(s,e)=>zod.z.object({temperature:Le.schema,maxTokens:je(s).schema,stop:ze(e).schema,topP:Be.schema,frequencyPenalty:Fe.schema,presencePenalty:De.schema,seed:Ne.schema.transform(t=>t===0?void 0:t),logProbs:$e.schema,topLogProbs:Ue.schema,toolChoice:He.schema}),N=(s,e)=>({temperature:Le.def,maxTokens:je(s).def,stop:ze(e).def,topP:Be.def,frequencyPenalty:Fe.def,presencePenalty:De.def,seed:Ne.def,logProbs:$e.def,topLogProbs:Ue.def,toolChoice:He.def});var Uo=provider.ObjectSchemaConfigItem({param:"response_schema",title:provider.CHAT_CONFIG.RESPONSE_SCHEMA.title,description:provider.CHAT_CONFIG.RESPONSE_SCHEMA.description,objectSchema:types.ResponseSchema}),Ho=provider.SelectStringConfigItem({param:"response_format",title:provider.CHAT_CONFIG.RESPONSE_FORMAT_WITH_SCHEMA.title,description:provider.CHAT_CONFIG.RESPONSE_FORMAT_WITH_SCHEMA.description,default:"text",choices:["text","json_object","json_schema"]}),Q=(s,e)=>G(M({},N(s,e)),{responseFormat:Ho.def,responseSchema:Uo.def}),Z=(s,e)=>D(s,e).extend({responseFormat:Ho.schema,responseSchema:Uo.schema});var Ko=provider.RangeConfigItem({param:"temperature",title:provider.CHAT_CONFIG.TEMPERATURE.title,description:provider.CHAT_CONFIG.TEMPERATURE.description,min:1,max:1,step:.01,default:1}),Jo=s=>provider.RangeConfigItem({param:"max_completion_tokens",title:provider.CHAT_CONFIG.MAX_TOKENS.title,description:provider.CHAT_CONFIG.MAX_TOKENS.description,min:0,max:s,step:1,default:0}),Wo=(s,e)=>G(M({},Q(s,e)),{temperature:Ko.def,maxTokens:Jo(s).def}),Yo=(s,e)=>Z(s,e).extend({temperature:Ko.schema,maxTokens:Jo(s).schema});var Qo=provider.SelectStringConfigItem({param:"response_format",title:provider.CHAT_CONFIG.RESPONSE_FORMAT.title,description:provider.CHAT_CONFIG.RESPONSE_FORMAT.description,default:"text",choices:["text","json_object"]}),Zo=(s,e)=>G(M({},N(s,e)),{responseFormat:Qo.def}),et=(s,e)=>D(s,e).extend({responseFormat:Qo.schema});var Ve=provider.SelectStringConfigItem({param:"encoding_format",title:"Encoding format",description:"Select the encoding format for the word embedding.",default:"float",choices:["float","base64"]}),Ke=s=>provider.RangeConfigItem({param:"dimensions",title:"Dimensions",description:"Select the number of dimensions for the word embedding.",min:1,max:s,step:1,default:s});var oe=()=>zod.z.object({encodingFormat:Ve.schema}),te=()=>({encodingFormat:Ve.def});var ot=s=>oe().extend({dimensions:Ke(s).schema}),tt=s=>G(M({},te()),{dimensions:Ke(s).def});var c={base:(s,e)=>({def:N(s,e),schema:D(s,e)}),responseFormat:(s,e)=>({def:Zo(s,e),schema:et(s,e)}),responseSchema:(s,e)=>({def:Q(s,e),schema:Z(s,e)}),oSeries:(s,e)=>({def:Wo(s,e),schema:Yo(s,e)})},v={base:()=>({def:te(),schema:oe()}),dimensions:s=>({def:tt(s),schema:ot(s)})};var g=zod.z.enum([types.SystemRoleLiteral,types.UserRoleLiteral,types.AssistantRoleLiteral,types.ToolRoleLiteral]),y={system:types.SystemRoleLiteral,user:types.UserRoleLiteral,assistant:types.AssistantRoleLiteral,tool:types.ToolRoleLiteral},ae=zod.z.enum([types.UserRoleLiteral,types.AssistantRoleLiteral]),ie={user:types.UserRoleLiteral,assistant:types.AssistantRoleLiteral};var E=[types.TextModalityLiteral,types.ImageModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],x=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]),pe=[types.TextModalityLiteral],me=zod.z.enum([types.TextModalityLiteral]),P=[types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],I=zod.z.enum([types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]);var de=zod.z.object({token:zod.z.string(),logprob:zod.z.number(),bytes:zod.z.array(zod.z.number()).nullable()}),rt=zod.z.object({content:zod.z.array(de.extend({top_logprobs:zod.z.array(de)})).nullable().optional(),refusal:zod.z.array(de.extend({top_logprobs:zod.z.array(de)})).nullable().optional()}).nullable(),is=zod.z.array(zod.z.object({id:zod.z.string().min(1),type:zod.z.enum(["function"]),function:zod.z.object({name:zod.z.string(),arguments:zod.z.string()})})),lt=zod.z.object({id:zod.z.string(),object:zod.z.literal("chat.completion"),created:zod.z.number(),model:zod.z.string(),system_fingerprint:zod.z.string().nullable(),choices:zod.z.array(zod.z.object({index:zod.z.number(),message:zod.z.object({role:zod.z.string(),content:zod.z.string().nullable().optional(),tool_calls:is.optional(),refusal:zod.z.string().nullable().optional()}),logprobs:rt.optional(),finish_reason:zod.z.string()})),usage:zod.z.object({prompt_tokens:zod.z.number(),completion_tokens:zod.z.number(),total_tokens:zod.z.number()})}),rs=zod.z.array(zod.z.object({index:zod.z.number().int(),id:zod.z.string().min(1).optional(),type:zod.z.enum(["function"]).optional(),function:zod.z.object({name:zod.z.string().min(1).optional(),arguments:zod.z.string().optional()}).optional()})),pt=zod.z.object({id:zod.z.string(),object:zod.z.string(),created:zod.z.number(),model:zod.z.string(),system_fingerprint:zod.z.string().nullable(),choices:zod.z.array(zod.z.object({index:zod.z.number(),delta:zod.z.object({content:zod.z.string().nullable().optional(),tool_calls:rs.optional(),refusal:zod.z.string().nullable().optional()}).or(zod.z.object({})),logprobs:rt,finish_reason:zod.z.string().nullable()})),usage:zod.z.object({prompt_tokens:zod.z.number(),completion_tokens:zod.z.number(),total_tokens:zod.z.number()}).nullable().optional()});var ls=zod.z.object({type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1).optional(),strict:zod.z.boolean().optional(),parameters:zod.z.any()})}),ps=zod.z.enum(["none","auto","required"]),ms=zod.z.object({type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1)})}),ds=zod.z.object({type:zod.z.enum(["text","json_object"])}).or(zod.z.object({type:zod.z.literal("json_schema"),json_schema:zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1).optional(),strict:zod.z.boolean().optional(),schema:zod.z.any()})})),We=zod.z.object({text:zod.z.string().min(1),type:zod.z.literal("text")}),cs=zod.z.object({type:zod.z.literal("image_url"),image_url:zod.z.object({url:zod.z.string().url().min(1),detail:zod.z.enum(["low","high","auto"]).optional()})}),hs=zod.z.object({id:zod.z.string().min(1),type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1),arguments:zod.z.string().min(1)})}),us=zod.z.object({role:zod.z.literal("system"),content:zod.z.string().min(1).or(zod.z.array(We).min(1))}),fs=zod.z.object({role:zod.z.literal("user"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([We,cs])).min(1))}),Ts=zod.z.object({role:zod.z.literal("assistant"),content:zod.z.string().min(1).or(zod.z.array(We).min(1)).optional(),tool_calls:zod.z.array(hs).min(1).optional()}),_s=zod.z.object({role:zod.z.literal("tool"),tool_call_id:zod.z.string().min(1),content:zod.z.string().min(1)}),gs=zod.z.union([us,fs,Ts,_s]),ce=zod.z.object({model:zod.z.string().min(1).optional(),messages:zod.z.array(gs).min(1),frequency_penalty:zod.z.number().min(-2).max(2).nullable().optional(),logprobs:zod.z.boolean().nullable().optional(),top_logprobs:zod.z.number().min(0).max(20).nullable().optional(),max_tokens:zod.z.number().min(0).nullable().optional(),presence_penalty:zod.z.number().min(-2).max(2).nullable().optional(),response_format:ds.optional(),seed:zod.z.number().nullable().optional(),stop:zod.z.string().or(zod.z.array(zod.z.string()).max(4)).nullable().optional(),temperature:zod.z.number().min(0).max(2).nullable().optional(),top_p:zod.z.number().min(0).max(1).nullable().optional(),tools:zod.z.array(ls).optional(),tool_choice:ps.or(ms).optional()});var mt=ce.omit({max_tokens:!0}).extend({max_completion_tokens:zod.z.number().min(0).nullable().optional()});var Ms="openai",j=class{constructor(){this.version="v1";this.name=Ms;this.chatModelFactories={[eo]:{model:fe,modelOptions:ut,modelSchema:oo},[Ye]:{model:he,modelOptions:ct,modelSchema:Xe},[Qe]:{model:ue,modelOptions:ht,modelSchema:Ze},[to]:{model:Te,modelOptions:ft,modelSchema:so},[no]:{model:_e,modelOptions:Tt,modelSchema:ao},[io]:{model:ge,modelOptions:_t,modelSchema:ro},[lo]:{model:ye,modelOptions:gt,modelSchema:po},[mo]:{model:Me,modelOptions:yt,modelSchema:co},[ho]:{model:Ce,modelOptions:Mt,modelSchema:uo},[fo]:{model:be,modelOptions:Ct,modelSchema:To},[_o]:{model:Oe,modelOptions:bt,modelSchema:go},[yo]:{model:Pe,modelOptions:Ot,modelSchema:Mo},[Co]:{model:Ie,modelOptions:Pt,modelSchema:bo},[Oo]:{model:Se,modelOptions:It,modelSchema:Po},[Io]:{model:Ee,modelOptions:St,modelSchema:So},[Eo]:{model:xe,modelOptions:Et,modelSchema:xo},[Ro]:{model:Re,modelOptions:xt,modelSchema:Ao}};this.embeddingModelFactories={[wo]:{model:Ae,modelOptions:Rt,modelSchema:Go},[vo]:{model:we,modelOptions:At,modelSchema:qo},[ko]:{model:Ge,modelOptions:wt,modelSchema:Lo}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((e,t)=>(e[t]=this.chatModelFactories[t].modelSchema,e),{})}chatModel(e){let t=e.modelName;if(!(t in this.chatModelFactories))throw new provider.ProviderError({info:`OpenAI chat model: ${t} not found`,cause:new Error(`OpenAI chat model: ${t} not found, available chat models:
8
- [${this.chatModelLiterals().join(", ")}]`)});let o=this.chatModelFactories[t].model,n=this.chatModelFactories[t].modelOptions.parse(e);return new o(n)}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((e,t)=>(e[t]=this.embeddingModelFactories[t].modelSchema,e),{})}embeddingModel(e){let t=e.modelName;if(!(t in this.embeddingModelFactories))throw new provider.ProviderError({info:`OpenAI embedding model: ${t} not found`,cause:new Error(`OpenAI embedding model: ${t} not found, available embedding models:
9
- [${this.embeddingModelLiterals().join(", ")}]`)});let o=this.embeddingModelFactories[t].model,n=this.embeddingModelFactories[t].modelOptions.parse(e);return new o(n)}};j.baseUrl="https://api.openai.com/v1";var u=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),completeChatUrl:zod.z.string().url().optional(),streamChatUrl:zod.z.string().url().optional(),organization:zod.z.string().optional()}),f=class{constructor(e,t){this.version="v1";let o=u.parse(t);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash(o.baseUrl||j.baseUrl),this.streamChatUrl=provider.urlWithoutTrailingSlash(o.streamChatUrl||`${this.baseUrl}/chat/completions`),this.completeChatUrl=provider.urlWithoutTrailingSlash(o.completeChatUrl||`${this.baseUrl}/chat/completions`),this.organization=o.organization;}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return M({Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},this.organization?{"OpenAI-Organization":this.organization}:{})}getDefaultParams(){return {model:this.modelName}}getRetryDelay(e){let t=i=>{let l=/(\d+)(h|m|s|ms)/g,h={h:36e5,m:6e4,s:1e3,ms:1},d,T=0;for(;(d=l.exec(i))!==null;){let _=parseInt(d[1]),C=d[2];T+=_*h[C];}return T},o=0,n=0,a=!0;e["x-ratelimit-reset-requests"]&&(o=t(e["x-ratelimit-reset-requests"])),e["x-ratelimit-reset-tokens"]&&(n=t(e["x-ratelimit-reset-tokens"]));let m=Math.max(o,n);return {shouldRetry:a,delayMs:m}}getTokenCount(e){return e.reduce((t,o)=>t+o.content.map(n=>n.modality==="text"?n.value:"").join(" ").length,0)}transformModelRequest(e){let t=ce.safeParse(e);if(!t.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:t.error});let o=t.data,n=o.model;if(o.tool_choice&&(!o.tools||o.tools.length===0))throw new provider.InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let a={};o.response_format&&(a.responseFormat=o.response_format.type,o.response_format.type==="json_schema"&&(a.responseSchema={name:o.response_format.json_schema.name,description:o.response_format.json_schema.description||"",strict:o.response_format.json_schema.strict,schema:o.response_format.json_schema.schema})),o.tool_choice&&(typeof o.tool_choice=="string"?a.toolChoice=o.tool_choice:a.toolChoice=o.tool_choice.function.name),a.seed=o.seed,a.maxTokens=o.max_tokens,a.temperature=o.temperature,a.topP=o.top_p,a.presencePenalty=o.presence_penalty,a.frequencyPenalty=o.frequency_penalty,a.stop=o.stop,a.logProbs=o.logprobs,a.topLogProbs=o.top_logprobs;let m=types.Config().parse(provider.removeUndefinedEntries(a)),i=[],l={};o.messages.forEach(d=>{let T=d.role;switch(T){case"system":{let _=d.content;if(typeof _=="string")i.push({role:T,content:[{modality:types.TextModalityLiteral,value:_}]});else {let C=_.map(O=>({modality:types.TextModalityLiteral,value:O.text}));i.push({role:T,content:C});}}break;case"user":{let _=d.content;if(typeof _=="string")i.push({role:T,content:[{modality:types.TextModalityLiteral,value:_}]});else {let C=_.map(O=>O.type==="text"?{modality:types.TextModalityLiteral,value:O.text}:O.image_url.url.startsWith("data:")?{modality:types.ImageModalityLiteral,detail:O.image_url.detail||"auto",value:{type:types.Base64ImageContentTypeLiteral,base64:O.image_url.url,media_type:provider.getMimeTypeFromBase64(O.image_url.url)}}:{modality:types.ImageModalityLiteral,detail:O.image_url.detail||"auto",value:{type:types.UrlImageContentTypeLiteral,url:O.image_url.url}});i.push({role:T,content:C});}}break;case"assistant":{let _=[];if(!d.content&&!d.tool_calls)throw new provider.InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("one of'content' or 'tool_calls' must be provided")});if(d.content){let C=d.content;typeof C=="string"?_.push({modality:types.TextModalityLiteral,value:C}):C.forEach(O=>{_.push({modality:types.TextModalityLiteral,value:O.text});});}d.tool_calls&&d.tool_calls.forEach((O,Dt)=>{let ke={modality:types.ToolCallModalityLiteral,id:O.id,index:Dt,name:O.function.name,arguments:O.function.arguments};_.push(ke),l[ke.id]=ke;}),i.push({role:T,content:_});}break;case"tool":{let _=d;i.push({role:T,content:[{modality:types.ToolResponseModalityLiteral,id:_.tool_call_id,index:l[_.tool_call_id].index,name:l[_.tool_call_id].name,data:_.content}]});}break}});let h=[];return o.tools&&o.tools.forEach(d=>{h.push({type:"function",definition:{schema:{name:d.function.name,description:d.function.description||"",strict:d.function.strict,parameters:d.function.parameters}}});}),{modelName:n,config:m,messages:i,tools:h.length>0?h:void 0}}transformConfig(e,t,o){let n=e.toolChoice;delete e.toolChoice;let a=this.modelSchema.config.schema.safeParse(e);if(!a.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:a.error});let m=a.data;n!==void 0&&(m.toolChoice=n),Object.keys(m).forEach(l=>{if(!(l in this.modelSchema.config.def))throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${l}',
7
+ var Nt=Object.defineProperty,$t=Object.defineProperties;var Ut=Object.getOwnPropertyDescriptors;var No=Object.getOwnPropertySymbols;var Ht=Object.prototype.hasOwnProperty,Vt=Object.prototype.propertyIsEnumerable;var Kt=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n);var $o=(n,e,t)=>e in n?Nt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,M=(n,e)=>{for(var t in e||(e={}))Ht.call(e,t)&&$o(n,t,e[t]);if(No)for(var t of No(e))Vt.call(e,t)&&$o(n,t,e[t]);return n},G=(n,e)=>$t(n,Ut(e));var S=(n,e,t)=>new Promise((o,s)=>{var a=l=>{try{i(t.next(l));}catch(h){s(h);}},m=l=>{try{i(t.throw(l));}catch(h){s(h);}},i=l=>l.done?o(l.value):Promise.resolve(l.value).then(a,m);i((t=t.apply(n,e)).next());}),Jt=function(n,e){this[0]=n,this[1]=e;},Y=(n,e,t)=>{var o=(m,i,l,h)=>{try{var d=t[m](i),T=(i=d.value)instanceof Jt,_=d.done;Promise.resolve(T?i[0]:i).then(C=>T?o(m==="return"?m:"next",i[1]?{done:C.done,value:C.value}:C,l,h):l({value:C,done:_})).catch(C=>o("throw",C,l,h));}catch(C){h(C);}},s=m=>a[m]=i=>new Promise((l,h)=>o(m,i,l,h)),a={};return t=t.apply(n,e),a[Kt("asyncIterator")]=()=>a,s("next"),s("throw"),s("return"),a};var Le=provider.RangeConfigItem({param:"temperature",title:provider.CHAT_CONFIG.TEMPERATURE.title,description:provider.CHAT_CONFIG.TEMPERATURE.description,min:0,max:2,step:.01,default:1}),je=n=>provider.RangeConfigItem({param:"max_tokens",title:provider.CHAT_CONFIG.MAX_TOKENS.title,description:provider.CHAT_CONFIG.MAX_TOKENS.description,min:0,max:n,step:1,default:0}),ze=n=>provider.MultiStringConfigItem({param:"stop",title:provider.CHAT_CONFIG.STOP(n).title,description:provider.CHAT_CONFIG.STOP(n).description,max:n}),Be=provider.RangeConfigItem({param:"top_p",title:provider.CHAT_CONFIG.TOP_P.title,description:provider.CHAT_CONFIG.TOP_P.description,min:0,max:1,step:.01,default:1}),Fe=provider.RangeConfigItem({param:"frequency_penalty",title:provider.CHAT_CONFIG.FREQUENCY_PENALTY.title,description:provider.CHAT_CONFIG.FREQUENCY_PENALTY.description,min:-2,max:2,step:.01,default:0}),De=provider.RangeConfigItem({param:"presence_penalty",title:provider.CHAT_CONFIG.PRESENCE_PENALTY.title,description:provider.CHAT_CONFIG.PRESENCE_PENALTY.description,min:-2,max:2,step:.01,default:0}),Ne=provider.RangeConfigItem({param:"seed",title:provider.CHAT_CONFIG.SEED.title,description:provider.CHAT_CONFIG.SEED.description,min:0,max:1e6,step:1,default:0}),$e=provider.SelectBooleanConfigItem({param:"logprobs",title:provider.CHAT_CONFIG.LOG_PROBS.title,description:provider.CHAT_CONFIG.LOG_PROBS.description,default:!1}),Ue=provider.RangeConfigItem({param:"top_logprobs",title:provider.CHAT_CONFIG.TOP_LOG_PROBS.title,description:provider.CHAT_CONFIG.TOP_LOG_PROBS.description,min:0,max:20,step:1,default:0}),He=provider.SelectStringConfigItem({param:"tool_choice",title:"Tool choice",description:"Controls which (if any) tool is called by the model. 'none' means the model will not call a function. 'auto' means the model can pick between generating a message or calling a tool.",default:"auto",choices:["auto","required","none"]});var F=(n,e)=>zod.z.object({temperature:Le.schema,maxTokens:je(n).schema,stop:ze(e).schema,topP:Be.schema,frequencyPenalty:Fe.schema,presencePenalty:De.schema,seed:Ne.schema.transform(t=>t===0?void 0:t),logProbs:$e.schema,topLogProbs:Ue.schema,toolChoice:He.schema}),D=(n,e)=>({temperature:Le.def,maxTokens:je(n).def,stop:ze(e).def,topP:Be.def,frequencyPenalty:Fe.def,presencePenalty:De.def,seed:Ne.def,logProbs:$e.def,topLogProbs:Ue.def,toolChoice:He.def});var Uo=provider.ObjectSchemaConfigItem({param:"response_schema",title:provider.CHAT_CONFIG.RESPONSE_SCHEMA.title,description:provider.CHAT_CONFIG.RESPONSE_SCHEMA.description,objectSchema:types.ResponseSchema}),Ho=provider.SelectStringConfigItem({param:"response_format",title:provider.CHAT_CONFIG.RESPONSE_FORMAT_WITH_SCHEMA.title,description:provider.CHAT_CONFIG.RESPONSE_FORMAT_WITH_SCHEMA.description,default:"text",choices:["text","json_object","json_schema"]}),Q=(n,e)=>G(M({},D(n,e)),{responseFormat:Ho.def,responseSchema:Uo.def}),Z=(n,e)=>F(n,e).extend({responseFormat:Ho.schema,responseSchema:Uo.schema});var Ko=provider.RangeConfigItem({param:"temperature",title:provider.CHAT_CONFIG.TEMPERATURE.title,description:provider.CHAT_CONFIG.TEMPERATURE.description,min:1,max:1,step:.01,default:1}),Jo=n=>provider.RangeConfigItem({param:"max_completion_tokens",title:provider.CHAT_CONFIG.MAX_TOKENS.title,description:provider.CHAT_CONFIG.MAX_TOKENS.description,min:0,max:n,step:1,default:0}),Wo=(n,e)=>G(M({},Q(n,e)),{temperature:Ko.def,maxTokens:Jo(n).def}),Yo=(n,e)=>Z(n,e).extend({temperature:Ko.schema,maxTokens:Jo(n).schema});var Qo=provider.SelectStringConfigItem({param:"response_format",title:provider.CHAT_CONFIG.RESPONSE_FORMAT.title,description:provider.CHAT_CONFIG.RESPONSE_FORMAT.description,default:"text",choices:["text","json_object"]}),Zo=(n,e)=>G(M({},D(n,e)),{responseFormat:Qo.def}),et=(n,e)=>F(n,e).extend({responseFormat:Qo.schema});var Ve=provider.SelectStringConfigItem({param:"encoding_format",title:"Encoding format",description:"Select the encoding format for the word embedding.",default:"float",choices:["float","base64"]}),Ke=n=>provider.RangeConfigItem({param:"dimensions",title:"Dimensions",description:"Select the number of dimensions for the word embedding.",min:1,max:n,step:1,default:n});var oe=()=>zod.z.object({encodingFormat:Ve.schema}),te=()=>({encodingFormat:Ve.def});var ot=n=>oe().extend({dimensions:Ke(n).schema}),tt=n=>G(M({},te()),{dimensions:Ke(n).def});var c={base:(n,e)=>({def:D(n,e),schema:F(n,e)}),responseFormat:(n,e)=>({def:Zo(n,e),schema:et(n,e)}),responseSchema:(n,e)=>({def:Q(n,e),schema:Z(n,e)}),oSeries:(n,e)=>({def:Wo(n,e),schema:Yo(n,e)})},v={base:()=>({def:te(),schema:oe()}),dimensions:n=>({def:tt(n),schema:ot(n)})};var g=zod.z.enum([types.SystemRoleLiteral,types.UserRoleLiteral,types.AssistantRoleLiteral,types.ToolRoleLiteral]),y={system:types.SystemRoleLiteral,user:types.UserRoleLiteral,assistant:types.AssistantRoleLiteral,tool:types.ToolRoleLiteral},ae=zod.z.enum([types.UserRoleLiteral,types.AssistantRoleLiteral]),ie={user:types.UserRoleLiteral,assistant:types.AssistantRoleLiteral};var E=[types.TextModalityLiteral,types.ImageModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],x=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]),pe=[types.TextModalityLiteral],me=zod.z.enum([types.TextModalityLiteral]),P=[types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],I=zod.z.enum([types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]);var de=zod.z.object({token:zod.z.string(),logprob:zod.z.number(),bytes:zod.z.array(zod.z.number()).nullable()}),rt=zod.z.object({content:zod.z.array(de.extend({top_logprobs:zod.z.array(de)})).nullable().optional(),refusal:zod.z.array(de.extend({top_logprobs:zod.z.array(de)})).nullable().optional()}).nullable(),rn=zod.z.array(zod.z.object({id:zod.z.string().min(1),type:zod.z.enum(["function"]),function:zod.z.object({name:zod.z.string(),arguments:zod.z.string()})})),lt=zod.z.object({id:zod.z.string(),object:zod.z.literal("chat.completion"),created:zod.z.number(),model:zod.z.string(),system_fingerprint:zod.z.string().nullable(),choices:zod.z.array(zod.z.object({index:zod.z.number(),message:zod.z.object({role:zod.z.string(),content:zod.z.string().nullable().optional(),tool_calls:rn.optional(),refusal:zod.z.string().nullable().optional()}),logprobs:rt.optional(),finish_reason:zod.z.string()})),usage:zod.z.object({prompt_tokens:zod.z.number(),completion_tokens:zod.z.number(),total_tokens:zod.z.number()})}),ln=zod.z.array(zod.z.object({index:zod.z.number().int(),id:zod.z.string().min(1).optional(),type:zod.z.enum(["function"]).optional(),function:zod.z.object({name:zod.z.string().min(1).optional(),arguments:zod.z.string().optional()}).optional()})),pt=zod.z.object({id:zod.z.string(),object:zod.z.string(),created:zod.z.number(),model:zod.z.string(),system_fingerprint:zod.z.string().nullable(),choices:zod.z.array(zod.z.object({index:zod.z.number(),delta:zod.z.object({content:zod.z.string().nullable().optional(),tool_calls:ln.optional(),refusal:zod.z.string().nullable().optional()}).or(zod.z.object({})),logprobs:rt,finish_reason:zod.z.string().nullable()})),usage:zod.z.object({prompt_tokens:zod.z.number(),completion_tokens:zod.z.number(),total_tokens:zod.z.number()}).nullable().optional()});var pn=zod.z.object({type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1).optional(),strict:zod.z.boolean().optional(),parameters:zod.z.any()})}),mn=zod.z.enum(["none","auto","required"]),dn=zod.z.object({type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1)})}),cn=zod.z.object({type:zod.z.enum(["text","json_object"])}).or(zod.z.object({type:zod.z.literal("json_schema"),json_schema:zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1).optional(),strict:zod.z.boolean().optional(),schema:zod.z.any()})})),We=zod.z.object({text:zod.z.string().min(1),type:zod.z.literal("text")}),hn=zod.z.object({type:zod.z.literal("image_url"),image_url:zod.z.object({url:zod.z.string().url().min(1),detail:zod.z.enum(["low","high","auto"]).optional()})}),un=zod.z.object({id:zod.z.string().min(1),type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1),arguments:zod.z.string().min(1)})}),fn=zod.z.object({role:zod.z.literal("system"),content:zod.z.string().min(1).or(zod.z.array(We).min(1))}),Tn=zod.z.object({role:zod.z.literal("user"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([We,hn])).min(1))}),_n=zod.z.object({role:zod.z.literal("assistant"),content:zod.z.string().min(1).or(zod.z.array(We).min(1)).optional(),tool_calls:zod.z.array(un).min(1).optional()}),gn=zod.z.object({role:zod.z.literal("tool"),tool_call_id:zod.z.string().min(1),content:zod.z.string().min(1)}),yn=zod.z.union([fn,Tn,_n,gn]),ce=zod.z.object({model:zod.z.string().min(1).optional(),messages:zod.z.array(yn).min(1),frequency_penalty:zod.z.number().min(-2).max(2).nullable().optional(),logprobs:zod.z.boolean().nullable().optional(),top_logprobs:zod.z.number().min(0).max(20).nullable().optional(),max_tokens:zod.z.number().min(0).nullable().optional(),presence_penalty:zod.z.number().min(-2).max(2).nullable().optional(),response_format:cn.optional(),seed:zod.z.number().nullable().optional(),stop:zod.z.string().or(zod.z.array(zod.z.string()).max(4)).nullable().optional(),temperature:zod.z.number().min(0).max(2).nullable().optional(),top_p:zod.z.number().min(0).max(1).nullable().optional(),tools:zod.z.array(pn).optional(),tool_choice:mn.or(dn).optional()});var mt=ce.omit({max_tokens:!0}).extend({max_completion_tokens:zod.z.number().min(0).nullable().optional()});var Cn="openai",j=class{constructor(){this.version="v1";this.name=Cn;this.chatModelFactories={[eo]:{model:fe,modelOptions:ut,modelSchema:oo},[Ye]:{model:he,modelOptions:ct,modelSchema:Xe},[Qe]:{model:ue,modelOptions:ht,modelSchema:Ze},[to]:{model:Te,modelOptions:ft,modelSchema:no},[so]:{model:_e,modelOptions:Tt,modelSchema:ao},[io]:{model:ge,modelOptions:_t,modelSchema:ro},[lo]:{model:ye,modelOptions:gt,modelSchema:po},[mo]:{model:Me,modelOptions:yt,modelSchema:co},[ho]:{model:Ce,modelOptions:Mt,modelSchema:uo},[fo]:{model:be,modelOptions:Ct,modelSchema:To},[_o]:{model:Oe,modelOptions:bt,modelSchema:go},[yo]:{model:Pe,modelOptions:Ot,modelSchema:Mo},[Co]:{model:Ie,modelOptions:Pt,modelSchema:bo},[Oo]:{model:Se,modelOptions:It,modelSchema:Po},[Io]:{model:Ee,modelOptions:St,modelSchema:So},[Eo]:{model:xe,modelOptions:Et,modelSchema:xo},[Ro]:{model:Re,modelOptions:xt,modelSchema:Ao}};this.embeddingModelFactories={[wo]:{model:Ae,modelOptions:Rt,modelSchema:Go},[vo]:{model:we,modelOptions:At,modelSchema:qo},[ko]:{model:Ge,modelOptions:wt,modelSchema:Lo}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((e,t)=>(e[t]=this.chatModelFactories[t].modelSchema,e),{})}chatModel(e){let t=e.modelName;if(!(t in this.chatModelFactories))throw new provider.ProviderError({info:`OpenAI chat model: ${t} not found`,cause:new Error(`OpenAI chat model: ${t} not found, available chat models:
8
+ [${this.chatModelLiterals().join(", ")}]`)});let o=this.chatModelFactories[t].model,s=this.chatModelFactories[t].modelOptions.parse(e);return new o(s)}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((e,t)=>(e[t]=this.embeddingModelFactories[t].modelSchema,e),{})}embeddingModel(e){let t=e.modelName;if(!(t in this.embeddingModelFactories))throw new provider.ProviderError({info:`OpenAI embedding model: ${t} not found`,cause:new Error(`OpenAI embedding model: ${t} not found, available embedding models:
9
+ [${this.embeddingModelLiterals().join(", ")}]`)});let o=this.embeddingModelFactories[t].model,s=this.embeddingModelFactories[t].modelOptions.parse(e);return new o(s)}};j.baseUrl="https://api.openai.com/v1";var u=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),completeChatUrl:zod.z.string().url().optional(),streamChatUrl:zod.z.string().url().optional(),organization:zod.z.string().optional()}),f=class{constructor(e,t){this.version="v1";let o=u.parse(t);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash(o.baseUrl||j.baseUrl),this.streamChatUrl=provider.urlWithoutTrailingSlash(o.streamChatUrl||`${this.baseUrl}/chat/completions`),this.completeChatUrl=provider.urlWithoutTrailingSlash(o.completeChatUrl||`${this.baseUrl}/chat/completions`),this.organization=o.organization;}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return M({Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},this.organization?{"OpenAI-Organization":this.organization}:{})}getDefaultParams(){return {model:this.modelName}}getRetryDelay(e){let t=i=>{let l=/(\d+)(h|m|s|ms)/g,h={h:36e5,m:6e4,s:1e3,ms:1},d,T=0;for(;(d=l.exec(i))!==null;){let _=parseInt(d[1]),C=d[2];T+=_*h[C];}return T},o=0,s=0,a=!0;e["x-ratelimit-reset-requests"]&&(o=t(e["x-ratelimit-reset-requests"])),e["x-ratelimit-reset-tokens"]&&(s=t(e["x-ratelimit-reset-tokens"]));let m=Math.max(o,s);return {shouldRetry:a,delayMs:m}}getTokenCount(e){return e.reduce((t,o)=>t+o.content.map(s=>s.modality==="text"?s.value:"").join(" ").length,0)}transformModelRequest(e){let t=ce.safeParse(e);if(!t.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:t.error});let o=t.data,s=o.model;if(o.tool_choice&&(!o.tools||o.tools.length===0))throw new provider.InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let a={};o.response_format&&(a.responseFormat=o.response_format.type,o.response_format.type==="json_schema"&&(a.responseSchema={name:o.response_format.json_schema.name,description:o.response_format.json_schema.description||"",strict:o.response_format.json_schema.strict,schema:o.response_format.json_schema.schema})),o.tool_choice&&(typeof o.tool_choice=="string"?a.toolChoice=o.tool_choice:a.toolChoice=o.tool_choice.function.name),a.seed=o.seed,a.maxTokens=o.max_tokens,a.temperature=o.temperature,a.topP=o.top_p,a.presencePenalty=o.presence_penalty,a.frequencyPenalty=o.frequency_penalty,a.stop=o.stop,a.logProbs=o.logprobs,a.topLogProbs=o.top_logprobs;let m=types.Config().parse(provider.removeUndefinedEntries(a)),i=[],l={};o.messages.forEach(d=>{let T=d.role;switch(T){case"system":{let _=d.content;if(typeof _=="string")i.push({role:T,content:[{modality:types.TextModalityLiteral,value:_}]});else {let C=_.map(O=>({modality:types.TextModalityLiteral,value:O.text}));i.push({role:T,content:C});}}break;case"user":{let _=d.content;if(typeof _=="string")i.push({role:T,content:[{modality:types.TextModalityLiteral,value:_}]});else {let C=_.map(O=>O.type==="text"?{modality:types.TextModalityLiteral,value:O.text}:O.image_url.url.startsWith("data:")?{modality:types.ImageModalityLiteral,detail:O.image_url.detail||"auto",value:{type:types.Base64ImageContentTypeLiteral,base64:O.image_url.url,media_type:provider.getMimeTypeFromBase64(O.image_url.url)}}:{modality:types.ImageModalityLiteral,detail:O.image_url.detail||"auto",value:{type:types.UrlImageContentTypeLiteral,url:O.image_url.url}});i.push({role:T,content:C});}}break;case"assistant":{let _=[];if(!d.content&&!d.tool_calls)throw new provider.InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("one of'content' or 'tool_calls' must be provided")});if(d.content){let C=d.content;typeof C=="string"?_.push({modality:types.TextModalityLiteral,value:C}):C.forEach(O=>{_.push({modality:types.TextModalityLiteral,value:O.text});});}d.tool_calls&&d.tool_calls.forEach((O,Dt)=>{let ke={modality:types.ToolCallModalityLiteral,id:O.id,index:Dt,name:O.function.name,arguments:O.function.arguments};_.push(ke),l[ke.id]=ke;}),i.push({role:T,content:_});}break;case"tool":{let _=d;i.push({role:T,content:[{modality:types.ToolResponseModalityLiteral,id:_.tool_call_id,index:l[_.tool_call_id].index,name:l[_.tool_call_id].name,data:_.content}]});}break}});let h=[];return o.tools&&o.tools.forEach(d=>{h.push({type:"function",definition:{schema:{name:d.function.name,description:d.function.description||"",strict:d.function.strict,parameters:d.function.parameters}}});}),{modelName:s,config:m,messages:i,tools:h.length>0?h:void 0}}transformConfig(e,t,o){let s=e.toolChoice;delete e.toolChoice;let a=this.modelSchema.config.schema.safeParse(e);if(!a.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:a.error});let m=a.data;s!==void 0&&(m.toolChoice=s),Object.keys(m).forEach(l=>{if(!(l in this.modelSchema.config.def))throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${l}',
10
10
  available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let i=Object.keys(m).reduce((l,h)=>{let d=this.modelSchema.config.def[h],T=d.param,_=m[h];return T==="max_tokens"&&d.type==="range"&&_===0?l[T]=d.max:l[T]=_,l},{});if(i.top_logprobs&&!i.logprobs)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'logprobs' must be 'true' when 'top_logprobs' is specified")});if("tool_choice"in i&&i.tool_choice!==void 0){let l=i.tool_choice;if(!o||o&&o.length===0)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(o&&o.length>0){let h=this.modelSchema.config.def.toolChoice;if(!h.choices.includes(l))if(o.map(d=>d.definition.schema.name).includes(l))i.tool_choice={type:"function",function:{name:l}};else throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`toolChoice : '${l}' is not part of provided 'tools' names or
11
- one of [${h.choices.join(", ")}]`)})}}if("response_format"in i&&i.response_format!==void 0){let l=i.response_format;if(l==="json_schema")if("response_schema"in i)i.response_format={type:"json_schema",json_schema:i.response_schema},delete i.response_schema;else throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'responseSchema' is required in config when 'responseFormat' is 'json_schema'")});else i.response_format={type:l};}return i}transformMessages(e){if(!e||e&&e.length===0)return {messages:[]};let t=e.map(n=>{let a=types.Message().safeParse(n);if(!a.success)throw new provider.InvalidMessagesError({info:"Invalid messages",cause:a.error});return a.data});return t.forEach(n=>{n.content.forEach(a=>{if(!this.modelSchema.modalities.includes(a.modality))throw new provider.InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${a.modality}',
12
- available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),t.forEach(n=>{if(!Object.keys(this.modelSchema.roles).includes(n.role))throw new provider.InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${n.role}',
13
- available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}),{messages:t.map(n=>{switch(n.role){case types.SystemRoleLiteral:{let a=[];return n.content.forEach(m=>{if(m.modality===types.TextModalityLiteral)a.push({type:"text",text:m.value});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${m.modality}'`)})}),{role:this.modelSchema.roles[n.role],content:a}}case types.AssistantRoleLiteral:{let a=[],m=[];return n.content.forEach(i=>{if(i.modality===types.TextModalityLiteral)a.push({type:"text",text:i.value});else if(i.modality===types.ToolCallModalityLiteral)m.push({id:i.id,type:"function",function:{name:i.name,arguments:i.arguments}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${i.modality}'`)})}),M({role:this.modelSchema.roles[n.role],content:a},m.length>0?{tool_calls:m}:{})}case types.UserRoleLiteral:{let a=[],m=[];n.content.forEach(l=>{if(l.modality===types.TextModalityLiteral)a.push({type:"text",text:l.value});else if(l.modality===types.ImageModalityLiteral)m.push({type:"image_url",image_url:{url:l.value.type==="url"?l.value.url:l.value.base64,detail:l.detail}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${l.modality}'`)})});let i=[...a,...m];return {role:this.modelSchema.roles[n.role],content:i}}case types.ToolRoleLiteral:{if(n.content.length!==1)throw new provider.InvalidMessagesError({info:`Invalid message for role : '${n.role}'`,cause:new Error(`role : '${n.role}' must have exactly one content item`)});if(n.content[0].modality!==types.ToolResponseModalityLiteral)throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' must have content with modality : '${types.ToolResponseModalityLiteral}'`)});let a=n.content[0];return {role:this.modelSchema.roles[n.role],tool_call_id:a.id,content:a.data}}default:throw new provider.InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${n.role}' is not supported,
14
- available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}})}}transformTools(e){if(!this.modelSchema.modalities.includes(types.ToolCallModalityLiteral))throw new provider.InvalidToolsError({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${types.ToolCallModalityLiteral}'`)});return !e||e&&e.length===0?{tools:[]}:{tools:e.map(n=>{let a=types.Tool().safeParse(n);if(!a.success)throw new provider.InvalidToolsError({info:"Invalid tools",cause:a.error});return a.data}).map(n=>({type:"function",function:n.definition.schema}))}}getCompleteChatUrl(e,t,o){return S(this,null,function*(){return new Promise(n=>{n(this.completeChatUrl);})})}getCompleteChatHeaders(e,t,o){return S(this,null,function*(){return new Promise(n=>{n(this.getDefaultHeaders());})})}getCompleteChatData(e,t,o){return S(this,null,function*(){let n=this.transformConfig(e,t,o),a=this.transformMessages(t);if(a.messages&&a.messages.length===0)throw new provider.InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let m=o?this.transformTools(o):{};return new Promise(i=>{i(M(M(M(M({},this.getDefaultParams()),n),a),m));})})}transformCompleteChatResponse(e){let t=lt.safeParse(e);if(t.success){if(t.data.choices.length===0)throw new provider.ModelResponseError({info:"Invalid response from model",cause:new Error(`No choices in response : ${JSON.stringify(t.data)}`)});let o=t.data,n=[],a=o.choices[0].message;a.content&&n.push(types.createTextMessage(types.AssistantRoleLiteral,a.content)),a.refusal&&n.push(types.createTextMessage(types.AssistantRoleLiteral,a.refusal)),a.tool_calls&&a.tool_calls.forEach((h,d)=>{n.push(types.createToolCallMessage(types.AssistantRoleLiteral,d,h.id,h.function.name,h.function.arguments));});let m={promptTokens:o.usage.prompt_tokens,completionTokens:o.usage.completion_tokens,totalTokens:o.usage.total_tokens},i=[],l=o.choices[0].logprobs;return l&&(l.content&&i.push(...l.content.map(h=>({token:h.token,logProb:h.logprob,bytes:h.bytes,topLogProbs:h.top_logprobs.map(d=>({token:d.token,logProb:d.logprob,bytes:d.bytes}))}))),l.refusal&&i.push(...l.refusal.map(h=>({token:h.token,logProb:h.logprob,bytes:h.bytes,topLogProbs:h.top_logprobs.map(d=>({token:d.token,logProb:d.logprob,bytes:d.bytes}))})))),{messages:n,usage:m,logProbs:i}}throw new provider.ModelResponseError({info:"Invalid response from model",cause:t.error})}getStreamChatUrl(e,t,o){return S(this,null,function*(){return new Promise(n=>{n(this.streamChatUrl);})})}getStreamChatHeaders(e,t,o){return S(this,null,function*(){return new Promise(n=>{n(this.getDefaultHeaders());})})}getStreamChatData(e,t,o){return S(this,null,function*(){let n=this.transformConfig(e,t,o),a=this.transformMessages(t);if(a.messages&&a.messages.length===0)throw new provider.InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let m=o?this.transformTools(o):{};return new Promise(i=>{i(M(M(M(M({stream:!0,stream_options:{include_usage:!0}},this.getDefaultParams()),n),a),m));})})}transformStreamChatResponseChunk(e,t){return Y(this,null,function*(){var n,a;let o=(t+e).split(`
15
- `).filter(m=>m.trim()!=="");for(let m of o){if(m==="data: [DONE]")return;if(m.startsWith("data: {")&&m.endsWith("}")){let i;try{i=JSON.parse(m.substring(6));}catch(h){throw new provider.ModelResponseError({info:"Malformed JSON received in stream",cause:new Error(`Malformed JSON received in stream : ${i}`)})}let l=pt.safeParse(i);if(l.success){let h={partialMessages:[]},d=l.data;if(d.choices.length>0){let T=d.choices[0].delta;if(T!==void 0&&Object.keys(T).length!==0){if("content"in T&&T.content!==null)h.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,T.content));else if("refusal"in T&&T.refusal!==null)h.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,T.refusal));else if("tool_calls"in T&&T.tool_calls!==void 0){let _=T.tool_calls.at(0);h.partialMessages.push(types.createPartialToolCallMessage(types.AssistantRoleLiteral,_.index,_.id,(n=_.function)==null?void 0:n.name,(a=_.function)==null?void 0:a.arguments));}}}d.usage&&(h.usage={promptTokens:d.usage.prompt_tokens,completionTokens:d.usage.completion_tokens,totalTokens:d.usage.total_tokens}),yield {partialResponse:h,buffer:t};}else throw new provider.ModelResponseError({info:"Invalid response from model",cause:l.error})}}})}};var H=class extends f{constructor(e,t){super(e,t);}transformModelRequest(e){let t=mt.safeParse(e);if(!t.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:t.error});let o=t.data,n=G(M({},o),{max_tokens:o.max_completion_tokens});return delete n.max_completion_tokens,super.transformModelRequest(n)}transformTools(e){throw new provider.ModelError({info:`Model: '${this.modelSchema.name}' does not support 'tools'.`,cause:new Error(`Model: '${this.modelSchema.name}' does not support 'tools'.`)})}getStreamChatUrl(e,t,o){return S(this,null,function*(){throw new provider.ModelError({info:`Model: '${this.modelSchema.name}' does not support streaming.`,cause:new Error(`Model: '${this.modelSchema.name}' does not support streaming.`)})})}getStreamChatHeaders(e,t,o){return S(this,null,function*(){throw new provider.ModelError({info:`Model: '${this.modelSchema.name}' does not support streaming.`,cause:new Error(`Model: '${this.modelSchema.name}' does not support streaming.`)})})}getStreamChatData(e,t,o){return S(this,null,function*(){throw new provider.ModelError({info:`Model: '${this.modelSchema.name}' does not support streaming.`,cause:new Error(`Model: '${this.modelSchema.name}' does not support streaming.`)})})}transformStreamChatResponseChunk(e,t){return Y(this,null,function*(){throw new provider.ModelError({info:`Model: '${this.modelSchema.name}' does not support streaming.`,cause:new Error(`Model: '${this.modelSchema.name}' does not support streaming.`)})})}};var Ye="gpt-3.5-turbo-0125",ks="The latest GPT-3.5 Turbo model with higher accuracy at responding in requested formats and a fix for a bug which caused a text encoding issue for non-English language function calls. Training data up to Sept 2021.",Xe=provider.ChatModelSchema(g,I).parse({name:Ye,description:ks,maxInputTokens:4092,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.responseFormat(4092,4).def,schema:c.responseFormat(4092,4).schema}}),ct=u,he=class extends f{constructor(e){super(Xe,e);}};var Qe="gpt-3.5-turbo-1106",js="The latest GPT-3.5 Turbo model with improved instruction following, JSON mode, reproducible outputs, parallel function calling, and more. Returns a maximum of 4,096 output tokens. Training data up to Sept 2021.",Ze=provider.ChatModelSchema(g,I).parse({name:Qe,description:js,maxInputTokens:4092,maxOutputTokens:16385,roles:y,modalities:P,config:{def:c.responseFormat(16385,4).def,schema:c.responseFormat(16385,4).schema}}),ht=u,ue=class extends f{constructor(e){super(Ze,e);}};var eo="gpt-3.5-turbo",Bs="Currently points to gpt-3.5-turbo-0125. Training data up to Sept 2021.",oo=provider.ChatModelSchema(g,I).parse({name:eo,description:Bs,maxInputTokens:4092,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.responseFormat(4092,4).def,schema:c.responseFormat(4092,4).schema}}),ut=u,fe=class extends f{constructor(e){super(oo,e);}};var to="gpt-4-0125-preview",Ds="The latest GPT-4 model intended to reduce cases of \u201Claziness\u201D where the model doesn\u2019t complete a task. Training data up to Apr 2023.",so=provider.ChatModelSchema(g,I).parse({name:to,description:Ds,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.base(4092,4).def,schema:c.base(4092,4).schema}}),ft=u,Te=class extends f{constructor(e){super(so,e);}};var no="gpt-4-0613",$s="Snapshot of gpt-4 from June 13th 2023 with improved function calling support. Training data up to Sept 2021.",ao=provider.ChatModelSchema(g,I).parse({name:no,description:$s,maxInputTokens:8192,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.base(4092,4).def,schema:c.base(4092,4).schema}}),Tt=u,_e=class extends f{constructor(e){super(ao,e);}};var io="gpt-4-1106-preview",Hs="GPT-4 Turbo model featuring improved instruction following, JSON mode, reproducible outputs, parallel function calling, and more. Returns a maximum of 4,096 output tokens. This preview model is not yet suited for production traffic. Training data up to Apr 2023.",ro=provider.ChatModelSchema(g,I).parse({name:io,description:Hs,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.base(4092,4).def,schema:c.base(4092,4).schema}}),_t=u,ge=class extends f{constructor(e){super(ro,e);}};var lo="gpt-4-turbo-2024-04-09",Ks="GPT-4 Turbo with Vision model. Vision requests can now use JSON mode and function calling. gpt-4-turbo currently points to this version. Training data up to Dec 2023.",po=provider.ChatModelSchema(g,x).parse({name:lo,description:Ks,maxInputTokens:128e3,maxOutputTokens:4096,roles:y,modalities:E,config:{def:c.responseFormat(4096,4).def,schema:c.responseFormat(4096,4).schema}}),gt=u,ye=class extends f{constructor(e){super(po,e);}};var mo="gpt-4-turbo-preview",Ws="Currently points to gpt-4-0125-preview. Training data up to Apr 2023.",co=provider.ChatModelSchema(g,I).parse({name:mo,description:Ws,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.responseFormat(4092,4).def,schema:c.responseFormat(4092,4).schema}}),yt=u,Me=class extends f{constructor(e){super(co,e);}};var ho="gpt-4-turbo",Xs="The latest GPT-4 Turbo model with vision capabilities. Vision requests can now use JSON mode and function calling. Currently points to gpt-4-turbo-2024-04-09. Training data up to Dec 2023.",uo=provider.ChatModelSchema(g,x).parse({name:ho,description:Xs,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:E,config:{def:c.responseFormat(4092,4).def,schema:c.responseFormat(4092,4).schema}}),Mt=u,Ce=class extends f{constructor(e){super(uo,e);}};var fo="gpt-4",Zs="Currently points to gpt-4-0613. Training data up to Sept 2021.",To=provider.ChatModelSchema(g,I).parse({name:fo,description:Zs,maxInputTokens:8192,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.base(4092,4).def,schema:c.base(4092,4).schema}}),Ct=u,be=class extends f{constructor(e){super(To,e);}};var _o="gpt-4o-2024-08-06",on="Latest snapshot of gpt-4o that supports Structured Outputs. Training data up to Oct 2023.",go=provider.ChatModelSchema(g,x).parse({name:_o,description:on,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:E,config:{def:c.responseSchema(4092,4).def,schema:c.responseSchema(4092,4).schema}}),bt=u,Oe=class extends f{constructor(e){super(go,e);}};var yo="gpt-4o-mini",sn="Most advanced, multimodal flagship model that is cheaper and faster than GPT-4 Turbo. Currently points to gpt-4o-2024-05-13. Training data up to Oct 2023.",Mo=provider.ChatModelSchema(g,x).parse({name:yo,description:sn,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:E,config:{def:c.responseSchema(4092,4).def,schema:c.responseSchema(4092,4).schema}}),Ot=u,Pe=class extends f{constructor(e){super(Mo,e);}};var Co="gpt-4o",an="Most advanced, multimodal flagship model that is cheaper and faster than GPT-4 Turbo. Currently points to gpt-4o-2024-05-13. Training data up to Oct 2023.",bo=provider.ChatModelSchema(g,x).parse({name:Co,description:an,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:E,config:{def:c.responseFormat(4092,4).def,schema:c.responseFormat(4092,4).schema}}),Pt=u,Ie=class extends f{constructor(e){super(bo,e);}};var Oo="gpt-4o-mini-2024-07-18",ln="Most advanced, multimodal flagship model that is cheaper and faster than GPT-4 Turbo. Currently points to gpt-4o-2024-05-13. Training data up to Oct 2023.",Po=provider.ChatModelSchema(g,x).parse({name:Oo,description:ln,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:E,config:{def:c.responseSchema(4092,4).def,schema:c.responseSchema(4092,4).schema}}),It=u,Se=class extends f{constructor(e){super(Po,e);}};var Io="gpt-4o-2024-05-13",mn="Latest snapshot of gpt-4o that supports Structured Outputs. Training data up to Oct 2023.",So=provider.ChatModelSchema(g,x).parse({name:Io,description:mn,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:E,config:{def:c.responseSchema(4092,4).def,schema:c.responseSchema(4092,4).schema}}),St=u,Ee=class extends f{constructor(e){super(So,e);}};var Eo="o1-mini",cn="Faster and cheaper reasoning model particularly good at coding, math, and science. Training data up to Oct 2023.",xo=provider.ChatModelSchema(ae,me).parse({name:Eo,description:cn,maxInputTokens:128e3,maxOutputTokens:4092,roles:ie,modalities:pe,config:{def:c.oSeries(4092,4).def,schema:c.oSeries(4092,4).schema}}),Et=u,xe=class extends H{constructor(e){super(xo,e);}};var Ro="o1-preview",un="Reasoning model designed to solve hard problems across domains. Training data up to Oct 2023.",Ao=provider.ChatModelSchema(ae,me).parse({name:Ro,description:un,maxInputTokens:128e3,maxOutputTokens:4092,roles:ie,modalities:pe,config:{def:c.oSeries(4092,4).def,schema:c.oSeries(4092,4).schema}}),xt=u,Re=class extends H{constructor(e){super(Ao,e);}};var V=[types.EmbeddingTextModalityLiteral,types.EmbeddingTokenModalityLiteral],K=zod.z.enum([types.EmbeddingTextModalityLiteral,types.EmbeddingTokenModalityLiteral]);var jt=zod.z.object({object:zod.z.literal("list"),model:zod.z.string(),data:zod.z.array(zod.z.object({index:zod.z.number(),object:zod.z.literal("embedding"),embedding:zod.z.array(zod.z.number()).or(zod.z.string().base64())})),usage:zod.z.object({prompt_tokens:zod.z.number().nonnegative(),total_tokens:zod.z.number().nonnegative()})});var Tn=zod.z.string().min(1).or(zod.z.array(zod.z.string().min(1)).min(1)).or(zod.z.array(zod.z.number().int().nonnegative()).min(1)).or(zod.z.array(zod.z.array(zod.z.number().int().nonnegative()).min(1)).min(1)),zt=zod.z.object({model:zod.z.string().min(1).optional(),input:Tn,encoding_format:zod.z.enum(["float","base64"]).optional(),dimensions:zod.z.number().int().min(1).optional()});var F=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),getEmbeddingsUrl:zod.z.string().url().optional()}),k=class{constructor(e,t){this.version="v1";let o=F.parse(t);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash(o.baseUrl||j.baseUrl),this.getEmbeddingsUrl=provider.urlWithoutTrailingSlash(o.getEmbeddingsUrl||`${this.baseUrl}/embeddings`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"}}getDefaultParams(){return {model:this.modelSchema.name}}getRetryDelay(e){let t=i=>{let l=/(\d+)(h|m|s|ms)/g,h={h:36e5,m:6e4,s:1e3,ms:1},d,T=0;for(;(d=l.exec(i))!==null;){let _=parseInt(d[1]),C=d[2];T+=_*h[C];}return T},o=0,n=0,a=!0;e["x-ratelimit-reset-requests"]&&(o=t(e["x-ratelimit-reset-requests"])),e["x-ratelimit-reset-tokens"]&&(n=t(e["x-ratelimit-reset-tokens"]));let m=Math.max(o,n);return {shouldRetry:a,delayMs:m}}getTokenCount(e){return e.requests.reduce((t,o)=>t+o.length,0)}transformModelRequest(e){let t=zt.safeParse(e);if(!t.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:t.error});let o=t.data,n=o.model,a={encodingFormat:o.encoding_format,dimensions:o.dimensions},m=types.Config().parse(provider.removeUndefinedEntries(a)),i,l;return typeof o.input=="string"?l=types.EmbeddingTextModalityLiteral:typeof o.input[0]=="string"?l=types.EmbeddingTextModalityLiteral:l=types.EmbeddingTokenModalityLiteral,l===types.EmbeddingTextModalityLiteral?typeof o.input=="string"?i={modality:l,requests:[o.input]}:i={modality:l,requests:o.input}:typeof o.input[0]=="number"?i={modality:l,requests:[o.input]}:i={modality:l,requests:o.input},{modelName:n,config:m,embeddingRequests:i}}transformConfig(e,t){let o=this.modelSchema.config.schema.safeParse(e);if(!o.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:o.error});let n=o.data;return Object.keys(n).forEach(m=>{if(!this.modelSchema.config.def[m])throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error(`Invalid config key : '${m}',
16
- available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(n).reduce((m,i)=>{let h=this.modelSchema.config.def[i].param,d=n[i];return m[h]=d,m},{})}transformEmbeddingRequests(e){let t=types.EmbeddingRequests().safeParse(e);if(!t.success)throw new provider.InvalidEmbeddingRequestsError({info:"Invalid embedding requests",cause:t.error});return {input:t.data.requests}}getGetEmbeddingsUrl(e,t){return S(this,null,function*(){return new Promise(o=>{o(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(e,t){return S(this,null,function*(){return new Promise(o=>{o(this.getDefaultHeaders());})})}getGetEmbeddingsData(e,t){return S(this,null,function*(){return new Promise(o=>{o(M(M(M({},this.getDefaultParams()),this.transformConfig(e,t)),this.transformEmbeddingRequests(t)));})})}transformGetEmbeddingsResponse(e){let t,o=jt.safeParse(e);if(o.success){let n=o.data;t=typeof n.data[0].embedding=="string"?types.Base64EmbeddingLiteral:types.FloatEmbeddingLiteral;let a=n.data.map(m=>typeof m.embedding=="string"?{index:m.index,embedding:m.embedding}:{index:m.index,embedding:m.embedding});return {encodingFormat:t,embeddings:a,usage:{totalTokens:n.usage.total_tokens}}}throw new provider.ModelResponseError({info:"Invalid response from model",cause:o.error})}};var wo="text-embedding-ada-002",En="Most capable 2nd generation embedding model, replacing 16 first generation models",Go=provider.EmbeddingModelSchema(K).parse({name:wo,description:En,modalities:V,maxInputTokens:8192,maxOutputTokens:1536,config:{def:v.base().def,schema:v.base().schema}}),Rt=F,Ae=class extends k{constructor(e){super(Go,e);}};var vo="text-embedding-3-small",Rn="Increased performance over 2nd generation ada embedding model",qo=provider.EmbeddingModelSchema(K).parse({name:vo,description:Rn,modalities:V,maxInputTokens:8192,maxOutputTokens:1536,config:{def:v.dimensions(1536).def,schema:v.dimensions(1536).schema}}),At=F,we=class extends k{constructor(e){super(qo,e);}};var ko="text-embedding-3-large",wn="Most capable embedding model for both english and non-english tasks",Lo=provider.EmbeddingModelSchema(K).parse({name:ko,description:wn,modalities:V,maxInputTokens:8192,maxOutputTokens:3072,config:{def:v.dimensions(3072).def,schema:v.dimensions(3072).schema}}),wt=F,Ge=class extends k{constructor(e){super(Lo,e);}};
11
+ one of [${h.choices.join(", ")}]`)})}}if("response_format"in i&&i.response_format!==void 0){let l=i.response_format;if(l==="json_schema")if("response_schema"in i)i.response_format={type:"json_schema",json_schema:i.response_schema},delete i.response_schema;else throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'responseSchema' is required in config when 'responseFormat' is 'json_schema'")});else i.response_format={type:l};}return i}transformMessages(e){if(!e||e&&e.length===0)return {messages:[]};let t=e.map(s=>{let a=types.Message().safeParse(s);if(!a.success)throw new provider.InvalidMessagesError({info:"Invalid messages",cause:a.error});return a.data});return t.forEach(s=>{s.content.forEach(a=>{if(!this.modelSchema.modalities.includes(a.modality))throw new provider.InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${a.modality}',
12
+ available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),t.forEach(s=>{if(!Object.keys(this.modelSchema.roles).includes(s.role))throw new provider.InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${s.role}',
13
+ available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}),{messages:t.map(s=>{switch(s.role){case types.SystemRoleLiteral:{let a=[];return s.content.forEach(m=>{if(m.modality===types.TextModalityLiteral)a.push({type:"text",text:m.value});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${m.modality}'`)})}),{role:this.modelSchema.roles[s.role],content:a}}case types.AssistantRoleLiteral:{let a=[],m=[];return s.content.forEach(i=>{if(i.modality===types.TextModalityLiteral)a.push({type:"text",text:i.value});else if(i.modality===types.ToolCallModalityLiteral)m.push({id:i.id,type:"function",function:{name:i.name,arguments:i.arguments}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${i.modality}'`)})}),M({role:this.modelSchema.roles[s.role],content:a},m.length>0?{tool_calls:m}:{})}case types.UserRoleLiteral:{let a=[],m=[];s.content.forEach(l=>{if(l.modality===types.TextModalityLiteral)a.push({type:"text",text:l.value});else if(l.modality===types.ImageModalityLiteral)m.push({type:"image_url",image_url:{url:l.value.type==="url"?l.value.url:l.value.base64,detail:l.detail}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${l.modality}'`)})});let i=[...a,...m];return {role:this.modelSchema.roles[s.role],content:i}}case types.ToolRoleLiteral:{if(s.content.length!==1)throw new provider.InvalidMessagesError({info:`Invalid message for role : '${s.role}'`,cause:new Error(`role : '${s.role}' must have exactly one content item`)});if(s.content[0].modality!==types.ToolResponseModalityLiteral)throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' must have content with modality : '${types.ToolResponseModalityLiteral}'`)});let a=s.content[0];return {role:this.modelSchema.roles[s.role],tool_call_id:a.id,content:a.data}}default:throw new provider.InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' is not supported,
14
+ available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}})}}transformTools(e){if(!this.modelSchema.modalities.includes(types.ToolCallModalityLiteral))throw new provider.InvalidToolsError({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${types.ToolCallModalityLiteral}'`)});return !e||e&&e.length===0?{tools:[]}:{tools:e.map(s=>{let a=types.Tool().safeParse(s);if(!a.success)throw new provider.InvalidToolsError({info:"Invalid tools",cause:a.error});return a.data}).map(s=>({type:"function",function:s.definition.schema}))}}getCompleteChatUrl(e,t,o){return S(this,null,function*(){return new Promise(s=>{s(this.completeChatUrl);})})}getCompleteChatHeaders(e,t,o){return S(this,null,function*(){return new Promise(s=>{s(this.getDefaultHeaders());})})}getCompleteChatData(e,t,o){return S(this,null,function*(){let s=this.transformConfig(e,t,o),a=this.transformMessages(t);if(a.messages&&a.messages.length===0)throw new provider.InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let m=o?this.transformTools(o):{};return new Promise(i=>{i(M(M(M(M({},this.getDefaultParams()),s),a),m));})})}transformCompleteChatResponse(e){let t=lt.safeParse(e);if(t.success){if(t.data.choices.length===0)throw new provider.ModelResponseError({info:"Invalid response from model",cause:new Error(`No choices in response : ${JSON.stringify(t.data)}`)});let o=t.data,s=[{role:types.AssistantRoleLiteral,content:[]}],a=o.choices[0].message;a.content&&s[0].content.push(types.createTextContent(a.content)),a.refusal&&s[0].content.push(types.createTextContent(a.refusal)),a.tool_calls&&a.tool_calls.forEach((h,d)=>{s[0].content.push(types.createToolCallContent(d,h.id,h.function.name,h.function.arguments));});let m={promptTokens:o.usage.prompt_tokens,completionTokens:o.usage.completion_tokens,totalTokens:o.usage.total_tokens},i=[],l=o.choices[0].logprobs;return l&&(l.content&&i.push(...l.content.map(h=>({token:h.token,logProb:h.logprob,bytes:h.bytes,topLogProbs:h.top_logprobs.map(d=>({token:d.token,logProb:d.logprob,bytes:d.bytes}))}))),l.refusal&&i.push(...l.refusal.map(h=>({token:h.token,logProb:h.logprob,bytes:h.bytes,topLogProbs:h.top_logprobs.map(d=>({token:d.token,logProb:d.logprob,bytes:d.bytes}))})))),{messages:s,usage:m,logProbs:i}}throw new provider.ModelResponseError({info:"Invalid response from model",cause:t.error})}getStreamChatUrl(e,t,o){return S(this,null,function*(){return new Promise(s=>{s(this.streamChatUrl);})})}getStreamChatHeaders(e,t,o){return S(this,null,function*(){return new Promise(s=>{s(this.getDefaultHeaders());})})}getStreamChatData(e,t,o){return S(this,null,function*(){let s=this.transformConfig(e,t,o),a=this.transformMessages(t);if(a.messages&&a.messages.length===0)throw new provider.InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let m=o?this.transformTools(o):{};return new Promise(i=>{i(M(M(M(M({stream:!0,stream_options:{include_usage:!0}},this.getDefaultParams()),s),a),m));})})}transformStreamChatResponseChunk(e,t){return Y(this,null,function*(){var s,a;let o=(t+e).split(`
15
+ `).filter(m=>m.trim()!=="");for(let m of o){if(m==="data: [DONE]")return;if(m.startsWith("data: {")&&m.endsWith("}")){let i;try{i=JSON.parse(m.substring(6));}catch(h){throw new provider.ModelResponseError({info:`Malformed JSON received in stream : ${i}`,cause:h})}let l=pt.safeParse(i);if(l.success){let h={partialMessages:[]},d=l.data;if(d.choices.length>0){let T=d.choices[0].delta;if(T!==void 0&&Object.keys(T).length!==0){if("content"in T&&T.content!==null)h.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,T.content));else if("refusal"in T&&T.refusal!==null)h.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,T.refusal));else if("tool_calls"in T&&T.tool_calls!==void 0){let _=T.tool_calls.at(0);h.partialMessages.push(types.createPartialToolCallMessage(types.AssistantRoleLiteral,_.index,_.id,(s=_.function)==null?void 0:s.name,(a=_.function)==null?void 0:a.arguments));}}}d.usage&&(h.usage={promptTokens:d.usage.prompt_tokens,completionTokens:d.usage.completion_tokens,totalTokens:d.usage.total_tokens}),yield {partialResponse:h,buffer:t};}else throw new provider.ModelResponseError({info:"Invalid response from model",cause:l.error})}}})}};var U=class extends f{constructor(e,t){super(e,t);}transformModelRequest(e){let t=mt.safeParse(e);if(!t.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:t.error});let o=t.data,s=G(M({},o),{max_tokens:o.max_completion_tokens});return delete s.max_completion_tokens,super.transformModelRequest(s)}transformTools(e){throw new provider.ModelError({info:`Model: '${this.modelSchema.name}' does not support 'tools'.`,cause:new Error(`Model: '${this.modelSchema.name}' does not support 'tools'.`)})}getStreamChatUrl(e,t,o){return S(this,null,function*(){throw new provider.ModelError({info:`Model: '${this.modelSchema.name}' does not support streaming.`,cause:new Error(`Model: '${this.modelSchema.name}' does not support streaming.`)})})}getStreamChatHeaders(e,t,o){return S(this,null,function*(){throw new provider.ModelError({info:`Model: '${this.modelSchema.name}' does not support streaming.`,cause:new Error(`Model: '${this.modelSchema.name}' does not support streaming.`)})})}getStreamChatData(e,t,o){return S(this,null,function*(){throw new provider.ModelError({info:`Model: '${this.modelSchema.name}' does not support streaming.`,cause:new Error(`Model: '${this.modelSchema.name}' does not support streaming.`)})})}transformStreamChatResponseChunk(e,t){return Y(this,null,function*(){throw new provider.ModelError({info:`Model: '${this.modelSchema.name}' does not support streaming.`,cause:new Error(`Model: '${this.modelSchema.name}' does not support streaming.`)})})}};var Ye="gpt-3.5-turbo-0125",Ln="The latest GPT-3.5 Turbo model with higher accuracy at responding in requested formats and a fix for a bug which caused a text encoding issue for non-English language function calls. Training data up to Sept 2021.",Xe=provider.ChatModelSchema(g,I).parse({name:Ye,description:Ln,maxInputTokens:4092,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.responseFormat(4092,4).def,schema:c.responseFormat(4092,4).schema}}),ct=u,he=class extends f{constructor(e){super(Xe,e);}};var Qe="gpt-3.5-turbo-1106",zn="The latest GPT-3.5 Turbo model with improved instruction following, JSON mode, reproducible outputs, parallel function calling, and more. Returns a maximum of 4,096 output tokens. Training data up to Sept 2021.",Ze=provider.ChatModelSchema(g,I).parse({name:Qe,description:zn,maxInputTokens:4092,maxOutputTokens:16385,roles:y,modalities:P,config:{def:c.responseFormat(16385,4).def,schema:c.responseFormat(16385,4).schema}}),ht=u,ue=class extends f{constructor(e){super(Ze,e);}};var eo="gpt-3.5-turbo",Fn="Currently points to gpt-3.5-turbo-0125. Training data up to Sept 2021.",oo=provider.ChatModelSchema(g,I).parse({name:eo,description:Fn,maxInputTokens:4092,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.responseFormat(4092,4).def,schema:c.responseFormat(4092,4).schema}}),ut=u,fe=class extends f{constructor(e){super(oo,e);}};var to="gpt-4-0125-preview",Nn="The latest GPT-4 model intended to reduce cases of \u201Claziness\u201D where the model doesn\u2019t complete a task. Training data up to Apr 2023.",no=provider.ChatModelSchema(g,I).parse({name:to,description:Nn,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.base(4092,4).def,schema:c.base(4092,4).schema}}),ft=u,Te=class extends f{constructor(e){super(no,e);}};var so="gpt-4-0613",Un="Snapshot of gpt-4 from June 13th 2023 with improved function calling support. Training data up to Sept 2021.",ao=provider.ChatModelSchema(g,I).parse({name:so,description:Un,maxInputTokens:8192,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.base(4092,4).def,schema:c.base(4092,4).schema}}),Tt=u,_e=class extends f{constructor(e){super(ao,e);}};var io="gpt-4-1106-preview",Vn="GPT-4 Turbo model featuring improved instruction following, JSON mode, reproducible outputs, parallel function calling, and more. Returns a maximum of 4,096 output tokens. This preview model is not yet suited for production traffic. Training data up to Apr 2023.",ro=provider.ChatModelSchema(g,I).parse({name:io,description:Vn,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.base(4092,4).def,schema:c.base(4092,4).schema}}),_t=u,ge=class extends f{constructor(e){super(ro,e);}};var lo="gpt-4-turbo-2024-04-09",Jn="GPT-4 Turbo with Vision model. Vision requests can now use JSON mode and function calling. gpt-4-turbo currently points to this version. Training data up to Dec 2023.",po=provider.ChatModelSchema(g,x).parse({name:lo,description:Jn,maxInputTokens:128e3,maxOutputTokens:4096,roles:y,modalities:E,config:{def:c.responseFormat(4096,4).def,schema:c.responseFormat(4096,4).schema}}),gt=u,ye=class extends f{constructor(e){super(po,e);}};var mo="gpt-4-turbo-preview",Yn="Currently points to gpt-4-0125-preview. Training data up to Apr 2023.",co=provider.ChatModelSchema(g,I).parse({name:mo,description:Yn,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.responseFormat(4092,4).def,schema:c.responseFormat(4092,4).schema}}),yt=u,Me=class extends f{constructor(e){super(co,e);}};var ho="gpt-4-turbo",Qn="The latest GPT-4 Turbo model with vision capabilities. Vision requests can now use JSON mode and function calling. Currently points to gpt-4-turbo-2024-04-09. Training data up to Dec 2023.",uo=provider.ChatModelSchema(g,x).parse({name:ho,description:Qn,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:E,config:{def:c.responseFormat(4092,4).def,schema:c.responseFormat(4092,4).schema}}),Mt=u,Ce=class extends f{constructor(e){super(uo,e);}};var fo="gpt-4",es="Currently points to gpt-4-0613. Training data up to Sept 2021.",To=provider.ChatModelSchema(g,I).parse({name:fo,description:es,maxInputTokens:8192,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.base(4092,4).def,schema:c.base(4092,4).schema}}),Ct=u,be=class extends f{constructor(e){super(To,e);}};var _o="gpt-4o-2024-08-06",ts="Latest snapshot of gpt-4o that supports Structured Outputs. Training data up to Oct 2023.",go=provider.ChatModelSchema(g,x).parse({name:_o,description:ts,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:E,config:{def:c.responseSchema(4092,4).def,schema:c.responseSchema(4092,4).schema}}),bt=u,Oe=class extends f{constructor(e){super(go,e);}};var yo="gpt-4o-mini",ss="Most advanced, multimodal flagship model that is cheaper and faster than GPT-4 Turbo. Currently points to gpt-4o-2024-05-13. Training data up to Oct 2023.",Mo=provider.ChatModelSchema(g,x).parse({name:yo,description:ss,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:E,config:{def:c.responseSchema(4092,4).def,schema:c.responseSchema(4092,4).schema}}),Ot=u,Pe=class extends f{constructor(e){super(Mo,e);}};var Co="gpt-4o",is="Most advanced, multimodal flagship model that is cheaper and faster than GPT-4 Turbo. Currently points to gpt-4o-2024-05-13. Training data up to Oct 2023.",bo=provider.ChatModelSchema(g,x).parse({name:Co,description:is,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:E,config:{def:c.responseFormat(4092,4).def,schema:c.responseFormat(4092,4).schema}}),Pt=u,Ie=class extends f{constructor(e){super(bo,e);}};var Oo="gpt-4o-mini-2024-07-18",ls="Most advanced, multimodal flagship model that is cheaper and faster than GPT-4 Turbo. Currently points to gpt-4o-2024-05-13. Training data up to Oct 2023.",Po=provider.ChatModelSchema(g,x).parse({name:Oo,description:ls,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:E,config:{def:c.responseSchema(4092,4).def,schema:c.responseSchema(4092,4).schema}}),It=u,Se=class extends f{constructor(e){super(Po,e);}};var Io="gpt-4o-2024-05-13",ms="Latest snapshot of gpt-4o that supports Structured Outputs. Training data up to Oct 2023.",So=provider.ChatModelSchema(g,x).parse({name:Io,description:ms,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:E,config:{def:c.responseSchema(4092,4).def,schema:c.responseSchema(4092,4).schema}}),St=u,Ee=class extends f{constructor(e){super(So,e);}};var Eo="o1-mini",cs="Faster and cheaper reasoning model particularly good at coding, math, and science. Training data up to Oct 2023.",xo=provider.ChatModelSchema(ae,me).parse({name:Eo,description:cs,maxInputTokens:128e3,maxOutputTokens:4092,roles:ie,modalities:pe,config:{def:c.oSeries(4092,4).def,schema:c.oSeries(4092,4).schema}}),Et=u,xe=class extends U{constructor(e){super(xo,e);}};var Ro="o1-preview",us="Reasoning model designed to solve hard problems across domains. Training data up to Oct 2023.",Ao=provider.ChatModelSchema(ae,me).parse({name:Ro,description:us,maxInputTokens:128e3,maxOutputTokens:4092,roles:ie,modalities:pe,config:{def:c.oSeries(4092,4).def,schema:c.oSeries(4092,4).schema}}),xt=u,Re=class extends U{constructor(e){super(Ao,e);}};var H=[types.EmbeddingTextModalityLiteral,types.EmbeddingTokenModalityLiteral],V=zod.z.enum([types.EmbeddingTextModalityLiteral,types.EmbeddingTokenModalityLiteral]);var jt=zod.z.object({object:zod.z.literal("list"),model:zod.z.string(),data:zod.z.array(zod.z.object({index:zod.z.number(),object:zod.z.literal("embedding"),embedding:zod.z.array(zod.z.number()).or(zod.z.string().base64())})),usage:zod.z.object({prompt_tokens:zod.z.number().nonnegative(),total_tokens:zod.z.number().nonnegative()})});var Ts=zod.z.string().min(1).or(zod.z.array(zod.z.string().min(1)).min(1)).or(zod.z.array(zod.z.number().int().nonnegative()).min(1)).or(zod.z.array(zod.z.array(zod.z.number().int().nonnegative()).min(1)).min(1)),zt=zod.z.object({model:zod.z.string().min(1).optional(),input:Ts,encoding_format:zod.z.enum(["float","base64"]).optional(),dimensions:zod.z.number().int().min(1).optional()});var B=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),getEmbeddingsUrl:zod.z.string().url().optional()}),k=class{constructor(e,t){this.version="v1";let o=B.parse(t);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash(o.baseUrl||j.baseUrl),this.getEmbeddingsUrl=provider.urlWithoutTrailingSlash(o.getEmbeddingsUrl||`${this.baseUrl}/embeddings`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"}}getDefaultParams(){return {model:this.modelSchema.name}}getRetryDelay(e){let t=i=>{let l=/(\d+)(h|m|s|ms)/g,h={h:36e5,m:6e4,s:1e3,ms:1},d,T=0;for(;(d=l.exec(i))!==null;){let _=parseInt(d[1]),C=d[2];T+=_*h[C];}return T},o=0,s=0,a=!0;e["x-ratelimit-reset-requests"]&&(o=t(e["x-ratelimit-reset-requests"])),e["x-ratelimit-reset-tokens"]&&(s=t(e["x-ratelimit-reset-tokens"]));let m=Math.max(o,s);return {shouldRetry:a,delayMs:m}}getTokenCount(e){return e.requests.reduce((t,o)=>t+o.length,0)}transformModelRequest(e){let t=zt.safeParse(e);if(!t.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:t.error});let o=t.data,s=o.model,a={encodingFormat:o.encoding_format,dimensions:o.dimensions},m=types.Config().parse(provider.removeUndefinedEntries(a)),i,l;return typeof o.input=="string"?l=types.EmbeddingTextModalityLiteral:typeof o.input[0]=="string"?l=types.EmbeddingTextModalityLiteral:l=types.EmbeddingTokenModalityLiteral,l===types.EmbeddingTextModalityLiteral?typeof o.input=="string"?i={modality:l,requests:[o.input]}:i={modality:l,requests:o.input}:typeof o.input[0]=="number"?i={modality:l,requests:[o.input]}:i={modality:l,requests:o.input},{modelName:s,config:m,embeddingRequests:i}}transformConfig(e,t){let o=this.modelSchema.config.schema.safeParse(e);if(!o.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:o.error});let s=o.data;return Object.keys(s).forEach(m=>{if(!this.modelSchema.config.def[m])throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error(`Invalid config key : '${m}',
16
+ available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(s).reduce((m,i)=>{let h=this.modelSchema.config.def[i].param,d=s[i];return m[h]=d,m},{})}transformEmbeddingRequests(e){let t=types.EmbeddingRequests().safeParse(e);if(!t.success)throw new provider.InvalidEmbeddingRequestsError({info:"Invalid embedding requests",cause:t.error});return {input:t.data.requests}}getGetEmbeddingsUrl(e,t){return S(this,null,function*(){return new Promise(o=>{o(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(e,t){return S(this,null,function*(){return new Promise(o=>{o(this.getDefaultHeaders());})})}getGetEmbeddingsData(e,t){return S(this,null,function*(){return new Promise(o=>{o(M(M(M({},this.getDefaultParams()),this.transformConfig(e,t)),this.transformEmbeddingRequests(t)));})})}transformGetEmbeddingsResponse(e){let t,o=jt.safeParse(e);if(o.success){let s=o.data;t=typeof s.data[0].embedding=="string"?types.Base64EmbeddingLiteral:types.FloatEmbeddingLiteral;let a=s.data.map(m=>typeof m.embedding=="string"?{index:m.index,embedding:m.embedding}:{index:m.index,embedding:m.embedding});return {encodingFormat:t,embeddings:a,usage:{totalTokens:s.usage.total_tokens}}}throw new provider.ModelResponseError({info:"Invalid response from model",cause:o.error})}};var wo="text-embedding-ada-002",Es="Most capable 2nd generation embedding model, replacing 16 first generation models",Go=provider.EmbeddingModelSchema(V).parse({name:wo,description:Es,modalities:H,maxInputTokens:8192,maxOutputTokens:1536,config:{def:v.base().def,schema:v.base().schema}}),Rt=B,Ae=class extends k{constructor(e){super(Go,e);}};var vo="text-embedding-3-small",Rs="Increased performance over 2nd generation ada embedding model",qo=provider.EmbeddingModelSchema(V).parse({name:vo,description:Rs,modalities:H,maxInputTokens:8192,maxOutputTokens:1536,config:{def:v.dimensions(1536).def,schema:v.dimensions(1536).schema}}),At=B,we=class extends k{constructor(e){super(qo,e);}};var ko="text-embedding-3-large",ws="Most capable embedding model for both english and non-english tasks",Lo=provider.EmbeddingModelSchema(V).parse({name:ko,description:ws,modalities:H,maxInputTokens:8192,maxOutputTokens:3072,config:{def:v.dimensions(3072).def,schema:v.dimensions(3072).schema}}),wt=B,Ge=class extends k{constructor(e){super(Lo,e);}};
17
17
 
18
18
  exports.BaseChatModel = f;
19
19
  exports.BaseChatModelOptions = u;
20
20
  exports.BaseEmbeddingModel = k;
21
- exports.BaseEmbeddingModelOptions = F;
22
- exports.BaseOSeriesChatModel = H;
23
- exports.ChatModelBaseConfigDef = N;
24
- exports.ChatModelBaseConfigSchema = D;
21
+ exports.BaseEmbeddingModelOptions = B;
22
+ exports.BaseOSeriesChatModel = U;
23
+ exports.ChatModelBaseConfigDef = D;
24
+ exports.ChatModelBaseConfigSchema = F;
25
25
  exports.ChatModelOSeriesConfigDef = Wo;
26
26
  exports.ChatModelOSeriesConfigSchema = Yo;
27
27
  exports.ChatModelResponseFormatConfigDef = Zo;
@@ -51,9 +51,9 @@ exports.GPT_4Schema = To;
51
51
  exports.GPT_4_0125_Preview = Te;
52
52
  exports.GPT_4_0125_PreviewLiteral = to;
53
53
  exports.GPT_4_0125_PreviewOptions = ft;
54
- exports.GPT_4_0125_PreviewSchema = so;
54
+ exports.GPT_4_0125_PreviewSchema = no;
55
55
  exports.GPT_4_0613 = _e;
56
- exports.GPT_4_0613Literal = no;
56
+ exports.GPT_4_0613Literal = so;
57
57
  exports.GPT_4_0613Options = Tt;
58
58
  exports.GPT_4_0613Schema = ao;
59
59
  exports.GPT_4_1106_Preview = ge;
@@ -114,29 +114,29 @@ exports.OpenAIChatModelTextToolModalities = P;
114
114
  exports.OpenAIChatModelTextToolModalitiesEnum = I;
115
115
  exports.OpenAIChatOSeriesRequest = mt;
116
116
  exports.OpenAIChatRequest = ce;
117
- exports.OpenAIChatRequestAssistantMessage = Ts;
118
- exports.OpenAIChatRequestImageContent = cs;
119
- exports.OpenAIChatRequestMessage = gs;
120
- exports.OpenAIChatRequestResponseFormat = ds;
121
- exports.OpenAIChatRequestSystemMessage = us;
117
+ exports.OpenAIChatRequestAssistantMessage = _n;
118
+ exports.OpenAIChatRequestImageContent = hn;
119
+ exports.OpenAIChatRequestMessage = yn;
120
+ exports.OpenAIChatRequestResponseFormat = cn;
121
+ exports.OpenAIChatRequestSystemMessage = fn;
122
122
  exports.OpenAIChatRequestTextContent = We;
123
- exports.OpenAIChatRequestTool = ls;
124
- exports.OpenAIChatRequestToolCallContent = hs;
125
- exports.OpenAIChatRequestToolChoiceEnum = ps;
126
- exports.OpenAIChatRequestToolChoiceFunction = ms;
127
- exports.OpenAIChatRequestToolMessage = _s;
128
- exports.OpenAIChatRequestUserMessage = fs;
123
+ exports.OpenAIChatRequestTool = pn;
124
+ exports.OpenAIChatRequestToolCallContent = un;
125
+ exports.OpenAIChatRequestToolChoiceEnum = mn;
126
+ exports.OpenAIChatRequestToolChoiceFunction = dn;
127
+ exports.OpenAIChatRequestToolMessage = gn;
128
+ exports.OpenAIChatRequestUserMessage = Tn;
129
129
  exports.OpenAICompleteChatResponse = lt;
130
130
  exports.OpenAIEmbeddingModelConfigs = v;
131
- exports.OpenAIEmbeddingModelModalities = V;
132
- exports.OpenAIEmbeddingModelModalitiesEnum = K;
131
+ exports.OpenAIEmbeddingModelModalities = H;
132
+ exports.OpenAIEmbeddingModelModalitiesEnum = V;
133
133
  exports.OpenAIEmbeddingRequest = zt;
134
- exports.OpenAIEmbeddingRequestInput = Tn;
134
+ exports.OpenAIEmbeddingRequestInput = Ts;
135
135
  exports.OpenAIGetEmbeddingsResponse = jt;
136
136
  exports.OpenAIStreamChatResponse = pt;
137
- exports.OpenAIToolCallsCompleteChatResponse = is;
138
- exports.OpenAIToolCallsStreamChatResponse = rs;
139
- exports.ProviderLiteral = Ms;
137
+ exports.OpenAIToolCallsCompleteChatResponse = rn;
138
+ exports.OpenAIToolCallsStreamChatResponse = ln;
139
+ exports.ProviderLiteral = Cn;
140
140
  exports.Text_Embedding_3_Large = Ge;
141
141
  exports.Text_Embedding_3_LargeLiteral = ko;
142
142
  exports.Text_Embedding_3_LargeSchema = Lo;