@adaline/openai 0.11.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.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var qt=Object.defineProperty,kt=Object.defineProperties;var jt=Object.getOwnProp
|
|
|
12
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
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
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:
|
|
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
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
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
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),{})}};
|