@adaline/openai 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +69 -69
- package/dist/index.d.ts +69 -69
- package/dist/index.js +115 -117
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -4,164 +4,162 @@ 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,Dt=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 Do=(n,e,t)=>e in n?Nt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,C=(n,e)=>{for(var t in e||(e={}))Ht.call(e,t)&&Do(n,t,e[t]);if(No)for(var t of No(e))Vt.call(e,t)&&Do(n,t,e[t]);return n},x=(n,e)=>Dt(n,Ut(e));var S=(n,e,t)=>new Promise((o,s)=>{var a=p=>{try{i(t.next(p));}catch(h){s(h);}},l=p=>{try{i(t.throw(p));}catch(h){s(h);}},i=p=>p.done?o(p.value):Promise.resolve(p.value).then(a,l);i((t=t.apply(n,e)).next());}),Jt=function(n,e){this[0]=n,this[1]=e;},W=(n,e,t)=>{var o=(l,i,p,h)=>{try{var d=t[l](i),T=(i=d.value)instanceof Jt,_=d.done;Promise.resolve(T?i[0]:i).then(b=>T?o(l==="return"?l:"next",i[1]?{done:b.done,value:b.value}:b,p,h):p({value:b,done:_})).catch(b=>o("throw",b,p,h));}catch(b){h(b);}},s=l=>a[l]=i=>new Promise((p,h)=>o(l,i,p,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}),$e=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}),De=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:$e.schema,seed:Ne.schema.transform(t=>t===0?void 0:t),logProbs:De.schema,topLogProbs:Ue.schema,toolChoice:He.schema}),$=(n,e)=>({temperature:Le.def,maxTokens:je(n).def,stop:ze(e).def,topP:Be.def,frequencyPenalty:Fe.def,presencePenalty:$e.def,seed:Ne.def,logProbs:De.def,topLogProbs:Ue.def,toolChoice:He.def});var Ho=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"]}),Vo=(n,e)=>x(C({},$(n,e)),{responseFormat:Ho.def}),Ko=(n,e)=>F(n,e).extend({responseFormat:Ho.schema});var Jo=provider.ObjectSchemaConfigItem({param:"response_schema",title:provider.CHAT_CONFIG.RESPONSE_SCHEMA.title,description:provider.CHAT_CONFIG.RESPONSE_SCHEMA.description,objectSchema:types.ResponseSchema}),Wo=provider.SelectStringConfigItem({param:"response_format",title:provider.CHAT_CONFIG.RESPONSE_FORMAT_WITH_SCHEMA.title,description:provider.CHAT_CONFIG.RESPONSE_FORMAT_WITH_SCHEMA.description,default:"text",choices:["text","json_object","json_schema"]}),X=(n,e)=>x(C({},$(n,e)),{responseFormat:Wo.def,responseSchema:Jo.def}),Q=(n,e)=>F(n,e).extend({responseFormat:Wo.schema,responseSchema:Jo.schema});var Xo=provider.RangeConfigItem({param:"temperature",title:provider.CHAT_CONFIG.TEMPERATURE.title,description:provider.CHAT_CONFIG.TEMPERATURE.description,min:1,max:1,step:.01,default:1}),Qo=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}),Zo=(n,e)=>x(C({},X(n,e)),{temperature:Xo.def,maxTokens:Qo(n).def}),et=(n,e)=>Q(n,e).extend({temperature:Xo.schema,maxTokens:Qo(n).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 ee=()=>zod.z.object({encodingFormat:Ve.schema}),oe=()=>({encodingFormat:Ve.def});var ot=n=>ee().extend({dimensions:Ke(n).schema}),tt=n=>x(C({},oe()),{dimensions:Ke(n).def});var c={base:(n,e)=>({def:$(n,e),schema:F(n,e)}),responseFormat:(n,e)=>({def:Vo(n,e),schema:Ko(n,e)}),responseSchema:(n,e)=>({def:X(n,e),schema:Q(n,e)}),oSeries:(n,e)=>({def:Zo(n,e),schema:et(n,e)})},v={base:()=>({def:oe(),schema:ee()}),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},se=zod.z.enum([types.UserRoleLiteral,types.AssistantRoleLiteral]),ae={user:types.UserRoleLiteral,assistant:types.AssistantRoleLiteral};var E=[types.TextModalityLiteral,types.ImageModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],R=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]),pe=[types.TextModalityLiteral],le=zod.z.enum([types.TextModalityLiteral]),P=[types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],I=zod.z.enum([types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]);var me=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(me.extend({top_logprobs:zod.z.array(me)})).nullable().optional(),refusal:zod.z.array(me.extend({top_logprobs:zod.z.array(me)})).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()})})),pt=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()})}),pn=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()})),lt=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:pn.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 ln=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]),de=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(ln).optional(),tool_choice:mn.or(dn).optional()});var mt=de.omit({max_tokens:!0}).extend({max_completion_tokens:zod.z.number().min(0).nullable().optional()});var u=zod.z.object({modelName:zod.z.string(),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()}),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),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 C({Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json",source:"adaline.ai"},this.organization?{"OpenAI-Organization":this.organization}:{})}getDefaultParams(){return {model:this.modelName}}getRetryDelay(e){let t=i=>{let p=/(\d+)(h|m|s|ms)/g,h={h:36e5,m:6e4,s:1e3,ms:1},d,T=0;for(;(d=p.exec(i))!==null;){let _=parseInt(d[1]),b=d[2];T+=_*h[b];}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 l=Math.max(o,s);return {shouldRetry:a,delayMs:l}}getTokenCount(e){return e.reduce((t,o)=>t+o.content.map(s=>s.modality==="text"?s.value:"").join(" ").length,0)}transformModelRequest(e){let t=de.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 l=types.Config().parse(provider.removeUndefinedEntries(a)),i=[],p={};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 b=_.map(M=>({modality:types.TextModalityLiteral,value:M.text}));i.push({role:T,content:b});}}break;case"user":{let _=d.content;if(typeof _=="string")i.push({role:T,content:[{modality:types.TextModalityLiteral,value:_}]});else {let b=_.map(M=>M.type==="text"?{modality:types.TextModalityLiteral,value:M.text}:M.image_url.url.startsWith("data:")?{modality:types.ImageModalityLiteral,detail:M.image_url.detail||"auto",value:{type:types.Base64ImageContentTypeLiteral,base64:M.image_url.url,media_type:provider.getMimeTypeFromBase64(M.image_url.url)}}:{modality:types.ImageModalityLiteral,detail:M.image_url.detail||"auto",value:{type:types.UrlImageContentTypeLiteral,url:M.image_url.url}});i.push({role:T,content:b});}}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 b=d.content;typeof b=="string"?_.push({modality:types.TextModalityLiteral,value:b}):b.forEach(M=>{_.push({modality:types.TextModalityLiteral,value:M.text});});}d.tool_calls&&d.tool_calls.forEach((M,$t)=>{let ke={modality:types.ToolCallModalityLiteral,id:M.id,index:$t,name:M.function.name,arguments:M.function.arguments};_.push(ke),p[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:p[_.tool_call_id].index,name:p[_.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:l,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 l=a.data;s!==void 0&&(l.toolChoice=s),Object.keys(l).forEach(p=>{if(!(p in this.modelSchema.config.def))throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${p}',
|
|
8
|
-
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let i=Object.keys(
|
|
9
|
-
one of [${h.choices.join(", ")}]`)})}}if("response_format"in i&&i.response_format!==void 0){let
|
|
10
|
-
available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),t.forEach(
|
|
11
|
-
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}),{messages:t.map(
|
|
12
|
-
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(
|
|
13
|
-
`).filter(l=>l.trim()!=="");for(let l of o){if(l==="data: [DONE]")return;if(l.startsWith("data: {")&&l.endsWith("}")){let i;try{i=JSON.parse(l.substring(6));}catch(h){throw new provider.ModelResponseError({info:"Malformed JSON received in stream",cause:new Error(`Malformed JSON received in stream : ${i}`)})}let p=lt.safeParse(i);if(p.success){let h={partialMessages:[]},d=p.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:p.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=x(C({},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 W(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 eo="gpt-3.5-turbo-0125",kn="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.",oo=provider.ChatModelSchema(g,I).parse({name:eo,description:kn,maxInputTokens:4092,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.responseFormat(4092,4).def,schema:c.responseFormat(4092,4).schema}}),ut=u,ue=class extends f{constructor(e){super(oo,e);}};var to="gpt-3.5-turbo-1106",jn="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.",no=provider.ChatModelSchema(g,I).parse({name:to,description:jn,maxInputTokens:4092,maxOutputTokens:16385,roles:y,modalities:P,config:{def:c.responseFormat(16385,4).def,schema:c.responseFormat(16385,4).schema}}),ft=u,fe=class extends f{constructor(e){super(no,e);}};var so="gpt-3.5-turbo",Bn="Currently points to gpt-3.5-turbo-0125. Training data up to Sept 2021.",ao=provider.ChatModelSchema(g,I).parse({name:so,description:Bn,maxInputTokens:4092,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.responseFormat(4092,4).def,schema:c.responseFormat(4092,4).schema}}),Tt=u,Te=class extends f{constructor(e){super(ao,e);}};var io="gpt-4-0125-preview",$n="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.",ro=provider.ChatModelSchema(g,I).parse({name:io,description:$n,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.base(4092,4).def,schema:c.base(4092,4).schema}}),_t=u,_e=class extends f{constructor(e){super(ro,e);}};var po="gpt-4-0613",Dn="Snapshot of gpt-4 from June 13th 2023 with improved function calling support. Training data up to Sept 2021.",lo=provider.ChatModelSchema(g,I).parse({name:po,description:Dn,maxInputTokens:8192,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.base(4092,4).def,schema:c.base(4092,4).schema}}),gt=u,ge=class extends f{constructor(e){super(lo,e);}};var mo="gpt-4-1106-preview",Hn="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.",co=provider.ChatModelSchema(g,I).parse({name:mo,description:Hn,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.base(4092,4).def,schema:c.base(4092,4).schema}}),yt=u,ye=class extends f{constructor(e){super(co,e);}};var ho="gpt-4-turbo-2024-04-09",Kn="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.",uo=provider.ChatModelSchema(g,R).parse({name:ho,description:Kn,maxInputTokens:128e3,maxOutputTokens:4096,roles:y,modalities:E,config:{def:c.responseFormat(4096,4).def,schema:c.responseFormat(4096,4).schema}}),Ct=u,Ce=class extends f{constructor(e){super(uo,e);}};var fo="gpt-4-turbo-preview",Wn="Currently points to gpt-4-0125-preview. Training data up to Apr 2023.",To=provider.ChatModelSchema(g,I).parse({name:fo,description:Wn,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.responseFormat(4092,4).def,schema:c.responseFormat(4092,4).schema}}),bt=u,be=class extends f{constructor(e){super(To,e);}};var _o="gpt-4-turbo",Xn="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.",go=provider.ChatModelSchema(g,R).parse({name:_o,description:Xn,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:E,config:{def:c.responseFormat(4092,4).def,schema:c.responseFormat(4092,4).schema}}),Ot=u,Oe=class extends f{constructor(e){super(go,e);}};var yo="gpt-4",Zn="Currently points to gpt-4-0613. Training data up to Sept 2021.",Co=provider.ChatModelSchema(g,I).parse({name:yo,description:Zn,maxInputTokens:8192,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.base(4092,4).def,schema:c.base(4092,4).schema}}),Mt=u,Me=class extends f{constructor(e){super(Co,e);}};var bo="gpt-4o-2024-08-06",os="Latest snapshot of gpt-4o that supports Structured Outputs. Training data up to Oct 2023.",Oo=provider.ChatModelSchema(g,R).parse({name:bo,description:os,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:E,config:{def:c.responseSchema(4092,4).def,schema:c.responseSchema(4092,4).schema}}),Pt=u,Pe=class extends f{constructor(e){super(Oo,e);}};var Mo="gpt-4o-mini",ns="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,R).parse({name:Mo,description:ns,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:E,config:{def:c.responseSchema(4092,4).def,schema:c.responseSchema(4092,4).schema}}),It=u,Ie=class extends f{constructor(e){super(Po,e);}};var Io="gpt-4o",as="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.",So=provider.ChatModelSchema(g,R).parse({name:Io,description:as,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:E,config:{def:c.responseFormat(4092,4).def,schema:c.responseFormat(4092,4).schema}}),St=u,Se=class extends f{constructor(e){super(So,e);}};var Eo="gpt-4o-mini-2024-07-18",rs="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.",Ro=provider.ChatModelSchema(g,R).parse({name:Eo,description:rs,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:E,config:{def:c.responseSchema(4092,4).def,schema:c.responseSchema(4092,4).schema}}),Et=u,Ee=class extends f{constructor(e){super(Ro,e);}};var xo="gpt-4o-2024-05-13",ls="Latest snapshot of gpt-4o that supports Structured Outputs. Training data up to Oct 2023.",Ao=provider.ChatModelSchema(g,R).parse({name:xo,description:ls,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:E,config:{def:c.responseSchema(4092,4).def,schema:c.responseSchema(4092,4).schema}}),Rt=u,Re=class extends f{constructor(e){super(Ao,e);}};var wo="o1-mini",ds="Faster and cheaper reasoning model particularly good at coding, math, and science. Training data up to Oct 2023.",Go=provider.ChatModelSchema(se,le).parse({name:wo,description:ds,maxInputTokens:128e3,maxOutputTokens:4092,roles:ae,modalities:pe,config:{def:c.oSeries(4092,4).def,schema:c.oSeries(4092,4).schema}}),xt=u,xe=class extends U{constructor(e){super(Go,e);}};var vo="o1-preview",hs="Reasoning model designed to solve hard problems across domains. Training data up to Oct 2023.",qo=provider.ChatModelSchema(se,le).parse({name:vo,description:hs,maxInputTokens:128e3,maxOutputTokens:4092,roles:ae,modalities:pe,config:{def:c.oSeries(4092,4).def,schema:c.oSeries(4092,4).schema}}),At=u,Ae=class extends U{constructor(e){super(qo,e);}};var H=[types.EmbeddingTextModalityLiteral,types.EmbeddingTokenModalityLiteral],V=zod.z.enum([types.EmbeddingTextModalityLiteral,types.EmbeddingTokenModalityLiteral]);var vt=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 fs=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)),qt=zod.z.object({model:zod.z.string().min(1).optional(),input:fs,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(),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),this.getEmbeddingsUrl=provider.urlWithoutTrailingSlash(o.getEmbeddingsUrl||`${this.baseUrl}/embeddings`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json",source:"adaline.ai"}}getDefaultParams(){return {model:this.modelSchema.name}}getRetryDelay(e){let t=i=>{let p=/(\d+)(h|m|s|ms)/g,h={h:36e5,m:6e4,s:1e3,ms:1},d,T=0;for(;(d=p.exec(i))!==null;){let _=parseInt(d[1]),b=d[2];T+=_*h[b];}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 l=Math.max(o,s);return {shouldRetry:a,delayMs:l}}getTokenCount(e){return e.requests.reduce((t,o)=>t+o.length,0)}transformModelRequest(e){let t=qt.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},l=types.Config().parse(provider.removeUndefinedEntries(a)),i,p;return typeof o.input=="string"?p=types.EmbeddingTextModalityLiteral:typeof o.input[0]=="string"?p=types.EmbeddingTextModalityLiteral:p=types.EmbeddingTokenModalityLiteral,p===types.EmbeddingTextModalityLiteral?typeof o.input=="string"?i={modality:p,requests:[o.input]}:i={modality:p,requests:o.input}:typeof o.input[0]=="number"?i={modality:p,requests:[o.input]}:i={modality:p,requests:o.input},{modelName:s,config:l,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(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}',
|
|
14
|
-
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(
|
|
15
|
-
[${this.chatModelLiterals().join(", ")}]`)});if(!(t in this.
|
|
16
|
-
[${this.
|
|
17
|
-
[${this.embeddingModelLiterals().join(", ")}]`)});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:
|
|
18
|
-
[${this.embeddingModelLiterals().join(", ")}]`)});let o=this.embeddingModelFactories[t].model,s=x(C({},e),{modelName:t,baseUrl:(l=e.baseUrl)!=null?l:this.baseUrl}),a=this.embeddingModelFactories[t].modelOptions.parse(s);return new o(a)}};
|
|
7
|
+
var Nt=Object.defineProperty,Ut=Object.defineProperties;var $t=Object.getOwnPropertyDescriptors;var Do=Object.getOwnPropertySymbols;var Ht=Object.prototype.hasOwnProperty,Vt=Object.prototype.propertyIsEnumerable;var Kt=(s,e)=>(e=Symbol[s])?e:Symbol.for("Symbol."+s);var No=(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)&&No(s,t,e[t]);if(Do)for(var t of Do(e))Vt.call(e,t)&&No(s,t,e[t]);return s},R=(s,e)=>Ut(s,$t(e));var S=(s,e,t)=>new Promise((o,n)=>{var a=l=>{try{i(t.next(l));}catch(h){n(h);}},p=l=>{try{i(t.throw(l));}catch(h){n(h);}},i=l=>l.done?o(l.value):Promise.resolve(l.value).then(a,p);i((t=t.apply(s,e)).next());}),Jt=function(s,e){this[0]=s,this[1]=e;},W=(s,e,t)=>{var o=(p,i,l,h)=>{try{var d=t[p](i),T=(i=d.value)instanceof Jt,_=d.done;Promise.resolve(T?i[0]:i).then(C=>T?o(p==="return"?p:"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=p=>a[p]=i=>new Promise((l,h)=>o(p,i,l,h)),a={};return t=t.apply(s,e),a[Kt("asyncIterator")]=()=>a,n("next"),n("throw"),n("return"),a};var ke=provider.RangeConfigItem({param:"temperature",title:provider.CHAT_CONFIG.TEMPERATURE.title,description:provider.CHAT_CONFIG.TEMPERATURE.description,min:0,max:2,step:.01,default:1}),Le=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}),je=s=>provider.MultiStringConfigItem({param:"stop",title:provider.CHAT_CONFIG.STOP(s).title,description:provider.CHAT_CONFIG.STOP(s).description,max:s}),ze=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}),Be=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}),Fe=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}),De=provider.RangeConfigItem({param:"seed",title:provider.CHAT_CONFIG.SEED.title,description:provider.CHAT_CONFIG.SEED.description,min:0,max:1e6,step:1,default:0}),Ne=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}),$e=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=(s,e)=>zod.z.object({temperature:ke.schema,maxTokens:Le(s).schema,stop:je(e).schema,topP:ze.schema,frequencyPenalty:Be.schema,presencePenalty:Fe.schema,seed:De.schema.transform(t=>t===0?void 0:t),logProbs:Ne.schema,topLogProbs:Ue.schema,toolChoice:$e.schema}),D=(s,e)=>({temperature:ke.def,maxTokens:Le(s).def,stop:je(e).def,topP:ze.def,frequencyPenalty:Be.def,presencePenalty:Fe.def,seed:De.def,logProbs:Ne.def,topLogProbs:Ue.def,toolChoice:$e.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}),$o=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"]}),X=(s,e)=>R(M({},D(s,e)),{responseFormat:$o.def,responseSchema:Uo.def}),Q=(s,e)=>F(s,e).extend({responseFormat:$o.schema,responseSchema:Uo.schema});var Vo=provider.RangeConfigItem({param:"temperature",title:provider.CHAT_CONFIG.TEMPERATURE.title,description:provider.CHAT_CONFIG.TEMPERATURE.description,min:1,max:1,step:.01,default:1}),Ko=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}),Jo=(s,e)=>R(M({},X(s,e)),{temperature:Vo.def,maxTokens:Ko(s).def}),Wo=(s,e)=>Q(s,e).extend({temperature:Vo.schema,maxTokens:Ko(s).schema});var Xo=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"]}),Qo=(s,e)=>R(M({},D(s,e)),{responseFormat:Xo.def}),Zo=(s,e)=>F(s,e).extend({responseFormat:Xo.schema});var He=provider.SelectStringConfigItem({param:"encoding_format",title:"Encoding format",description:"Select the encoding format for the word embedding.",default:"float",choices:["float","base64"]}),Ve=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 ee=()=>zod.z.object({encodingFormat:He.schema}),oe=()=>({encodingFormat:He.def});var et=s=>ee().extend({dimensions:Ve(s).schema}),ot=s=>R(M({},oe()),{dimensions:Ve(s).def});var c={base:(s,e)=>({def:D(s,e),schema:F(s,e)}),responseFormat:(s,e)=>({def:Qo(s,e),schema:Zo(s,e)}),responseSchema:(s,e)=>({def:X(s,e),schema:Q(s,e)}),oSeries:(s,e)=>({def:Jo(s,e),schema:Wo(s,e)})},v={base:()=>({def:oe(),schema:ee()}),dimensions:s=>({def:ot(s),schema:et(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},ne=zod.z.enum([types.UserRoleLiteral,types.AssistantRoleLiteral]),ae={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]),le=[types.TextModalityLiteral],pe=zod.z.enum([types.TextModalityLiteral]),P=[types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],I=zod.z.enum([types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]);var me=zod.z.object({token:zod.z.string(),logprob:zod.z.number(),bytes:zod.z.array(zod.z.number()).nullable()}),it=zod.z.object({content:zod.z.array(me.extend({top_logprobs:zod.z.array(me)})).nullable().optional(),refusal:zod.z.array(me.extend({top_logprobs:zod.z.array(me)})).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()})})),rt=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:it.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()})),lt=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:it,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()})})),Je=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(Je).min(1))}),fs=zod.z.object({role:zod.z.literal("user"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([Je,cs])).min(1))}),Ts=zod.z.object({role:zod.z.literal("assistant"),content:zod.z.string().min(1).or(zod.z.array(Je).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]),de=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 pt=de.omit({max_tokens:!0}).extend({max_completion_tokens:zod.z.number().min(0).nullable().optional()});var u=zod.z.object({modelName:zod.z.string(),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()}),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),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 p=Math.max(o,n);return {shouldRetry:a,delayMs:p}}getTokenCount(e){return e.reduce((t,o)=>t+o.content.map(n=>n.modality==="text"?n.value:"").join(" ").length,0)}transformModelRequest(e){let t=de.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 p=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 qe={modality:types.ToolCallModalityLiteral,id:O.id,index:Dt,name:O.function.name,arguments:O.function.arguments};_.push(qe),l[qe.id]=qe;}),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:p,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 p=a.data;n!==void 0&&(p.toolChoice=n),Object.keys(p).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}',
|
|
8
|
+
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let i=Object.keys(p).reduce((l,h)=>{let d=this.modelSchema.config.def[h],T=d.param,_=p[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
|
|
9
|
+
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}',
|
|
10
|
+
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}',
|
|
11
|
+
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}),{messages:t.map(n=>{switch(n.role){case types.SystemRoleLiteral:{let a=[];return n.content.forEach(p=>{if(p.modality===types.TextModalityLiteral)a.push({type:"text",text:p.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 : '${p.modality}'`)})}),{role:this.modelSchema.roles[n.role],content:a}}case types.AssistantRoleLiteral:{let a=[],p=[];return n.content.forEach(i=>{if(i.modality===types.TextModalityLiteral)a.push({type:"text",text:i.value});else if(i.modality===types.ToolCallModalityLiteral)p.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},p.length>0?{tool_calls:p}:{})}case types.UserRoleLiteral:{let a=[],p=[];n.content.forEach(l=>{if(l.modality===types.TextModalityLiteral)a.push({type:"text",text:l.value});else if(l.modality===types.ImageModalityLiteral)p.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,...p];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,
|
|
12
|
+
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 p=o?this.transformTools(o):{};return new Promise(i=>{i(M(M(M(M({},this.getDefaultParams()),n),a),p));})})}transformCompleteChatResponse(e){let t=rt.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 p={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:p,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 p=o?this.transformTools(o):{};return new Promise(i=>{i(M(M(M(M({stream:!0,stream_options:{include_usage:!0}},this.getDefaultParams()),n),a),p));})})}transformStreamChatResponseChunk(e,t){return W(this,null,function*(){var n,a;let o=(t+e).split(`
|
|
13
|
+
`).filter(p=>p.trim()!=="");for(let p of o){if(p==="data: [DONE]")return;if(p.startsWith("data: {")&&p.endsWith("}")){let i;try{i=JSON.parse(p.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=lt.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 $=class extends f{constructor(e,t){super(e,t);}transformModelRequest(e){let t=pt.safeParse(e);if(!t.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:t.error});let o=t.data,n=R(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 W(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 Ze="gpt-3.5-turbo-0125",qs="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.",eo=provider.ChatModelSchema(g,I).parse({name:Ze,description:qs,maxInputTokens:4092,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.responseFormat(4092,4).def,schema:c.responseFormat(4092,4).schema}}),ht=u,ue=class extends f{constructor(e){super(eo,e);}};var oo="gpt-3.5-turbo-1106",Ls="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.",to=provider.ChatModelSchema(g,I).parse({name:oo,description:Ls,maxInputTokens:4092,maxOutputTokens:16385,roles:y,modalities:P,config:{def:c.responseFormat(16385,4).def,schema:c.responseFormat(16385,4).schema}}),ut=u,fe=class extends f{constructor(e){super(to,e);}};var so="gpt-3.5-turbo",zs="Currently points to gpt-3.5-turbo-0125. Training data up to Sept 2021.",no=provider.ChatModelSchema(g,I).parse({name:so,description:zs,maxInputTokens:4092,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.responseFormat(4092,4).def,schema:c.responseFormat(4092,4).schema}}),ft=u,Te=class extends f{constructor(e){super(no,e);}};var ao="gpt-4-0125-preview",Fs="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.",io=provider.ChatModelSchema(g,I).parse({name:ao,description:Fs,maxInputTokens:128e3,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(io,e);}};var ro="gpt-4-0613",Ns="Snapshot of gpt-4 from June 13th 2023 with improved function calling support. Training data up to Sept 2021.",lo=provider.ChatModelSchema(g,I).parse({name:ro,description:Ns,maxInputTokens:8192,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(lo,e);}};var po="gpt-4-1106-preview",$s="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.",mo=provider.ChatModelSchema(g,I).parse({name:po,description:$s,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.base(4092,4).def,schema:c.base(4092,4).schema}}),gt=u,ye=class extends f{constructor(e){super(mo,e);}};var co="gpt-4-turbo-2024-04-09",Vs="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.",ho=provider.ChatModelSchema(g,x).parse({name:co,description:Vs,maxInputTokens:128e3,maxOutputTokens:4096,roles:y,modalities:E,config:{def:c.responseFormat(4096,4).def,schema:c.responseFormat(4096,4).schema}}),yt=u,Me=class extends f{constructor(e){super(ho,e);}};var uo="gpt-4-turbo-preview",Js="Currently points to gpt-4-0125-preview. Training data up to Apr 2023.",fo=provider.ChatModelSchema(g,I).parse({name:uo,description:Js,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.responseFormat(4092,4).def,schema:c.responseFormat(4092,4).schema}}),Mt=u,Ce=class extends f{constructor(e){super(fo,e);}};var To="gpt-4-turbo",Ys="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.",_o=provider.ChatModelSchema(g,x).parse({name:To,description:Ys,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:E,config:{def:c.responseFormat(4092,4).def,schema:c.responseFormat(4092,4).schema}}),Ct=u,be=class extends f{constructor(e){super(_o,e);}};var go="gpt-4",Qs="Currently points to gpt-4-0613. Training data up to Sept 2021.",yo=provider.ChatModelSchema(g,I).parse({name:go,description:Qs,maxInputTokens:8192,maxOutputTokens:4092,roles:y,modalities:P,config:{def:c.base(4092,4).def,schema:c.base(4092,4).schema}}),bt=u,Oe=class extends f{constructor(e){super(yo,e);}};var Mo="gpt-4o-2024-08-06",en="Latest snapshot of gpt-4o that supports Structured Outputs. Training data up to Oct 2023.",Co=provider.ChatModelSchema(g,x).parse({name:Mo,description:en,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(Co,e);}};var bo="gpt-4o-mini",tn="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.",Oo=provider.ChatModelSchema(g,x).parse({name:bo,description:tn,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:E,config:{def:c.responseSchema(4092,4).def,schema:c.responseSchema(4092,4).schema}}),Pt=u,Ie=class extends f{constructor(e){super(Oo,e);}};var Po="gpt-4o",nn="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.",Io=provider.ChatModelSchema(g,x).parse({name:Po,description:nn,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:E,config:{def:c.responseFormat(4092,4).def,schema:c.responseFormat(4092,4).schema}}),It=u,Se=class extends f{constructor(e){super(Io,e);}};var So="gpt-4o-mini-2024-07-18",rn="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.",Eo=provider.ChatModelSchema(g,x).parse({name:So,description:rn,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(Eo,e);}};var xo="gpt-4o-2024-05-13",pn="Latest snapshot of gpt-4o that supports Structured Outputs. Training data up to Oct 2023.",Ro=provider.ChatModelSchema(g,x).parse({name:xo,description:pn,maxInputTokens:128e3,maxOutputTokens:4092,roles:y,modalities:E,config:{def:c.responseSchema(4092,4).def,schema:c.responseSchema(4092,4).schema}}),Et=u,xe=class extends f{constructor(e){super(Ro,e);}};var Ao="o1-mini",dn="Faster and cheaper reasoning model particularly good at coding, math, and science. Training data up to Oct 2023.",wo=provider.ChatModelSchema(ne,pe).parse({name:Ao,description:dn,maxInputTokens:128e3,maxOutputTokens:4092,roles:ae,modalities:le,config:{def:c.oSeries(4092,4).def,schema:c.oSeries(4092,4).schema}}),xt=u,Re=class extends ${constructor(e){super(wo,e);}};var Go="o1-preview",hn="Reasoning model designed to solve hard problems across domains. Training data up to Oct 2023.",vo=provider.ChatModelSchema(ne,pe).parse({name:Go,description:hn,maxInputTokens:128e3,maxOutputTokens:4092,roles:ae,modalities:le,config:{def:c.oSeries(4092,4).def,schema:c.oSeries(4092,4).schema}}),Rt=u,Ae=class extends ${constructor(e){super(vo,e);}};var H=[types.EmbeddingTextModalityLiteral,types.EmbeddingTokenModalityLiteral],V=zod.z.enum([types.EmbeddingTextModalityLiteral,types.EmbeddingTokenModalityLiteral]);var Gt=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 fn=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)),vt=zod.z.object({model:zod.z.string().min(1).optional(),input:fn,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(),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),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 p=Math.max(o,n);return {shouldRetry:a,delayMs:p}}getTokenCount(e){return e.requests.reduce((t,o)=>t+o.length,0)}transformModelRequest(e){let t=vt.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},p=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:p,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(p=>{if(!this.modelSchema.config.def[p])throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error(`Invalid config key : '${p}',
|
|
14
|
+
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(n).reduce((p,i)=>{let h=this.modelSchema.config.def[i].param,d=n[i];return p[h]=d,p},{})}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=Gt.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(p=>typeof p.embedding=="string"?{index:p.index,embedding:p.embedding}:{index:p.index,embedding:p.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 ko="text-embedding-ada-002",Sn="Most capable 2nd generation embedding model, replacing 16 first generation models",Lo=provider.EmbeddingModelSchema(V).parse({name:ko,description:Sn,modalities:H,maxInputTokens:8192,maxOutputTokens:1536,config:{def:v.base().def,schema:v.base().schema}}),Lt=B,we=class extends k{constructor(e){super(Lo,e);}};var jo="text-embedding-3-small",xn="Increased performance over 2nd generation ada embedding model",zo=provider.EmbeddingModelSchema(V).parse({name:jo,description:xn,modalities:H,maxInputTokens:8192,maxOutputTokens:1536,config:{def:v.dimensions(1536).def,schema:v.dimensions(1536).schema}}),jt=B,Ge=class extends k{constructor(e){super(zo,e);}};var Bo="text-embedding-3-large",An="Most capable embedding model for both english and non-english tasks",Fo=provider.EmbeddingModelSchema(V).parse({name:Bo,description:An,modalities:H,maxInputTokens:8192,maxOutputTokens:3072,config:{def:v.dimensions(3072).def,schema:v.dimensions(3072).schema}}),zt=B,ve=class extends k{constructor(e){super(Fo,e);}};var wn="openai",Ft=class{constructor(){this.version="v1";this.name=wn;this.baseUrl="https://api.openai.com/v1";this.chatModelFactories={[so]:{model:Te,modelOptions:ft,modelSchema:no},[Ze]:{model:ue,modelOptions:ht,modelSchema:eo},[oo]:{model:fe,modelOptions:ut,modelSchema:to},[ao]:{model:_e,modelOptions:Tt,modelSchema:io},[ro]:{model:ge,modelOptions:_t,modelSchema:lo},[po]:{model:ye,modelOptions:gt,modelSchema:mo},[co]:{model:Me,modelOptions:yt,modelSchema:ho},[uo]:{model:Ce,modelOptions:Mt,modelSchema:fo},[To]:{model:be,modelOptions:Ct,modelSchema:_o},[go]:{model:Oe,modelOptions:bt,modelSchema:yo},[Mo]:{model:Pe,modelOptions:Ot,modelSchema:Co},[bo]:{model:Ie,modelOptions:Pt,modelSchema:Oo},[Po]:{model:Se,modelOptions:It,modelSchema:Io},[So]:{model:Ee,modelOptions:St,modelSchema:Eo},[xo]:{model:xe,modelOptions:Et,modelSchema:Ro},[Ao]:{model:Re,modelOptions:xt,modelSchema:wo},[Go]:{model:Ae,modelOptions:Rt,modelSchema:vo}};this.embeddingModelFactories={[ko]:{model:we,modelOptions:Lt,modelSchema:Lo},[jo]:{model:Ge,modelOptions:jt,modelSchema:zo},[Bo]:{model:ve,modelOptions:zt,modelSchema:Fo}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((e,t)=>(e[t]=this.chatModelFactories[t].modelSchema,e),{})}chatModel(e){var p;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:
|
|
15
|
+
[${this.chatModelLiterals().join(", ")}]`)});let o=this.chatModelFactories[t].model,n=R(M({},e),{baseUrl:(p=e.baseUrl)!=null?p:this.baseUrl}),a=this.chatModelFactories[t].modelOptions.parse(n);return new o(a)}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((e,t)=>(e[t]=this.embeddingModelFactories[t].modelSchema,e),{})}embeddingModel(e){var p;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:
|
|
16
|
+
[${this.embeddingModelLiterals().join(", ")}]`)});let o=this.embeddingModelFactories[t].model,n=R(M({},e),{baseUrl:(p=e.baseUrl)!=null?p:this.baseUrl}),a=this.embeddingModelFactories[t].modelOptions.parse(n);return new o(a)}};
|
|
19
17
|
|
|
20
18
|
exports.BaseChatModel = f;
|
|
21
19
|
exports.BaseChatModelOptions = u;
|
|
22
20
|
exports.BaseEmbeddingModel = k;
|
|
23
21
|
exports.BaseEmbeddingModelOptions = B;
|
|
24
|
-
exports.BaseOSeriesChatModel =
|
|
25
|
-
exports.ChatModelBaseConfigDef =
|
|
22
|
+
exports.BaseOSeriesChatModel = $;
|
|
23
|
+
exports.ChatModelBaseConfigDef = D;
|
|
26
24
|
exports.ChatModelBaseConfigSchema = F;
|
|
27
|
-
exports.ChatModelOSeriesConfigDef =
|
|
28
|
-
exports.ChatModelOSeriesConfigSchema =
|
|
29
|
-
exports.ChatModelResponseFormatConfigDef =
|
|
30
|
-
exports.ChatModelResponseFormatConfigSchema =
|
|
25
|
+
exports.ChatModelOSeriesConfigDef = Jo;
|
|
26
|
+
exports.ChatModelOSeriesConfigSchema = Wo;
|
|
27
|
+
exports.ChatModelResponseFormatConfigDef = Qo;
|
|
28
|
+
exports.ChatModelResponseFormatConfigSchema = Zo;
|
|
31
29
|
exports.ChatModelResponseSchemaConfigDef = X;
|
|
32
30
|
exports.ChatModelResponseSchemaConfigSchema = Q;
|
|
33
31
|
exports.EmbeddingModelBaseConfigDef = oe;
|
|
34
32
|
exports.EmbeddingModelBaseConfigSchema = ee;
|
|
35
|
-
exports.EmbeddingModelDimensionsConfigDef =
|
|
36
|
-
exports.EmbeddingModelDimensionsConfigSchema =
|
|
33
|
+
exports.EmbeddingModelDimensionsConfigDef = ot;
|
|
34
|
+
exports.EmbeddingModelDimensionsConfigSchema = et;
|
|
37
35
|
exports.GPT_3_5_Turbo = Te;
|
|
38
36
|
exports.GPT_3_5_TurboLiteral = so;
|
|
39
|
-
exports.GPT_3_5_TurboOptions =
|
|
40
|
-
exports.GPT_3_5_TurboSchema =
|
|
37
|
+
exports.GPT_3_5_TurboOptions = ft;
|
|
38
|
+
exports.GPT_3_5_TurboSchema = no;
|
|
41
39
|
exports.GPT_3_5_Turbo_0125 = ue;
|
|
42
|
-
exports.GPT_3_5_Turbo_0125Literal =
|
|
43
|
-
exports.GPT_3_5_Turbo_0125Options =
|
|
44
|
-
exports.GPT_3_5_Turbo_0125Schema =
|
|
40
|
+
exports.GPT_3_5_Turbo_0125Literal = Ze;
|
|
41
|
+
exports.GPT_3_5_Turbo_0125Options = ht;
|
|
42
|
+
exports.GPT_3_5_Turbo_0125Schema = eo;
|
|
45
43
|
exports.GPT_3_5_Turbo_1106 = fe;
|
|
46
|
-
exports.GPT_3_5_Turbo_1106Literal =
|
|
47
|
-
exports.GPT_3_5_Turbo_1106Options =
|
|
48
|
-
exports.GPT_3_5_Turbo_1106Schema =
|
|
49
|
-
exports.GPT_4 =
|
|
50
|
-
exports.GPT_4Literal =
|
|
51
|
-
exports.GPT_4Options =
|
|
52
|
-
exports.GPT_4Schema =
|
|
44
|
+
exports.GPT_3_5_Turbo_1106Literal = oo;
|
|
45
|
+
exports.GPT_3_5_Turbo_1106Options = ut;
|
|
46
|
+
exports.GPT_3_5_Turbo_1106Schema = to;
|
|
47
|
+
exports.GPT_4 = Oe;
|
|
48
|
+
exports.GPT_4Literal = go;
|
|
49
|
+
exports.GPT_4Options = bt;
|
|
50
|
+
exports.GPT_4Schema = yo;
|
|
53
51
|
exports.GPT_4_0125_Preview = _e;
|
|
54
|
-
exports.GPT_4_0125_PreviewLiteral =
|
|
55
|
-
exports.GPT_4_0125_PreviewOptions =
|
|
56
|
-
exports.GPT_4_0125_PreviewSchema =
|
|
52
|
+
exports.GPT_4_0125_PreviewLiteral = ao;
|
|
53
|
+
exports.GPT_4_0125_PreviewOptions = Tt;
|
|
54
|
+
exports.GPT_4_0125_PreviewSchema = io;
|
|
57
55
|
exports.GPT_4_0613 = ge;
|
|
58
|
-
exports.GPT_4_0613Literal =
|
|
59
|
-
exports.GPT_4_0613Options =
|
|
56
|
+
exports.GPT_4_0613Literal = ro;
|
|
57
|
+
exports.GPT_4_0613Options = _t;
|
|
60
58
|
exports.GPT_4_0613Schema = lo;
|
|
61
59
|
exports.GPT_4_1106_Preview = ye;
|
|
62
|
-
exports.GPT_4_1106_PreviewLiteral =
|
|
63
|
-
exports.GPT_4_1106_PreviewOptions =
|
|
64
|
-
exports.GPT_4_1106_PreviewSchema =
|
|
65
|
-
exports.GPT_4_Turbo =
|
|
66
|
-
exports.GPT_4_TurboLiteral =
|
|
67
|
-
exports.GPT_4_TurboOptions =
|
|
68
|
-
exports.GPT_4_TurboSchema =
|
|
69
|
-
exports.GPT_4_Turbo_2024_04_09 =
|
|
70
|
-
exports.GPT_4_Turbo_2024_04_09Literal =
|
|
71
|
-
exports.GPT_4_Turbo_2024_04_09Options =
|
|
72
|
-
exports.GPT_4_Turbo_2024_04_09Schema =
|
|
73
|
-
exports.GPT_4_Turbo_Preview =
|
|
74
|
-
exports.GPT_4_Turbo_PreviewLiteral =
|
|
75
|
-
exports.GPT_4_Turbo_PreviewOptions =
|
|
76
|
-
exports.GPT_4_Turbo_PreviewSchema =
|
|
60
|
+
exports.GPT_4_1106_PreviewLiteral = po;
|
|
61
|
+
exports.GPT_4_1106_PreviewOptions = gt;
|
|
62
|
+
exports.GPT_4_1106_PreviewSchema = mo;
|
|
63
|
+
exports.GPT_4_Turbo = be;
|
|
64
|
+
exports.GPT_4_TurboLiteral = To;
|
|
65
|
+
exports.GPT_4_TurboOptions = Ct;
|
|
66
|
+
exports.GPT_4_TurboSchema = _o;
|
|
67
|
+
exports.GPT_4_Turbo_2024_04_09 = Me;
|
|
68
|
+
exports.GPT_4_Turbo_2024_04_09Literal = co;
|
|
69
|
+
exports.GPT_4_Turbo_2024_04_09Options = yt;
|
|
70
|
+
exports.GPT_4_Turbo_2024_04_09Schema = ho;
|
|
71
|
+
exports.GPT_4_Turbo_Preview = Ce;
|
|
72
|
+
exports.GPT_4_Turbo_PreviewLiteral = uo;
|
|
73
|
+
exports.GPT_4_Turbo_PreviewOptions = Mt;
|
|
74
|
+
exports.GPT_4_Turbo_PreviewSchema = fo;
|
|
77
75
|
exports.GPT_4o = Se;
|
|
78
|
-
exports.GPT_4oLiteral =
|
|
79
|
-
exports.GPT_4oOptions =
|
|
80
|
-
exports.GPT_4oSchema =
|
|
81
|
-
exports.GPT_4o_2024_05_13 =
|
|
76
|
+
exports.GPT_4oLiteral = Po;
|
|
77
|
+
exports.GPT_4oOptions = It;
|
|
78
|
+
exports.GPT_4oSchema = Io;
|
|
79
|
+
exports.GPT_4o_2024_05_13 = xe;
|
|
82
80
|
exports.GPT_4o_2024_05_13Literal = xo;
|
|
83
|
-
exports.GPT_4o_2024_05_13Options =
|
|
84
|
-
exports.GPT_4o_2024_05_13Schema =
|
|
81
|
+
exports.GPT_4o_2024_05_13Options = Et;
|
|
82
|
+
exports.GPT_4o_2024_05_13Schema = Ro;
|
|
85
83
|
exports.GPT_4o_2024_08_06 = Pe;
|
|
86
|
-
exports.GPT_4o_2024_08_06Literal =
|
|
87
|
-
exports.GPT_4o_2024_08_06Options =
|
|
88
|
-
exports.GPT_4o_2024_08_06Schema =
|
|
84
|
+
exports.GPT_4o_2024_08_06Literal = Mo;
|
|
85
|
+
exports.GPT_4o_2024_08_06Options = Ot;
|
|
86
|
+
exports.GPT_4o_2024_08_06Schema = Co;
|
|
89
87
|
exports.GPT_4o_Mini = Ie;
|
|
90
|
-
exports.GPT_4o_MiniLiteral =
|
|
91
|
-
exports.GPT_4o_MiniOptions =
|
|
92
|
-
exports.GPT_4o_MiniSchema =
|
|
88
|
+
exports.GPT_4o_MiniLiteral = bo;
|
|
89
|
+
exports.GPT_4o_MiniOptions = Pt;
|
|
90
|
+
exports.GPT_4o_MiniSchema = Oo;
|
|
93
91
|
exports.GPT_4o_Mini_2024_07_18 = Ee;
|
|
94
|
-
exports.GPT_4o_Mini_2024_07_18Literal =
|
|
95
|
-
exports.GPT_4o_Mini_2024_07_18Options =
|
|
96
|
-
exports.GPT_4o_Mini_2024_07_18Schema =
|
|
97
|
-
exports.O1_Mini =
|
|
98
|
-
exports.O1_MiniLiteral =
|
|
92
|
+
exports.GPT_4o_Mini_2024_07_18Literal = So;
|
|
93
|
+
exports.GPT_4o_Mini_2024_07_18Options = St;
|
|
94
|
+
exports.GPT_4o_Mini_2024_07_18Schema = Eo;
|
|
95
|
+
exports.O1_Mini = Re;
|
|
96
|
+
exports.O1_MiniLiteral = Ao;
|
|
99
97
|
exports.O1_MiniOptions = xt;
|
|
100
|
-
exports.O1_MiniSchema =
|
|
98
|
+
exports.O1_MiniSchema = wo;
|
|
101
99
|
exports.O1_Preview = Ae;
|
|
102
|
-
exports.O1_PreviewLiteral =
|
|
103
|
-
exports.O1_PreviewOptions =
|
|
104
|
-
exports.O1_PreviewSchema =
|
|
100
|
+
exports.O1_PreviewLiteral = Go;
|
|
101
|
+
exports.O1_PreviewOptions = Rt;
|
|
102
|
+
exports.O1_PreviewSchema = vo;
|
|
105
103
|
exports.OpenAI = Ft;
|
|
106
104
|
exports.OpenAIChatModelConfigs = c;
|
|
107
105
|
exports.OpenAIChatModelModalities = E;
|
|
108
|
-
exports.OpenAIChatModelModalitiesEnum =
|
|
109
|
-
exports.OpenAIChatModelOSSeriesRoles =
|
|
106
|
+
exports.OpenAIChatModelModalitiesEnum = x;
|
|
107
|
+
exports.OpenAIChatModelOSSeriesRoles = ne;
|
|
110
108
|
exports.OpenAIChatModelOSSeriesRolesMap = ae;
|
|
111
109
|
exports.OpenAIChatModelRoles = g;
|
|
112
110
|
exports.OpenAIChatModelRolesMap = y;
|
|
113
|
-
exports.OpenAIChatModelTextModalities =
|
|
114
|
-
exports.OpenAIChatModelTextModalitiesEnum =
|
|
111
|
+
exports.OpenAIChatModelTextModalities = le;
|
|
112
|
+
exports.OpenAIChatModelTextModalitiesEnum = pe;
|
|
115
113
|
exports.OpenAIChatModelTextToolModalities = P;
|
|
116
114
|
exports.OpenAIChatModelTextToolModalitiesEnum = I;
|
|
117
|
-
exports.OpenAIChatOSeriesRequest =
|
|
115
|
+
exports.OpenAIChatOSeriesRequest = pt;
|
|
118
116
|
exports.OpenAIChatRequest = de;
|
|
119
|
-
exports.OpenAIChatRequestAssistantMessage =
|
|
120
|
-
exports.OpenAIChatRequestImageContent =
|
|
121
|
-
exports.OpenAIChatRequestMessage =
|
|
122
|
-
exports.OpenAIChatRequestResponseFormat =
|
|
123
|
-
exports.OpenAIChatRequestSystemMessage =
|
|
124
|
-
exports.OpenAIChatRequestTextContent =
|
|
125
|
-
exports.OpenAIChatRequestTool =
|
|
126
|
-
exports.OpenAIChatRequestToolCallContent =
|
|
127
|
-
exports.OpenAIChatRequestToolChoiceEnum =
|
|
128
|
-
exports.OpenAIChatRequestToolChoiceFunction =
|
|
129
|
-
exports.OpenAIChatRequestToolMessage =
|
|
130
|
-
exports.OpenAIChatRequestUserMessage =
|
|
131
|
-
exports.OpenAICompleteChatResponse =
|
|
117
|
+
exports.OpenAIChatRequestAssistantMessage = Ts;
|
|
118
|
+
exports.OpenAIChatRequestImageContent = cs;
|
|
119
|
+
exports.OpenAIChatRequestMessage = gs;
|
|
120
|
+
exports.OpenAIChatRequestResponseFormat = ds;
|
|
121
|
+
exports.OpenAIChatRequestSystemMessage = us;
|
|
122
|
+
exports.OpenAIChatRequestTextContent = Je;
|
|
123
|
+
exports.OpenAIChatRequestTool = ls;
|
|
124
|
+
exports.OpenAIChatRequestToolCallContent = hs;
|
|
125
|
+
exports.OpenAIChatRequestToolChoiceEnum = ps;
|
|
126
|
+
exports.OpenAIChatRequestToolChoiceFunction = ms;
|
|
127
|
+
exports.OpenAIChatRequestToolMessage = _s;
|
|
128
|
+
exports.OpenAIChatRequestUserMessage = fs;
|
|
129
|
+
exports.OpenAICompleteChatResponse = rt;
|
|
132
130
|
exports.OpenAIEmbeddingModelConfigs = v;
|
|
133
131
|
exports.OpenAIEmbeddingModelModalities = H;
|
|
134
132
|
exports.OpenAIEmbeddingModelModalitiesEnum = V;
|
|
135
|
-
exports.OpenAIEmbeddingRequest =
|
|
136
|
-
exports.OpenAIEmbeddingRequestInput =
|
|
137
|
-
exports.OpenAIGetEmbeddingsResponse =
|
|
133
|
+
exports.OpenAIEmbeddingRequest = vt;
|
|
134
|
+
exports.OpenAIEmbeddingRequestInput = fn;
|
|
135
|
+
exports.OpenAIGetEmbeddingsResponse = Gt;
|
|
138
136
|
exports.OpenAIStreamChatResponse = lt;
|
|
139
|
-
exports.OpenAIToolCallsCompleteChatResponse =
|
|
140
|
-
exports.OpenAIToolCallsStreamChatResponse =
|
|
141
|
-
exports.ProviderLiteral =
|
|
137
|
+
exports.OpenAIToolCallsCompleteChatResponse = is;
|
|
138
|
+
exports.OpenAIToolCallsStreamChatResponse = rs;
|
|
139
|
+
exports.ProviderLiteral = wn;
|
|
142
140
|
exports.Text_Embedding_3_Large = ve;
|
|
143
|
-
exports.Text_Embedding_3_LargeLiteral =
|
|
144
|
-
exports.Text_Embedding_3_LargeSchema =
|
|
145
|
-
exports.Text_Embedding_3_Large_Options =
|
|
141
|
+
exports.Text_Embedding_3_LargeLiteral = Bo;
|
|
142
|
+
exports.Text_Embedding_3_LargeSchema = Fo;
|
|
143
|
+
exports.Text_Embedding_3_Large_Options = zt;
|
|
146
144
|
exports.Text_Embedding_3_Small = Ge;
|
|
147
|
-
exports.Text_Embedding_3_SmallLiteral =
|
|
148
|
-
exports.Text_Embedding_3_SmallSchema =
|
|
149
|
-
exports.Text_Embedding_3_Small_Options =
|
|
145
|
+
exports.Text_Embedding_3_SmallLiteral = jo;
|
|
146
|
+
exports.Text_Embedding_3_SmallSchema = zo;
|
|
147
|
+
exports.Text_Embedding_3_Small_Options = jt;
|
|
150
148
|
exports.Text_Embedding_Ada002 = we;
|
|
151
|
-
exports.Text_Embedding_Ada002Literal =
|
|
152
|
-
exports.Text_Embedding_Ada002Schema =
|
|
153
|
-
exports.Text_Embedding_Ada002_Options =
|
|
154
|
-
exports.dimensions =
|
|
155
|
-
exports.encodingFormat =
|
|
156
|
-
exports.frequencyPenalty =
|
|
157
|
-
exports.logProbs =
|
|
158
|
-
exports.maxTokens =
|
|
159
|
-
exports.presencePenalty =
|
|
160
|
-
exports.seed =
|
|
161
|
-
exports.stop =
|
|
162
|
-
exports.temperature =
|
|
163
|
-
exports.toolChoice =
|
|
149
|
+
exports.Text_Embedding_Ada002Literal = ko;
|
|
150
|
+
exports.Text_Embedding_Ada002Schema = Lo;
|
|
151
|
+
exports.Text_Embedding_Ada002_Options = Lt;
|
|
152
|
+
exports.dimensions = Ve;
|
|
153
|
+
exports.encodingFormat = He;
|
|
154
|
+
exports.frequencyPenalty = Be;
|
|
155
|
+
exports.logProbs = Ne;
|
|
156
|
+
exports.maxTokens = Le;
|
|
157
|
+
exports.presencePenalty = Fe;
|
|
158
|
+
exports.seed = De;
|
|
159
|
+
exports.stop = je;
|
|
160
|
+
exports.temperature = ke;
|
|
161
|
+
exports.toolChoice = $e;
|
|
164
162
|
exports.topLogProbs = Ue;
|
|
165
|
-
exports.topP =
|
|
163
|
+
exports.topP = ze;
|
|
166
164
|
//# sourceMappingURL=index.js.map
|
|
167
165
|
//# sourceMappingURL=index.js.map
|