@adaline/openai 0.7.0 → 0.8.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,21 +4,21 @@ var zod = require('zod');
4
4
  var provider = require('@adaline/provider');
5
5
  var types = require('@adaline/types');
6
6
 
7
- var et=Object.defineProperty,tt=Object.defineProperties;var ot=Object.getOwnPropertyDescriptors;var de=Object.getOwnPropertySymbols;var nt=Object.prototype.hasOwnProperty,st=Object.prototype.propertyIsEnumerable;var at=(p,e)=>(e=Symbol[p])?e:Symbol.for("Symbol."+p);var ce=(p,e,o)=>e in p?et(p,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):p[e]=o,y=(p,e)=>{for(var o in e||(e={}))nt.call(e,o)&&ce(p,o,e[o]);if(de)for(var o of de(e))st.call(e,o)&&ce(p,o,e[o]);return p},x=(p,e)=>tt(p,ot(e));var R=(p,e,o)=>new Promise((t,n)=>{var i=l=>{try{r(o.next(l));}catch(c){n(c);}},s=l=>{try{r(o.throw(l));}catch(c){n(c);}},r=l=>l.done?t(l.value):Promise.resolve(l.value).then(i,s);r((o=o.apply(p,e)).next());}),rt=function(p,e){this[0]=p,this[1]=e;},ue=(p,e,o)=>{var t=(s,r,l,c)=>{try{var d=o[s](r),h=(r=d.value)instanceof rt,f=d.done;Promise.resolve(h?r[0]:r).then(g=>h?t(s==="return"?s:"next",r[1]?{done:g.done,value:g.value}:g,l,c):l({value:g,done:f})).catch(g=>t("throw",g,l,c));}catch(g){c(g);}},n=s=>i[s]=r=>new Promise((l,c)=>t(s,r,l,c)),i={};return o=o.apply(p,e),i[at("asyncIterator")]=()=>i,n("next"),n("throw"),n("return"),i};var B=provider.RangeConfigItem({param:"temperature",title:provider.CONFIG.TEMPERATURE.title,description:provider.CONFIG.TEMPERATURE.description,min:0,max:2,step:.01,default:1}),N=p=>provider.RangeConfigItem({param:"max_tokens",title:provider.CONFIG.MAX_TOKENS.title,description:provider.CONFIG.MAX_TOKENS.description,min:0,max:p,step:1,default:0}),G=p=>provider.MultiStringConfigItem({param:"stop",title:provider.CONFIG.STOP(p).title,description:provider.CONFIG.STOP(p).description,max:p}),K=provider.RangeConfigItem({param:"top_p",title:provider.CONFIG.TOP_P.title,description:provider.CONFIG.TOP_P.description,min:0,max:1,step:.01,default:1}),V=provider.RangeConfigItem({param:"frequency_penalty",title:provider.CONFIG.FREQUENCY_PENALTY.title,description:provider.CONFIG.FREQUENCY_PENALTY.description,min:-2,max:2,step:.01,default:0}),H=provider.RangeConfigItem({param:"presence_penalty",title:provider.CONFIG.PRESENCE_PENALTY.title,description:provider.CONFIG.PRESENCE_PENALTY.description,min:-2,max:2,step:.01,default:0}),J=provider.RangeConfigItem({param:"seed",title:"Seed",description:"This is in BETA. Set a seed to get reproducible results. Determinism is not guaranteed. Set to 0 to disable.",min:0,max:1e6,step:1,default:0}),W=provider.SelectBooleanConfigItem({param:"logprobs",title:"LogProbs",description:"Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned.",default:!1}),Y=provider.RangeConfigItem({param:"top_logprobs",title:"Top logprobs",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.",min:0,max:20,step:1,default:0}),Z=provider.SelectStringConfigItem({param:"response_format",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.",default:"text",choices:["text","json_object"]}),Q=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 q=(p,e)=>zod.z.object({temperature:B.schema,maxTokens:N(p).schema,stop:G(e).schema,topP:K.schema,frequencyPenalty:V.schema,presencePenalty:H.schema,seed:J.schema.transform(o=>o===0?void 0:o),logProbs:W.schema,topLogProbs:Y.schema,responseFormat:Z.schema,toolChoice:Q.schema}),w=(p,e)=>({temperature:B.def,maxTokens:N(p).def,stop:G(e).def,topP:K.def,frequencyPenalty:V.def,presencePenalty:H.def,seed:J.def,responseFormat:Z.def,logProbs:W.def,topLogProbs:Y.def,toolChoice:Q.def});var ct=["object","array","number","string","boolean","enum"],fe=zod.z.enum(ct),ut=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([fe,zod.z.array(zod.z.union([fe,zod.z.literal("null")]))]).optional(),default:zod.z.any().optional(),title:zod.z.string().optional(),description:zod.z.string().max(4096).optional(),properties:zod.z.record(zod.z.any()).optional(),required:zod.z.array(zod.z.string()).optional(),minItems:zod.z.number().int().min(0).optional(),maxItems:zod.z.number().int().optional(),items:zod.z.record(zod.z.any()).optional(),enum:zod.z.array(zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()])).optional(),minimum:zod.z.number().optional(),maximum:zod.z.number().optional(),minLength:zod.z.number().int().min(0).optional(),maxLength:zod.z.number().int().optional(),$ref:zod.z.string().optional()}),ht=zod.z.object({type:zod.z.enum(["object"]),required:zod.z.array(zod.z.string()),$defs:zod.z.record(zod.z.any()).optional(),properties:zod.z.record(ut),additionalProperties:zod.z.literal(!1)}),ft=zod.z.object({name:zod.z.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:zod.z.string().max(4096),strict:zod.z.boolean().optional(),schema:ht}).optional(),ge=provider.ObjectSchemaConfigItem({param:"response_schema",title:"Response schema",description:"When response format is set to 'json_schema', the model will return a JSON object of the specified schema.",objectSchema:ft}),ye=provider.SelectStringConfigItem({param:"response_format",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.",default:"text",choices:["text","json_object","json_schema"]}),be=(p,e)=>x(y({},w(p,e)),{responseFormat:ye.def,responseSchema:ge.def}),Te=(p,e)=>q(p,e).extend({responseFormat:ye.schema,responseSchema:ge.schema});var X=provider.SelectStringConfigItem({param:"encoding_format",title:"Encoding format",description:"Select the encoding format for the word embedding.",default:"float",choices:["float","base64"]}),ee=provider.RangeConfigItem({param:"dimensions",title:"Dimensions",description:"Select the number of dimensions for the word embedding.",min:1,max:1024,step:1,default:1024});var Ce=()=>zod.z.object({encodingFormat:X.schema,dimensions:ee.schema}),Me=()=>({encodingFormat:X.def,dimensions:ee.def});var te={base:(p,e)=>({def:w(p,e),schema:q(p,e)}),responseSchema:(p,e)=>({def:be(p,e),schema:Te(p,e)})},oe={base:()=>({def:Me(),schema:Ce()})};var Se=zod.z.enum([types.SystemRoleLiteral,types.UserRoleLiteral,types.AssistantRoleLiteral,types.ToolRoleLiteral]),Ae={system:types.SystemRoleLiteral,user:types.UserRoleLiteral,assistant:types.AssistantRoleLiteral,tool:types.ToolRoleLiteral};var Pe=[types.TextModalityLiteral,types.ImageModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],je=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]);var P=zod.z.object({token:zod.z.string(),logprob:zod.z.number(),bytes:zod.z.array(zod.z.number()).nullable()}),ve=zod.z.object({content:zod.z.array(P.extend({top_logprobs:zod.z.array(P)})).nullable(),refusal:zod.z.array(P.extend({top_logprobs:zod.z.array(P)})).nullable()}).nullable(),Mt=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()})})),ke=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(),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:Mt.optional(),refusal:zod.z.string().nullable().optional()}),logprobs:ve,finish_reason:zod.z.string()})),usage:zod.z.object({prompt_tokens:zod.z.number(),completion_tokens:zod.z.number(),total_tokens:zod.z.number()})}),Rt=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()})),Ue=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:Rt.optional(),refusal:zod.z.string().nullable().optional()}).or(zod.z.object({})),logprobs:ve,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 Ot=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()})}),It=zod.z.enum(["none","auto","required"]),Et=zod.z.object({type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1)})}),St=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()})})),ne=zod.z.object({text:zod.z.string().min(1),type:zod.z.literal("text")}),At=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()})}),xt=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)})}),_t=zod.z.object({role:zod.z.literal("system"),content:zod.z.string().min(1).or(zod.z.array(ne).min(1))}),qt=zod.z.object({role:zod.z.literal("user"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([ne,At])).min(1))}),wt=zod.z.object({role:zod.z.literal("assistant"),content:zod.z.string().min(1).or(zod.z.array(ne).min(1)).optional(),tool_calls:zod.z.array(xt).min(1).optional()}).refine(p=>!(!p.content&&!p.tool_calls),{message:"one of 'content' or 'tool_calls' must be provided",path:["content","tool_calls"]}),Pt=zod.z.object({role:zod.z.literal("tool"),tool_call_id:zod.z.string().min(1),content:zod.z.string().min(1)}),jt=zod.z.union([_t,qt,wt,Pt]),Fe=zod.z.object({model:zod.z.string().min(1).optional(),messages:zod.z.array(jt).min(1).optional(),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:St.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(Ot).optional(),tool_choice:It.or(Et).optional()}).refine(p=>!(p.tool_choice&&(!p.tools||p.tools.length===0)),{message:"'tools' must be provided if 'tool_choice' is provided",path:["tools"]});var re=zod.z.object({apiKey:zod.z.string(),baseUrl:zod.z.string().url(),completeChatUrl:zod.z.string().url().optional(),streamChatUrl:zod.z.string().url().optional(),organization:zod.z.string().optional()}),k=class{constructor(e,o){this.version="v1";let t=re.parse(o);this.modelSchema=e,this.apiKey=t.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash(t.baseUrl),this.streamChatUrl=provider.urlWithoutTrailingSlash(t.streamChatUrl||`${this.baseUrl}/chat/completions`),this.completeChatUrl=provider.urlWithoutTrailingSlash(t.completeChatUrl||`${this.baseUrl}/chat/completions`),this.organization=t.organization;}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return y({Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},this.organization?{"OpenAI-Organization":this.organization}:{})}getDefaultParams(){return {model:this.modelSchema.name}}getRetryDelay(e){let o=r=>{let l=/(\d+)(h|m|s|ms)/g,c={h:36e5,m:6e4,s:1e3,ms:1},d,h=0;for(;(d=l.exec(r))!==null;){let f=parseInt(d[1]),g=d[2];h+=f*c[g];}return h},t=0,n=0,i=!0;e["x-ratelimit-reset-requests"]&&(t=o(e["x-ratelimit-reset-requests"])),e["x-ratelimit-reset-tokens"]&&(n=o(e["x-ratelimit-reset-tokens"]));let s=Math.max(t,n);return {shouldRetry:i,delayMs:s}}getTokenCount(e){return e.reduce((o,t)=>o+t.content.map(n=>n.modality==="text"?n.value:"").join(" ").length,0)}transformModelRequest(e){let o=Fe.safeParse(e);if(!o.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:o.error});let t=o.data,n=t.model,i={seed:t.seed,maxTokens:t.max_tokens,temperature:t.temperature,topP:t.top_p,presencePenalty:t.presence_penalty,frequencyPenalty:t.frequency_penalty,stop:t.stop,logProbs:t.logprobs,topLogProbs:t.top_logprobs,toolChoice:t.tool_choice,responseFormat:t.response_format},s=types.Config().parse(provider.removeUndefinedEntries(i));s.responseFormat&&s.responseFormat.type==="json_schema"&&!s.responseFormat.json_schema&&(s.responseSchema={name:s.responseFormat.json_schema.name,description:s.responseFormat.json_schema.description||"",strict:s.responseFormat.json_schema.strict,schema:s.responseFormat.json_schema.parameters});let r=[],l={};t.messages&&t.messages.forEach(d=>{let h=d.role;switch(h){case"system":{let f=d.content;if(typeof f=="string")r.push({role:h,content:[{modality:types.TextModalityLiteral,value:f}]});else {let g=f.map(T=>({modality:types.TextModalityLiteral,value:T.text}));r.push({role:h,content:g});}}break;case"user":{let f=d.content;if(typeof f=="string")r.push({role:h,content:[{modality:types.TextModalityLiteral,value:f}]});else {let g=f.map(T=>T.type==="text"?{modality:types.TextModalityLiteral,value:T.text}:{modality:types.ImageModalityLiteral,detail:T.image_url.detail||"auto",value:{type:types.UrlImageContentTypeLiteral,url:T.image_url.url}});r.push({role:h,content:g});}}break;case"assistant":{let f=[];if(d.content){let g=d.content;typeof g=="string"?f.push({modality:types.TextModalityLiteral,value:g}):g.forEach(T=>{f.push({modality:types.TextModalityLiteral,value:T.text});});}d.tool_calls&&d.tool_calls.forEach((T,Xe)=>{let D={modality:types.ToolCallModalityLiteral,id:T.id,index:Xe,name:T.function.name,arguments:T.function.arguments};f.push(D),l[D.id]=D;}),r.push({role:h,content:f});}break;case"tool":{let f=d;r.push({role:h,content:[{modality:types.ToolResponseModalityLiteral,id:f.tool_call_id,index:l[f.tool_call_id].index,name:l[f.tool_call_id].name,data:f.content}]});}break}});let c=[];return t.tools&&t.tools.forEach(d=>{c.push({type:"function",definition:{schema:{name:d.function.name,description:d.function.description||"",strict:d.function.strict,parameters:d.function.parameters}}});}),{modelName:n,config:s,messages:r,tools:c}}transformConfig(e,o,t){let n=e.toolChoice;delete e.toolChoice;let i=this.modelSchema.config.schema.safeParse(e);if(!i.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:i.error});let s=i.data;n!==void 0&&(s.toolChoice=n),Object.keys(s).forEach(l=>{if(!(l in this.modelSchema.config.def))throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error(`Invalid config key : '${l}',
8
- available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let r=Object.keys(s).reduce((l,c)=>{let d=this.modelSchema.config.def[c],h=d.param,f=s[c];return h==="max_tokens"&&d.type==="range"&&f===0?l[h]=d.max:l[h]=f,l},{});if("tool_choice"in r&&r.tool_choice!==void 0){let l=r.tool_choice;if(!t||t&&t.length===0)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(t&&t.length>0){let c=this.modelSchema.config.def.toolChoice;if(!c.choices.includes(l))if(t.map(d=>d.definition.schema.name).includes(l))r.tool_choice={type:"function",function:{name:l}};else throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error(`toolChoice : '${l}' is not part of provided 'tools' names or
9
- one of [${c.choices.join(", ")}]`)})}}if("response_format"in r&&r.response_format!==void 0){let l=r.response_format;if(l==="json_schema")if("response_schema"in r)r.response_format={type:"json_schema",json_schema:r.response_schema},delete r.response_schema;else throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error("'responseSchema' is required in config when 'responseFormat' is 'json_schema'")});else r.response_format={type:l};}return r}transformMessages(e){if(!e||e&&e.length===0)return {messages:[]};let o=e.map(n=>{let i=types.Message().safeParse(n);if(!i.success)throw new provider.InvalidMessagesError({info:"Invalid messages",cause:i.error});return i.data});return o.forEach(n=>{n.content.forEach(i=>{if(!this.modelSchema.modalities.includes(i.modality))throw new provider.InvalidMessagesError({info:`Invalid message content for model : '${this.modelSchema.name}'`,cause:new Error(`model : '${this.modelSchema.name}' does not support modality : '${i.modality}',
10
- available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),{messages:o.map(n=>{switch(n.role){case types.SystemRoleLiteral:{let i=[];return n.content.forEach(s=>{if(s.modality===types.TextModalityLiteral)i.push({type:"text",text:s.value});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelSchema.name}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${s.modality}'`)})}),{role:this.modelSchema.roles[n.role],content:i}}case types.AssistantRoleLiteral:{let i=[],s=[];return n.content.forEach(r=>{if(r.modality===types.TextModalityLiteral)i.push({type:"text",text:r.value});else if(r.modality===types.ToolCallModalityLiteral)s.push({id:r.id,type:"function",function:{name:r.name,arguments:r.arguments}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelSchema.name}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${r.modality}'`)})}),y({role:this.modelSchema.roles[n.role],content:i},s.length>0?{tool_calls:s}:{})}case types.UserRoleLiteral:{let i=[],s=[];n.content.forEach(l=>{if(l.modality===types.TextModalityLiteral)i.push({type:"text",text:l.value});else if(l.modality===types.ImageModalityLiteral)s.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.modelSchema.name}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${l.modality}'`)})});let r=[...i,...s];return {role:this.modelSchema.roles[n.role],content:r}}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.modelSchema.name}`,cause:new Error(`role : '${n.role}' must have content with modality : '${types.ToolResponseModalityLiteral}'`)});let i=n.content[0];return {role:this.modelSchema.roles[n.role],tool_call_id:i.id,content:i.data}}default:throw new provider.InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelSchema.name}`,cause:new Error(`role : '${n.role}' is not supported,
11
- 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.modelSchema.name}`,cause:new Error(`model : '${this.modelSchema.name}' does not support tool modality : '${types.ToolCallModalityLiteral}'`)});return !e||e&&e.length===0?{tools:[]}:{tools:e.map(n=>{let i=types.Tool().safeParse(n);if(!i.success)throw new provider.InvalidToolsError({info:"Invalid tools",cause:i.error});return i.data}).map(n=>({type:"function",function:n.definition.schema}))}}getCompleteChatUrl(e,o,t){return R(this,null,function*(){return new Promise(n=>{n(this.completeChatUrl);})})}getCompleteChatHeaders(e,o,t){return R(this,null,function*(){return new Promise(n=>{n(this.getDefaultHeaders());})})}getCompleteChatData(e,o,t){return R(this,null,function*(){let n=this.transformConfig(e,o,t),i=this.transformMessages(o);if(i.messages&&i.messages.length===0)throw new provider.InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let s=t?this.transformTools(t):{};return new Promise(r=>{r(y(y(y(y({},this.getDefaultParams()),n),i),s));})})}transformCompleteChatResponse(e){let o=ke.safeParse(e);if(o.success){if(o.data.choices.length===0)throw new provider.ModelResponseError({info:"Invalid response from model",cause:new Error(`No choices in response : ${JSON.stringify(o.data)}`)});let t=o.data,n=[],i=t.choices[0].message;i.content&&n.push(types.createTextMessage(types.AssistantRoleLiteral,i.content)),i.refusal&&n.push(types.createTextMessage(types.AssistantRoleLiteral,i.refusal)),i.tool_calls&&i.tool_calls.forEach((c,d)=>{n.push(types.createToolCallMessage(types.AssistantRoleLiteral,d,c.id,c.function.name,c.function.arguments));});let s={promptTokens:t.usage.prompt_tokens,completionTokens:t.usage.completion_tokens,totalTokens:t.usage.total_tokens},r=[],l=t.choices[0].logprobs;return l&&(l.content&&r.push(...l.content.map(c=>({token:c.token,logProb:c.logprob,bytes:c.bytes,topLogProbs:c.top_logprobs.map(d=>({token:d.token,logProb:d.logprob,bytes:d.bytes}))}))),l.refusal&&r.push(...l.refusal.map(c=>({token:c.token,logProb:c.logprob,bytes:c.bytes,topLogProbs:c.top_logprobs.map(d=>({token:d.token,logProb:d.logprob,bytes:d.bytes}))})))),{messages:n,usage:s,logProbs:r}}throw new provider.ModelResponseError({info:"Invalid response from model",cause:o.error})}getStreamChatUrl(e,o,t){return R(this,null,function*(){return new Promise(n=>{n(this.streamChatUrl);})})}getStreamChatHeaders(e,o,t){return R(this,null,function*(){return new Promise(n=>{n(this.getDefaultHeaders());})})}getStreamChatData(e,o,t){return R(this,null,function*(){let n=this.transformConfig(e,o,t),i=this.transformMessages(o);if(i.messages&&i.messages.length===0)throw new provider.InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let s=t?this.transformTools(t):{};return new Promise(r=>{r(y(y(y(y({stream:!0,stream_options:{include_usage:!0}},this.getDefaultParams()),n),i),s));})})}transformStreamChatResponseChunk(e,o){return ue(this,null,function*(){var n,i;let t=(o+e).split(`
12
- `).filter(s=>s.trim()!=="");for(let s of t){if(s==="data: [DONE]")return;if(s.startsWith("data: {")&&s.endsWith("}")){let r;try{r=JSON.parse(s.substring(6));}catch(c){throw new provider.ModelResponseError({info:"Malformed JSON received in stream",cause:new Error(`Malformed JSON received in stream : ${r}`)})}let l=Ue.safeParse(r);if(l.success){let c={partialMessages:[]},d=l.data;if(d.choices.length>0){let h=d.choices[0].delta;if(h!==void 0&&Object.keys(h).length!==0){if("content"in h&&h.content!==null)c.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,h.content));else if("refusal"in h&&h.refusal!==null)c.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,h.refusal));else if("tool_calls"in h&&h.tool_calls!==void 0){let f=h.tool_calls.at(0);c.partialMessages.push(types.createPartialToolCallMessage(types.AssistantRoleLiteral,f.index,f.id,(n=f.function)==null?void 0:n.name,(i=f.function)==null?void 0:i.arguments));}}}d.usage&&(c.usage={promptTokens:d.usage.prompt_tokens,completionTokens:d.usage.completion_tokens,totalTokens:d.usage.total_tokens}),yield {partialResponse:c,buffer:o};}else throw new provider.ModelResponseError({info:"Invalid response from model",cause:l.error})}}})}};var Vt="gpt-4o",Ht="GPT-4o is a large-scale multimodal model trained by OpenAI. It is the successor to GPT-4 and is designed to be more powerful and capable than its predecessor.",ie=provider.ChatModelSchema(Se,je).parse({name:Vt,description:Ht,maxInputTokens:128e3,maxOutputTokens:128e3,roles:Ae,modalities:Pe,config:{def:te.base(128e3,4).def,schema:te.base(128e3,4).schema}}),Be=re,U=class extends k{constructor(e){super(ie,e);}};var Ke=[types.EmbeddingTextModalityLiteral,types.EmbeddingTokenModalityLiteral],Ve=zod.z.enum([types.EmbeddingTextModalityLiteral,types.EmbeddingTokenModalityLiteral]);var He=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 Wt=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)),Je=zod.z.object({model:zod.z.string().min(1).optional(),input:Wt.optional(),encoding_format:zod.z.enum(["float","base64"]).optional(),dimensions:zod.z.number().int().min(1).optional()});var me=zod.z.object({apiKey:zod.z.string(),baseUrl:zod.z.string().url(),getEmbeddingsUrl:zod.z.string().url().optional()}),$=class{constructor(e,o){this.version="v1";let t=me.parse(o);this.modelSchema=e,this.apiKey=t.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash(t.baseUrl),this.getEmbeddingsUrl=provider.urlWithoutTrailingSlash(t.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 o=r=>{let l=/(\d+)(h|m|s|ms)/g,c={h:36e5,m:6e4,s:1e3,ms:1},d,h=0;for(;(d=l.exec(r))!==null;){let f=parseInt(d[1]),g=d[2];h+=f*c[g];}return h},t=0,n=0,i=!0;e["x-ratelimit-reset-requests"]&&(t=o(e["x-ratelimit-reset-requests"])),e["x-ratelimit-reset-tokens"]&&(n=o(e["x-ratelimit-reset-tokens"]));let s=Math.max(t,n);return {shouldRetry:i,delayMs:s}}getTokenCount(e){return e.requests.reduce((o,t)=>o+t.length,0)}transformModelRequest(e){let o=Je.safeParse(e);if(!o.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:o.error});let t=o.data,n=t.model,i={encodingFormat:t.encoding_format,dimensions:t.dimensions},s=types.Config().parse(provider.removeUndefinedEntries(i)),r,l;return t.input&&(typeof t.input=="string"?l=types.EmbeddingTextModalityLiteral:typeof t.input[0]=="string"?l=types.EmbeddingTextModalityLiteral:l=types.EmbeddingTokenModalityLiteral,l===types.EmbeddingTextModalityLiteral?typeof t.input=="string"?r={modality:l,requests:[t.input]}:r={modality:l,requests:t.input}:typeof t.input[0]=="number"?r={modality:l,requests:[t.input]}:r={modality:l,requests:t.input}),{modelName:n,config:s,embeddingRequests:r}}transformConfig(e,o){let t=this.modelSchema.config.schema.safeParse(e);if(!t.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:t.error});let n=t.data;return Object.keys(n).forEach(s=>{if(!this.modelSchema.config.def[s])throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error(`Invalid config key : '${s}',
13
- available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(n).reduce((s,r)=>{let c=this.modelSchema.config.def[r].param,d=n[r];return s[c]=d,s},{})}transformEmbeddingRequests(e){let o=types.EmbeddingRequests().safeParse(e);if(!o.success)throw new provider.InvalidEmbeddingRequestsError({info:"Invalid embedding requests",cause:o.error});return {input:o.data.requests}}getGetEmbeddingsUrl(e,o){return R(this,null,function*(){return new Promise(t=>{t(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(e,o){return R(this,null,function*(){return new Promise(t=>{t(this.getDefaultHeaders());})})}getGetEmbeddingsData(e,o){return R(this,null,function*(){return new Promise(t=>{t(y(y(y({},this.getDefaultParams()),this.transformConfig(e,o)),this.transformEmbeddingRequests(o)));})})}transformGetEmbeddingsResponse(e){let o,t=He.safeParse(e);if(t.success){let n=t.data;o=typeof n.data[0].embedding=="string"?types.Base64EmbeddingLiteral:types.FloatEmbeddingLiteral;let i=n.data.map(s=>typeof s.embedding=="string"?{index:s.index,embedding:s.embedding}:{index:s.index,embedding:s.embedding});return {encodingFormat:o,embeddings:i,usage:{totalTokens:n.usage.total_tokens}}}throw new provider.ModelResponseError({info:"Invalid response from model",cause:t.error})}};var ro="text-embedding-ada-002",io="some description",pe=provider.EmbeddingModelSchema(Ve).parse({name:ro,description:io,modalities:Ke,maxInputTokens:8192,maxOutputTokens:8192,config:{def:oe.base().def,schema:oe.base().schema}}),Ze=me,L=class extends ${constructor(e){super(pe,e);}};var lo="openai",Qe=class{constructor(){this.version="v1";this.name=lo;this.baseUrl="https://api.openai.com/v1";this.chatModelFactories={"gpt-4o":{model:U,modelOptions:Be,modelSchema:ie}};this.embeddingModelFactories={"text-embedding-ada-002":{model:L,modelOptions:Ze,modelSchema:pe}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModel(e,o){var s;if(!(e in this.chatModelFactories))throw new provider.ProviderError({info:`OpenAI chat model: ${e} not found`,cause:new Error(`OpenAI chat model: ${e} not found, available chat models:
14
- ${this.chatModelLiterals().join(", ")}`)});let t=this.chatModelFactories[e].model,n=x(y({},o),{baseUrl:(s=o.baseUrl)!=null?s:this.baseUrl}),i=this.chatModelFactories[e].modelOptions.parse(n);return new t(i)}chatModelSchema(e){if(!(e in this.chatModelFactories))throw new provider.ProviderError({info:`OpenAI chat model: ${e} not found`,cause:new Error(`OpenAI chat model: ${e} not found, available chat models:
15
- ${this.chatModelLiterals().join(", ")}`)});return this.chatModelFactories[e].modelSchema}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((e,o)=>(e[o]=this.chatModelFactories[o].modelSchema,e),{})}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModel(e,o){var s;if(!(e in this.embeddingModelFactories))throw new provider.ProviderError({info:`OpenAI embedding model: ${e} not found`,cause:new Error(`OpenAI embedding model: ${e} not found, available embedding models:
16
- ${this.embeddingModelLiterals().join(", ")}`)});let t=this.embeddingModelFactories[e].model,n=x(y({},o),{baseUrl:(s=o.baseUrl)!=null?s:this.baseUrl}),i=this.embeddingModelFactories[e].modelOptions.parse(n);return new t(i)}embeddingModelSchema(e){if(!(e in this.embeddingModelFactories))throw new provider.ProviderError({info:`OpenAI embedding model: ${e} not found`,cause:new Error(`OpenAI embedding model: ${e} not found, available embedding models:
7
+ var et=Object.defineProperty,tt=Object.defineProperties;var ot=Object.getOwnPropertyDescriptors;var de=Object.getOwnPropertySymbols;var nt=Object.prototype.hasOwnProperty,st=Object.prototype.propertyIsEnumerable;var at=(p,e)=>(e=Symbol[p])?e:Symbol.for("Symbol."+p);var ce=(p,e,o)=>e in p?et(p,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):p[e]=o,y=(p,e)=>{for(var o in e||(e={}))nt.call(e,o)&&ce(p,o,e[o]);if(de)for(var o of de(e))st.call(e,o)&&ce(p,o,e[o]);return p},_=(p,e)=>tt(p,ot(e));var R=(p,e,o)=>new Promise((t,n)=>{var s=i=>{try{r(o.next(i));}catch(c){n(c);}},l=i=>{try{r(o.throw(i));}catch(c){n(c);}},r=i=>i.done?t(i.value):Promise.resolve(i.value).then(s,l);r((o=o.apply(p,e)).next());}),rt=function(p,e){this[0]=p,this[1]=e;},ue=(p,e,o)=>{var t=(l,r,i,c)=>{try{var d=o[l](r),h=(r=d.value)instanceof rt,f=d.done;Promise.resolve(h?r[0]:r).then(g=>h?t(l==="return"?l:"next",r[1]?{done:g.done,value:g.value}:g,i,c):i({value:g,done:f})).catch(g=>t("throw",g,i,c));}catch(g){c(g);}},n=l=>s[l]=r=>new Promise((i,c)=>t(l,r,i,c)),s={};return o=o.apply(p,e),s[at("asyncIterator")]=()=>s,n("next"),n("throw"),n("return"),s};var B=provider.RangeConfigItem({param:"temperature",title:provider.CONFIG.TEMPERATURE.title,description:provider.CONFIG.TEMPERATURE.description,min:0,max:2,step:.01,default:1}),N=p=>provider.RangeConfigItem({param:"max_tokens",title:provider.CONFIG.MAX_TOKENS.title,description:provider.CONFIG.MAX_TOKENS.description,min:0,max:p,step:1,default:0}),G=p=>provider.MultiStringConfigItem({param:"stop",title:provider.CONFIG.STOP(p).title,description:provider.CONFIG.STOP(p).description,max:p}),K=provider.RangeConfigItem({param:"top_p",title:provider.CONFIG.TOP_P.title,description:provider.CONFIG.TOP_P.description,min:0,max:1,step:.01,default:1}),V=provider.RangeConfigItem({param:"frequency_penalty",title:provider.CONFIG.FREQUENCY_PENALTY.title,description:provider.CONFIG.FREQUENCY_PENALTY.description,min:-2,max:2,step:.01,default:0}),H=provider.RangeConfigItem({param:"presence_penalty",title:provider.CONFIG.PRESENCE_PENALTY.title,description:provider.CONFIG.PRESENCE_PENALTY.description,min:-2,max:2,step:.01,default:0}),J=provider.RangeConfigItem({param:"seed",title:"Seed",description:"This is in BETA. Set a seed to get reproducible results. Determinism is not guaranteed. Set to 0 to disable.",min:0,max:1e6,step:1,default:0}),W=provider.SelectBooleanConfigItem({param:"logprobs",title:"LogProbs",description:"Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned.",default:!1}),Y=provider.RangeConfigItem({param:"top_logprobs",title:"Top logprobs",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.",min:0,max:20,step:1,default:0}),Z=provider.SelectStringConfigItem({param:"response_format",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.",default:"text",choices:["text","json_object"]}),Q=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 q=(p,e)=>zod.z.object({temperature:B.schema,maxTokens:N(p).schema,stop:G(e).schema,topP:K.schema,frequencyPenalty:V.schema,presencePenalty:H.schema,seed:J.schema.transform(o=>o===0?void 0:o),logProbs:W.schema,topLogProbs:Y.schema,responseFormat:Z.schema,toolChoice:Q.schema}),w=(p,e)=>({temperature:B.def,maxTokens:N(p).def,stop:G(e).def,topP:K.def,frequencyPenalty:V.def,presencePenalty:H.def,seed:J.def,responseFormat:Z.def,logProbs:W.def,topLogProbs:Y.def,toolChoice:Q.def});var ct=["object","array","number","string","boolean","enum"],fe=zod.z.enum(ct),ut=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([fe,zod.z.array(zod.z.union([fe,zod.z.literal("null")]))]).optional(),default:zod.z.any().optional(),title:zod.z.string().optional(),description:zod.z.string().max(4096).optional(),properties:zod.z.record(zod.z.any()).optional(),required:zod.z.array(zod.z.string()).optional(),minItems:zod.z.number().int().min(0).optional(),maxItems:zod.z.number().int().optional(),items:zod.z.record(zod.z.any()).optional(),enum:zod.z.array(zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()])).optional(),minimum:zod.z.number().optional(),maximum:zod.z.number().optional(),minLength:zod.z.number().int().min(0).optional(),maxLength:zod.z.number().int().optional(),$ref:zod.z.string().optional()}),ht=zod.z.object({type:zod.z.enum(["object"]),required:zod.z.array(zod.z.string()),$defs:zod.z.record(zod.z.any()).optional(),properties:zod.z.record(ut),additionalProperties:zod.z.literal(!1)}),ft=zod.z.object({name:zod.z.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:zod.z.string().max(4096),strict:zod.z.boolean().optional(),schema:ht}).optional(),ge=provider.ObjectSchemaConfigItem({param:"response_schema",title:"Response schema",description:"When response format is set to 'json_schema', the model will return a JSON object of the specified schema.",objectSchema:ft}),ye=provider.SelectStringConfigItem({param:"response_format",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.",default:"text",choices:["text","json_object","json_schema"]}),be=(p,e)=>_(y({},w(p,e)),{responseFormat:ye.def,responseSchema:ge.def}),Te=(p,e)=>q(p,e).extend({responseFormat:ye.schema,responseSchema:ge.schema});var X=provider.SelectStringConfigItem({param:"encoding_format",title:"Encoding format",description:"Select the encoding format for the word embedding.",default:"float",choices:["float","base64"]}),ee=provider.RangeConfigItem({param:"dimensions",title:"Dimensions",description:"Select the number of dimensions for the word embedding.",min:1,max:1024,step:1,default:1024});var Ce=()=>zod.z.object({encodingFormat:X.schema,dimensions:ee.schema}),Me=()=>({encodingFormat:X.def,dimensions:ee.def});var te={base:(p,e)=>({def:w(p,e),schema:q(p,e)}),responseSchema:(p,e)=>({def:be(p,e),schema:Te(p,e)})},oe={base:()=>({def:Me(),schema:Ce()})};var Se=zod.z.enum([types.SystemRoleLiteral,types.UserRoleLiteral,types.AssistantRoleLiteral,types.ToolRoleLiteral]),Ae={system:types.SystemRoleLiteral,user:types.UserRoleLiteral,assistant:types.AssistantRoleLiteral,tool:types.ToolRoleLiteral};var Pe=[types.TextModalityLiteral,types.ImageModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],je=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]);var P=zod.z.object({token:zod.z.string(),logprob:zod.z.number(),bytes:zod.z.array(zod.z.number()).nullable()}),ve=zod.z.object({content:zod.z.array(P.extend({top_logprobs:zod.z.array(P)})).nullable(),refusal:zod.z.array(P.extend({top_logprobs:zod.z.array(P)})).nullable()}).nullable(),Mt=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()})})),ke=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(),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:Mt.optional(),refusal:zod.z.string().nullable().optional()}),logprobs:ve,finish_reason:zod.z.string()})),usage:zod.z.object({prompt_tokens:zod.z.number(),completion_tokens:zod.z.number(),total_tokens:zod.z.number()})}),Rt=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()})),Ue=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:Rt.optional(),refusal:zod.z.string().nullable().optional()}).or(zod.z.object({})),logprobs:ve,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 Ot=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()})}),It=zod.z.enum(["none","auto","required"]),Et=zod.z.object({type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1)})}),St=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()})})),ne=zod.z.object({text:zod.z.string().min(1),type:zod.z.literal("text")}),At=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()})}),_t=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)})}),xt=zod.z.object({role:zod.z.literal("system"),content:zod.z.string().min(1).or(zod.z.array(ne).min(1))}),qt=zod.z.object({role:zod.z.literal("user"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([ne,At])).min(1))}),wt=zod.z.object({role:zod.z.literal("assistant"),content:zod.z.string().min(1).or(zod.z.array(ne).min(1)).optional(),tool_calls:zod.z.array(_t).min(1).optional()}).refine(p=>!(!p.content&&!p.tool_calls),{message:"one of 'content' or 'tool_calls' must be provided",path:["content","tool_calls"]}),Pt=zod.z.object({role:zod.z.literal("tool"),tool_call_id:zod.z.string().min(1),content:zod.z.string().min(1)}),jt=zod.z.union([xt,qt,wt,Pt]),$e=zod.z.object({model:zod.z.string().min(1).optional(),messages:zod.z.array(jt).min(1).optional(),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:St.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(Ot).optional(),tool_choice:It.or(Et).optional()}).refine(p=>!(p.tool_choice&&(!p.tools||p.tools.length===0)),{message:"'tools' must be provided if 'tool_choice' is provided",path:["tools"]});var re=zod.z.object({apiKey:zod.z.string(),baseUrl:zod.z.string().url(),completeChatUrl:zod.z.string().url().optional(),streamChatUrl:zod.z.string().url().optional(),organization:zod.z.string().optional()}),k=class{constructor(e,o){this.version="v1";let t=re.parse(o);this.modelSchema=e,this.apiKey=t.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash(t.baseUrl),this.streamChatUrl=provider.urlWithoutTrailingSlash(t.streamChatUrl||`${this.baseUrl}/chat/completions`),this.completeChatUrl=provider.urlWithoutTrailingSlash(t.completeChatUrl||`${this.baseUrl}/chat/completions`),this.organization=t.organization;}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return y({Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},this.organization?{"OpenAI-Organization":this.organization}:{})}getDefaultParams(){return {model:this.modelSchema.name}}getRetryDelay(e){let o=r=>{let i=/(\d+)(h|m|s|ms)/g,c={h:36e5,m:6e4,s:1e3,ms:1},d,h=0;for(;(d=i.exec(r))!==null;){let f=parseInt(d[1]),g=d[2];h+=f*c[g];}return h},t=0,n=0,s=!0;e["x-ratelimit-reset-requests"]&&(t=o(e["x-ratelimit-reset-requests"])),e["x-ratelimit-reset-tokens"]&&(n=o(e["x-ratelimit-reset-tokens"]));let l=Math.max(t,n);return {shouldRetry:s,delayMs:l}}getTokenCount(e){return e.reduce((o,t)=>o+t.content.map(n=>n.modality==="text"?n.value:"").join(" ").length,0)}transformModelRequest(e){let o=$e.safeParse(e);if(!o.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:o.error});let t=o.data,n=t.model,s={};t.response_format&&(s.responseFormat=t.response_format.type,t.response_format.type==="json_schema"&&(s.responseSchema={name:t.response_format.json_schema.name,description:t.response_format.json_schema.description||"",strict:t.response_format.json_schema.strict,schema:t.response_format.json_schema.schema})),t.tool_choice&&(typeof t.tool_choice=="string"?s.toolChoice=t.tool_choice:s.toolChoice=t.tool_choice.function.name),s.seed=t.seed,s.maxTokens=t.max_tokens,s.temperature=t.temperature,s.topP=t.top_p,s.presencePenalty=t.presence_penalty,s.frequencyPenalty=t.frequency_penalty,s.stop=t.stop,s.logProbs=t.logprobs,s.topLogProbs=t.top_logprobs;let l=types.Config().parse(provider.removeUndefinedEntries(s)),r=[],i={};t.messages&&t.messages.forEach(d=>{let h=d.role;switch(h){case"system":{let f=d.content;if(typeof f=="string")r.push({role:h,content:[{modality:types.TextModalityLiteral,value:f}]});else {let g=f.map(T=>({modality:types.TextModalityLiteral,value:T.text}));r.push({role:h,content:g});}}break;case"user":{let f=d.content;if(typeof f=="string")r.push({role:h,content:[{modality:types.TextModalityLiteral,value:f}]});else {let g=f.map(T=>T.type==="text"?{modality:types.TextModalityLiteral,value:T.text}:{modality:types.ImageModalityLiteral,detail:T.image_url.detail||"auto",value:{type:types.UrlImageContentTypeLiteral,url:T.image_url.url}});r.push({role:h,content:g});}}break;case"assistant":{let f=[];if(d.content){let g=d.content;typeof g=="string"?f.push({modality:types.TextModalityLiteral,value:g}):g.forEach(T=>{f.push({modality:types.TextModalityLiteral,value:T.text});});}d.tool_calls&&d.tool_calls.forEach((T,Xe)=>{let D={modality:types.ToolCallModalityLiteral,id:T.id,index:Xe,name:T.function.name,arguments:T.function.arguments};f.push(D),i[D.id]=D;}),r.push({role:h,content:f});}break;case"tool":{let f=d;r.push({role:h,content:[{modality:types.ToolResponseModalityLiteral,id:f.tool_call_id,index:i[f.tool_call_id].index,name:i[f.tool_call_id].name,data:f.content}]});}break}});let c=[];return t.tools&&t.tools.forEach(d=>{c.push({type:"function",definition:{schema:{name:d.function.name,description:d.function.description||"",strict:d.function.strict,parameters:d.function.parameters}}});}),{modelName:n,config:l,messages:r,tools:c}}transformConfig(e,o,t){let n=e.toolChoice;delete e.toolChoice;let s=this.modelSchema.config.schema.safeParse(e);if(!s.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:s.error});let l=s.data;n!==void 0&&(l.toolChoice=n),Object.keys(l).forEach(i=>{if(!(i in this.modelSchema.config.def))throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error(`Invalid config key : '${i}',
8
+ available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let r=Object.keys(l).reduce((i,c)=>{let d=this.modelSchema.config.def[c],h=d.param,f=l[c];return h==="max_tokens"&&d.type==="range"&&f===0?i[h]=d.max:i[h]=f,i},{});if("tool_choice"in r&&r.tool_choice!==void 0){let i=r.tool_choice;if(!t||t&&t.length===0)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(t&&t.length>0){let c=this.modelSchema.config.def.toolChoice;if(!c.choices.includes(i))if(t.map(d=>d.definition.schema.name).includes(i))r.tool_choice={type:"function",function:{name:i}};else throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error(`toolChoice : '${i}' is not part of provided 'tools' names or
9
+ one of [${c.choices.join(", ")}]`)})}}if("response_format"in r&&r.response_format!==void 0){let i=r.response_format;if(i==="json_schema")if("response_schema"in r)r.response_format={type:"json_schema",json_schema:r.response_schema},delete r.response_schema;else throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error("'responseSchema' is required in config when 'responseFormat' is 'json_schema'")});else r.response_format={type:i};}return r}transformMessages(e){if(!e||e&&e.length===0)return {messages:[]};let o=e.map(n=>{let s=types.Message().safeParse(n);if(!s.success)throw new provider.InvalidMessagesError({info:"Invalid messages",cause:s.error});return s.data});return o.forEach(n=>{n.content.forEach(s=>{if(!this.modelSchema.modalities.includes(s.modality))throw new provider.InvalidMessagesError({info:`Invalid message content for model : '${this.modelSchema.name}'`,cause:new Error(`model : '${this.modelSchema.name}' does not support modality : '${s.modality}',
10
+ available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),{messages:o.map(n=>{switch(n.role){case types.SystemRoleLiteral:{let s=[];return n.content.forEach(l=>{if(l.modality===types.TextModalityLiteral)s.push({type:"text",text:l.value});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelSchema.name}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${l.modality}'`)})}),{role:this.modelSchema.roles[n.role],content:s}}case types.AssistantRoleLiteral:{let s=[],l=[];return n.content.forEach(r=>{if(r.modality===types.TextModalityLiteral)s.push({type:"text",text:r.value});else if(r.modality===types.ToolCallModalityLiteral)l.push({id:r.id,type:"function",function:{name:r.name,arguments:r.arguments}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelSchema.name}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${r.modality}'`)})}),y({role:this.modelSchema.roles[n.role],content:s},l.length>0?{tool_calls:l}:{})}case types.UserRoleLiteral:{let s=[],l=[];n.content.forEach(i=>{if(i.modality===types.TextModalityLiteral)s.push({type:"text",text:i.value});else if(i.modality===types.ImageModalityLiteral)l.push({type:"image_url",image_url:{url:i.value.type==="url"?i.value.url:i.value.base64,detail:i.detail}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelSchema.name}`,cause:new Error(`role : '${n.role}' cannot have content with modality : '${i.modality}'`)})});let r=[...s,...l];return {role:this.modelSchema.roles[n.role],content:r}}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.modelSchema.name}`,cause:new Error(`role : '${n.role}' must have content with modality : '${types.ToolResponseModalityLiteral}'`)});let s=n.content[0];return {role:this.modelSchema.roles[n.role],tool_call_id:s.id,content:s.data}}default:throw new provider.InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelSchema.name}`,cause:new Error(`role : '${n.role}' is not supported,
11
+ 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.modelSchema.name}`,cause:new Error(`model : '${this.modelSchema.name}' does not support tool modality : '${types.ToolCallModalityLiteral}'`)});return !e||e&&e.length===0?{tools:[]}:{tools:e.map(n=>{let s=types.Tool().safeParse(n);if(!s.success)throw new provider.InvalidToolsError({info:"Invalid tools",cause:s.error});return s.data}).map(n=>({type:"function",function:n.definition.schema}))}}getCompleteChatUrl(e,o,t){return R(this,null,function*(){return new Promise(n=>{n(this.completeChatUrl);})})}getCompleteChatHeaders(e,o,t){return R(this,null,function*(){return new Promise(n=>{n(this.getDefaultHeaders());})})}getCompleteChatData(e,o,t){return R(this,null,function*(){let n=this.transformConfig(e,o,t),s=this.transformMessages(o);if(s.messages&&s.messages.length===0)throw new provider.InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let l=t?this.transformTools(t):{};return new Promise(r=>{r(y(y(y(y({},this.getDefaultParams()),n),s),l));})})}transformCompleteChatResponse(e){let o=ke.safeParse(e);if(o.success){if(o.data.choices.length===0)throw new provider.ModelResponseError({info:"Invalid response from model",cause:new Error(`No choices in response : ${JSON.stringify(o.data)}`)});let t=o.data,n=[],s=t.choices[0].message;s.content&&n.push(types.createTextMessage(types.AssistantRoleLiteral,s.content)),s.refusal&&n.push(types.createTextMessage(types.AssistantRoleLiteral,s.refusal)),s.tool_calls&&s.tool_calls.forEach((c,d)=>{n.push(types.createToolCallMessage(types.AssistantRoleLiteral,d,c.id,c.function.name,c.function.arguments));});let l={promptTokens:t.usage.prompt_tokens,completionTokens:t.usage.completion_tokens,totalTokens:t.usage.total_tokens},r=[],i=t.choices[0].logprobs;return i&&(i.content&&r.push(...i.content.map(c=>({token:c.token,logProb:c.logprob,bytes:c.bytes,topLogProbs:c.top_logprobs.map(d=>({token:d.token,logProb:d.logprob,bytes:d.bytes}))}))),i.refusal&&r.push(...i.refusal.map(c=>({token:c.token,logProb:c.logprob,bytes:c.bytes,topLogProbs:c.top_logprobs.map(d=>({token:d.token,logProb:d.logprob,bytes:d.bytes}))})))),{messages:n,usage:l,logProbs:r}}throw new provider.ModelResponseError({info:"Invalid response from model",cause:o.error})}getStreamChatUrl(e,o,t){return R(this,null,function*(){return new Promise(n=>{n(this.streamChatUrl);})})}getStreamChatHeaders(e,o,t){return R(this,null,function*(){return new Promise(n=>{n(this.getDefaultHeaders());})})}getStreamChatData(e,o,t){return R(this,null,function*(){let n=this.transformConfig(e,o,t),s=this.transformMessages(o);if(s.messages&&s.messages.length===0)throw new provider.InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let l=t?this.transformTools(t):{};return new Promise(r=>{r(y(y(y(y({stream:!0,stream_options:{include_usage:!0}},this.getDefaultParams()),n),s),l));})})}transformStreamChatResponseChunk(e,o){return ue(this,null,function*(){var n,s;let t=(o+e).split(`
12
+ `).filter(l=>l.trim()!=="");for(let l of t){if(l==="data: [DONE]")return;if(l.startsWith("data: {")&&l.endsWith("}")){let r;try{r=JSON.parse(l.substring(6));}catch(c){throw new provider.ModelResponseError({info:"Malformed JSON received in stream",cause:new Error(`Malformed JSON received in stream : ${r}`)})}let i=Ue.safeParse(r);if(i.success){let c={partialMessages:[]},d=i.data;if(d.choices.length>0){let h=d.choices[0].delta;if(h!==void 0&&Object.keys(h).length!==0){if("content"in h&&h.content!==null)c.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,h.content));else if("refusal"in h&&h.refusal!==null)c.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,h.refusal));else if("tool_calls"in h&&h.tool_calls!==void 0){let f=h.tool_calls.at(0);c.partialMessages.push(types.createPartialToolCallMessage(types.AssistantRoleLiteral,f.index,f.id,(n=f.function)==null?void 0:n.name,(s=f.function)==null?void 0:s.arguments));}}}d.usage&&(c.usage={promptTokens:d.usage.prompt_tokens,completionTokens:d.usage.completion_tokens,totalTokens:d.usage.total_tokens}),yield {partialResponse:c,buffer:o};}else throw new provider.ModelResponseError({info:"Invalid response from model",cause:i.error})}}})}};var Vt="gpt-4o",Ht="GPT-4o is a large-scale multimodal model trained by OpenAI. It is the successor to GPT-4 and is designed to be more powerful and capable than its predecessor.",ie=provider.ChatModelSchema(Se,je).parse({name:Vt,description:Ht,maxInputTokens:128e3,maxOutputTokens:128e3,roles:Ae,modalities:Pe,config:{def:te.base(128e3,4).def,schema:te.base(128e3,4).schema}}),Be=re,U=class extends k{constructor(e){super(ie,e);}};var Ke=[types.EmbeddingTextModalityLiteral,types.EmbeddingTokenModalityLiteral],Ve=zod.z.enum([types.EmbeddingTextModalityLiteral,types.EmbeddingTokenModalityLiteral]);var He=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 Wt=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)),Je=zod.z.object({model:zod.z.string().min(1).optional(),input:Wt.optional(),encoding_format:zod.z.enum(["float","base64"]).optional(),dimensions:zod.z.number().int().min(1).optional()});var me=zod.z.object({apiKey:zod.z.string(),baseUrl:zod.z.string().url(),getEmbeddingsUrl:zod.z.string().url().optional()}),F=class{constructor(e,o){this.version="v1";let t=me.parse(o);this.modelSchema=e,this.apiKey=t.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash(t.baseUrl),this.getEmbeddingsUrl=provider.urlWithoutTrailingSlash(t.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 o=r=>{let i=/(\d+)(h|m|s|ms)/g,c={h:36e5,m:6e4,s:1e3,ms:1},d,h=0;for(;(d=i.exec(r))!==null;){let f=parseInt(d[1]),g=d[2];h+=f*c[g];}return h},t=0,n=0,s=!0;e["x-ratelimit-reset-requests"]&&(t=o(e["x-ratelimit-reset-requests"])),e["x-ratelimit-reset-tokens"]&&(n=o(e["x-ratelimit-reset-tokens"]));let l=Math.max(t,n);return {shouldRetry:s,delayMs:l}}getTokenCount(e){return e.requests.reduce((o,t)=>o+t.length,0)}transformModelRequest(e){let o=Je.safeParse(e);if(!o.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:o.error});let t=o.data,n=t.model,s={encodingFormat:t.encoding_format,dimensions:t.dimensions},l=types.Config().parse(provider.removeUndefinedEntries(s)),r,i;return t.input&&(typeof t.input=="string"?i=types.EmbeddingTextModalityLiteral:typeof t.input[0]=="string"?i=types.EmbeddingTextModalityLiteral:i=types.EmbeddingTokenModalityLiteral,i===types.EmbeddingTextModalityLiteral?typeof t.input=="string"?r={modality:i,requests:[t.input]}:r={modality:i,requests:t.input}:typeof t.input[0]=="number"?r={modality:i,requests:[t.input]}:r={modality:i,requests:t.input}),{modelName:n,config:l,embeddingRequests:r}}transformConfig(e,o){let t=this.modelSchema.config.schema.safeParse(e);if(!t.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:t.error});let n=t.data;return Object.keys(n).forEach(l=>{if(!this.modelSchema.config.def[l])throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error(`Invalid config key : '${l}',
13
+ available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(n).reduce((l,r)=>{let c=this.modelSchema.config.def[r].param,d=n[r];return l[c]=d,l},{})}transformEmbeddingRequests(e){let o=types.EmbeddingRequests().safeParse(e);if(!o.success)throw new provider.InvalidEmbeddingRequestsError({info:"Invalid embedding requests",cause:o.error});return {input:o.data.requests}}getGetEmbeddingsUrl(e,o){return R(this,null,function*(){return new Promise(t=>{t(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(e,o){return R(this,null,function*(){return new Promise(t=>{t(this.getDefaultHeaders());})})}getGetEmbeddingsData(e,o){return R(this,null,function*(){return new Promise(t=>{t(y(y(y({},this.getDefaultParams()),this.transformConfig(e,o)),this.transformEmbeddingRequests(o)));})})}transformGetEmbeddingsResponse(e){let o,t=He.safeParse(e);if(t.success){let n=t.data;o=typeof n.data[0].embedding=="string"?types.Base64EmbeddingLiteral:types.FloatEmbeddingLiteral;let s=n.data.map(l=>typeof l.embedding=="string"?{index:l.index,embedding:l.embedding}:{index:l.index,embedding:l.embedding});return {encodingFormat:o,embeddings:s,usage:{totalTokens:n.usage.total_tokens}}}throw new provider.ModelResponseError({info:"Invalid response from model",cause:t.error})}};var ro="text-embedding-ada-002",io="some description",pe=provider.EmbeddingModelSchema(Ve).parse({name:ro,description:io,modalities:Ke,maxInputTokens:8192,maxOutputTokens:8192,config:{def:oe.base().def,schema:oe.base().schema}}),Ze=me,L=class extends F{constructor(e){super(pe,e);}};var lo="openai",Qe=class{constructor(){this.version="v1";this.name=lo;this.baseUrl="https://api.openai.com/v1";this.chatModelFactories={"gpt-4o":{model:U,modelOptions:Be,modelSchema:ie}};this.embeddingModelFactories={"text-embedding-ada-002":{model:L,modelOptions:Ze,modelSchema:pe}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModel(e,o){var l;if(!(e in this.chatModelFactories))throw new provider.ProviderError({info:`OpenAI chat model: ${e} not found`,cause:new Error(`OpenAI chat model: ${e} not found, available chat models:
14
+ ${this.chatModelLiterals().join(", ")}`)});let t=this.chatModelFactories[e].model,n=_(y({},o),{baseUrl:(l=o.baseUrl)!=null?l:this.baseUrl}),s=this.chatModelFactories[e].modelOptions.parse(n);return new t(s)}chatModelSchema(e){if(!(e in this.chatModelFactories))throw new provider.ProviderError({info:`OpenAI chat model: ${e} not found`,cause:new Error(`OpenAI chat model: ${e} not found, available chat models:
15
+ ${this.chatModelLiterals().join(", ")}`)});return this.chatModelFactories[e].modelSchema}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((e,o)=>(e[o]=this.chatModelFactories[o].modelSchema,e),{})}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModel(e,o){var l;if(!(e in this.embeddingModelFactories))throw new provider.ProviderError({info:`OpenAI embedding model: ${e} not found`,cause:new Error(`OpenAI embedding model: ${e} not found, available embedding models:
16
+ ${this.embeddingModelLiterals().join(", ")}`)});let t=this.embeddingModelFactories[e].model,n=_(y({},o),{baseUrl:(l=o.baseUrl)!=null?l:this.baseUrl}),s=this.embeddingModelFactories[e].modelOptions.parse(n);return new t(s)}embeddingModelSchema(e){if(!(e in this.embeddingModelFactories))throw new provider.ProviderError({info:`OpenAI embedding model: ${e} not found`,cause:new Error(`OpenAI embedding model: ${e} not found, available embedding models:
17
17
  ${this.embeddingModelLiterals().join(", ")}`)});return this.embeddingModelFactories[e].modelSchema}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((e,o)=>(e[o]=this.embeddingModelFactories[o].modelSchema,e),{})}};
18
18
 
19
19
  exports.BaseChatModel = k;
20
20
  exports.BaseChatModelOptions = re;
21
- exports.BaseEmbeddingModel = $;
21
+ exports.BaseEmbeddingModel = F;
22
22
  exports.BaseEmbeddingModelOptions = me;
23
23
  exports.ChatModelBaseConfigDef = w;
24
24
  exports.ChatModelBaseConfigSchema = q;
@@ -35,15 +35,15 @@ exports.OpenAIChatModelModalities = Pe;
35
35
  exports.OpenAIChatModelModalitiesEnum = je;
36
36
  exports.OpenAIChatModelRoles = Se;
37
37
  exports.OpenAIChatModelRolesMap = Ae;
38
- exports.OpenAIChatRequest = Fe;
38
+ exports.OpenAIChatRequest = $e;
39
39
  exports.OpenAIChatRequestAssistantMessage = wt;
40
40
  exports.OpenAIChatRequestImageContent = At;
41
41
  exports.OpenAIChatRequestMessage = jt;
42
42
  exports.OpenAIChatRequestResponseFormat = St;
43
- exports.OpenAIChatRequestSystemMessage = _t;
43
+ exports.OpenAIChatRequestSystemMessage = xt;
44
44
  exports.OpenAIChatRequestTextContent = ne;
45
45
  exports.OpenAIChatRequestTool = Ot;
46
- exports.OpenAIChatRequestToolCallContent = xt;
46
+ exports.OpenAIChatRequestToolCallContent = _t;
47
47
  exports.OpenAIChatRequestToolChoiceEnum = It;
48
48
  exports.OpenAIChatRequestToolChoiceFunction = Et;
49
49
  exports.OpenAIChatRequestToolMessage = Pt;