@adaline/openai 0.10.0 → 0.12.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 +53 -25
- package/dist/index.d.ts +53 -25
- package/dist/index.js +146 -123
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -4,133 +4,156 @@ var zod = require('zod');
|
|
|
4
4
|
var provider = require('@adaline/provider');
|
|
5
5
|
var types = require('@adaline/types');
|
|
6
6
|
|
|
7
|
-
var mt=Object.defineProperty,lt=Object.defineProperties;var dt=Object.getOwnPropertyDescriptors;var po=Object.getOwnPropertySymbols;var ct=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable;var ut=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n);var mo=(n,e,t)=>e in n?mt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,C=(n,e)=>{for(var t in e||(e={}))ct.call(e,t)&&mo(n,t,e[t]);if(po)for(var t of po(e))ht.call(e,t)&&mo(n,t,e[t]);return n},R=(n,e)=>lt(n,dt(e));var S=(n,e,t)=>new Promise((o,s)=>{var a=p=>{try{r(t.next(p));}catch(c){s(c);}},m=p=>{try{r(t.throw(p));}catch(c){s(c);}},r=p=>p.done?o(p.value):Promise.resolve(p.value).then(a,m);r((t=t.apply(n,e)).next());}),ft=function(n,e){this[0]=n,this[1]=e;},H=(n,e,t)=>{var o=(m,r,p,c)=>{try{var d=t[m](r),f=(r=d.value)instanceof ft,g=d.done;Promise.resolve(f?r[0]:r).then(O=>f?o(m==="return"?m:"next",r[1]?{done:O.done,value:O.value}:O,p,c):p({value:O,done:g})).catch(O=>o("throw",O,p,c));}catch(O){c(O);}},s=m=>a[m]=r=>new Promise((p,c)=>o(m,r,p,c)),a={};return t=t.apply(n,e),a[ut("asyncIterator")]=()=>a,s("next"),s("throw"),s("return"),a};var xe=provider.RangeConfigItem({param:"temperature",title:provider.CONFIG.TEMPERATURE.title,description:provider.CONFIG.TEMPERATURE.description,min:0,max:2,step:.01,default:1}),Re=n=>provider.RangeConfigItem({param:"max_tokens",title:provider.CONFIG.MAX_TOKENS.title,description:provider.CONFIG.MAX_TOKENS.description,min:0,max:n,step:1,default:0}),Ee=n=>provider.MultiStringConfigItem({param:"stop",title:provider.CONFIG.STOP(n).title,description:provider.CONFIG.STOP(n).description,max:n}),Ae=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}),we=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}),ve=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}),qe=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}),Ge=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}),ke=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}),je=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 B=(n,e)=>zod.z.object({temperature:xe.schema,maxTokens:Re(n).schema,stop:Ee(e).schema,topP:Ae.schema,frequencyPenalty:we.schema,presencePenalty:ve.schema,seed:qe.schema.transform(t=>t===0?void 0:t),logProbs:Ge.schema,topLogProbs:ke.schema,toolChoice:je.schema}),$=(n,e)=>({temperature:xe.def,maxTokens:Re(n).def,stop:Ee(e).def,topP:Ae.def,frequencyPenalty:we.def,presencePenalty:ve.def,seed:qe.def,logProbs:Ge.def,topLogProbs:ke.def,toolChoice:je.def});var lo=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"]}),co=(n,e)=>R(C({},$(n,e)),{responseFormat:lo.def}),ho=(n,e)=>B(n,e).extend({responseFormat:lo.schema});var Mt=["object","array","number","string","boolean","enum"],uo=zod.z.enum(Mt),It=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([uo,zod.z.array(zod.z.union([uo,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()}),St=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(It),additionalProperties:zod.z.literal(!1)}),Pt=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:St}).optional(),fo=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:Pt}),go=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"]}),J=(n,e)=>R(C({},$(n,e)),{responseFormat:go.def,responseSchema:fo.def}),W=(n,e)=>B(n,e).extend({responseFormat:go.schema,responseSchema:fo.schema});var yo=n=>provider.RangeConfigItem({param:"max_completion_tokens",title:provider.CONFIG.MAX_TOKENS.title,description:provider.CONFIG.MAX_TOKENS.description,min:0,max:n,step:1,default:0}),_o=(n,e)=>R(C({},J(n,e)),{maxTokens:yo(n).def}),bo=(n,e)=>W(n,e).extend({maxTokens:yo(n).schema});var ze=provider.SelectStringConfigItem({param:"encoding_format",title:"Encoding format",description:"Select the encoding format for the word embedding.",default:"float",choices:["float","base64"]}),Le=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 Y=()=>zod.z.object({encodingFormat:ze.schema}),X=()=>({encodingFormat:ze.def});var Co=n=>Y().extend({dimensions:Le(n).schema}),Oo=n=>R(C({},X()),{dimensions:Le(n).def});var h={base:(n,e)=>({def:$(n,e),schema:B(n,e)}),responseFormat:(n,e)=>({def:co(n,e),schema:ho(n,e)}),responseSchema:(n,e)=>({def:J(n,e),schema:W(n,e)}),oSeries:(n,e)=>({def:_o(n,e),schema:bo(n,e)})},G={base:()=>({def:X(),schema:Y()}),dimensions:n=>({def:Oo(n),schema:Co(n)})};var y=zod.z.enum([types.SystemRoleLiteral,types.UserRoleLiteral,types.AssistantRoleLiteral,types.ToolRoleLiteral]),_={system:types.SystemRoleLiteral,user:types.UserRoleLiteral,assistant:types.AssistantRoleLiteral,tool:types.ToolRoleLiteral};var P=[types.TextModalityLiteral,types.ImageModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],x=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]),M=[types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],I=zod.z.enum([types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]);var oe=zod.z.object({token:zod.z.string(),logprob:zod.z.number(),bytes:zod.z.array(zod.z.number()).nullable()}),Eo=zod.z.object({content:zod.z.array(oe.extend({top_logprobs:zod.z.array(oe)})).nullable(),refusal:zod.z.array(oe.extend({top_logprobs:zod.z.array(oe)})).nullable()}).nullable(),vt=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()})})),Ao=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:vt.optional(),refusal:zod.z.string().nullable().optional()}),logprobs:Eo.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()})}),qt=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()})),wo=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:qt.optional(),refusal:zod.z.string().nullable().optional()}).or(zod.z.object({})),logprobs:Eo,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 Gt=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()})}),kt=zod.z.enum(["none","auto","required"]),jt=zod.z.object({type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1)})}),zt=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()})})),Fe=zod.z.object({text:zod.z.string().min(1),type:zod.z.literal("text")}),Lt=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()})}),Ft=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)})}),Bt=zod.z.object({role:zod.z.literal("system"),content:zod.z.string().min(1).or(zod.z.array(Fe).min(1))}),$t=zod.z.object({role:zod.z.literal("user"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([Fe,Lt])).min(1))}),Dt=zod.z.object({role:zod.z.literal("assistant"),content:zod.z.string().min(1).or(zod.z.array(Fe).min(1)).optional(),tool_calls:zod.z.array(Ft).min(1).optional()}),Ut=zod.z.object({role:zod.z.literal("tool"),tool_call_id:zod.z.string().min(1),content:zod.z.string().min(1)}),Nt=zod.z.union([Bt,$t,Dt,Ut]),te=zod.z.object({model:zod.z.string().min(1).optional(),messages:zod.z.array(Nt).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:zt.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(Gt).optional(),tool_choice:kt.or(jt).optional()});var vo=te.omit({max_tokens:!0}).extend({max_completion_tokens:zod.z.number().min(0).nullable().optional()});var T=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()}),b=class{constructor(e,t){this.version="v1";let o=T.parse(t);this.modelSchema=e,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"},this.organization?{"OpenAI-Organization":this.organization}:{})}getDefaultParams(){return {model:this.modelSchema.name}}getRetryDelay(e){let t=r=>{let p=/(\d+)(h|m|s|ms)/g,c={h:36e5,m:6e4,s:1e3,ms:1},d,f=0;for(;(d=p.exec(r))!==null;){let g=parseInt(d[1]),O=d[2];f+=g*c[O];}return f},o=0,s=0,a=!0;e["x-ratelimit-reset-requests"]&&(o=t(e["x-ratelimit-reset-requests"])),e["x-ratelimit-reset-tokens"]&&(s=t(e["x-ratelimit-reset-tokens"]));let m=Math.max(o,s);return {shouldRetry:a,delayMs:m}}getTokenCount(e){return e.reduce((t,o)=>t+o.content.map(s=>s.modality==="text"?s.value:"").join(" ").length,0)}transformModelRequest(e){let t=te.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.modelSchema.name}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let a={};o.response_format&&(a.responseFormat=o.response_format.type,o.response_format.type==="json_schema"&&(a.responseSchema={name:o.response_format.json_schema.name,description:o.response_format.json_schema.description||"",strict:o.response_format.json_schema.strict,schema:o.response_format.json_schema.schema})),o.tool_choice&&(typeof o.tool_choice=="string"?a.toolChoice=o.tool_choice:a.toolChoice=o.tool_choice.function.name),a.seed=o.seed,a.maxTokens=o.max_tokens,a.temperature=o.temperature,a.topP=o.top_p,a.presencePenalty=o.presence_penalty,a.frequencyPenalty=o.frequency_penalty,a.stop=o.stop,a.logProbs=o.logprobs,a.topLogProbs=o.top_logprobs;let m=types.Config().parse(provider.removeUndefinedEntries(a)),r=[],p={};o.messages.forEach(d=>{let f=d.role;switch(f){case"system":{let g=d.content;if(typeof g=="string")r.push({role:f,content:[{modality:types.TextModalityLiteral,value:g}]});else {let O=g.map(A=>({modality:types.TextModalityLiteral,value:A.text}));r.push({role:f,content:O});}}break;case"user":{let g=d.content;if(typeof g=="string")r.push({role:f,content:[{modality:types.TextModalityLiteral,value:g}]});else {let O=g.map(A=>A.type==="text"?{modality:types.TextModalityLiteral,value:A.text}:{modality:types.ImageModalityLiteral,detail:A.image_url.detail||"auto",value:{type:types.UrlImageContentTypeLiteral,url:A.image_url.url}});r.push({role:f,content:O});}}break;case"assistant":{let g=[];if(!d.content&&!d.tool_calls)throw new provider.InvalidModelRequestError({info:`Invalid model request for model : '${this.modelSchema.name}'`,cause:new Error("one of'content' or 'tool_calls' must be provided")});if(d.content){let O=d.content;typeof O=="string"?g.push({modality:types.TextModalityLiteral,value:O}):O.forEach(A=>{g.push({modality:types.TextModalityLiteral,value:A.text});});}d.tool_calls&&d.tool_calls.forEach((A,pt)=>{let Pe={modality:types.ToolCallModalityLiteral,id:A.id,index:pt,name:A.function.name,arguments:A.function.arguments};g.push(Pe),p[Pe.id]=Pe;}),r.push({role:f,content:g});}break;case"tool":{let g=d;r.push({role:f,content:[{modality:types.ToolResponseModalityLiteral,id:g.tool_call_id,index:p[g.tool_call_id].index,name:p[g.tool_call_id].name,data:g.content}]});}break}});let c=[];return o.tools&&o.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:s,config:m,messages:r,tools:c.length>0?c: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.modelSchema.name}'`,cause:a.error});let m=a.data;s!==void 0&&(m.toolChoice=s),Object.keys(m).forEach(p=>{if(!(p in this.modelSchema.config.def))throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error(`Invalid config key : '${p}',
|
|
8
|
-
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let
|
|
9
|
-
one of [${c.choices.join(", ")}]`)})}}if("response_format"in
|
|
10
|
-
available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),
|
|
11
|
-
|
|
12
|
-
`).filter(m=>m.trim()!=="");for(let m of o){if(m==="data: [DONE]")return;if(m.startsWith("data: {")&&m.endsWith("}")){let r;try{r=JSON.parse(m.substring(6));}catch(c){throw new provider.ModelResponseError({info:"Malformed JSON received in stream",cause:new Error(`Malformed JSON received in stream : ${r}`)})}let p=wo.safeParse(r);if(p.success){let c={partialMessages:[]},d=p.data;if(d.choices.length>0){let f=d.choices[0].delta;if(f!==void 0&&Object.keys(f).length!==0){if("content"in f&&f.content!==null)c.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,f.content));else if("refusal"in f&&f.refusal!==null)c.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,f.refusal));else if("tool_calls"in f&&f.tool_calls!==void 0){let g=f.tool_calls.at(0);c.partialMessages.push(types.createPartialToolCallMessage(types.AssistantRoleLiteral,g.index,g.id,(s=g.function)==null?void 0:s.name,(a=g.function)==null?void 0:a.arguments));}}}d.usage&&(c.usage={promptTokens:d.usage.prompt_tokens,completionTokens:d.usage.completion_tokens,totalTokens:d.usage.total_tokens}),yield {partialResponse:c,buffer:t};}else throw new provider.ModelResponseError({info:"Invalid response from model",cause:p.error})}}})}};var U=class extends b{constructor(e,t){super(e,t);}transformModelRequest(e){let t=vo.safeParse(e);if(!t.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:t.error});let o=t.data,s=R(C({},o),{max_tokens:o.max_completion_tokens});return delete s.max_completion_tokens,super.transformModelRequest(s)}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 H(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 sn="gpt-3.5-turbo-0125",an="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.",Ue=provider.ChatModelSchema(y,I).parse({name:sn,description:an,maxInputTokens:4092,maxOutputTokens:4092,roles:_,modalities:M,config:{def:h.responseFormat(4092,4).def,schema:h.responseFormat(4092,4).schema}}),zo=T,ie=class extends b{constructor(e){super(Ue,e);}};var pn="gpt-3.5-turbo-1106",mn="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.",Ne=provider.ChatModelSchema(y,I).parse({name:pn,description:mn,maxInputTokens:4092,maxOutputTokens:16385,roles:_,modalities:M,config:{def:h.responseFormat(16385,4).def,schema:h.responseFormat(16385,4).schema}}),Lo=T,re=class extends b{constructor(e){super(Ne,e);}};var dn="gpt-3.5-turbo",cn="Currently points to gpt-3.5-turbo-0125. Training data up to Sept 2021.",Ve=provider.ChatModelSchema(y,I).parse({name:dn,description:cn,maxInputTokens:4092,maxOutputTokens:4092,roles:_,modalities:M,config:{def:h.responseFormat(4092,4).def,schema:h.responseFormat(4092,4).schema}}),Fo=T,pe=class extends b{constructor(e){super(Ve,e);}};var un="gpt-4-0125-preview",fn="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.",Ke=provider.ChatModelSchema(y,I).parse({name:un,description:fn,maxInputTokens:128e3,maxOutputTokens:4092,roles:_,modalities:M,config:{def:h.base(4092,4).def,schema:h.base(4092,4).schema}}),Bo=T,me=class extends b{constructor(e){super(Ke,e);}};var Tn="gpt-4-0613",yn="Snapshot of gpt-4 from June 13th 2023 with improved function calling support. Training data up to Sept 2021.",He=provider.ChatModelSchema(y,I).parse({name:Tn,description:yn,maxInputTokens:8192,maxOutputTokens:4092,roles:_,modalities:M,config:{def:h.base(4092,4).def,schema:h.base(4092,4).schema}}),$o=T,le=class extends b{constructor(e){super(He,e);}};var bn="gpt-4-1106-preview",Cn="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.",Je=provider.ChatModelSchema(y,I).parse({name:bn,description:Cn,maxInputTokens:128e3,maxOutputTokens:4092,roles:_,modalities:M,config:{def:h.base(4092,4).def,schema:h.base(4092,4).schema}}),Do=T,de=class extends b{constructor(e){super(Je,e);}};var Mn="gpt-4-turbo-2024-04-09",In="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.",We=provider.ChatModelSchema(y,x).parse({name:Mn,description:In,maxInputTokens:128e3,maxOutputTokens:4096,roles:_,modalities:P,config:{def:h.responseFormat(4096,4).def,schema:h.responseFormat(4096,4).schema}}),Uo=T,ce=class extends b{constructor(e){super(We,e);}};var Pn="gpt-4-turbo-preview",xn="Currently points to gpt-4-0125-preview. Training data up to Apr 2023.",Ye=provider.ChatModelSchema(y,I).parse({name:Pn,description:xn,maxInputTokens:128e3,maxOutputTokens:4092,roles:_,modalities:M,config:{def:h.responseFormat(4092,4).def,schema:h.responseFormat(4092,4).schema}}),No=T,he=class extends b{constructor(e){super(Ye,e);}};var En="gpt-4-turbo",An="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.",Xe=provider.ChatModelSchema(y,x).parse({name:En,description:An,maxInputTokens:128e3,maxOutputTokens:4092,roles:_,modalities:P,config:{def:h.responseFormat(4092,4).def,schema:h.responseFormat(4092,4).schema}}),Vo=T,ue=class extends b{constructor(e){super(Xe,e);}};var vn="gpt-4",qn="Currently points to gpt-4-0613. Training data up to Sept 2021.",Ze=provider.ChatModelSchema(y,I).parse({name:vn,description:qn,maxInputTokens:8192,maxOutputTokens:4092,roles:_,modalities:M,config:{def:h.base(4092,4).def,schema:h.base(4092,4).schema}}),Ko=T,fe=class extends b{constructor(e){super(Ze,e);}};var kn="gpt-4o-2024-08-06",jn="Latest snapshot of gpt-4o that supports Structured Outputs. Training data up to Oct 2023.",Qe=provider.ChatModelSchema(y,x).parse({name:kn,description:jn,maxInputTokens:128e3,maxOutputTokens:4092,roles:_,modalities:P,config:{def:h.responseSchema(4092,4).def,schema:h.responseSchema(4092,4).schema}}),Ho=T,ge=class extends b{constructor(e){super(Qe,e);}};var Ln="gpt-4o-mini",Fn="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(y,x).parse({name:Ln,description:Fn,maxInputTokens:128e3,maxOutputTokens:4092,roles:_,modalities:P,config:{def:h.responseSchema(4092,4).def,schema:h.responseSchema(4092,4).schema}}),Jo=T,Te=class extends b{constructor(e){super(eo,e);}};var $n="gpt-4o",Dn="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(y,x).parse({name:$n,description:Dn,maxInputTokens:128e3,maxOutputTokens:4092,roles:_,modalities:P,config:{def:h.responseFormat(4092,4).def,schema:h.responseFormat(4092,4).schema}}),Wo=T,ye=class extends b{constructor(e){super(oo,e);}};var Nn="o1-mini",Vn="Faster and cheaper reasoning model particularly good at coding, math, and science. Training data up to Oct 2023.",to=provider.ChatModelSchema(y,x).parse({name:Nn,description:Vn,maxInputTokens:128e3,maxOutputTokens:4092,roles:_,modalities:P,config:{def:h.oSeries(4092,4).def,schema:h.oSeries(4092,4).schema}}),Yo=T,_e=class extends U{constructor(e){super(to,e);}};var Hn="o1-preview",Jn="Reasoning model designed to solve hard problems across domains. Training data up to Oct 2023.",no=provider.ChatModelSchema(y,x).parse({name:Hn,description:Jn,maxInputTokens:128e3,maxOutputTokens:4092,roles:_,modalities:P,config:{def:h.oSeries(4092,4).def,schema:h.oSeries(4092,4).schema}}),Xo=T,be=class extends U{constructor(e){super(no,e);}};var N=[types.EmbeddingTextModalityLiteral,types.EmbeddingTokenModalityLiteral],V=zod.z.enum([types.EmbeddingTextModalityLiteral,types.EmbeddingTokenModalityLiteral]);var et=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 Yn=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)),ot=zod.z.object({model:zod.z.string().min(1).optional(),input:Yn,encoding_format:zod.z.enum(["float","base64"]).optional(),dimensions:zod.z.number().int().min(1).optional()});var F=zod.z.object({apiKey:zod.z.string(),baseUrl:zod.z.string().url(),getEmbeddingsUrl:zod.z.string().url().optional()}),j=class{constructor(e,t){this.version="v1";let o=F.parse(t);this.modelSchema=e,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=r=>{let p=/(\d+)(h|m|s|ms)/g,c={h:36e5,m:6e4,s:1e3,ms:1},d,f=0;for(;(d=p.exec(r))!==null;){let g=parseInt(d[1]),O=d[2];f+=g*c[O];}return f},o=0,s=0,a=!0;e["x-ratelimit-reset-requests"]&&(o=t(e["x-ratelimit-reset-requests"])),e["x-ratelimit-reset-tokens"]&&(s=t(e["x-ratelimit-reset-tokens"]));let m=Math.max(o,s);return {shouldRetry:a,delayMs:m}}getTokenCount(e){return e.requests.reduce((t,o)=>t+o.length,0)}transformModelRequest(e){let t=ot.safeParse(e);if(!t.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:t.error});let o=t.data,s=o.model,a={encodingFormat:o.encoding_format,dimensions:o.dimensions},m=types.Config().parse(provider.removeUndefinedEntries(a)),r,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"?r={modality:p,requests:[o.input]}:r={modality:p,requests:o.input}:typeof o.input[0]=="number"?r={modality:p,requests:[o.input]}:r={modality:p,requests:o.input},{modelName:s,config:m,embeddingRequests:r}}transformConfig(e,t){let o=this.modelSchema.config.schema.safeParse(e);if(!o.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:o.error});let s=o.data;return Object.keys(s).forEach(m=>{if(!this.modelSchema.config.def[m])throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error(`Invalid config key : '${m}',
|
|
13
|
-
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(s).reduce((m,r)=>{let c=this.modelSchema.config.def[r].param,d=s[r];return m[c]=d,m},{})}transformEmbeddingRequests(e){let t=types.EmbeddingRequests().safeParse(e);if(!t.success)throw new provider.InvalidEmbeddingRequestsError({info:"Invalid embedding requests",cause:t.error});return {input:t.data.requests}}getGetEmbeddingsUrl(e,t){return S(this,null,function*(){return new Promise(o=>{o(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(e,t){return S(this,null,function*(){return new Promise(o=>{o(this.getDefaultHeaders());})})}getGetEmbeddingsData(e,t){return S(this,null,function*(){return new Promise(o=>{o(C(C(C({},this.getDefaultParams()),this.transformConfig(e,t)),this.transformEmbeddingRequests(t)));})})}transformGetEmbeddingsResponse(e){let t,o=et.safeParse(e);if(o.success){let s=o.data;t=typeof s.data[0].embedding=="string"?types.Base64EmbeddingLiteral:types.FloatEmbeddingLiteral;let a=s.data.map(m=>typeof m.embedding=="string"?{index:m.index,embedding:m.embedding}:{index:m.index,embedding:m.embedding});return {encodingFormat:t,embeddings:a,usage:{totalTokens:s.usage.total_tokens}}}throw new provider.ModelResponseError({info:"Invalid response from model",cause:o.error})}};var rs="text-embedding-ada-002",ps="Most capable 2nd generation embedding model, replacing 16 first generation models",ao=provider.EmbeddingModelSchema(V).parse({name:rs,description:ps,modalities:N,maxInputTokens:8192,maxOutputTokens:1536,config:{def:G.base().def,schema:G.base().schema}}),st=F,Oe=class extends j{constructor(e){super(ao,e);}};var ls="text-embedding-3-small",ds="Increased performance over 2nd generation ada embedding model",io=provider.EmbeddingModelSchema(V).parse({name:ls,description:ds,modalities:N,maxInputTokens:8192,maxOutputTokens:1536,config:{def:G.dimensions(1536).def,schema:G.dimensions(1536).schema}}),at=F,Me=class extends j{constructor(e){super(io,e);}};var hs="text-embedding-3-large",us="Most capable embedding model for both english and non-english tasks",ro=provider.EmbeddingModelSchema(V).parse({name:hs,description:us,modalities:N,maxInputTokens:8192,maxOutputTokens:3072,config:{def:G.dimensions(3072).def,schema:G.dimensions(3072).schema}}),it=F,Ie=class extends j{constructor(e){super(ro,e);}};var fs="openai",rt=class{constructor(){this.version="v1";this.name=fs;this.baseUrl="https://api.openai.com/v1";this.chatModelFactories={"gpt-3.5-turbo":{model:pe,modelOptions:Fo,modelSchema:Ve},"gpt-3.5-turbo-0125":{model:ie,modelOptions:zo,modelSchema:Ue},"gpt-3.5-turbo-1106":{model:re,modelOptions:Lo,modelSchema:Ne},"gpt-4-0125-preview":{model:me,modelOptions:Bo,modelSchema:Ke},"gpt-4-0613":{model:le,modelOptions:$o,modelSchema:He},"gpt-4-1106-preview":{model:de,modelOptions:Do,modelSchema:Je},"gpt-4-turbo-2024-04-09":{model:ce,modelOptions:Uo,modelSchema:We},"gpt-4-turbo-preview":{model:he,modelOptions:No,modelSchema:Ye},"gpt-4-turbo":{model:ue,modelOptions:Vo,modelSchema:Xe},"gpt-4":{model:fe,modelOptions:Ko,modelSchema:Ze},"gpt-4o-2024-08-06":{model:ge,modelOptions:Ho,modelSchema:Qe},"gpt-4o-mini":{model:Te,modelOptions:Jo,modelSchema:eo},"gpt-4o":{model:ye,modelOptions:Wo,modelSchema:oo},"o1-mini":{model:_e,modelOptions:Yo,modelSchema:to},"o1-preview":{model:be,modelOptions:Xo,modelSchema:no}};this.embeddingModelFactories={"text-embedding-ada-002":{model:Oe,modelOptions:st,modelSchema:ao},"text-embedding-3-small":{model:Me,modelOptions:at,modelSchema:io},"text-embedding-3-large":{model:Ie,modelOptions:it,modelSchema:ro}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModel(e,t){var m;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
|
-
|
|
15
|
-
${this.chatModelLiterals().join(", ")}`)});
|
|
16
|
-
${this.
|
|
17
|
-
${this.embeddingModelLiterals().join(", ")}`)});
|
|
7
|
+
var qt=Object.defineProperty,kt=Object.defineProperties;var jt=Object.getOwnPropertyDescriptors;var jo=Object.getOwnPropertySymbols;var Lt=Object.prototype.hasOwnProperty,zt=Object.prototype.propertyIsEnumerable;var $t=(n,e)=>(e=Symbol[n])?e:Symbol.for("Symbol."+n);var Lo=(n,e,t)=>e in n?qt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,y=(n,e)=>{for(var t in e||(e={}))Lt.call(e,t)&&Lo(n,t,e[t]);if(jo)for(var t of jo(e))zt.call(e,t)&&Lo(n,t,e[t]);return n},x=(n,e)=>kt(n,jt(e));var I=(n,e,t)=>new Promise((o,s)=>{var a=l=>{try{i(t.next(l));}catch(c){s(c);}},m=l=>{try{i(t.throw(l));}catch(c){s(c);}},i=l=>l.done?o(l.value):Promise.resolve(l.value).then(a,m);i((t=t.apply(n,e)).next());}),Bt=function(n,e){this[0]=n,this[1]=e;},W=(n,e,t)=>{var o=(m,i,l,c)=>{try{var d=t[m](i),f=(i=d.value)instanceof Bt,g=d.done;Promise.resolve(f?i[0]:i).then(O=>f?o(m==="return"?m:"next",i[1]?{done:O.done,value:O.value}:O,l,c):l({value:O,done:g})).catch(O=>o("throw",O,l,c));}catch(O){c(O);}},s=m=>a[m]=i=>new Promise((l,c)=>o(m,i,l,c)),a={};return t=t.apply(n,e),a[$t("asyncIterator")]=()=>a,s("next"),s("throw"),s("return"),a};var qe=provider.RangeConfigItem({param:"temperature",title:provider.CONFIG.TEMPERATURE.title,description:provider.CONFIG.TEMPERATURE.description,min:0,max:2,step:.01,default:1}),ke=n=>provider.RangeConfigItem({param:"max_tokens",title:provider.CONFIG.MAX_TOKENS.title,description:provider.CONFIG.MAX_TOKENS.description,min:0,max:n,step:1,default:0}),je=n=>provider.MultiStringConfigItem({param:"stop",title:provider.CONFIG.STOP(n).title,description:provider.CONFIG.STOP(n).description,max:n}),Le=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}),ze=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}),$e=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}),Be=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}),Fe=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}),Ue=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}),De=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 B=(n,e)=>zod.z.object({temperature:qe.schema,maxTokens:ke(n).schema,stop:je(e).schema,topP:Le.schema,frequencyPenalty:ze.schema,presencePenalty:$e.schema,seed:Be.schema.transform(t=>t===0?void 0:t),logProbs:Fe.schema,topLogProbs:Ue.schema,toolChoice:De.schema}),F=(n,e)=>({temperature:qe.def,maxTokens:ke(n).def,stop:je(e).def,topP:Le.def,frequencyPenalty:ze.def,presencePenalty:$e.def,seed:Be.def,logProbs:Fe.def,topLogProbs:Ue.def,toolChoice:De.def});var zo=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"]}),$o=(n,e)=>x(y({},F(n,e)),{responseFormat:zo.def}),Bo=(n,e)=>B(n,e).extend({responseFormat:zo.schema});var Jt=["object","array","number","string","boolean","enum"],Fo=zod.z.enum(Jt),Wt=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([Fo,zod.z.array(zod.z.union([Fo,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()}),Yt=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(Wt),additionalProperties:zod.z.literal(!1)}),Xt=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:Yt}).optional(),Uo=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:Xt}),Do=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"]}),Y=(n,e)=>x(y({},F(n,e)),{responseFormat:Do.def,responseSchema:Uo.def}),X=(n,e)=>B(n,e).extend({responseFormat:Do.schema,responseSchema:Uo.schema});var Vo=provider.RangeConfigItem({param:"temperature",title:provider.CONFIG.TEMPERATURE.title,description:provider.CONFIG.TEMPERATURE.description,min:1,max:1,step:.01,default:1}),Ko=n=>provider.RangeConfigItem({param:"max_completion_tokens",title:provider.CONFIG.MAX_TOKENS.title,description:provider.CONFIG.MAX_TOKENS.description,min:0,max:n,step:1,default:0}),Ho=(n,e)=>x(y({},Y(n,e)),{temperature:Vo.def,maxTokens:Ko(n).def}),Jo=(n,e)=>X(n,e).extend({temperature:Vo.schema,maxTokens:Ko(n).schema});var Ne=provider.SelectStringConfigItem({param:"encoding_format",title:"Encoding format",description:"Select the encoding format for the word embedding.",default:"float",choices:["float","base64"]}),Ve=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 Q=()=>zod.z.object({encodingFormat:Ne.schema}),ee=()=>({encodingFormat:Ne.def});var Wo=n=>Q().extend({dimensions:Ve(n).schema}),Yo=n=>x(y({},ee()),{dimensions:Ve(n).def});var h={base:(n,e)=>({def:F(n,e),schema:B(n,e)}),responseFormat:(n,e)=>({def:$o(n,e),schema:Bo(n,e)}),responseSchema:(n,e)=>({def:Y(n,e),schema:X(n,e)}),oSeries:(n,e)=>({def:Ho(n,e),schema:Jo(n,e)})},q={base:()=>({def:ee(),schema:Q()}),dimensions:n=>({def:Yo(n),schema:Wo(n)})};var b=zod.z.enum([types.SystemRoleLiteral,types.UserRoleLiteral,types.AssistantRoleLiteral,types.ToolRoleLiteral]),C={system:types.SystemRoleLiteral,user:types.UserRoleLiteral,assistant:types.AssistantRoleLiteral,tool:types.ToolRoleLiteral},ne=zod.z.enum([types.UserRoleLiteral,types.AssistantRoleLiteral]),se={user:types.UserRoleLiteral,assistant:types.AssistantRoleLiteral};var v=[types.TextModalityLiteral,types.ImageModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],G=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]),re=[types.TextModalityLiteral],le=zod.z.enum([types.TextModalityLiteral]),S=[types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],P=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()}),ot=zod.z.object({content:zod.z.array(me.extend({top_logprobs:zod.z.array(me)})).nullable(),refusal:zod.z.array(me.extend({top_logprobs:zod.z.array(me)})).nullable()}).nullable(),on=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()})})),tt=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:on.optional(),refusal:zod.z.string().nullable().optional()}),logprobs:ot.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()})}),tn=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()})),nt=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:tn.optional(),refusal:zod.z.string().nullable().optional()}).or(zod.z.object({})),logprobs:ot,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 nn=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()})}),sn=zod.z.enum(["none","auto","required"]),an=zod.z.object({type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1)})}),rn=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()})})),He=zod.z.object({text:zod.z.string().min(1),type:zod.z.literal("text")}),ln=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()})}),mn=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)})}),pn=zod.z.object({role:zod.z.literal("system"),content:zod.z.string().min(1).or(zod.z.array(He).min(1))}),dn=zod.z.object({role:zod.z.literal("user"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([He,ln])).min(1))}),cn=zod.z.object({role:zod.z.literal("assistant"),content:zod.z.string().min(1).or(zod.z.array(He).min(1)).optional(),tool_calls:zod.z.array(mn).min(1).optional()}),hn=zod.z.object({role:zod.z.literal("tool"),tool_call_id:zod.z.string().min(1),content:zod.z.string().min(1)}),un=zod.z.union([pn,dn,cn,hn]),pe=zod.z.object({model:zod.z.string().min(1).optional(),messages:zod.z.array(un).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:rn.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(nn).optional(),tool_choice:sn.or(an).optional()});var st=pe.omit({max_tokens:!0}).extend({max_completion_tokens:zod.z.number().min(0).nullable().optional()});var T=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()}),_=class{constructor(e,t){this.version="v1";let o=T.parse(t);this.modelSchema=e,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 y({Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json",source:"adaline.ai"},this.organization?{"OpenAI-Organization":this.organization}:{})}getDefaultParams(){return {model:this.modelSchema.name}}getRetryDelay(e){let t=i=>{let l=/(\d+)(h|m|s|ms)/g,c={h:36e5,m:6e4,s:1e3,ms:1},d,f=0;for(;(d=l.exec(i))!==null;){let g=parseInt(d[1]),O=d[2];f+=g*c[O];}return f},o=0,s=0,a=!0;e["x-ratelimit-reset-requests"]&&(o=t(e["x-ratelimit-reset-requests"])),e["x-ratelimit-reset-tokens"]&&(s=t(e["x-ratelimit-reset-tokens"]));let m=Math.max(o,s);return {shouldRetry:a,delayMs:m}}getTokenCount(e){return e.reduce((t,o)=>t+o.content.map(s=>s.modality==="text"?s.value:"").join(" ").length,0)}transformModelRequest(e){let t=pe.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.modelSchema.name}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let a={};o.response_format&&(a.responseFormat=o.response_format.type,o.response_format.type==="json_schema"&&(a.responseSchema={name:o.response_format.json_schema.name,description:o.response_format.json_schema.description||"",strict:o.response_format.json_schema.strict,schema:o.response_format.json_schema.schema})),o.tool_choice&&(typeof o.tool_choice=="string"?a.toolChoice=o.tool_choice:a.toolChoice=o.tool_choice.function.name),a.seed=o.seed,a.maxTokens=o.max_tokens,a.temperature=o.temperature,a.topP=o.top_p,a.presencePenalty=o.presence_penalty,a.frequencyPenalty=o.frequency_penalty,a.stop=o.stop,a.logProbs=o.logprobs,a.topLogProbs=o.top_logprobs;let m=types.Config().parse(provider.removeUndefinedEntries(a)),i=[],l={};o.messages.forEach(d=>{let f=d.role;switch(f){case"system":{let g=d.content;if(typeof g=="string")i.push({role:f,content:[{modality:types.TextModalityLiteral,value:g}]});else {let O=g.map(M=>({modality:types.TextModalityLiteral,value:M.text}));i.push({role:f,content:O});}}break;case"user":{let g=d.content;if(typeof g=="string")i.push({role:f,content:[{modality:types.TextModalityLiteral,value:g}]});else {let O=g.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:f,content:O});}}break;case"assistant":{let g=[];if(!d.content&&!d.tool_calls)throw new provider.InvalidModelRequestError({info:`Invalid model request for model : '${this.modelSchema.name}'`,cause:new Error("one of'content' or 'tool_calls' must be provided")});if(d.content){let O=d.content;typeof O=="string"?g.push({modality:types.TextModalityLiteral,value:O}):O.forEach(M=>{g.push({modality:types.TextModalityLiteral,value:M.text});});}d.tool_calls&&d.tool_calls.forEach((M,Gt)=>{let Ge={modality:types.ToolCallModalityLiteral,id:M.id,index:Gt,name:M.function.name,arguments:M.function.arguments};g.push(Ge),l[Ge.id]=Ge;}),i.push({role:f,content:g});}break;case"tool":{let g=d;i.push({role:f,content:[{modality:types.ToolResponseModalityLiteral,id:g.tool_call_id,index:l[g.tool_call_id].index,name:l[g.tool_call_id].name,data:g.content}]});}break}});let c=[];return o.tools&&o.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:s,config:m,messages:i,tools:c.length>0?c: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.modelSchema.name}'`,cause:a.error});let m=a.data;s!==void 0&&(m.toolChoice=s),Object.keys(m).forEach(l=>{if(!(l in this.modelSchema.config.def))throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error(`Invalid config key : '${l}',
|
|
8
|
+
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let i=Object.keys(m).reduce((l,c)=>{let d=this.modelSchema.config.def[c],f=d.param,g=m[c];return f==="max_tokens"&&d.type==="range"&&g===0?l[f]=d.max:l[f]=g,l},{});if(i.top_logprobs&&!i.logprobs)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,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.modelSchema.name}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(o&&o.length>0){let c=this.modelSchema.config.def.toolChoice;if(!c.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.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 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.modelSchema.name}'`,cause:new Error("'responseSchema' is required in config when 'responseFormat' is 'json_schema'")});else i.response_format={type:l};}return i}transformMessages(e){if(!e||e&&e.length===0)return {messages:[]};let t=e.map(s=>{let a=types.Message().safeParse(s);if(!a.success)throw new provider.InvalidMessagesError({info:"Invalid messages",cause:a.error});return a.data});return t.forEach(s=>{s.content.forEach(a=>{if(!this.modelSchema.modalities.includes(a.modality))throw new provider.InvalidMessagesError({info:`Invalid message content for model : '${this.modelSchema.name}'`,cause:new Error(`model : '${this.modelSchema.name}' does not support modality : '${a.modality}',
|
|
10
|
+
available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),t.forEach(s=>{if(!Object.keys(this.modelSchema.roles).includes(s.role))throw new provider.InvalidMessagesError({info:`Invalid message content for model : '${this.modelSchema.name}'`,cause:new Error(`model : '${this.modelSchema.name}' does not support role : '${s.role}',
|
|
11
|
+
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}),{messages:t.map(s=>{switch(s.role){case types.SystemRoleLiteral:{let a=[];return s.content.forEach(m=>{if(m.modality===types.TextModalityLiteral)a.push({type:"text",text:m.value});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelSchema.name}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${m.modality}'`)})}),{role:this.modelSchema.roles[s.role],content:a}}case types.AssistantRoleLiteral:{let a=[],m=[];return s.content.forEach(i=>{if(i.modality===types.TextModalityLiteral)a.push({type:"text",text:i.value});else if(i.modality===types.ToolCallModalityLiteral)m.push({id:i.id,type:"function",function:{name:i.name,arguments:i.arguments}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelSchema.name}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${i.modality}'`)})}),y({role:this.modelSchema.roles[s.role],content:a},m.length>0?{tool_calls:m}:{})}case types.UserRoleLiteral:{let a=[],m=[];s.content.forEach(l=>{if(l.modality===types.TextModalityLiteral)a.push({type:"text",text:l.value});else if(l.modality===types.ImageModalityLiteral)m.push({type:"image_url",image_url:{url:l.value.type==="url"?l.value.url:l.value.base64,detail:l.detail}});else throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelSchema.name}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${l.modality}'`)})});let i=[...a,...m];return {role:this.modelSchema.roles[s.role],content:i}}case types.ToolRoleLiteral:{if(s.content.length!==1)throw new provider.InvalidMessagesError({info:`Invalid message for role : '${s.role}'`,cause:new Error(`role : '${s.role}' must have exactly one content item`)});if(s.content[0].modality!==types.ToolResponseModalityLiteral)throw new provider.InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelSchema.name}`,cause:new Error(`role : '${s.role}' must have content with modality : '${types.ToolResponseModalityLiteral}'`)});let a=s.content[0];return {role:this.modelSchema.roles[s.role],tool_call_id:a.id,content:a.data}}default:throw new provider.InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelSchema.name}`,cause:new Error(`role : '${s.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.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(s=>{let a=types.Tool().safeParse(s);if(!a.success)throw new provider.InvalidToolsError({info:"Invalid tools",cause:a.error});return a.data}).map(s=>({type:"function",function:s.definition.schema}))}}getCompleteChatUrl(e,t,o){return I(this,null,function*(){return new Promise(s=>{s(this.completeChatUrl);})})}getCompleteChatHeaders(e,t,o){return I(this,null,function*(){return new Promise(s=>{s(this.getDefaultHeaders());})})}getCompleteChatData(e,t,o){return I(this,null,function*(){let s=this.transformConfig(e,t,o),a=this.transformMessages(t);if(a.messages&&a.messages.length===0)throw new provider.InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let m=o?this.transformTools(o):{};return new Promise(i=>{i(y(y(y(y({},this.getDefaultParams()),s),a),m));})})}transformCompleteChatResponse(e){let t=tt.safeParse(e);if(t.success){if(t.data.choices.length===0)throw new provider.ModelResponseError({info:"Invalid response from model",cause:new Error(`No choices in response : ${JSON.stringify(t.data)}`)});let o=t.data,s=[],a=o.choices[0].message;a.content&&s.push(types.createTextMessage(types.AssistantRoleLiteral,a.content)),a.refusal&&s.push(types.createTextMessage(types.AssistantRoleLiteral,a.refusal)),a.tool_calls&&a.tool_calls.forEach((c,d)=>{s.push(types.createToolCallMessage(types.AssistantRoleLiteral,d,c.id,c.function.name,c.function.arguments));});let m={promptTokens:o.usage.prompt_tokens,completionTokens:o.usage.completion_tokens,totalTokens:o.usage.total_tokens},i=[],l=o.choices[0].logprobs;return l&&(l.content&&i.push(...l.content.map(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&&i.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:s,usage:m,logProbs:i}}throw new provider.ModelResponseError({info:"Invalid response from model",cause:t.error})}getStreamChatUrl(e,t,o){return I(this,null,function*(){return new Promise(s=>{s(this.streamChatUrl);})})}getStreamChatHeaders(e,t,o){return I(this,null,function*(){return new Promise(s=>{s(this.getDefaultHeaders());})})}getStreamChatData(e,t,o){return I(this,null,function*(){let s=this.transformConfig(e,t,o),a=this.transformMessages(t);if(a.messages&&a.messages.length===0)throw new provider.InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let m=o?this.transformTools(o):{};return new Promise(i=>{i(y(y(y(y({stream:!0,stream_options:{include_usage:!0}},this.getDefaultParams()),s),a),m));})})}transformStreamChatResponseChunk(e,t){return W(this,null,function*(){var s,a;let o=(t+e).split(`
|
|
13
|
+
`).filter(m=>m.trim()!=="");for(let m of o){if(m==="data: [DONE]")return;if(m.startsWith("data: {")&&m.endsWith("}")){let i;try{i=JSON.parse(m.substring(6));}catch(c){throw new provider.ModelResponseError({info:"Malformed JSON received in stream",cause:new Error(`Malformed JSON received in stream : ${i}`)})}let l=nt.safeParse(i);if(l.success){let c={partialMessages:[]},d=l.data;if(d.choices.length>0){let f=d.choices[0].delta;if(f!==void 0&&Object.keys(f).length!==0){if("content"in f&&f.content!==null)c.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,f.content));else if("refusal"in f&&f.refusal!==null)c.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,f.refusal));else if("tool_calls"in f&&f.tool_calls!==void 0){let g=f.tool_calls.at(0);c.partialMessages.push(types.createPartialToolCallMessage(types.AssistantRoleLiteral,g.index,g.id,(s=g.function)==null?void 0:s.name,(a=g.function)==null?void 0:a.arguments));}}}d.usage&&(c.usage={promptTokens:d.usage.prompt_tokens,completionTokens:d.usage.completion_tokens,totalTokens:d.usage.total_tokens}),yield {partialResponse:c,buffer:t};}else throw new provider.ModelResponseError({info:"Invalid response from model",cause:l.error})}}})}};var V=class extends _{constructor(e,t){super(e,t);}transformModelRequest(e){let t=st.safeParse(e);if(!t.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:t.error});let o=t.data,s=x(y({},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 I(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 I(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 I(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",An="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.",Qe=provider.ChatModelSchema(b,P).parse({name:Ze,description:An,maxInputTokens:4092,maxOutputTokens:4092,roles:C,modalities:S,config:{def:h.responseFormat(4092,4).def,schema:h.responseFormat(4092,4).schema}}),lt=T,he=class extends _{constructor(e){super(Qe,e);}};var eo="gpt-3.5-turbo-1106",vn="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.",oo=provider.ChatModelSchema(b,P).parse({name:eo,description:vn,maxInputTokens:4092,maxOutputTokens:16385,roles:C,modalities:S,config:{def:h.responseFormat(16385,4).def,schema:h.responseFormat(16385,4).schema}}),mt=T,ue=class extends _{constructor(e){super(oo,e);}};var to="gpt-3.5-turbo",qn="Currently points to gpt-3.5-turbo-0125. Training data up to Sept 2021.",no=provider.ChatModelSchema(b,P).parse({name:to,description:qn,maxInputTokens:4092,maxOutputTokens:4092,roles:C,modalities:S,config:{def:h.responseFormat(4092,4).def,schema:h.responseFormat(4092,4).schema}}),pt=T,fe=class extends _{constructor(e){super(no,e);}};var so="gpt-4-0125-preview",jn="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.",ao=provider.ChatModelSchema(b,P).parse({name:so,description:jn,maxInputTokens:128e3,maxOutputTokens:4092,roles:C,modalities:S,config:{def:h.base(4092,4).def,schema:h.base(4092,4).schema}}),dt=T,ge=class extends _{constructor(e){super(ao,e);}};var io="gpt-4-0613",zn="Snapshot of gpt-4 from June 13th 2023 with improved function calling support. Training data up to Sept 2021.",ro=provider.ChatModelSchema(b,P).parse({name:io,description:zn,maxInputTokens:8192,maxOutputTokens:4092,roles:C,modalities:S,config:{def:h.base(4092,4).def,schema:h.base(4092,4).schema}}),ct=T,Te=class extends _{constructor(e){super(ro,e);}};var lo="gpt-4-1106-preview",Bn="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(b,P).parse({name:lo,description:Bn,maxInputTokens:128e3,maxOutputTokens:4092,roles:C,modalities:S,config:{def:h.base(4092,4).def,schema:h.base(4092,4).schema}}),ht=T,_e=class extends _{constructor(e){super(mo,e);}};var po="gpt-4-turbo-2024-04-09",Un="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.",co=provider.ChatModelSchema(b,G).parse({name:po,description:Un,maxInputTokens:128e3,maxOutputTokens:4096,roles:C,modalities:v,config:{def:h.responseFormat(4096,4).def,schema:h.responseFormat(4096,4).schema}}),ut=T,ye=class extends _{constructor(e){super(co,e);}};var ho="gpt-4-turbo-preview",Nn="Currently points to gpt-4-0125-preview. Training data up to Apr 2023.",uo=provider.ChatModelSchema(b,P).parse({name:ho,description:Nn,maxInputTokens:128e3,maxOutputTokens:4092,roles:C,modalities:S,config:{def:h.responseFormat(4092,4).def,schema:h.responseFormat(4092,4).schema}}),ft=T,be=class extends _{constructor(e){super(uo,e);}};var fo="gpt-4-turbo",Kn="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(b,G).parse({name:fo,description:Kn,maxInputTokens:128e3,maxOutputTokens:4092,roles:C,modalities:v,config:{def:h.responseFormat(4092,4).def,schema:h.responseFormat(4092,4).schema}}),gt=T,Ce=class extends _{constructor(e){super(go,e);}};var To="gpt-4",Jn="Currently points to gpt-4-0613. Training data up to Sept 2021.",_o=provider.ChatModelSchema(b,P).parse({name:To,description:Jn,maxInputTokens:8192,maxOutputTokens:4092,roles:C,modalities:S,config:{def:h.base(4092,4).def,schema:h.base(4092,4).schema}}),Tt=T,Oe=class extends _{constructor(e){super(_o,e);}};var yo="gpt-4o-2024-08-06",Yn="Latest snapshot of gpt-4o that supports Structured Outputs. Training data up to Oct 2023.",bo=provider.ChatModelSchema(b,G).parse({name:yo,description:Yn,maxInputTokens:128e3,maxOutputTokens:4092,roles:C,modalities:v,config:{def:h.responseSchema(4092,4).def,schema:h.responseSchema(4092,4).schema}}),_t=T,Me=class extends _{constructor(e){super(bo,e);}};var Co="gpt-4o-mini",Zn="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(b,G).parse({name:Co,description:Zn,maxInputTokens:128e3,maxOutputTokens:4092,roles:C,modalities:v,config:{def:h.responseSchema(4092,4).def,schema:h.responseSchema(4092,4).schema}}),yt=T,Se=class extends _{constructor(e){super(Oo,e);}};var Mo="gpt-4o",es="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(b,G).parse({name:Mo,description:es,maxInputTokens:128e3,maxOutputTokens:4092,roles:C,modalities:v,config:{def:h.responseFormat(4092,4).def,schema:h.responseFormat(4092,4).schema}}),bt=T,Pe=class extends _{constructor(e){super(So,e);}};var Po="o1-mini",ts="Faster and cheaper reasoning model particularly good at coding, math, and science. Training data up to Oct 2023.",Io=provider.ChatModelSchema(ne,le).parse({name:Po,description:ts,maxInputTokens:128e3,maxOutputTokens:4092,roles:se,modalities:re,config:{def:h.oSeries(4092,4).def,schema:h.oSeries(4092,4).schema}}),Ct=T,Ie=class extends V{constructor(e){super(Io,e);}};var xo="o1-preview",ss="Reasoning model designed to solve hard problems across domains. Training data up to Oct 2023.",Ro=provider.ChatModelSchema(ne,le).parse({name:xo,description:ss,maxInputTokens:128e3,maxOutputTokens:4092,roles:se,modalities:re,config:{def:h.oSeries(4092,4).def,schema:h.oSeries(4092,4).schema}}),Ot=T,xe=class extends V{constructor(e){super(Ro,e);}};var K=[types.EmbeddingTextModalityLiteral,types.EmbeddingTokenModalityLiteral],H=zod.z.enum([types.EmbeddingTextModalityLiteral,types.EmbeddingTokenModalityLiteral]);var Pt=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 is=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)),It=zod.z.object({model:zod.z.string().min(1).optional(),input:is,encoding_format:zod.z.enum(["float","base64"]).optional(),dimensions:zod.z.number().int().min(1).optional()});var $=zod.z.object({apiKey:zod.z.string(),baseUrl:zod.z.string().url(),getEmbeddingsUrl:zod.z.string().url().optional()}),j=class{constructor(e,t){this.version="v1";let o=$.parse(t);this.modelSchema=e,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 l=/(\d+)(h|m|s|ms)/g,c={h:36e5,m:6e4,s:1e3,ms:1},d,f=0;for(;(d=l.exec(i))!==null;){let g=parseInt(d[1]),O=d[2];f+=g*c[O];}return f},o=0,s=0,a=!0;e["x-ratelimit-reset-requests"]&&(o=t(e["x-ratelimit-reset-requests"])),e["x-ratelimit-reset-tokens"]&&(s=t(e["x-ratelimit-reset-tokens"]));let m=Math.max(o,s);return {shouldRetry:a,delayMs:m}}getTokenCount(e){return e.requests.reduce((t,o)=>t+o.length,0)}transformModelRequest(e){let t=It.safeParse(e);if(!t.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:t.error});let o=t.data,s=o.model,a={encodingFormat:o.encoding_format,dimensions:o.dimensions},m=types.Config().parse(provider.removeUndefinedEntries(a)),i,l;return typeof o.input=="string"?l=types.EmbeddingTextModalityLiteral:typeof o.input[0]=="string"?l=types.EmbeddingTextModalityLiteral:l=types.EmbeddingTokenModalityLiteral,l===types.EmbeddingTextModalityLiteral?typeof o.input=="string"?i={modality:l,requests:[o.input]}:i={modality:l,requests:o.input}:typeof o.input[0]=="number"?i={modality:l,requests:[o.input]}:i={modality:l,requests:o.input},{modelName:s,config:m,embeddingRequests:i}}transformConfig(e,t){let o=this.modelSchema.config.schema.safeParse(e);if(!o.success)throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:o.error});let s=o.data;return Object.keys(s).forEach(m=>{if(!this.modelSchema.config.def[m])throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error(`Invalid config key : '${m}',
|
|
14
|
+
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(s).reduce((m,i)=>{let c=this.modelSchema.config.def[i].param,d=s[i];return m[c]=d,m},{})}transformEmbeddingRequests(e){let t=types.EmbeddingRequests().safeParse(e);if(!t.success)throw new provider.InvalidEmbeddingRequestsError({info:"Invalid embedding requests",cause:t.error});return {input:t.data.requests}}getGetEmbeddingsUrl(e,t){return I(this,null,function*(){return new Promise(o=>{o(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(e,t){return I(this,null,function*(){return new Promise(o=>{o(this.getDefaultHeaders());})})}getGetEmbeddingsData(e,t){return I(this,null,function*(){return new Promise(o=>{o(y(y(y({},this.getDefaultParams()),this.transformConfig(e,t)),this.transformEmbeddingRequests(t)));})})}transformGetEmbeddingsResponse(e){let t,o=Pt.safeParse(e);if(o.success){let s=o.data;t=typeof s.data[0].embedding=="string"?types.Base64EmbeddingLiteral:types.FloatEmbeddingLiteral;let a=s.data.map(m=>typeof m.embedding=="string"?{index:m.index,embedding:m.embedding}:{index:m.index,embedding:m.embedding});return {encodingFormat:t,embeddings:a,usage:{totalTokens:s.usage.total_tokens}}}throw new provider.ModelResponseError({info:"Invalid response from model",cause:o.error})}};var Ao="text-embedding-ada-002",Ts="Most capable 2nd generation embedding model, replacing 16 first generation models",wo=provider.EmbeddingModelSchema(H).parse({name:Ao,description:Ts,modalities:K,maxInputTokens:8192,maxOutputTokens:1536,config:{def:q.base().def,schema:q.base().schema}}),Et=$,Ee=class extends j{constructor(e){super(wo,e);}};var vo="text-embedding-3-small",ys="Increased performance over 2nd generation ada embedding model",Go=provider.EmbeddingModelSchema(H).parse({name:vo,description:ys,modalities:K,maxInputTokens:8192,maxOutputTokens:1536,config:{def:q.dimensions(1536).def,schema:q.dimensions(1536).schema}}),At=$,Ae=class extends j{constructor(e){super(Go,e);}};var qo="text-embedding-3-large",Cs="Most capable embedding model for both english and non-english tasks",ko=provider.EmbeddingModelSchema(H).parse({name:qo,description:Cs,modalities:K,maxInputTokens:8192,maxOutputTokens:3072,config:{def:q.dimensions(3072).def,schema:q.dimensions(3072).schema}}),wt=$,we=class extends j{constructor(e){super(ko,e);}};var Os="openai",vt=class{constructor(){this.version="v1";this.name=Os;this.baseUrl="https://api.openai.com/v1";this.chatModelFactories={[to]:{model:fe,modelOptions:pt,modelSchema:no},[Ze]:{model:he,modelOptions:lt,modelSchema:Qe},[eo]:{model:ue,modelOptions:mt,modelSchema:oo},[so]:{model:ge,modelOptions:dt,modelSchema:ao},[io]:{model:Te,modelOptions:ct,modelSchema:ro},[lo]:{model:_e,modelOptions:ht,modelSchema:mo},[po]:{model:ye,modelOptions:ut,modelSchema:co},[ho]:{model:be,modelOptions:ft,modelSchema:uo},[fo]:{model:Ce,modelOptions:gt,modelSchema:go},[To]:{model:Oe,modelOptions:Tt,modelSchema:_o},[yo]:{model:Me,modelOptions:_t,modelSchema:bo},[Co]:{model:Se,modelOptions:yt,modelSchema:Oo},[Mo]:{model:Pe,modelOptions:bt,modelSchema:So},[Po]:{model:Ie,modelOptions:Ct,modelSchema:Io},[xo]:{model:xe,modelOptions:Ot,modelSchema:Ro}};this.embeddingModelFactories={[Ao]:{model:Ee,modelOptions:Et,modelSchema:wo},[vo]:{model:Ae,modelOptions:At,modelSchema:Go},[qo]:{model:we,modelOptions:wt,modelSchema:ko}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModel(e,t){var m;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(", ")}]`)});let o=this.chatModelFactories[e].model,s=x(y({},t),{baseUrl:(m=t.baseUrl)!=null?m:this.baseUrl}),a=this.chatModelFactories[e].modelOptions.parse(s);return new o(a)}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:
|
|
16
|
+
[${this.chatModelLiterals().join(", ")}]`)});return this.chatModelFactories[e].modelSchema}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((e,t)=>(e[t]=this.chatModelFactories[t].modelSchema,e),{})}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModel(e,t){var m;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
|
+
[${this.embeddingModelLiterals().join(", ")}]`)});let o=this.embeddingModelFactories[e].model,s=x(y({},t),{baseUrl:(m=t.baseUrl)!=null?m:this.baseUrl}),a=this.embeddingModelFactories[e].modelOptions.parse(s);return new o(a)}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:
|
|
18
|
+
[${this.embeddingModelLiterals().join(", ")}]`)});return this.embeddingModelFactories[e].modelSchema}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((e,t)=>(e[t]=this.embeddingModelFactories[t].modelSchema,e),{})}};
|
|
18
19
|
|
|
19
|
-
exports.BaseChatModel =
|
|
20
|
+
exports.BaseChatModel = _;
|
|
20
21
|
exports.BaseChatModelOptions = T;
|
|
21
22
|
exports.BaseEmbeddingModel = j;
|
|
22
|
-
exports.BaseEmbeddingModelOptions =
|
|
23
|
-
exports.BaseOSeriesChatModel =
|
|
24
|
-
exports.ChatModelBaseConfigDef =
|
|
23
|
+
exports.BaseEmbeddingModelOptions = $;
|
|
24
|
+
exports.BaseOSeriesChatModel = V;
|
|
25
|
+
exports.ChatModelBaseConfigDef = F;
|
|
25
26
|
exports.ChatModelBaseConfigSchema = B;
|
|
26
|
-
exports.ChatModelOSeriesConfigDef =
|
|
27
|
-
exports.ChatModelOSeriesConfigSchema =
|
|
28
|
-
exports.ChatModelResponseFormatConfigDef =
|
|
29
|
-
exports.ChatModelResponseFormatConfigSchema =
|
|
30
|
-
exports.ChatModelResponseSchemaConfigDef =
|
|
31
|
-
exports.ChatModelResponseSchemaConfigSchema =
|
|
32
|
-
exports.EmbeddingModelBaseConfigDef =
|
|
33
|
-
exports.EmbeddingModelBaseConfigSchema =
|
|
34
|
-
exports.EmbeddingModelDimensionsConfigDef =
|
|
35
|
-
exports.EmbeddingModelDimensionsConfigSchema =
|
|
36
|
-
exports.GPT_3_5_Turbo =
|
|
37
|
-
exports.
|
|
38
|
-
exports.
|
|
39
|
-
exports.
|
|
40
|
-
exports.
|
|
41
|
-
exports.
|
|
42
|
-
exports.
|
|
43
|
-
exports.
|
|
44
|
-
exports.
|
|
45
|
-
exports.
|
|
46
|
-
exports.
|
|
47
|
-
exports.
|
|
48
|
-
exports.
|
|
49
|
-
exports.
|
|
50
|
-
exports.
|
|
51
|
-
exports.
|
|
52
|
-
exports.
|
|
53
|
-
exports.
|
|
54
|
-
exports.
|
|
55
|
-
exports.
|
|
56
|
-
exports.
|
|
57
|
-
exports.
|
|
58
|
-
exports.
|
|
59
|
-
exports.
|
|
60
|
-
exports.
|
|
61
|
-
exports.
|
|
62
|
-
exports.
|
|
63
|
-
exports.
|
|
64
|
-
exports.
|
|
65
|
-
exports.
|
|
66
|
-
exports.
|
|
67
|
-
exports.
|
|
68
|
-
exports.
|
|
69
|
-
exports.
|
|
70
|
-
exports.
|
|
71
|
-
exports.
|
|
72
|
-
exports.
|
|
73
|
-
exports.
|
|
74
|
-
exports.
|
|
75
|
-
exports.
|
|
76
|
-
exports.
|
|
77
|
-
exports.
|
|
78
|
-
exports.
|
|
79
|
-
exports.
|
|
80
|
-
exports.
|
|
81
|
-
exports.
|
|
27
|
+
exports.ChatModelOSeriesConfigDef = Ho;
|
|
28
|
+
exports.ChatModelOSeriesConfigSchema = Jo;
|
|
29
|
+
exports.ChatModelResponseFormatConfigDef = $o;
|
|
30
|
+
exports.ChatModelResponseFormatConfigSchema = Bo;
|
|
31
|
+
exports.ChatModelResponseSchemaConfigDef = Y;
|
|
32
|
+
exports.ChatModelResponseSchemaConfigSchema = X;
|
|
33
|
+
exports.EmbeddingModelBaseConfigDef = ee;
|
|
34
|
+
exports.EmbeddingModelBaseConfigSchema = Q;
|
|
35
|
+
exports.EmbeddingModelDimensionsConfigDef = Yo;
|
|
36
|
+
exports.EmbeddingModelDimensionsConfigSchema = Wo;
|
|
37
|
+
exports.GPT_3_5_Turbo = fe;
|
|
38
|
+
exports.GPT_3_5_TurboLiteral = to;
|
|
39
|
+
exports.GPT_3_5_TurboOptions = pt;
|
|
40
|
+
exports.GPT_3_5_TurboSchema = no;
|
|
41
|
+
exports.GPT_3_5_Turbo_0125 = he;
|
|
42
|
+
exports.GPT_3_5_Turbo_0125Literal = Ze;
|
|
43
|
+
exports.GPT_3_5_Turbo_0125Options = lt;
|
|
44
|
+
exports.GPT_3_5_Turbo_0125Schema = Qe;
|
|
45
|
+
exports.GPT_3_5_Turbo_1106 = ue;
|
|
46
|
+
exports.GPT_3_5_Turbo_1106Literal = eo;
|
|
47
|
+
exports.GPT_3_5_Turbo_1106Options = mt;
|
|
48
|
+
exports.GPT_3_5_Turbo_1106Schema = oo;
|
|
49
|
+
exports.GPT_4 = Oe;
|
|
50
|
+
exports.GPT_4Literal = To;
|
|
51
|
+
exports.GPT_4Options = Tt;
|
|
52
|
+
exports.GPT_4Schema = _o;
|
|
53
|
+
exports.GPT_4_0125_Preview = ge;
|
|
54
|
+
exports.GPT_4_0125_PreviewLiteral = so;
|
|
55
|
+
exports.GPT_4_0125_PreviewOptions = dt;
|
|
56
|
+
exports.GPT_4_0125_PreviewSchema = ao;
|
|
57
|
+
exports.GPT_4_0613 = Te;
|
|
58
|
+
exports.GPT_4_0613Literal = io;
|
|
59
|
+
exports.GPT_4_0613Options = ct;
|
|
60
|
+
exports.GPT_4_0613Schema = ro;
|
|
61
|
+
exports.GPT_4_1106_Preview = _e;
|
|
62
|
+
exports.GPT_4_1106_PreviewLiteral = lo;
|
|
63
|
+
exports.GPT_4_1106_PreviewOptions = ht;
|
|
64
|
+
exports.GPT_4_1106_PreviewSchema = mo;
|
|
65
|
+
exports.GPT_4_Turbo = Ce;
|
|
66
|
+
exports.GPT_4_TurboLiteral = fo;
|
|
67
|
+
exports.GPT_4_TurboOptions = gt;
|
|
68
|
+
exports.GPT_4_TurboSchema = go;
|
|
69
|
+
exports.GPT_4_Turbo_2024_04_09 = ye;
|
|
70
|
+
exports.GPT_4_Turbo_2024_04_09Literal = po;
|
|
71
|
+
exports.GPT_4_Turbo_2024_04_09Options = ut;
|
|
72
|
+
exports.GPT_4_Turbo_2024_04_09Schema = co;
|
|
73
|
+
exports.GPT_4_Turbo_Preview = be;
|
|
74
|
+
exports.GPT_4_Turbo_PreviewLiteral = ho;
|
|
75
|
+
exports.GPT_4_Turbo_PreviewOptions = ft;
|
|
76
|
+
exports.GPT_4_Turbo_PreviewSchema = uo;
|
|
77
|
+
exports.GPT_4o = Pe;
|
|
78
|
+
exports.GPT_4oLiteral = Mo;
|
|
79
|
+
exports.GPT_4oOptions = bt;
|
|
80
|
+
exports.GPT_4oSchema = So;
|
|
81
|
+
exports.GPT_4o_2024_08_06 = Me;
|
|
82
|
+
exports.GPT_4o_2024_08_06Literal = yo;
|
|
83
|
+
exports.GPT_4o_2024_08_06Options = _t;
|
|
84
|
+
exports.GPT_4o_2024_08_06Schema = bo;
|
|
85
|
+
exports.GPT_4o_Mini = Se;
|
|
86
|
+
exports.GPT_4o_MiniLiteral = Co;
|
|
87
|
+
exports.GPT_4o_MiniOptions = yt;
|
|
88
|
+
exports.GPT_4o_MiniSchema = Oo;
|
|
89
|
+
exports.O1_Mini = Ie;
|
|
90
|
+
exports.O1_MiniLiteral = Po;
|
|
91
|
+
exports.O1_MiniOptions = Ct;
|
|
92
|
+
exports.O1_MiniSchema = Io;
|
|
93
|
+
exports.O1_Preview = xe;
|
|
94
|
+
exports.O1_PreviewLiteral = xo;
|
|
95
|
+
exports.O1_PreviewOptions = Ot;
|
|
96
|
+
exports.O1_PreviewSchema = Ro;
|
|
97
|
+
exports.OpenAI = vt;
|
|
82
98
|
exports.OpenAIChatModelConfigs = h;
|
|
83
|
-
exports.OpenAIChatModelModalities =
|
|
84
|
-
exports.OpenAIChatModelModalitiesEnum =
|
|
85
|
-
exports.
|
|
86
|
-
exports.
|
|
87
|
-
exports.
|
|
88
|
-
exports.
|
|
89
|
-
exports.
|
|
90
|
-
exports.
|
|
91
|
-
exports.
|
|
92
|
-
exports.
|
|
93
|
-
exports.
|
|
94
|
-
exports.
|
|
95
|
-
exports.
|
|
96
|
-
exports.
|
|
97
|
-
exports.
|
|
98
|
-
exports.
|
|
99
|
-
exports.
|
|
100
|
-
exports.
|
|
101
|
-
exports.
|
|
102
|
-
exports.
|
|
103
|
-
exports.
|
|
104
|
-
exports.
|
|
105
|
-
exports.
|
|
106
|
-
exports.
|
|
107
|
-
exports.
|
|
108
|
-
exports.
|
|
109
|
-
exports.
|
|
110
|
-
exports.
|
|
111
|
-
exports.
|
|
112
|
-
exports.
|
|
113
|
-
exports.
|
|
114
|
-
exports.
|
|
115
|
-
exports.
|
|
116
|
-
exports.
|
|
117
|
-
exports.
|
|
118
|
-
exports.
|
|
119
|
-
exports.
|
|
120
|
-
exports.
|
|
121
|
-
exports.
|
|
122
|
-
exports.
|
|
123
|
-
exports.
|
|
124
|
-
exports.
|
|
125
|
-
exports.
|
|
126
|
-
exports.
|
|
127
|
-
exports.
|
|
128
|
-
exports.
|
|
129
|
-
exports.
|
|
130
|
-
exports.
|
|
131
|
-
exports.
|
|
132
|
-
exports.
|
|
133
|
-
exports.
|
|
134
|
-
exports.
|
|
99
|
+
exports.OpenAIChatModelModalities = v;
|
|
100
|
+
exports.OpenAIChatModelModalitiesEnum = G;
|
|
101
|
+
exports.OpenAIChatModelOSSeriesRoles = ne;
|
|
102
|
+
exports.OpenAIChatModelOSSeriesRolesMap = se;
|
|
103
|
+
exports.OpenAIChatModelRoles = b;
|
|
104
|
+
exports.OpenAIChatModelRolesMap = C;
|
|
105
|
+
exports.OpenAIChatModelTextModalities = re;
|
|
106
|
+
exports.OpenAIChatModelTextModalitiesEnum = le;
|
|
107
|
+
exports.OpenAIChatModelTextToolModalities = S;
|
|
108
|
+
exports.OpenAIChatModelTextToolModalitiesEnum = P;
|
|
109
|
+
exports.OpenAIChatOSeriesRequest = st;
|
|
110
|
+
exports.OpenAIChatRequest = pe;
|
|
111
|
+
exports.OpenAIChatRequestAssistantMessage = cn;
|
|
112
|
+
exports.OpenAIChatRequestImageContent = ln;
|
|
113
|
+
exports.OpenAIChatRequestMessage = un;
|
|
114
|
+
exports.OpenAIChatRequestResponseFormat = rn;
|
|
115
|
+
exports.OpenAIChatRequestSystemMessage = pn;
|
|
116
|
+
exports.OpenAIChatRequestTextContent = He;
|
|
117
|
+
exports.OpenAIChatRequestTool = nn;
|
|
118
|
+
exports.OpenAIChatRequestToolCallContent = mn;
|
|
119
|
+
exports.OpenAIChatRequestToolChoiceEnum = sn;
|
|
120
|
+
exports.OpenAIChatRequestToolChoiceFunction = an;
|
|
121
|
+
exports.OpenAIChatRequestToolMessage = hn;
|
|
122
|
+
exports.OpenAIChatRequestUserMessage = dn;
|
|
123
|
+
exports.OpenAICompleteChatResponse = tt;
|
|
124
|
+
exports.OpenAIEmbeddingModelConfigs = q;
|
|
125
|
+
exports.OpenAIEmbeddingModelModalities = K;
|
|
126
|
+
exports.OpenAIEmbeddingModelModalitiesEnum = H;
|
|
127
|
+
exports.OpenAIEmbeddingRequest = It;
|
|
128
|
+
exports.OpenAIEmbeddingRequestInput = is;
|
|
129
|
+
exports.OpenAIGetEmbeddingsResponse = Pt;
|
|
130
|
+
exports.OpenAIStreamChatResponse = nt;
|
|
131
|
+
exports.OpenAIToolCallsCompleteChatResponse = on;
|
|
132
|
+
exports.OpenAIToolCallsStreamChatResponse = tn;
|
|
133
|
+
exports.ProviderLiteral = Os;
|
|
134
|
+
exports.Text_Embedding_3_Large = we;
|
|
135
|
+
exports.Text_Embedding_3_LargeLiteral = qo;
|
|
136
|
+
exports.Text_Embedding_3_LargeSchema = ko;
|
|
137
|
+
exports.Text_Embedding_3_Large_Options = wt;
|
|
138
|
+
exports.Text_Embedding_3_Small = Ae;
|
|
139
|
+
exports.Text_Embedding_3_SmallLiteral = vo;
|
|
140
|
+
exports.Text_Embedding_3_SmallSchema = Go;
|
|
141
|
+
exports.Text_Embedding_3_Small_Options = At;
|
|
142
|
+
exports.Text_Embedding_Ada002 = Ee;
|
|
143
|
+
exports.Text_Embedding_Ada002Literal = Ao;
|
|
144
|
+
exports.Text_Embedding_Ada002Schema = wo;
|
|
145
|
+
exports.Text_Embedding_Ada002_Options = Et;
|
|
146
|
+
exports.dimensions = Ve;
|
|
147
|
+
exports.encodingFormat = Ne;
|
|
148
|
+
exports.frequencyPenalty = ze;
|
|
149
|
+
exports.logProbs = Fe;
|
|
150
|
+
exports.maxTokens = ke;
|
|
151
|
+
exports.presencePenalty = $e;
|
|
152
|
+
exports.seed = Be;
|
|
153
|
+
exports.stop = je;
|
|
154
|
+
exports.temperature = qe;
|
|
155
|
+
exports.toolChoice = De;
|
|
156
|
+
exports.topLogProbs = Ue;
|
|
157
|
+
exports.topP = Le;
|
|
135
158
|
//# sourceMappingURL=index.js.map
|
|
136
159
|
//# sourceMappingURL=index.js.map
|