@adaline/openai 0.24.0 → 0.26.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 +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +159 -159
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -3688,6 +3688,14 @@ declare class BaseChatModel implements ChatModelV1<ChatModelSchemaType> {
|
|
|
3688
3688
|
partialResponse: PartialChatResponseType;
|
|
3689
3689
|
buffer: string;
|
|
3690
3690
|
}>;
|
|
3691
|
+
transformProxyStreamChatResponseChunk(chunk: string, buffer: string, data?: any, headers?: Record<string, string>, query?: Record<string, string>): AsyncGenerator<{
|
|
3692
|
+
partialResponse: PartialChatResponseType;
|
|
3693
|
+
buffer: string;
|
|
3694
|
+
}>;
|
|
3695
|
+
getProxyStreamChatUrl(data?: any, headers?: Record<string, string>, query?: Record<string, string>): Promise<UrlType>;
|
|
3696
|
+
getProxyCompleteChatUrl(data?: any, headers?: Record<string, string>, query?: Record<string, string>): Promise<UrlType>;
|
|
3697
|
+
getProxyCompleteChatHeaders(data?: any, headers?: Record<string, string>, query?: Record<string, string>): Promise<HeadersType>;
|
|
3698
|
+
getProxyStreamChatHeaders(data?: any, headers?: Record<string, string>, query?: Record<string, string>): Promise<HeadersType>;
|
|
3691
3699
|
}
|
|
3692
3700
|
|
|
3693
3701
|
declare class BaseOSeriesChatModel extends BaseChatModel {
|
|
@@ -3706,6 +3714,11 @@ declare class BaseOSeriesChatModel extends BaseChatModel {
|
|
|
3706
3714
|
partialResponse: PartialChatResponseType;
|
|
3707
3715
|
buffer: string;
|
|
3708
3716
|
}>;
|
|
3717
|
+
transformProxyStreamChatResponseChunk(chunk: string, buffer: string, data?: any, headers?: Record<string, string>, query?: Record<string, string>): AsyncGenerator<{
|
|
3718
|
+
partialResponse: PartialChatResponseType;
|
|
3719
|
+
buffer: string;
|
|
3720
|
+
}>;
|
|
3721
|
+
getProxyStreamChatUrl(data?: any, headers?: Record<string, string>, query?: Record<string, string>): Promise<UrlType>;
|
|
3709
3722
|
}
|
|
3710
3723
|
|
|
3711
3724
|
declare const GPT_3_5_Turbo_0125Literal = "gpt-3.5-turbo-0125";
|
package/dist/index.d.ts
CHANGED
|
@@ -3688,6 +3688,14 @@ declare class BaseChatModel implements ChatModelV1<ChatModelSchemaType> {
|
|
|
3688
3688
|
partialResponse: PartialChatResponseType;
|
|
3689
3689
|
buffer: string;
|
|
3690
3690
|
}>;
|
|
3691
|
+
transformProxyStreamChatResponseChunk(chunk: string, buffer: string, data?: any, headers?: Record<string, string>, query?: Record<string, string>): AsyncGenerator<{
|
|
3692
|
+
partialResponse: PartialChatResponseType;
|
|
3693
|
+
buffer: string;
|
|
3694
|
+
}>;
|
|
3695
|
+
getProxyStreamChatUrl(data?: any, headers?: Record<string, string>, query?: Record<string, string>): Promise<UrlType>;
|
|
3696
|
+
getProxyCompleteChatUrl(data?: any, headers?: Record<string, string>, query?: Record<string, string>): Promise<UrlType>;
|
|
3697
|
+
getProxyCompleteChatHeaders(data?: any, headers?: Record<string, string>, query?: Record<string, string>): Promise<HeadersType>;
|
|
3698
|
+
getProxyStreamChatHeaders(data?: any, headers?: Record<string, string>, query?: Record<string, string>): Promise<HeadersType>;
|
|
3691
3699
|
}
|
|
3692
3700
|
|
|
3693
3701
|
declare class BaseOSeriesChatModel extends BaseChatModel {
|
|
@@ -3706,6 +3714,11 @@ declare class BaseOSeriesChatModel extends BaseChatModel {
|
|
|
3706
3714
|
partialResponse: PartialChatResponseType;
|
|
3707
3715
|
buffer: string;
|
|
3708
3716
|
}>;
|
|
3717
|
+
transformProxyStreamChatResponseChunk(chunk: string, buffer: string, data?: any, headers?: Record<string, string>, query?: Record<string, string>): AsyncGenerator<{
|
|
3718
|
+
partialResponse: PartialChatResponseType;
|
|
3719
|
+
buffer: string;
|
|
3720
|
+
}>;
|
|
3721
|
+
getProxyStreamChatUrl(data?: any, headers?: Record<string, string>, query?: Record<string, string>): Promise<UrlType>;
|
|
3709
3722
|
}
|
|
3710
3723
|
|
|
3711
3724
|
declare const GPT_3_5_Turbo_0125Literal = "gpt-3.5-turbo-0125";
|
package/dist/index.js
CHANGED
|
@@ -4,174 +4,174 @@ var zod = require('zod');
|
|
|
4
4
|
var provider = require('@adaline/provider');
|
|
5
5
|
var types = require('@adaline/types');
|
|
6
6
|
|
|
7
|
-
var
|
|
8
|
-
[${this.chatModelLiterals().join(", ")}]`)});let o=this.chatModelFactories[t].model,
|
|
9
|
-
[${this.embeddingModelLiterals().join(", ")}]`)});let o=this.embeddingModelFactories[t].model,s=this.embeddingModelFactories[t].modelOptions.parse(e);return new o(s)}};D.baseUrl="https://api.openai.com/v1";var _=zod.z.enum([types.SystemRoleLiteral,types.UserRoleLiteral,types.AssistantRoleLiteral,types.ToolRoleLiteral]),T={system:types.SystemRoleLiteral,user:types.UserRoleLiteral,assistant:types.AssistantRoleLiteral,tool:types.ToolRoleLiteral},H=zod.z.enum([types.UserRoleLiteral,types.AssistantRoleLiteral]),V={user:types.UserRoleLiteral,assistant:types.AssistantRoleLiteral};var P=[types.TextModalityLiteral,types.ImageModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],S=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]),J=[types.TextModalityLiteral],W=zod.z.enum([types.TextModalityLiteral]),I=[types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],x=zod.z.enum([types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]);var ke=zod.z.object({token:zod.z.string(),logprob:zod.z.number(),bytes:zod.z.array(zod.z.number()).nullable()}),jt=zod.z.object({content:zod.z.array(ke.extend({top_logprobs:zod.z.array(ke)})).nullable().optional(),refusal:zod.z.array(ke.extend({top_logprobs:zod.z.array(ke)})).nullable().optional()}).nullable(),yn=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()})})),Dt=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:yn.optional(),refusal:zod.z.string().nullable().optional()}),logprobs:jt.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()})}),Mn=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()})),Ft=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().optional(),choices:zod.z.array(zod.z.object({index:zod.z.number(),delta:zod.z.object({content:zod.z.string().nullable().optional(),tool_calls:Mn.optional(),refusal:zod.z.string().nullable().optional()}).or(zod.z.object({})),logprobs:jt,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 On=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()})}),Cn=zod.z.enum(["none","auto","required"]),bn=zod.z.object({type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1)})}),Pn=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()})})),Ho=zod.z.object({text:zod.z.string().min(1),type:zod.z.literal("text")}),Sn=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()})}),In=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)})}),xn=zod.z.object({role:zod.z.literal("system"),content:zod.z.string().min(1).or(zod.z.array(Ho).min(1))}),An=zod.z.object({role:zod.z.literal("user"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([Ho,Sn])).min(1))}),En=zod.z.object({role:zod.z.literal("assistant"),content:zod.z.string().min(1).or(zod.z.array(Ho).min(1)).optional(),tool_calls:zod.z.array(In).min(1).optional()}),Rn=zod.z.object({role:zod.z.literal("tool"),tool_call_id:zod.z.string().min(1),content:zod.z.string().min(1)}),wn=zod.z.union([xn,An,En,Rn]),Le=zod.z.object({model:zod.z.string().min(1).optional(),messages:zod.z.array(wn).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_completion_tokens:zod.z.number().min(0).nullable().optional(),presence_penalty:zod.z.number().min(-2).max(2).nullable().optional(),response_format:Pn.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(On).optional(),tool_choice:Cn.or(bn).optional()});var $t=Le;var u=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),completeChatUrl:zod.z.string().url().optional(),streamChatUrl:zod.z.string().url().optional(),organization:zod.z.string().optional()}),f=class{constructor(e,t){this.version="v1";let o=u.parse(t);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash(o.baseUrl||D.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},c,O=0;for(;(c=l.exec(i))!==null;){let g=parseInt(c[1]),y=c[2];O+=g*h[y];}return O},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 d=Math.max(o,s);return {shouldRetry:a,delayMs:d}}getTokenCount(e){return e.reduce((t,o)=>t+o.content.map(s=>s.modality==="text"?s.value:"").join(" ").length,0)}transformModelRequest(e){let t=Le.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_completion_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 d=types.Config().parse(provider.removeUndefinedEntries(a)),i=[],l={};o.messages.forEach(c=>{let O=c.role;switch(O){case"system":{let g=c.content;if(typeof g=="string")i.push({role:O,content:[{modality:types.TextModalityLiteral,value:g}]});else {let y=g.map(C=>({modality:types.TextModalityLiteral,value:C.text}));i.push({role:O,content:y});}}break;case"user":{let g=c.content;if(typeof g=="string")i.push({role:O,content:[{modality:types.TextModalityLiteral,value:g}]});else {let y=g.map(C=>C.type==="text"?{modality:types.TextModalityLiteral,value:C.text}:C.image_url.url.startsWith("data:")?{modality:types.ImageModalityLiteral,detail:C.image_url.detail||"auto",value:{type:types.Base64ImageContentTypeLiteral,base64:C.image_url.url,media_type:provider.getMimeTypeFromBase64(C.image_url.url)}}:{modality:types.ImageModalityLiteral,detail:C.image_url.detail||"auto",value:{type:types.UrlImageContentTypeLiteral,url:C.image_url.url}});i.push({role:O,content:y});}}break;case"assistant":{let g=[];if(!c.content&&!c.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(c.content){let y=c.content;typeof y=="string"?g.push({modality:types.TextModalityLiteral,value:y}):y.forEach(C=>{g.push({modality:types.TextModalityLiteral,value:C.text});});}c.tool_calls&&c.tool_calls.forEach((C,E)=>{let z={modality:types.ToolCallModalityLiteral,id:C.id,index:E,name:C.function.name,arguments:C.function.arguments};g.push(z),l[z.id]=z;}),i.push({role:O,content:g});}break;case"tool":{let g=c;i.push({role:O,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 h=[];return o.tools&&o.tools.forEach(c=>{h.push({type:"function",definition:{schema:{name:c.function.name,description:c.function.description||"",strict:c.function.strict,parameters:c.function.parameters}}});}),{modelName:s,config:d,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 d=a.data;s!==void 0&&(d.toolChoice=s),Object.keys(d).forEach(l=>{if(!(l in this.modelSchema.config.def))throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${l}',
|
|
10
|
-
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let i=Object.keys(
|
|
11
|
-
one of [${h.choices.join(", ")}]`)})}}if("response_format"in i&&i.response_format!==void 0){let l=i.response_format;if(l==="json_schema")if("response_schema"in i)i.response_format={type:"json_schema",json_schema:i.response_schema},delete i.response_schema;else throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'responseSchema' is required in config when 'responseFormat' is 'json_schema'")});else i.response_format={type:l};}return i}transformMessages(e){if(!e||e&&e.length===0)return {messages:[]};let t=e.map(
|
|
12
|
-
available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),t.forEach(
|
|
13
|
-
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}),{messages:t.map(
|
|
14
|
-
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}})}}transformTools(e){if(!this.modelSchema.modalities.includes(types.ToolCallModalityLiteral))throw new provider.InvalidToolsError({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${types.ToolCallModalityLiteral}'`)});return !e||e&&e.length===0?{tools:[]}:{tools:e.map(
|
|
15
|
-
`,d);if(h===-1){a=o.substring(d);break}else {let c=o.substring(d,h).trim();c&&s.push(c),d=h+1;}}for(let h of s){if(h==="data: [DONE]")return;if(h.startsWith("data: ")){let c=h.substring(6);try{let O=JSON.parse(c),g=Ft.safeParse(O);if(g.success){let y={partialMessages:[]},C=g.data;if(C.choices.length>0){let E=C.choices[0].delta;if(E!==void 0&&Object.keys(E).length!==0){if("content"in E&&E.content!==null)y.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,E.content));else if("refusal"in E&&E.refusal!==null)y.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,E.refusal));else if("tool_calls"in E&&E.tool_calls!==void 0){let z=E.tool_calls.at(0);y.partialMessages.push(types.createPartialToolCallMessage(types.AssistantRoleLiteral,z.index,z.id,(i=z.function)==null?void 0:i.name,(l=z.function)==null?void 0:l.arguments));}}}C.usage&&(y.usage={promptTokens:C.usage.prompt_tokens,completionTokens:C.usage.completion_tokens,totalTokens:C.usage.total_tokens}),yield {partialResponse:y,buffer:a};}else throw new provider.ModelResponseError({info:"Invalid response from model",cause:g.error})}catch(O){throw new provider.ModelResponseError({info:`Malformed JSON received in stream: ${c}`,cause:O})}}}yield {partialResponse:{partialMessages:[]},buffer:a};})}};var q=class extends f{constructor(e,t){super(e,t);}transformModelRequest(e){let t=$t.safeParse(e);if(!t.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:t.error});let o=t.data,s=v(M({},o),{max_tokens:o.max_completion_tokens});return delete s.max_completion_tokens,super.transformModelRequest(s)}transformTools(e){throw new provider.ModelError({info:`Model: '${this.modelSchema.name}' does not support 'tools'.`,cause:new Error(`Model: '${this.modelSchema.name}' does not support 'tools'.`)})}getStreamChatUrl(e,t,o){return A(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 A(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 A(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 te(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 Qe="gpt-3.5-turbo-0125",Vn="The latest GPT-3.5 Turbo model with higher accuracy at responding in requested formats and a fix for a bug which caused a text encoding issue for non-English language function calls. Training data up to Sept 2021.",Xe=provider.ChatModelSchema(_,x).parse({name:Qe,description:Vn,maxInputTokens:4092,maxOutputTokens:4092,roles:T,modalities:I,config:{def:m.responseFormat(4092,4).def,schema:m.responseFormat(4092,4).schema}}),ct=u,le=class extends f{constructor(e){super(Xe,e);}};var Ze="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.",eo=provider.ChatModelSchema(_,x).parse({name:Ze,description:Jn,maxInputTokens:4092,maxOutputTokens:16385,roles:T,modalities:I,config:{def:m.responseFormat(16385,4).def,schema:m.responseFormat(16385,4).schema}}),ht=u,pe=class extends f{constructor(e){super(eo,e);}};var oo="gpt-3.5-turbo",Yn="Currently points to gpt-3.5-turbo-0125. Training data up to Sept 2021.",to=provider.ChatModelSchema(_,x).parse({name:oo,description:Yn,maxInputTokens:4092,maxOutputTokens:4092,roles:T,modalities:I,config:{def:m.responseFormat(4092,4).def,schema:m.responseFormat(4092,4).schema}}),ut=u,me=class extends f{constructor(e){super(to,e);}};var no="gpt-4-0125-preview",Xn="The latest GPT-4 model intended to reduce cases of \u201Claziness\u201D where the model doesn\u2019t complete a task. Training data up to Apr 2023.",so=provider.ChatModelSchema(_,x).parse({name:no,description:Xn,maxInputTokens:128e3,maxOutputTokens:4092,roles:T,modalities:I,config:{def:m.base(4092,4).def,schema:m.base(4092,4).schema}}),ft=u,de=class extends f{constructor(e){super(so,e);}};var ao="gpt-4-0613",es="Snapshot of gpt-4 from June 13th 2023 with improved function calling support. Training data up to Sept 2021.",io=provider.ChatModelSchema(_,x).parse({name:ao,description:es,maxInputTokens:8192,maxOutputTokens:4092,roles:T,modalities:I,config:{def:m.base(4092,4).def,schema:m.base(4092,4).schema}}),_t=u,ce=class extends f{constructor(e){super(io,e);}};var ro="gpt-4-1106-preview",ts="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.",lo=provider.ChatModelSchema(_,x).parse({name:ro,description:ts,maxInputTokens:128e3,maxOutputTokens:4092,roles:T,modalities:I,config:{def:m.base(4092,4).def,schema:m.base(4092,4).schema}}),Tt=u,he=class extends f{constructor(e){super(lo,e);}};var po="gpt-4-turbo-2024-04-09",ss="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.",mo=provider.ChatModelSchema(_,S).parse({name:po,description:ss,maxInputTokens:128e3,maxOutputTokens:4096,roles:T,modalities:P,config:{def:m.responseFormat(4096,4).def,schema:m.responseFormat(4096,4).schema}}),gt=u,ue=class extends f{constructor(e){super(mo,e);}};var co="gpt-4-turbo-preview",is="Currently points to gpt-4-0125-preview. Training data up to Apr 2023.",ho=provider.ChatModelSchema(_,x).parse({name:co,description:is,maxInputTokens:128e3,maxOutputTokens:4092,roles:T,modalities:I,config:{def:m.responseFormat(4092,4).def,schema:m.responseFormat(4092,4).schema}}),yt=u,fe=class extends f{constructor(e){super(ho,e);}};var uo="gpt-4-turbo",ls="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.",fo=provider.ChatModelSchema(_,S).parse({name:uo,description:ls,maxInputTokens:128e3,maxOutputTokens:4092,roles:T,modalities:P,config:{def:m.responseFormat(4092,4).def,schema:m.responseFormat(4092,4).schema}}),Mt=u,_e=class extends f{constructor(e){super(fo,e);}};var _o="gpt-4",ms="Currently points to gpt-4-0613. Training data up to Sept 2021.",To=provider.ChatModelSchema(_,x).parse({name:_o,description:ms,maxInputTokens:8192,maxOutputTokens:4092,roles:T,modalities:I,config:{def:m.base(4092,4).def,schema:m.base(4092,4).schema}}),Ot=u,Te=class extends f{constructor(e){super(To,e);}};var go="gpt-4o-2024-05-13",cs="Latest snapshot of gpt-4o that supports Structured Outputs. Training data up to Oct 2023.",yo=provider.ChatModelSchema(_,S).parse({name:go,description:cs,maxInputTokens:128e3,maxOutputTokens:4092,roles:T,modalities:P,config:{def:m.responseSchema(4092,4).def,schema:m.responseSchema(4092,4).schema}}),Ct=u,ge=class extends f{constructor(e){super(yo,e);}};var Mo="gpt-4o-2024-08-06",us="Latest snapshot of gpt-4o that supports Structured Outputs. Training data up to Oct 2023.",Oo=provider.ChatModelSchema(_,S).parse({name:Mo,description:us,maxInputTokens:128e3,maxOutputTokens:4092,roles:T,modalities:P,config:{def:m.responseSchema(4092,4).def,schema:m.responseSchema(4092,4).schema}}),bt=u,ye=class extends f{constructor(e){super(Oo,e);}};var Co="gpt-4o-mini-2024-07-18",_s="Most advanced, multimodal flagship model that is cheaper and faster than GPT-4 Turbo. Currently points to gpt-4o-2024-05-13. Training data up to Oct 2023.",bo=provider.ChatModelSchema(_,S).parse({name:Co,description:_s,maxInputTokens:128e3,maxOutputTokens:4092,roles:T,modalities:P,config:{def:m.responseSchema(4092,4).def,schema:m.responseSchema(4092,4).schema}}),Pt=u,Me=class extends f{constructor(e){super(bo,e);}};var Po="gpt-4o-mini",gs="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(_,S).parse({name:Po,description:gs,maxInputTokens:128e3,maxOutputTokens:4092,roles:T,modalities:P,config:{def:m.responseSchema(4092,4).def,schema:m.responseSchema(4092,4).schema}}),St=u,Oe=class extends f{constructor(e){super(So,e);}};var Io="gpt-4o",Ms="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.",xo=provider.ChatModelSchema(_,S).parse({name:Io,description:Ms,maxInputTokens:128e3,maxOutputTokens:4092,roles:T,modalities:P,config:{def:m.responseSchema(4092,4).def,schema:m.responseSchema(4092,4).schema}}),It=u,Ce=class extends f{constructor(e){super(xo,e);}};var Ao="o1-2024-12-17",Cs="A stable release model for production use, offering robust performance and advanced features. Training data up to December 2024.",Eo=provider.ChatModelSchema(_,S).parse({name:Ao,description:Cs,maxInputTokens:2e5,maxOutputTokens:1e5,roles:T,modalities:P,config:{def:m.oSeries(1e5,4).def,schema:m.oSeries(1e5,4).schema}}),xt=u,be=class extends f{constructor(e){super(Eo,e);}};var Ro="o1-mini-2024-09-12",Ps="Enhanced version of o1-mini optimized for faster reasoning in coding, math, and science. Training data up to September 2024.",wo=provider.ChatModelSchema(H,W).parse({name:Ro,description:Ps,maxInputTokens:128e3,maxOutputTokens:65536,roles:V,modalities:J,config:{def:m.oSeries(65536,4).def,schema:m.oSeries(65536,4).schema}}),At=u,Pe=class extends q{constructor(e){super(wo,e);}};var Go="o1-mini",Is="Faster and cheaper reasoning model particularly good at coding, math, and science. Training data up to Oct 2023.",vo=provider.ChatModelSchema(H,W).parse({name:Go,description:Is,maxInputTokens:128e3,maxOutputTokens:4092,roles:V,modalities:J,config:{def:m.oSeries(4092,4).def,schema:m.oSeries(4092,4).schema}}),Et=u,Se=class extends q{constructor(e){super(vo,e);}};var qo="o1-preview",As="Reasoning model designed to solve hard problems across domains. Training data up to Oct 2023.",ko=provider.ChatModelSchema(H,W).parse({name:qo,description:As,maxInputTokens:128e3,maxOutputTokens:4092,roles:V,modalities:J,config:{def:m.oSeries(4092,4).def,schema:m.oSeries(4092,4).schema}}),Rt=u,Ie=class extends q{constructor(e){super(ko,e);}};var Lo="o1",Rs="Highly capable general-purpose reasoning model with advanced capabilities in language, coding, and reasoning. Training data up to Oct 2023.",zo=provider.ChatModelSchema(_,S).parse({name:Lo,description:Rs,maxInputTokens:2e5,maxOutputTokens:1e5,roles:T,modalities:P,config:{def:m.oSeries(1e5,4).def,schema:m.oSeries(1e5,4).schema}}),wt=u,xe=class extends q{constructor(e){super(zo,e);}};var Q=[types.EmbeddingTextModalityLiteral,types.EmbeddingTokenModalityLiteral],X=zod.z.enum([types.EmbeddingTextModalityLiteral,types.EmbeddingTokenModalityLiteral]);var Jt=zod.z.object({object:zod.z.literal("list"),model:zod.z.string(),data:zod.z.array(zod.z.object({index:zod.z.number(),object:zod.z.literal("embedding"),embedding:zod.z.array(zod.z.number()).or(zod.z.string().base64())})),usage:zod.z.object({prompt_tokens:zod.z.number().nonnegative(),total_tokens:zod.z.number().nonnegative()})});var Gs=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)),Wt=zod.z.object({model:zod.z.string().min(1).optional(),input:Gs,encoding_format:zod.z.enum(["float","base64"]).optional(),dimensions:zod.z.number().int().min(1).optional()});var $=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),getEmbeddingsUrl:zod.z.string().url().optional()}),B=class{constructor(e,t){this.version="v1";let o=$.parse(t);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash(o.baseUrl||D.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},c,O=0;for(;(c=l.exec(i))!==null;){let g=parseInt(c[1]),y=c[2];O+=g*h[y];}return O},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 d=Math.max(o,s);return {shouldRetry:a,delayMs:d}}getTokenCount(e){return e.requests.reduce((t,o)=>t+o.length,0)}transformModelRequest(e){let t=Wt.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},d=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:d,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(d=>{if(!this.modelSchema.config.def[d])throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error(`Invalid config key : '${d}',
|
|
16
|
-
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(
|
|
7
|
+
var on=Object.defineProperty,tn=Object.defineProperties;var nn=Object.getOwnPropertyDescriptors;var Zo=Object.getOwnPropertySymbols;var sn=Object.prototype.hasOwnProperty,an=Object.prototype.propertyIsEnumerable;var ne=(s,e)=>(e=Symbol[s])?e:Symbol.for("Symbol."+s),rn=s=>{throw TypeError(s)};var et=(s,e,t)=>e in s?on(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,M=(s,e)=>{for(var t in e||(e={}))sn.call(e,t)&&et(s,t,e[t]);if(Zo)for(var t of Zo(e))an.call(e,t)&&et(s,t,e[t]);return s},v=(s,e)=>tn(s,nn(e));var b=(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());}),ot=function(s,e){this[0]=s,this[1]=e;},$=(s,e,t)=>{var o=(p,i,l,h)=>{try{var c=t[p](i),O=(i=c.value)instanceof ot,T=c.done;Promise.resolve(O?i[0]:i).then(y=>O?o(p==="return"?p:"next",i[1]?{done:y.done,value:y.value}:y,l,h):l({value:y,done:T})).catch(y=>o("throw",y,l,h));}catch(y){h(y);}},n=p=>a[p]=i=>new Promise((l,h)=>o(p,i,l,h)),a={};return t=t.apply(s,e),a[ne("asyncIterator")]=()=>a,n("next"),n("throw"),n("return"),a},se=s=>{var e=s[ne("asyncIterator")],t=!1,o,n={};return e==null?(e=s[ne("iterator")](),o=a=>n[a]=p=>e[a](p)):(e=e.call(s),o=a=>n[a]=p=>{if(t){if(t=!1,a==="throw")throw p;return p}return t=!0,{done:!1,value:new ot(new Promise(i=>{var l=e[a](p);l instanceof Object||rn("Object expected"),i(l);}),1)}}),n[ne("iterator")]=()=>n,o("next"),"throw"in e?o("throw"):n.throw=a=>{throw a},"return"in e&&o("return"),n};var Ue=provider.RangeConfigItem({param:"temperature",title:provider.CHAT_CONFIG.TEMPERATURE.title,description:provider.CHAT_CONFIG.TEMPERATURE.description,min:0,max:2,step:.01,default:1}),Fe=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}),$e=s=>provider.MultiStringConfigItem({param:"stop",title:provider.CHAT_CONFIG.STOP(s).title,description:provider.CHAT_CONFIG.STOP(s).description,max:s}),Ne=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}),He=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}),Ve=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}),Ke=provider.RangeConfigItem({param:"seed",title:provider.CHAT_CONFIG.SEED.title,description:provider.CHAT_CONFIG.SEED.description,min:0,max:1e6,step:1,default:0}),Je=provider.SelectBooleanConfigItem({param:"logprobs",title:provider.CHAT_CONFIG.LOG_PROBS.title,description:provider.CHAT_CONFIG.LOG_PROBS.description,default:!1}),We=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}),Ye=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 N=(s,e)=>zod.z.object({temperature:Ue.schema,maxTokens:Fe(s).schema,stop:$e(e).schema,topP:Ne.schema,frequencyPenalty:He.schema,presencePenalty:Ve.schema,seed:Ke.schema.transform(t=>t===0?void 0:t),logProbs:Je.schema,topLogProbs:We.schema,toolChoice:Ye.schema}),H=(s,e)=>({temperature:Ue.def,maxTokens:Fe(s).def,stop:$e(e).def,topP:Ne.def,frequencyPenalty:He.def,presencePenalty:Ve.def,seed:Ke.def,logProbs:Je.def,topLogProbs:We.def,toolChoice:Ye.def});var tt=provider.ObjectSchemaConfigItem({param:"response_schema",title:provider.CHAT_CONFIG.RESPONSE_SCHEMA.title,description:provider.CHAT_CONFIG.RESPONSE_SCHEMA.description,objectSchema:types.ResponseSchema}),nt=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"]}),ie=(s,e)=>v(M({},H(s,e)),{responseFormat:nt.def,responseSchema:tt.def}),re=(s,e)=>N(s,e).extend({responseFormat:nt.schema,responseSchema:tt.schema});var at=provider.RangeConfigItem({param:"temperature",title:provider.CHAT_CONFIG.TEMPERATURE.title,description:provider.CHAT_CONFIG.TEMPERATURE.description,min:1,max:1,step:.01,default:1}),it=(s,e)=>v(M({},ie(s,e)),{temperature:at.def}),rt=(s,e)=>re(s,e).extend({temperature:at.schema});var pt=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"]}),mt=(s,e)=>v(M({},H(s,e)),{responseFormat:pt.def}),dt=(s,e)=>N(s,e).extend({responseFormat:pt.schema});var Qe=provider.SelectStringConfigItem({param:"encoding_format",title:"Encoding format",description:"Select the encoding format for the word embedding.",default:"float",choices:["float","base64"]}),Xe=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 le=()=>zod.z.object({encodingFormat:Qe.schema}),pe=()=>({encodingFormat:Qe.def});var ct=s=>le().extend({dimensions:Xe(s).schema}),ht=s=>v(M({},pe()),{dimensions:Xe(s).def});var d={base:(s,e)=>({def:H(s,e),schema:N(s,e)}),responseFormat:(s,e)=>({def:mt(s,e),schema:dt(s,e)}),responseSchema:(s,e)=>({def:ie(s,e),schema:re(s,e)}),oSeries:(s,e)=>({def:it(s,e),schema:rt(s,e)})},k={base:()=>({def:pe(),schema:le()}),dimensions:s=>({def:ht(s),schema:ct(s)})};var Mn="openai",D=class{constructor(){this.version="v1";this.name=Mn;this.chatModelFactories={[no]:{model:ce,modelOptions:gt,modelSchema:so},[Ze]:{model:me,modelOptions:ft,modelSchema:eo},[oo]:{model:de,modelOptions:_t,modelSchema:to},[ao]:{model:he,modelOptions:Tt,modelSchema:io},[ro]:{model:ue,modelOptions:yt,modelSchema:lo},[po]:{model:fe,modelOptions:Mt,modelSchema:mo},[co]:{model:_e,modelOptions:Ot,modelSchema:ho},[uo]:{model:ge,modelOptions:Ct,modelSchema:fo},[_o]:{model:Te,modelOptions:bt,modelSchema:go},[To]:{model:ye,modelOptions:Pt,modelSchema:yo},[Co]:{model:Oe,modelOptions:It,modelSchema:bo},[Io]:{model:be,modelOptions:xt,modelSchema:Ro},[xo]:{model:Pe,modelOptions:At,modelSchema:Ao},[Po]:{model:Ce,modelOptions:Rt,modelSchema:So},[Mo]:{model:Me,modelOptions:St,modelSchema:Oo},[qo]:{model:Re,modelOptions:Gt,modelSchema:ko},[Lo]:{model:xe,modelOptions:vt,modelSchema:zo},[Bo]:{model:Ae,modelOptions:qt,modelSchema:jo},[Eo]:{model:Se,modelOptions:Et,modelSchema:wo},[Go]:{model:Ie,modelOptions:wt,modelSchema:vo}};this.embeddingModelFactories={[Do]:{model:Ee,modelOptions:kt,modelSchema:Uo},[Fo]:{model:we,modelOptions:Lt,modelSchema:$o},[No]:{model:Ge,modelOptions:zt,modelSchema:Ho}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((e,t)=>(e[t]=this.chatModelFactories[t].modelSchema,e),{})}chatModel(e){let t=e.modelName;if(!(t in this.chatModelFactories))throw new provider.ProviderError({info:`OpenAI chat model: ${t} not found`,cause:new Error(`OpenAI chat model: ${t} not found, available chat models:
|
|
8
|
+
[${this.chatModelLiterals().join(", ")}]`)});let o=this.chatModelFactories[t].model,n=this.chatModelFactories[t].modelOptions.parse(e);return new o(n)}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((e,t)=>(e[t]=this.embeddingModelFactories[t].modelSchema,e),{})}embeddingModel(e){let t=e.modelName;if(!(t in this.embeddingModelFactories))throw new provider.ProviderError({info:`OpenAI embedding model: ${t} not found`,cause:new Error(`OpenAI embedding model: ${t} not found, available embedding models:
|
|
9
|
+
[${this.embeddingModelLiterals().join(", ")}]`)});let o=this.embeddingModelFactories[t].model,n=this.embeddingModelFactories[t].modelOptions.parse(e);return new o(n)}};D.baseUrl="https://api.openai.com/v1";var _=zod.z.enum([types.SystemRoleLiteral,types.UserRoleLiteral,types.AssistantRoleLiteral,types.ToolRoleLiteral]),g={system:types.SystemRoleLiteral,user:types.UserRoleLiteral,assistant:types.AssistantRoleLiteral,tool:types.ToolRoleLiteral},V=zod.z.enum([types.UserRoleLiteral,types.AssistantRoleLiteral]),K={user:types.UserRoleLiteral,assistant:types.AssistantRoleLiteral};var S=[types.TextModalityLiteral,types.ImageModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],I=zod.z.enum([types.TextModalityLiteral,types.ImageModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]),W=[types.TextModalityLiteral],Y=zod.z.enum([types.TextModalityLiteral]),R=[types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral],x=zod.z.enum([types.TextModalityLiteral,types.ToolCallModalityLiteral,types.ToolResponseModalityLiteral]);var ze=zod.z.object({token:zod.z.string(),logprob:zod.z.number(),bytes:zod.z.array(zod.z.number()).nullable()}),Ft=zod.z.object({content:zod.z.array(ze.extend({top_logprobs:zod.z.array(ze)})).nullable().optional(),refusal:zod.z.array(ze.extend({top_logprobs:zod.z.array(ze)})).nullable().optional()}).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()})})),$t=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:Ft.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()})}),Cn=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().optional(),choices:zod.z.array(zod.z.object({index:zod.z.number(),delta:zod.z.object({content:zod.z.string().nullable().optional(),tool_calls:Cn.optional(),refusal:zod.z.string().nullable().optional()}).or(zod.z.object({})),logprobs:Ft,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 bn=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()})}),Pn=zod.z.enum(["none","auto","required"]),Sn=zod.z.object({type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1)})}),In=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()})})),Ko=zod.z.object({text:zod.z.string().min(1),type:zod.z.literal("text")}),Rn=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()})}),xn=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)})}),An=zod.z.object({role:zod.z.literal("system"),content:zod.z.string().min(1).or(zod.z.array(Ko).min(1))}),En=zod.z.object({role:zod.z.literal("user"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([Ko,Rn])).min(1))}),wn=zod.z.object({role:zod.z.literal("assistant"),content:zod.z.string().min(1).or(zod.z.array(Ko).min(1)).optional(),tool_calls:zod.z.array(xn).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)}),vn=zod.z.union([An,En,wn,Gn]),Be=zod.z.object({model:zod.z.string().min(1).optional(),messages:zod.z.array(vn).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_completion_tokens:zod.z.number().min(0).nullable().optional(),presence_penalty:zod.z.number().min(-2).max(2).nullable().optional(),response_format:In.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(bn).optional(),tool_choice:Pn.or(Sn).optional()});var Ht=Be;var u=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),completeChatUrl:zod.z.string().url().optional(),streamChatUrl:zod.z.string().url().optional(),organization:zod.z.string().optional()}),f=class{constructor(e,t){this.version="v1";let o=u.parse(t);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash(o.baseUrl||D.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},c,O=0;for(;(c=l.exec(i))!==null;){let T=parseInt(c[1]),y=c[2];O+=T*h[y];}return O},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=Be.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_completion_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(c=>{let O=c.role;switch(O){case"system":{let T=c.content;if(typeof T=="string")i.push({role:O,content:[{modality:types.TextModalityLiteral,value:T}]});else {let y=T.map(C=>({modality:types.TextModalityLiteral,value:C.text}));i.push({role:O,content:y});}}break;case"user":{let T=c.content;if(typeof T=="string")i.push({role:O,content:[{modality:types.TextModalityLiteral,value:T}]});else {let y=T.map(C=>C.type==="text"?{modality:types.TextModalityLiteral,value:C.text}:C.image_url.url.startsWith("data:")?{modality:types.ImageModalityLiteral,detail:C.image_url.detail||"auto",value:{type:types.Base64ImageContentTypeLiteral,base64:C.image_url.url,media_type:provider.getMimeTypeFromBase64(C.image_url.url)}}:{modality:types.ImageModalityLiteral,detail:C.image_url.detail||"auto",value:{type:types.UrlImageContentTypeLiteral,url:C.image_url.url}});i.push({role:O,content:y});}}break;case"assistant":{let T=[];if(!c.content&&!c.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(c.content){let y=c.content;typeof y=="string"?T.push({modality:types.TextModalityLiteral,value:y}):y.forEach(C=>{T.push({modality:types.TextModalityLiteral,value:C.text});});}c.tool_calls&&c.tool_calls.forEach((C,A)=>{let z={modality:types.ToolCallModalityLiteral,id:C.id,index:A,name:C.function.name,arguments:C.function.arguments};T.push(z),l[z.id]=z;}),i.push({role:O,content:T});}break;case"tool":{let T=c;i.push({role:O,content:[{modality:types.ToolResponseModalityLiteral,id:T.tool_call_id,index:l[T.tool_call_id].index,name:l[T.tool_call_id].name,data:T.content}]});}break}});let h=[];return o.tools&&o.tools.forEach(c=>{h.push({type:"function",definition:{schema:{name:c.function.name,description:c.function.description||"",strict:c.function.strict,parameters:c.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}',
|
|
10
|
+
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let i=Object.keys(p).reduce((l,h)=>{let c=this.modelSchema.config.def[h],O=c.param,T=p[h];return O==="max_completion_tokens"&&c.type==="range"&&T===0?l[O]=c.max:l[O]=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(c=>c.definition.schema.name).includes(l))i.tool_choice={type:"function",function:{name:l}};else throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`toolChoice : '${l}' is not part of provided 'tools' names or
|
|
11
|
+
one of [${h.choices.join(", ")}]`)})}}if("response_format"in i&&i.response_format!==void 0){let l=i.response_format;if(l==="json_schema")if("response_schema"in i)i.response_format={type:"json_schema",json_schema:i.response_schema},delete i.response_schema;else throw new provider.InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'responseSchema' is required in config when 'responseFormat' is 'json_schema'")});else i.response_format={type:l};}return i}transformMessages(e){if(!e||e&&e.length===0)return {messages:[]};let t=e.map(n=>{let a=types.Message().safeParse(n);if(!a.success)throw new provider.InvalidMessagesError({info:"Invalid messages",cause:a.error});return a.data});return t.forEach(n=>{n.content.forEach(a=>{if(!this.modelSchema.modalities.includes(a.modality))throw new provider.InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${a.modality}',
|
|
12
|
+
available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),t.forEach(n=>{if(!Object.keys(this.modelSchema.roles).includes(n.role))throw new provider.InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${n.role}',
|
|
13
|
+
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}),{messages:t.map(n=>{switch(n.role){case types.SystemRoleLiteral:{let a=[];return n.content.forEach(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,
|
|
14
|
+
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}})}}transformTools(e){if(!this.modelSchema.modalities.includes(types.ToolCallModalityLiteral))throw new provider.InvalidToolsError({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${types.ToolCallModalityLiteral}'`)});return !e||e&&e.length===0?{tools:[]}:{tools:e.map(n=>{let a=types.Tool().safeParse(n);if(!a.success)throw new provider.InvalidToolsError({info:"Invalid tools",cause:a.error});return a.data}).map(n=>({type:"function",function:n.definition.schema}))}}getCompleteChatUrl(e,t,o){return b(this,null,function*(){return new Promise(n=>{n(this.completeChatUrl);})})}getCompleteChatHeaders(e,t,o){return b(this,null,function*(){return new Promise(n=>{n(this.getDefaultHeaders());})})}getCompleteChatData(e,t,o){return b(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=$t.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=[{role:types.AssistantRoleLiteral,content:[]}],a=o.choices[0].message;a.content&&n[0].content.push(types.createTextContent(a.content)),a.refusal&&n[0].content.push(types.createTextContent(a.refusal)),a.tool_calls&&a.tool_calls.forEach((h,c)=>{n[0].content.push(types.createToolCallContent(c,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(c=>({token:c.token,logProb:c.logprob,bytes:c.bytes}))}))),l.refusal&&i.push(...l.refusal.map(h=>({token:h.token,logProb:h.logprob,bytes:h.bytes,topLogProbs:h.top_logprobs.map(c=>({token:c.token,logProb:c.logprob,bytes:c.bytes}))})))),{messages:n,usage:p,logProbs:i}}throw new provider.ModelResponseError({info:"Invalid response from model",cause:t.error})}getStreamChatUrl(e,t,o){return b(this,null,function*(){return new Promise(n=>{n(this.streamChatUrl);})})}getStreamChatHeaders(e,t,o){return b(this,null,function*(){return new Promise(n=>{n(this.getDefaultHeaders());})})}getStreamChatData(e,t,o){return b(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 $(this,null,function*(){var i,l;let o=t+e,n=[],a="",p=0;for(;p<o.length;){let h=o.indexOf(`
|
|
15
|
+
`,p);if(h===-1){a=o.substring(p);break}else {let c=o.substring(p,h).trim();c&&n.push(c),p=h+1;}}for(let h of n){if(h==="data: [DONE]")return;if(h.startsWith("data: ")){let c=h.substring(6);try{let O=JSON.parse(c),T=Nt.safeParse(O);if(T.success){let y={partialMessages:[]},C=T.data;if(C.choices.length>0){let A=C.choices[0].delta;if(A!==void 0&&Object.keys(A).length!==0){if("content"in A&&A.content!==null)y.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,A.content));else if("refusal"in A&&A.refusal!==null)y.partialMessages.push(types.createPartialTextMessage(types.AssistantRoleLiteral,A.refusal));else if("tool_calls"in A&&A.tool_calls!==void 0){let z=A.tool_calls.at(0);y.partialMessages.push(types.createPartialToolCallMessage(types.AssistantRoleLiteral,z.index,z.id,(i=z.function)==null?void 0:i.name,(l=z.function)==null?void 0:l.arguments));}}}C.usage&&(y.usage={promptTokens:C.usage.prompt_tokens,completionTokens:C.usage.completion_tokens,totalTokens:C.usage.total_tokens}),yield {partialResponse:y,buffer:a};}else throw new provider.ModelResponseError({info:"Invalid response from model",cause:T.error})}catch(O){throw new provider.ModelResponseError({info:`Malformed JSON received in stream: ${c}`,cause:O})}}}yield {partialResponse:{partialMessages:[]},buffer:a};})}transformProxyStreamChatResponseChunk(e,t,o,n,a){return $(this,null,function*(){yield*se(this.transformStreamChatResponseChunk(e,t));})}getProxyStreamChatUrl(e,t,o){return b(this,null,function*(){return new Promise(n=>{n(this.streamChatUrl);})})}getProxyCompleteChatUrl(e,t,o){return b(this,null,function*(){return new Promise(n=>{n(this.completeChatUrl);})})}getProxyCompleteChatHeaders(e,t,o){return b(this,null,function*(){if(!t)return {};let n=M({},t);return delete n.host,delete n["content-length"],n})}getProxyStreamChatHeaders(e,t,o){return b(this,null,function*(){return yield this.getProxyCompleteChatHeaders(e,t,o)})}};var q=class extends f{constructor(e,t){super(e,t);}transformModelRequest(e){let t=Ht.safeParse(e);if(!t.success)throw new provider.InvalidModelRequestError({info:"Invalid model request",cause:t.error});let o=t.data,n=v(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 b(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 b(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 b(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 $(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.`)})})}transformProxyStreamChatResponseChunk(e,t,o,n,a){return $(this,null,function*(){yield*se(this.transformStreamChatResponseChunk(e,t));})}getProxyStreamChatUrl(e,t,o){return b(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",Jn="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(_,x).parse({name:Ze,description:Jn,maxInputTokens:4092,maxOutputTokens:4092,roles:g,modalities:R,config:{def:d.responseFormat(4092,4).def,schema:d.responseFormat(4092,4).schema}}),ft=u,me=class extends f{constructor(e){super(eo,e);}};var oo="gpt-3.5-turbo-1106",Yn="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(_,x).parse({name:oo,description:Yn,maxInputTokens:4092,maxOutputTokens:16385,roles:g,modalities:R,config:{def:d.responseFormat(16385,4).def,schema:d.responseFormat(16385,4).schema}}),_t=u,de=class extends f{constructor(e){super(to,e);}};var no="gpt-3.5-turbo",Xn="Currently points to gpt-3.5-turbo-0125. Training data up to Sept 2021.",so=provider.ChatModelSchema(_,x).parse({name:no,description:Xn,maxInputTokens:4092,maxOutputTokens:4092,roles:g,modalities:R,config:{def:d.responseFormat(4092,4).def,schema:d.responseFormat(4092,4).schema}}),gt=u,ce=class extends f{constructor(e){super(so,e);}};var ao="gpt-4-0125-preview",es="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(_,x).parse({name:ao,description:es,maxInputTokens:128e3,maxOutputTokens:4092,roles:g,modalities:R,config:{def:d.base(4092,4).def,schema:d.base(4092,4).schema}}),Tt=u,he=class extends f{constructor(e){super(io,e);}};var ro="gpt-4-0613",ts="Snapshot of gpt-4 from June 13th 2023 with improved function calling support. Training data up to Sept 2021.",lo=provider.ChatModelSchema(_,x).parse({name:ro,description:ts,maxInputTokens:8192,maxOutputTokens:4092,roles:g,modalities:R,config:{def:d.base(4092,4).def,schema:d.base(4092,4).schema}}),yt=u,ue=class extends f{constructor(e){super(lo,e);}};var po="gpt-4-1106-preview",ss="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(_,x).parse({name:po,description:ss,maxInputTokens:128e3,maxOutputTokens:4092,roles:g,modalities:R,config:{def:d.base(4092,4).def,schema:d.base(4092,4).schema}}),Mt=u,fe=class extends f{constructor(e){super(mo,e);}};var co="gpt-4-turbo-2024-04-09",is="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(_,I).parse({name:co,description:is,maxInputTokens:128e3,maxOutputTokens:4096,roles:g,modalities:S,config:{def:d.responseFormat(4096,4).def,schema:d.responseFormat(4096,4).schema}}),Ot=u,_e=class extends f{constructor(e){super(ho,e);}};var uo="gpt-4-turbo-preview",ls="Currently points to gpt-4-0125-preview. Training data up to Apr 2023.",fo=provider.ChatModelSchema(_,x).parse({name:uo,description:ls,maxInputTokens:128e3,maxOutputTokens:4092,roles:g,modalities:R,config:{def:d.responseFormat(4092,4).def,schema:d.responseFormat(4092,4).schema}}),Ct=u,ge=class extends f{constructor(e){super(fo,e);}};var _o="gpt-4-turbo",ms="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(_,I).parse({name:_o,description:ms,maxInputTokens:128e3,maxOutputTokens:4092,roles:g,modalities:S,config:{def:d.responseFormat(4092,4).def,schema:d.responseFormat(4092,4).schema}}),bt=u,Te=class extends f{constructor(e){super(go,e);}};var To="gpt-4",cs="Currently points to gpt-4-0613. Training data up to Sept 2021.",yo=provider.ChatModelSchema(_,x).parse({name:To,description:cs,maxInputTokens:8192,maxOutputTokens:4092,roles:g,modalities:R,config:{def:d.base(4092,4).def,schema:d.base(4092,4).schema}}),Pt=u,ye=class extends f{constructor(e){super(yo,e);}};var Mo="gpt-4o-2024-05-13",us="Latest snapshot of gpt-4o that supports Structured Outputs. Training data up to Oct 2023.",Oo=provider.ChatModelSchema(_,I).parse({name:Mo,description:us,maxInputTokens:128e3,maxOutputTokens:4092,roles:g,modalities:S,config:{def:d.responseSchema(4092,4).def,schema:d.responseSchema(4092,4).schema}}),St=u,Me=class extends f{constructor(e){super(Oo,e);}};var Co="gpt-4o-2024-08-06",_s="Latest snapshot of gpt-4o that supports Structured Outputs. Training data up to Oct 2023.",bo=provider.ChatModelSchema(_,I).parse({name:Co,description:_s,maxInputTokens:128e3,maxOutputTokens:4092,roles:g,modalities:S,config:{def:d.responseSchema(4092,4).def,schema:d.responseSchema(4092,4).schema}}),It=u,Oe=class extends f{constructor(e){super(bo,e);}};var Po="gpt-4o-mini-2024-07-18",Ts="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(_,I).parse({name:Po,description:Ts,maxInputTokens:128e3,maxOutputTokens:4092,roles:g,modalities:S,config:{def:d.responseSchema(4092,4).def,schema:d.responseSchema(4092,4).schema}}),Rt=u,Ce=class extends f{constructor(e){super(So,e);}};var Io="gpt-4o-mini",Ms="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(_,I).parse({name:Io,description:Ms,maxInputTokens:128e3,maxOutputTokens:4092,roles:g,modalities:S,config:{def:d.responseSchema(4092,4).def,schema:d.responseSchema(4092,4).schema}}),xt=u,be=class extends f{constructor(e){super(Ro,e);}};var xo="gpt-4o",Cs="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.",Ao=provider.ChatModelSchema(_,I).parse({name:xo,description:Cs,maxInputTokens:128e3,maxOutputTokens:4092,roles:g,modalities:S,config:{def:d.responseSchema(4092,4).def,schema:d.responseSchema(4092,4).schema}}),At=u,Pe=class extends f{constructor(e){super(Ao,e);}};var Eo="o1-2024-12-17",Ps="A stable release model for production use, offering robust performance and advanced features. Training data up to December 2024.",wo=provider.ChatModelSchema(_,I).parse({name:Eo,description:Ps,maxInputTokens:2e5,maxOutputTokens:1e5,roles:g,modalities:S,config:{def:d.oSeries(1e5,4).def,schema:d.oSeries(1e5,4).schema}}),Et=u,Se=class extends f{constructor(e){super(wo,e);}};var Go="o1-mini-2024-09-12",Is="Enhanced version of o1-mini optimized for faster reasoning in coding, math, and science. Training data up to September 2024.",vo=provider.ChatModelSchema(V,Y).parse({name:Go,description:Is,maxInputTokens:128e3,maxOutputTokens:65536,roles:K,modalities:W,config:{def:d.oSeries(65536,4).def,schema:d.oSeries(65536,4).schema}}),wt=u,Ie=class extends q{constructor(e){super(vo,e);}};var qo="o1-mini",xs="Faster and cheaper reasoning model particularly good at coding, math, and science. Training data up to Oct 2023.",ko=provider.ChatModelSchema(V,Y).parse({name:qo,description:xs,maxInputTokens:128e3,maxOutputTokens:4092,roles:K,modalities:W,config:{def:d.oSeries(4092,4).def,schema:d.oSeries(4092,4).schema}}),Gt=u,Re=class extends q{constructor(e){super(ko,e);}};var Lo="o1-preview",Es="Reasoning model designed to solve hard problems across domains. Training data up to Oct 2023.",zo=provider.ChatModelSchema(V,Y).parse({name:Lo,description:Es,maxInputTokens:128e3,maxOutputTokens:4092,roles:K,modalities:W,config:{def:d.oSeries(4092,4).def,schema:d.oSeries(4092,4).schema}}),vt=u,xe=class extends q{constructor(e){super(zo,e);}};var Bo="o1",Gs="Highly capable general-purpose reasoning model with advanced capabilities in language, coding, and reasoning. Training data up to Oct 2023.",jo=provider.ChatModelSchema(_,I).parse({name:Bo,description:Gs,maxInputTokens:2e5,maxOutputTokens:1e5,roles:g,modalities:S,config:{def:d.oSeries(1e5,4).def,schema:d.oSeries(1e5,4).schema}}),qt=u,Ae=class extends q{constructor(e){super(jo,e);}};var Z=[types.EmbeddingTextModalityLiteral,types.EmbeddingTokenModalityLiteral],ee=zod.z.enum([types.EmbeddingTextModalityLiteral,types.EmbeddingTokenModalityLiteral]);var Qt=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 qs=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)),Xt=zod.z.object({model:zod.z.string().min(1).optional(),input:qs,encoding_format:zod.z.enum(["float","base64"]).optional(),dimensions:zod.z.number().int().min(1).optional()});var F=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),baseUrl:zod.z.string().url().optional(),getEmbeddingsUrl:zod.z.string().url().optional()}),B=class{constructor(e,t){this.version="v1";let o=F.parse(t);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=provider.urlWithoutTrailingSlash(o.baseUrl||D.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},c,O=0;for(;(c=l.exec(i))!==null;){let T=parseInt(c[1]),y=c[2];O+=T*h[y];}return O},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=Xt.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}',
|
|
16
|
+
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(n).reduce((p,i)=>{let h=this.modelSchema.config.def[i].param,c=n[i];return p[h]=c,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 b(this,null,function*(){return new Promise(o=>{o(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(e,t){return b(this,null,function*(){return new Promise(o=>{o(this.getDefaultHeaders());})})}getGetEmbeddingsData(e,t){return b(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=Qt.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 Do="text-embedding-ada-002",Hs="Most capable 2nd generation embedding model, replacing 16 first generation models",Uo=provider.EmbeddingModelSchema(ee).parse({name:Do,description:Hs,modalities:Z,maxInputTokens:8192,maxOutputTokens:1536,config:{def:k.base().def,schema:k.base().schema}}),kt=F,Ee=class extends B{constructor(e){super(Uo,e);}};var Fo="text-embedding-3-small",Ks="Increased performance over 2nd generation ada embedding model",$o=provider.EmbeddingModelSchema(ee).parse({name:Fo,description:Ks,modalities:Z,maxInputTokens:8192,maxOutputTokens:1536,config:{def:k.dimensions(1536).def,schema:k.dimensions(1536).schema}}),Lt=F,we=class extends B{constructor(e){super($o,e);}};var No="text-embedding-3-large",Ws="Most capable embedding model for both english and non-english tasks",Ho=provider.EmbeddingModelSchema(ee).parse({name:No,description:Ws,modalities:Z,maxInputTokens:8192,maxOutputTokens:3072,config:{def:k.dimensions(3072).def,schema:k.dimensions(3072).schema}}),zt=F,Ge=class extends B{constructor(e){super(Ho,e);}};
|
|
17
17
|
|
|
18
18
|
exports.BaseChatModel = f;
|
|
19
19
|
exports.BaseChatModelOptions = u;
|
|
20
20
|
exports.BaseEmbeddingModel = B;
|
|
21
|
-
exports.BaseEmbeddingModelOptions =
|
|
21
|
+
exports.BaseEmbeddingModelOptions = F;
|
|
22
22
|
exports.BaseOSeriesChatModel = q;
|
|
23
|
-
exports.ChatModelBaseConfigDef =
|
|
23
|
+
exports.ChatModelBaseConfigDef = H;
|
|
24
24
|
exports.ChatModelBaseConfigSchema = N;
|
|
25
|
-
exports.ChatModelOSeriesConfigDef =
|
|
26
|
-
exports.ChatModelOSeriesConfigSchema =
|
|
27
|
-
exports.ChatModelResponseFormatConfigDef =
|
|
28
|
-
exports.ChatModelResponseFormatConfigSchema =
|
|
29
|
-
exports.ChatModelResponseSchemaConfigDef =
|
|
30
|
-
exports.ChatModelResponseSchemaConfigSchema =
|
|
31
|
-
exports.EmbeddingModelBaseConfigDef =
|
|
32
|
-
exports.EmbeddingModelBaseConfigSchema =
|
|
33
|
-
exports.EmbeddingModelDimensionsConfigDef =
|
|
34
|
-
exports.EmbeddingModelDimensionsConfigSchema =
|
|
35
|
-
exports.GPT_3_5_Turbo =
|
|
36
|
-
exports.GPT_3_5_TurboLiteral =
|
|
37
|
-
exports.GPT_3_5_TurboOptions =
|
|
38
|
-
exports.GPT_3_5_TurboSchema =
|
|
39
|
-
exports.GPT_3_5_Turbo_0125 =
|
|
40
|
-
exports.GPT_3_5_Turbo_0125Literal =
|
|
41
|
-
exports.GPT_3_5_Turbo_0125Options =
|
|
42
|
-
exports.GPT_3_5_Turbo_0125Schema =
|
|
43
|
-
exports.GPT_3_5_Turbo_1106 =
|
|
44
|
-
exports.GPT_3_5_Turbo_1106Literal =
|
|
45
|
-
exports.GPT_3_5_Turbo_1106Options =
|
|
46
|
-
exports.GPT_3_5_Turbo_1106Schema =
|
|
47
|
-
exports.GPT_4 =
|
|
48
|
-
exports.GPT_4Literal =
|
|
49
|
-
exports.GPT_4Options =
|
|
50
|
-
exports.GPT_4Schema =
|
|
51
|
-
exports.GPT_4_0125_Preview =
|
|
52
|
-
exports.GPT_4_0125_PreviewLiteral =
|
|
53
|
-
exports.GPT_4_0125_PreviewOptions =
|
|
54
|
-
exports.GPT_4_0125_PreviewSchema =
|
|
55
|
-
exports.GPT_4_0613 =
|
|
56
|
-
exports.GPT_4_0613Literal =
|
|
57
|
-
exports.GPT_4_0613Options =
|
|
58
|
-
exports.GPT_4_0613Schema =
|
|
59
|
-
exports.GPT_4_1106_Preview =
|
|
60
|
-
exports.GPT_4_1106_PreviewLiteral =
|
|
61
|
-
exports.GPT_4_1106_PreviewOptions =
|
|
62
|
-
exports.GPT_4_1106_PreviewSchema =
|
|
63
|
-
exports.GPT_4_Turbo =
|
|
64
|
-
exports.GPT_4_TurboLiteral =
|
|
65
|
-
exports.GPT_4_TurboOptions =
|
|
66
|
-
exports.GPT_4_TurboSchema =
|
|
67
|
-
exports.GPT_4_Turbo_2024_04_09 =
|
|
68
|
-
exports.GPT_4_Turbo_2024_04_09Literal =
|
|
69
|
-
exports.GPT_4_Turbo_2024_04_09Options =
|
|
70
|
-
exports.GPT_4_Turbo_2024_04_09Schema =
|
|
71
|
-
exports.GPT_4_Turbo_Preview =
|
|
72
|
-
exports.GPT_4_Turbo_PreviewLiteral =
|
|
73
|
-
exports.GPT_4_Turbo_PreviewOptions =
|
|
74
|
-
exports.GPT_4_Turbo_PreviewSchema =
|
|
75
|
-
exports.GPT_4o =
|
|
76
|
-
exports.GPT_4oLiteral =
|
|
77
|
-
exports.GPT_4oOptions =
|
|
78
|
-
exports.GPT_4oSchema =
|
|
79
|
-
exports.GPT_4o_2024_05_13 =
|
|
80
|
-
exports.GPT_4o_2024_05_13Literal =
|
|
81
|
-
exports.GPT_4o_2024_05_13Options =
|
|
82
|
-
exports.GPT_4o_2024_05_13Schema =
|
|
83
|
-
exports.GPT_4o_2024_08_06 =
|
|
84
|
-
exports.GPT_4o_2024_08_06Literal =
|
|
85
|
-
exports.GPT_4o_2024_08_06Options =
|
|
86
|
-
exports.GPT_4o_2024_08_06Schema =
|
|
87
|
-
exports.GPT_4o_Mini =
|
|
88
|
-
exports.GPT_4o_MiniLiteral =
|
|
89
|
-
exports.GPT_4o_MiniOptions =
|
|
90
|
-
exports.GPT_4o_MiniSchema =
|
|
91
|
-
exports.GPT_4o_Mini_2024_07_18 =
|
|
92
|
-
exports.GPT_4o_Mini_2024_07_18Literal =
|
|
93
|
-
exports.GPT_4o_Mini_2024_07_18Options =
|
|
94
|
-
exports.GPT_4o_Mini_2024_07_18Schema =
|
|
95
|
-
exports.O1 =
|
|
96
|
-
exports.O1Literal =
|
|
97
|
-
exports.O1Options =
|
|
98
|
-
exports.O1Schema =
|
|
99
|
-
exports.O1_2024_12_17 =
|
|
100
|
-
exports.O1_2024_12_17Literal =
|
|
101
|
-
exports.O1_2024_12_17Options =
|
|
102
|
-
exports.O1_2024_12_17Schema =
|
|
103
|
-
exports.O1_Mini =
|
|
104
|
-
exports.O1_MiniLiteral =
|
|
105
|
-
exports.O1_MiniOptions =
|
|
106
|
-
exports.O1_MiniSchema =
|
|
107
|
-
exports.O1_Mini_2024_09_12 =
|
|
108
|
-
exports.O1_Mini_2024_09_12Literal =
|
|
109
|
-
exports.O1_Mini_2024_09_12Options =
|
|
110
|
-
exports.O1_Mini_2024_09_12Schema =
|
|
111
|
-
exports.O1_Preview =
|
|
112
|
-
exports.O1_PreviewLiteral =
|
|
113
|
-
exports.O1_PreviewOptions =
|
|
114
|
-
exports.O1_PreviewSchema =
|
|
25
|
+
exports.ChatModelOSeriesConfigDef = it;
|
|
26
|
+
exports.ChatModelOSeriesConfigSchema = rt;
|
|
27
|
+
exports.ChatModelResponseFormatConfigDef = mt;
|
|
28
|
+
exports.ChatModelResponseFormatConfigSchema = dt;
|
|
29
|
+
exports.ChatModelResponseSchemaConfigDef = ie;
|
|
30
|
+
exports.ChatModelResponseSchemaConfigSchema = re;
|
|
31
|
+
exports.EmbeddingModelBaseConfigDef = pe;
|
|
32
|
+
exports.EmbeddingModelBaseConfigSchema = le;
|
|
33
|
+
exports.EmbeddingModelDimensionsConfigDef = ht;
|
|
34
|
+
exports.EmbeddingModelDimensionsConfigSchema = ct;
|
|
35
|
+
exports.GPT_3_5_Turbo = ce;
|
|
36
|
+
exports.GPT_3_5_TurboLiteral = no;
|
|
37
|
+
exports.GPT_3_5_TurboOptions = gt;
|
|
38
|
+
exports.GPT_3_5_TurboSchema = so;
|
|
39
|
+
exports.GPT_3_5_Turbo_0125 = me;
|
|
40
|
+
exports.GPT_3_5_Turbo_0125Literal = Ze;
|
|
41
|
+
exports.GPT_3_5_Turbo_0125Options = ft;
|
|
42
|
+
exports.GPT_3_5_Turbo_0125Schema = eo;
|
|
43
|
+
exports.GPT_3_5_Turbo_1106 = de;
|
|
44
|
+
exports.GPT_3_5_Turbo_1106Literal = oo;
|
|
45
|
+
exports.GPT_3_5_Turbo_1106Options = _t;
|
|
46
|
+
exports.GPT_3_5_Turbo_1106Schema = to;
|
|
47
|
+
exports.GPT_4 = ye;
|
|
48
|
+
exports.GPT_4Literal = To;
|
|
49
|
+
exports.GPT_4Options = Pt;
|
|
50
|
+
exports.GPT_4Schema = yo;
|
|
51
|
+
exports.GPT_4_0125_Preview = he;
|
|
52
|
+
exports.GPT_4_0125_PreviewLiteral = ao;
|
|
53
|
+
exports.GPT_4_0125_PreviewOptions = Tt;
|
|
54
|
+
exports.GPT_4_0125_PreviewSchema = io;
|
|
55
|
+
exports.GPT_4_0613 = ue;
|
|
56
|
+
exports.GPT_4_0613Literal = ro;
|
|
57
|
+
exports.GPT_4_0613Options = yt;
|
|
58
|
+
exports.GPT_4_0613Schema = lo;
|
|
59
|
+
exports.GPT_4_1106_Preview = fe;
|
|
60
|
+
exports.GPT_4_1106_PreviewLiteral = po;
|
|
61
|
+
exports.GPT_4_1106_PreviewOptions = Mt;
|
|
62
|
+
exports.GPT_4_1106_PreviewSchema = mo;
|
|
63
|
+
exports.GPT_4_Turbo = Te;
|
|
64
|
+
exports.GPT_4_TurboLiteral = _o;
|
|
65
|
+
exports.GPT_4_TurboOptions = bt;
|
|
66
|
+
exports.GPT_4_TurboSchema = go;
|
|
67
|
+
exports.GPT_4_Turbo_2024_04_09 = _e;
|
|
68
|
+
exports.GPT_4_Turbo_2024_04_09Literal = co;
|
|
69
|
+
exports.GPT_4_Turbo_2024_04_09Options = Ot;
|
|
70
|
+
exports.GPT_4_Turbo_2024_04_09Schema = ho;
|
|
71
|
+
exports.GPT_4_Turbo_Preview = ge;
|
|
72
|
+
exports.GPT_4_Turbo_PreviewLiteral = uo;
|
|
73
|
+
exports.GPT_4_Turbo_PreviewOptions = Ct;
|
|
74
|
+
exports.GPT_4_Turbo_PreviewSchema = fo;
|
|
75
|
+
exports.GPT_4o = Pe;
|
|
76
|
+
exports.GPT_4oLiteral = xo;
|
|
77
|
+
exports.GPT_4oOptions = At;
|
|
78
|
+
exports.GPT_4oSchema = Ao;
|
|
79
|
+
exports.GPT_4o_2024_05_13 = Me;
|
|
80
|
+
exports.GPT_4o_2024_05_13Literal = Mo;
|
|
81
|
+
exports.GPT_4o_2024_05_13Options = St;
|
|
82
|
+
exports.GPT_4o_2024_05_13Schema = Oo;
|
|
83
|
+
exports.GPT_4o_2024_08_06 = Oe;
|
|
84
|
+
exports.GPT_4o_2024_08_06Literal = Co;
|
|
85
|
+
exports.GPT_4o_2024_08_06Options = It;
|
|
86
|
+
exports.GPT_4o_2024_08_06Schema = bo;
|
|
87
|
+
exports.GPT_4o_Mini = be;
|
|
88
|
+
exports.GPT_4o_MiniLiteral = Io;
|
|
89
|
+
exports.GPT_4o_MiniOptions = xt;
|
|
90
|
+
exports.GPT_4o_MiniSchema = Ro;
|
|
91
|
+
exports.GPT_4o_Mini_2024_07_18 = Ce;
|
|
92
|
+
exports.GPT_4o_Mini_2024_07_18Literal = Po;
|
|
93
|
+
exports.GPT_4o_Mini_2024_07_18Options = Rt;
|
|
94
|
+
exports.GPT_4o_Mini_2024_07_18Schema = So;
|
|
95
|
+
exports.O1 = Ae;
|
|
96
|
+
exports.O1Literal = Bo;
|
|
97
|
+
exports.O1Options = qt;
|
|
98
|
+
exports.O1Schema = jo;
|
|
99
|
+
exports.O1_2024_12_17 = Se;
|
|
100
|
+
exports.O1_2024_12_17Literal = Eo;
|
|
101
|
+
exports.O1_2024_12_17Options = Et;
|
|
102
|
+
exports.O1_2024_12_17Schema = wo;
|
|
103
|
+
exports.O1_Mini = Re;
|
|
104
|
+
exports.O1_MiniLiteral = qo;
|
|
105
|
+
exports.O1_MiniOptions = Gt;
|
|
106
|
+
exports.O1_MiniSchema = ko;
|
|
107
|
+
exports.O1_Mini_2024_09_12 = Ie;
|
|
108
|
+
exports.O1_Mini_2024_09_12Literal = Go;
|
|
109
|
+
exports.O1_Mini_2024_09_12Options = wt;
|
|
110
|
+
exports.O1_Mini_2024_09_12Schema = vo;
|
|
111
|
+
exports.O1_Preview = xe;
|
|
112
|
+
exports.O1_PreviewLiteral = Lo;
|
|
113
|
+
exports.O1_PreviewOptions = vt;
|
|
114
|
+
exports.O1_PreviewSchema = zo;
|
|
115
115
|
exports.OpenAI = D;
|
|
116
|
-
exports.OpenAIChatModelConfigs =
|
|
117
|
-
exports.OpenAIChatModelModalities =
|
|
118
|
-
exports.OpenAIChatModelModalitiesEnum =
|
|
119
|
-
exports.OpenAIChatModelOSSeriesRoles =
|
|
120
|
-
exports.OpenAIChatModelOSSeriesRolesMap =
|
|
116
|
+
exports.OpenAIChatModelConfigs = d;
|
|
117
|
+
exports.OpenAIChatModelModalities = S;
|
|
118
|
+
exports.OpenAIChatModelModalitiesEnum = I;
|
|
119
|
+
exports.OpenAIChatModelOSSeriesRoles = V;
|
|
120
|
+
exports.OpenAIChatModelOSSeriesRolesMap = K;
|
|
121
121
|
exports.OpenAIChatModelRoles = _;
|
|
122
|
-
exports.OpenAIChatModelRolesMap =
|
|
123
|
-
exports.OpenAIChatModelTextModalities =
|
|
124
|
-
exports.OpenAIChatModelTextModalitiesEnum =
|
|
125
|
-
exports.OpenAIChatModelTextToolModalities =
|
|
122
|
+
exports.OpenAIChatModelRolesMap = g;
|
|
123
|
+
exports.OpenAIChatModelTextModalities = W;
|
|
124
|
+
exports.OpenAIChatModelTextModalitiesEnum = Y;
|
|
125
|
+
exports.OpenAIChatModelTextToolModalities = R;
|
|
126
126
|
exports.OpenAIChatModelTextToolModalitiesEnum = x;
|
|
127
|
-
exports.OpenAIChatOSeriesRequest =
|
|
128
|
-
exports.OpenAIChatRequest =
|
|
129
|
-
exports.OpenAIChatRequestAssistantMessage =
|
|
130
|
-
exports.OpenAIChatRequestImageContent =
|
|
131
|
-
exports.OpenAIChatRequestMessage =
|
|
132
|
-
exports.OpenAIChatRequestResponseFormat =
|
|
133
|
-
exports.OpenAIChatRequestSystemMessage =
|
|
134
|
-
exports.OpenAIChatRequestTextContent =
|
|
135
|
-
exports.OpenAIChatRequestTool =
|
|
136
|
-
exports.OpenAIChatRequestToolCallContent =
|
|
137
|
-
exports.OpenAIChatRequestToolChoiceEnum =
|
|
138
|
-
exports.OpenAIChatRequestToolChoiceFunction =
|
|
139
|
-
exports.OpenAIChatRequestToolMessage =
|
|
140
|
-
exports.OpenAIChatRequestUserMessage =
|
|
141
|
-
exports.OpenAICompleteChatResponse =
|
|
127
|
+
exports.OpenAIChatOSeriesRequest = Ht;
|
|
128
|
+
exports.OpenAIChatRequest = Be;
|
|
129
|
+
exports.OpenAIChatRequestAssistantMessage = wn;
|
|
130
|
+
exports.OpenAIChatRequestImageContent = Rn;
|
|
131
|
+
exports.OpenAIChatRequestMessage = vn;
|
|
132
|
+
exports.OpenAIChatRequestResponseFormat = In;
|
|
133
|
+
exports.OpenAIChatRequestSystemMessage = An;
|
|
134
|
+
exports.OpenAIChatRequestTextContent = Ko;
|
|
135
|
+
exports.OpenAIChatRequestTool = bn;
|
|
136
|
+
exports.OpenAIChatRequestToolCallContent = xn;
|
|
137
|
+
exports.OpenAIChatRequestToolChoiceEnum = Pn;
|
|
138
|
+
exports.OpenAIChatRequestToolChoiceFunction = Sn;
|
|
139
|
+
exports.OpenAIChatRequestToolMessage = Gn;
|
|
140
|
+
exports.OpenAIChatRequestUserMessage = En;
|
|
141
|
+
exports.OpenAICompleteChatResponse = $t;
|
|
142
142
|
exports.OpenAIEmbeddingModelConfigs = k;
|
|
143
|
-
exports.OpenAIEmbeddingModelModalities =
|
|
144
|
-
exports.OpenAIEmbeddingModelModalitiesEnum =
|
|
145
|
-
exports.OpenAIEmbeddingRequest =
|
|
146
|
-
exports.OpenAIEmbeddingRequestInput =
|
|
147
|
-
exports.OpenAIGetEmbeddingsResponse =
|
|
148
|
-
exports.OpenAIStreamChatResponse =
|
|
149
|
-
exports.OpenAIToolCallsCompleteChatResponse =
|
|
150
|
-
exports.OpenAIToolCallsStreamChatResponse =
|
|
151
|
-
exports.ProviderLiteral =
|
|
152
|
-
exports.Text_Embedding_3_Large =
|
|
153
|
-
exports.Text_Embedding_3_LargeLiteral =
|
|
154
|
-
exports.Text_Embedding_3_LargeSchema =
|
|
155
|
-
exports.Text_Embedding_3_Large_Options =
|
|
156
|
-
exports.Text_Embedding_3_Small =
|
|
157
|
-
exports.Text_Embedding_3_SmallLiteral =
|
|
158
|
-
exports.Text_Embedding_3_SmallSchema =
|
|
159
|
-
exports.Text_Embedding_3_Small_Options =
|
|
160
|
-
exports.Text_Embedding_Ada002 =
|
|
161
|
-
exports.Text_Embedding_Ada002Literal =
|
|
162
|
-
exports.Text_Embedding_Ada002Schema =
|
|
163
|
-
exports.Text_Embedding_Ada002_Options =
|
|
164
|
-
exports.dimensions =
|
|
165
|
-
exports.encodingFormat =
|
|
166
|
-
exports.frequencyPenalty =
|
|
167
|
-
exports.logProbs =
|
|
168
|
-
exports.maxTokens =
|
|
169
|
-
exports.presencePenalty =
|
|
170
|
-
exports.seed =
|
|
171
|
-
exports.stop =
|
|
172
|
-
exports.temperature =
|
|
173
|
-
exports.toolChoice =
|
|
174
|
-
exports.topLogProbs =
|
|
175
|
-
exports.topP =
|
|
143
|
+
exports.OpenAIEmbeddingModelModalities = Z;
|
|
144
|
+
exports.OpenAIEmbeddingModelModalitiesEnum = ee;
|
|
145
|
+
exports.OpenAIEmbeddingRequest = Xt;
|
|
146
|
+
exports.OpenAIEmbeddingRequestInput = qs;
|
|
147
|
+
exports.OpenAIGetEmbeddingsResponse = Qt;
|
|
148
|
+
exports.OpenAIStreamChatResponse = Nt;
|
|
149
|
+
exports.OpenAIToolCallsCompleteChatResponse = On;
|
|
150
|
+
exports.OpenAIToolCallsStreamChatResponse = Cn;
|
|
151
|
+
exports.ProviderLiteral = Mn;
|
|
152
|
+
exports.Text_Embedding_3_Large = Ge;
|
|
153
|
+
exports.Text_Embedding_3_LargeLiteral = No;
|
|
154
|
+
exports.Text_Embedding_3_LargeSchema = Ho;
|
|
155
|
+
exports.Text_Embedding_3_Large_Options = zt;
|
|
156
|
+
exports.Text_Embedding_3_Small = we;
|
|
157
|
+
exports.Text_Embedding_3_SmallLiteral = Fo;
|
|
158
|
+
exports.Text_Embedding_3_SmallSchema = $o;
|
|
159
|
+
exports.Text_Embedding_3_Small_Options = Lt;
|
|
160
|
+
exports.Text_Embedding_Ada002 = Ee;
|
|
161
|
+
exports.Text_Embedding_Ada002Literal = Do;
|
|
162
|
+
exports.Text_Embedding_Ada002Schema = Uo;
|
|
163
|
+
exports.Text_Embedding_Ada002_Options = kt;
|
|
164
|
+
exports.dimensions = Xe;
|
|
165
|
+
exports.encodingFormat = Qe;
|
|
166
|
+
exports.frequencyPenalty = He;
|
|
167
|
+
exports.logProbs = Je;
|
|
168
|
+
exports.maxTokens = Fe;
|
|
169
|
+
exports.presencePenalty = Ve;
|
|
170
|
+
exports.seed = Ke;
|
|
171
|
+
exports.stop = $e;
|
|
172
|
+
exports.temperature = Ue;
|
|
173
|
+
exports.toolChoice = Ye;
|
|
174
|
+
exports.topLogProbs = We;
|
|
175
|
+
exports.topP = Ne;
|
|
176
176
|
//# sourceMappingURL=index.js.map
|
|
177
177
|
//# sourceMappingURL=index.js.map
|