@adaline/provider 0.9.0 → 0.10.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 CHANGED
@@ -2170,9 +2170,10 @@ declare const removeUndefinedEntries: <T = unknown>(record: Record<string, T | u
2170
2170
  declare const convertBase64ToUint8Array: (base64String: string) => Uint8Array;
2171
2171
  declare const convertUint8ArrayToBase64: (array: Uint8Array) => string;
2172
2172
  declare const encodedBase64ToString: (base64: string) => string;
2173
+ declare const getMimeTypeFromBase64: (base64: string) => string;
2173
2174
 
2174
2175
  declare const urlWithoutTrailingSlash: (url: string) => string;
2175
2176
 
2176
2177
  declare const isRunningInBrowser: () => boolean;
2177
2178
 
2178
- export { CONFIG, ChatModelSchema, type ChatModelSchemaType, type ChatModelV1, ConfigItemDef, type ConfigItemDefType, ConfigItemEnum, type ConfigItemEnumType, ConfigItemLiterals, EmbeddingModelSchema, type EmbeddingModelSchemaType, type EmbeddingModelV1, Headers, type HeadersType, InvalidConfigError, InvalidEmbeddingRequestsError, InvalidMessagesError, InvalidModelRequestError, InvalidToolsError, ModelError, ModelResponseError, MultiStringConfigItem, MultiStringConfigItemDef, MultiStringConfigItemSchema, type MultiStringConfigItemSchemaType, type MultiStringConfigItemType, MultiStringConfigItemTypeLiteral, ObjectSchemaConfigItem, ObjectSchemaConfigItemDef, ObjectSchemaConfigItemSchema, type ObjectSchemaConfigItemSchemaType, type ObjectSchemaConfigItemType, ObjectSchemaConfigItemTypeLiteral, Params, type ParamsType, ProviderError, type ProviderV1, RangeConfigItem, RangeConfigItemDef, type RangeConfigItemDefType, RangeConfigItemSchema, type RangeConfigItemSchemaType, RangeConfigItemTypeLiteral, SelectBooleanConfigItem, SelectBooleanConfigItemDef, type SelectBooleanConfigItemDefType, SelectBooleanConfigItemSchema, type SelectBooleanConfigItemSchemaType, SelectBooleanConfigItemTypeLiteral, SelectStringConfigItem, SelectStringConfigItemDef, type SelectStringConfigItemDefType, SelectStringConfigItemSchema, type SelectStringConfigItemSchemaType, SelectStringConfigItemTypeLiteral, Url, type UrlType, convertBase64ToUint8Array, convertUint8ArrayToBase64, encodedBase64ToString, getErrorMessage, isRunningInBrowser, removeUndefinedEntries, urlWithoutTrailingSlash };
2179
+ export { CONFIG, ChatModelSchema, type ChatModelSchemaType, type ChatModelV1, ConfigItemDef, type ConfigItemDefType, ConfigItemEnum, type ConfigItemEnumType, ConfigItemLiterals, EmbeddingModelSchema, type EmbeddingModelSchemaType, type EmbeddingModelV1, Headers, type HeadersType, InvalidConfigError, InvalidEmbeddingRequestsError, InvalidMessagesError, InvalidModelRequestError, InvalidToolsError, ModelError, ModelResponseError, MultiStringConfigItem, MultiStringConfigItemDef, MultiStringConfigItemSchema, type MultiStringConfigItemSchemaType, type MultiStringConfigItemType, MultiStringConfigItemTypeLiteral, ObjectSchemaConfigItem, ObjectSchemaConfigItemDef, ObjectSchemaConfigItemSchema, type ObjectSchemaConfigItemSchemaType, type ObjectSchemaConfigItemType, ObjectSchemaConfigItemTypeLiteral, Params, type ParamsType, ProviderError, type ProviderV1, RangeConfigItem, RangeConfigItemDef, type RangeConfigItemDefType, RangeConfigItemSchema, type RangeConfigItemSchemaType, RangeConfigItemTypeLiteral, SelectBooleanConfigItem, SelectBooleanConfigItemDef, type SelectBooleanConfigItemDefType, SelectBooleanConfigItemSchema, type SelectBooleanConfigItemSchemaType, SelectBooleanConfigItemTypeLiteral, SelectStringConfigItem, SelectStringConfigItemDef, type SelectStringConfigItemDefType, SelectStringConfigItemSchema, type SelectStringConfigItemSchemaType, SelectStringConfigItemTypeLiteral, Url, type UrlType, convertBase64ToUint8Array, convertUint8ArrayToBase64, encodedBase64ToString, getErrorMessage, getMimeTypeFromBase64, isRunningInBrowser, removeUndefinedEntries, urlWithoutTrailingSlash };
package/dist/index.d.ts CHANGED
@@ -2170,9 +2170,10 @@ declare const removeUndefinedEntries: <T = unknown>(record: Record<string, T | u
2170
2170
  declare const convertBase64ToUint8Array: (base64String: string) => Uint8Array;
2171
2171
  declare const convertUint8ArrayToBase64: (array: Uint8Array) => string;
2172
2172
  declare const encodedBase64ToString: (base64: string) => string;
2173
+ declare const getMimeTypeFromBase64: (base64: string) => string;
2173
2174
 
2174
2175
  declare const urlWithoutTrailingSlash: (url: string) => string;
2175
2176
 
2176
2177
  declare const isRunningInBrowser: () => boolean;
2177
2178
 
2178
- export { CONFIG, ChatModelSchema, type ChatModelSchemaType, type ChatModelV1, ConfigItemDef, type ConfigItemDefType, ConfigItemEnum, type ConfigItemEnumType, ConfigItemLiterals, EmbeddingModelSchema, type EmbeddingModelSchemaType, type EmbeddingModelV1, Headers, type HeadersType, InvalidConfigError, InvalidEmbeddingRequestsError, InvalidMessagesError, InvalidModelRequestError, InvalidToolsError, ModelError, ModelResponseError, MultiStringConfigItem, MultiStringConfigItemDef, MultiStringConfigItemSchema, type MultiStringConfigItemSchemaType, type MultiStringConfigItemType, MultiStringConfigItemTypeLiteral, ObjectSchemaConfigItem, ObjectSchemaConfigItemDef, ObjectSchemaConfigItemSchema, type ObjectSchemaConfigItemSchemaType, type ObjectSchemaConfigItemType, ObjectSchemaConfigItemTypeLiteral, Params, type ParamsType, ProviderError, type ProviderV1, RangeConfigItem, RangeConfigItemDef, type RangeConfigItemDefType, RangeConfigItemSchema, type RangeConfigItemSchemaType, RangeConfigItemTypeLiteral, SelectBooleanConfigItem, SelectBooleanConfigItemDef, type SelectBooleanConfigItemDefType, SelectBooleanConfigItemSchema, type SelectBooleanConfigItemSchemaType, SelectBooleanConfigItemTypeLiteral, SelectStringConfigItem, SelectStringConfigItemDef, type SelectStringConfigItemDefType, SelectStringConfigItemSchema, type SelectStringConfigItemSchemaType, SelectStringConfigItemTypeLiteral, Url, type UrlType, convertBase64ToUint8Array, convertUint8ArrayToBase64, encodedBase64ToString, getErrorMessage, isRunningInBrowser, removeUndefinedEntries, urlWithoutTrailingSlash };
2179
+ export { CONFIG, ChatModelSchema, type ChatModelSchemaType, type ChatModelV1, ConfigItemDef, type ConfigItemDefType, ConfigItemEnum, type ConfigItemEnumType, ConfigItemLiterals, EmbeddingModelSchema, type EmbeddingModelSchemaType, type EmbeddingModelV1, Headers, type HeadersType, InvalidConfigError, InvalidEmbeddingRequestsError, InvalidMessagesError, InvalidModelRequestError, InvalidToolsError, ModelError, ModelResponseError, MultiStringConfigItem, MultiStringConfigItemDef, MultiStringConfigItemSchema, type MultiStringConfigItemSchemaType, type MultiStringConfigItemType, MultiStringConfigItemTypeLiteral, ObjectSchemaConfigItem, ObjectSchemaConfigItemDef, ObjectSchemaConfigItemSchema, type ObjectSchemaConfigItemSchemaType, type ObjectSchemaConfigItemType, ObjectSchemaConfigItemTypeLiteral, Params, type ParamsType, ProviderError, type ProviderV1, RangeConfigItem, RangeConfigItemDef, type RangeConfigItemDefType, RangeConfigItemSchema, type RangeConfigItemSchemaType, RangeConfigItemTypeLiteral, SelectBooleanConfigItem, SelectBooleanConfigItemDef, type SelectBooleanConfigItemDefType, SelectBooleanConfigItemSchema, type SelectBooleanConfigItemSchemaType, SelectBooleanConfigItemTypeLiteral, SelectStringConfigItem, SelectStringConfigItemDef, type SelectStringConfigItemDefType, SelectStringConfigItemSchema, type SelectStringConfigItemSchemaType, SelectStringConfigItemTypeLiteral, Url, type UrlType, convertBase64ToUint8Array, convertUint8ArrayToBase64, encodedBase64ToString, getErrorMessage, getMimeTypeFromBase64, isRunningInBrowser, removeUndefinedEntries, urlWithoutTrailingSlash };
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  var types = require('@adaline/types');
4
4
  var zod = require('zod');
5
5
 
6
- var J=Object.defineProperty;var R=Object.getOwnPropertySymbols;var Q=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable;var O=(e,n,t)=>n in e?J(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,a=(e,n)=>{for(var t in n||(n={}))Q.call(n,t)&&O(e,t,n[t]);if(R)for(var t of R(n))X.call(n,t)&&O(e,t,n[t]);return e};var j="ProviderError",v=class e extends types.GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},j);this.name=j;this.info=t,this.cause=o;}static isProviderError(t){return t instanceof e}};var z="ModelError",D=class e extends types.GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},z);this.name=z;this.info=t,this.cause=o;}static isModelError(t){return t instanceof e}};var B="ModelResponseError",P=class e extends types.GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},B);this.name=B;this.cause=o,this.info=t;}static isModelResponseError(t){return t instanceof e}};var L="InvalidModelRequestError",U=class e extends types.GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},L);this.name=L;this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(t){return t instanceof e}};var A="InvalidConfigError",Z=class e extends types.GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},A);this.name=A;this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(t){return t instanceof e}};var q="InvalidMessagesError",K=class e extends types.GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},q);this.name=q;this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(t){return t instanceof e}};var G="InvalidToolsError",N=class e extends types.GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},G);this.name=G;this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(t){return t instanceof e}};var F="InvalidEmbeddingRequestsError",H=class e extends types.GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},F);this.name=F;this.info=t,this.cause=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(t){return t instanceof e}};var d="multi-string",E=zod.z.object({type:zod.z.literal(d),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),max:zod.z.number().int().positive()}),se=e=>zod.z.array(zod.z.string()).max(e).default([]).optional(),Ke=e=>({def:E.parse(a({type:d},e)),schema:se(e.max)});var h="range",x=zod.z.object({type:zod.z.literal(h),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),min:zod.z.number().int(),max:zod.z.number().int(),step:zod.z.number().positive(),default:zod.z.number().int()}),ae=(e,n,t,o)=>zod.z.number().min(e).max(n).step(t).default(o).optional(),He=e=>({def:x.parse(a({type:h},e)),schema:ae(e.min,e.max,e.step,e.default)});var S="select-string",w=zod.z.object({type:zod.z.literal(S),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),default:zod.z.string().min(1),choices:zod.z.array(zod.z.string().min(1))}),ce=(e,n)=>zod.z.enum(n).default(e).optional(),Je=e=>({def:w.parse(a({type:S},e)),schema:ce(e.default,e.choices)});var I="object-schema",M=zod.z.object({type:zod.z.literal(I),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),objectSchema:zod.z.any()}),me=e=>e,_e=e=>({def:M.parse(a({type:I},e)),schema:me(e.objectSchema)});var b="select-boolean",k=zod.z.object({type:zod.z.literal(b),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),default:zod.z.boolean().nullable()}),pe=e=>zod.z.boolean().nullable().default(e).optional(),ot=e=>({def:k.parse(a({type:b},e)),schema:pe(e.default)});var fe=[h,d,S,I,b],lt=zod.z.enum(fe),T=zod.z.discriminatedUnion("type",[x,E,w,k,M]);var ht=(e=types.RoleEnum,n=types.ModalityEnum)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(e,zod.z.string().min(1).optional()),modalities:zod.z.array(n).nonempty(),maxInputTokens:zod.z.number().int().positive().min(1),maxOutputTokens:zod.z.number().int().positive().min(1),config:zod.z.object({def:zod.z.record(zod.z.string().min(1),T),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(t=>{var u,g;let o=Object.keys(t.def),s=Object.keys((g=(u=t.schema)==null?void 0:u.shape)!=null?g:{});return o.every(C=>s.includes(C))&&s.every(C=>o.includes(C))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})});var Ct=(e=types.EmbeddingModalityEnum)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),modalities:zod.z.array(e).nonempty(),maxInputTokens:zod.z.number().int().positive().min(1),maxOutputTokens:zod.z.number().int().positive().min(1),config:zod.z.object({def:zod.z.record(zod.z.string().min(1),T),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(n=>{var s,u;let t=Object.keys(n.def),o=Object.keys((u=(s=n.schema)==null?void 0:s.shape)!=null?u:{});return t.every(g=>o.includes(g))&&o.every(g=>t.includes(g))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})});var wt=zod.z.record(zod.z.string());var Rt=zod.z.record(zod.z.union([zod.z.boolean(),zod.z.string(),zod.z.number(),zod.z.object({}),zod.z.array(zod.z.any()),zod.z.null(),zod.z.undefined()]));var vt=zod.z.string().url();var de={type:"range",title:"Temperature",description:"Adjusts the model's creativity level. With a setting of 0, the model strictly picks the most probable next word. For endeavors that benefit from a dash of inventiveness, consider dialing it up to 0.7 or higher, enabling the model to produce text that's unexpectedly fresh."},he={type:"range",title:"Max tokens",description:"Specify the total tokens for generation, where one token approximates four English characters. Setting this to 0 defaults to the model's maximum capacity."},Se=e=>({type:"multi",title:"Stop sequence",description:`Enter up to ${e} sequences that will halt additional text output. The generated text will exclude these sequences.`}),Ie={type:"range",title:"Top P",description:"Selects a subset of likely tokens for generation, restricting choices to the top-P fraction of possibilities, such as the top 10% when P=0.1. This approach can limit the variety of the output. By default, it's set to 1, indicating no restriction. It's advised to adjust this parameter or temperature to modulate output diversity, but not to modify both simultaneously."},be={type:"range",title:"Top K",description:"Select only from the highest K probabilities for each following word, effectively eliminating the less likely 'long tail' options."},Te={type:"range",title:"Frequency penalty",description:"Minimize redundancy. By assigning a penalty to frequently used tokens within the text, the likelihood of repeating identical phrases is reduced. The default setting for this penalty is zero."},Ce={type:"range",title:"Presence penalty",description:"Enhance the introduction of novel subjects by reducing the preference for tokens that have already appeared in the text, thus boosting the chances of exploring fresh topics. The standard setting for this is zero."},Dt={TEMPERATURE:de,MAX_TOKENS:he,STOP:Se,TOP_P:Ie,TOP_K:be,FREQUENCY_PENALTY:Te,PRESENCE_PENALTY:Ce};var Pt=e=>e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e);var Ut=e=>Object.fromEntries(Object.entries(e).filter(([n,t])=>t!=null));var $=()=>typeof window!="undefined"&&typeof window.document!="undefined"&&typeof navigator!="undefined";var Kt=e=>{let n=e.replace(/-/g,"+").replace(/_/g,"/"),t=globalThis.atob(n);return Uint8Array.from(t,o=>o.codePointAt(0))},Gt=e=>{let n="";for(let t=0;t<e.length;t++)n+=String.fromCodePoint(e[t]);return globalThis.btoa(n)},Nt=e=>{if($()){let n=atob(e),t=new Uint8Array(n.length);for(let s=0;s<n.length;s++)t[s]=n.charCodeAt(s);return new TextDecoder("utf-8").decode(t)}else return Buffer.from(e,"base64").toString("utf-8")};var Ht=e=>e==null?void 0:e.replace(/\/$/,"");
6
+ var J=Object.defineProperty;var R=Object.getOwnPropertySymbols;var Q=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable;var O=(e,n,t)=>n in e?J(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,a=(e,n)=>{for(var t in n||(n={}))Q.call(n,t)&&O(e,t,n[t]);if(R)for(var t of R(n))X.call(n,t)&&O(e,t,n[t]);return e};var j="ProviderError",v=class e extends types.GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},j);this.name=j;this.info=t,this.cause=o;}static isProviderError(t){return t instanceof e}};var z="ModelError",D=class e extends types.GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},z);this.name=z;this.info=t,this.cause=o;}static isModelError(t){return t instanceof e}};var B="ModelResponseError",P=class e extends types.GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},B);this.name=B;this.cause=o,this.info=t;}static isModelResponseError(t){return t instanceof e}};var L="InvalidModelRequestError",U=class e extends types.GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},L);this.name=L;this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(t){return t instanceof e}};var A="InvalidConfigError",Z=class e extends types.GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},A);this.name=A;this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(t){return t instanceof e}};var q="InvalidMessagesError",K=class e extends types.GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},q);this.name=q;this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(t){return t instanceof e}};var G="InvalidToolsError",N=class e extends types.GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},G);this.name=G;this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(t){return t instanceof e}};var F="InvalidEmbeddingRequestsError",H=class e extends types.GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},F);this.name=F;this.info=t,this.cause=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(t){return t instanceof e}};var d="multi-string",E=zod.z.object({type:zod.z.literal(d),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),max:zod.z.number().int().positive()}),se=e=>zod.z.array(zod.z.string()).max(e).default([]).optional(),Ke=e=>({def:E.parse(a({type:d},e)),schema:se(e.max)});var h="range",x=zod.z.object({type:zod.z.literal(h),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),min:zod.z.number().int(),max:zod.z.number().int(),step:zod.z.number().positive(),default:zod.z.number().int()}),ae=(e,n,t,o)=>zod.z.number().min(e).max(n).step(t).default(o).optional(),He=e=>({def:x.parse(a({type:h},e)),schema:ae(e.min,e.max,e.step,e.default)});var S="select-string",w=zod.z.object({type:zod.z.literal(S),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),default:zod.z.string().min(1),choices:zod.z.array(zod.z.string().min(1))}),me=(e,n)=>zod.z.enum(n).default(e).optional(),Je=e=>({def:w.parse(a({type:S},e)),schema:me(e.default,e.choices)});var I="object-schema",M=zod.z.object({type:zod.z.literal(I),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),objectSchema:zod.z.any()}),ce=e=>e,_e=e=>({def:M.parse(a({type:I},e)),schema:ce(e.objectSchema)});var b="select-boolean",k=zod.z.object({type:zod.z.literal(b),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),default:zod.z.boolean().nullable()}),pe=e=>zod.z.boolean().nullable().default(e).optional(),ot=e=>({def:k.parse(a({type:b},e)),schema:pe(e.default)});var fe=[h,d,S,I,b],lt=zod.z.enum(fe),T=zod.z.discriminatedUnion("type",[x,E,w,k,M]);var ht=(e=types.RoleEnum,n=types.ModalityEnum)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(e,zod.z.string().min(1).optional()),modalities:zod.z.array(n).nonempty(),maxInputTokens:zod.z.number().int().positive().min(1),maxOutputTokens:zod.z.number().int().positive().min(1),config:zod.z.object({def:zod.z.record(zod.z.string().min(1),T),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(t=>{var u,g;let o=Object.keys(t.def),s=Object.keys((g=(u=t.schema)==null?void 0:u.shape)!=null?g:{});return o.every(C=>s.includes(C))&&s.every(C=>o.includes(C))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})});var Ct=(e=types.EmbeddingModalityEnum)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),modalities:zod.z.array(e).nonempty(),maxInputTokens:zod.z.number().int().positive().min(1),maxOutputTokens:zod.z.number().int().positive().min(1),config:zod.z.object({def:zod.z.record(zod.z.string().min(1),T),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(n=>{var s,u;let t=Object.keys(n.def),o=Object.keys((u=(s=n.schema)==null?void 0:s.shape)!=null?u:{});return t.every(g=>o.includes(g))&&o.every(g=>t.includes(g))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})});var wt=zod.z.record(zod.z.string());var Rt=zod.z.record(zod.z.union([zod.z.boolean(),zod.z.string(),zod.z.number(),zod.z.object({}),zod.z.array(zod.z.any()),zod.z.null(),zod.z.undefined()]));var vt=zod.z.string().url();var de={type:"range",title:"Temperature",description:"Adjusts the model's creativity level. With a setting of 0, the model strictly picks the most probable next word. For endeavors that benefit from a dash of inventiveness, consider dialing it up to 0.7 or higher, enabling the model to produce text that's unexpectedly fresh."},he={type:"range",title:"Max tokens",description:"Specify the total tokens for generation, where one token approximates four English characters. Setting this to 0 defaults to the model's maximum capacity."},Se=e=>({type:"multi",title:"Stop sequence",description:`Enter up to ${e} sequences that will halt additional text output. The generated text will exclude these sequences.`}),Ie={type:"range",title:"Top P",description:"Selects a subset of likely tokens for generation, restricting choices to the top-P fraction of possibilities, such as the top 10% when P=0.1. This approach can limit the variety of the output. By default, it's set to 1, indicating no restriction. It's advised to adjust this parameter or temperature to modulate output diversity, but not to modify both simultaneously."},be={type:"range",title:"Top K",description:"Select only from the highest K probabilities for each following word, effectively eliminating the less likely 'long tail' options."},Te={type:"range",title:"Frequency penalty",description:"Minimize redundancy. By assigning a penalty to frequently used tokens within the text, the likelihood of repeating identical phrases is reduced. The default setting for this penalty is zero."},Ce={type:"range",title:"Presence penalty",description:"Enhance the introduction of novel subjects by reducing the preference for tokens that have already appeared in the text, thus boosting the chances of exploring fresh topics. The standard setting for this is zero."},Dt={TEMPERATURE:de,MAX_TOKENS:he,STOP:Se,TOP_P:Ie,TOP_K:be,FREQUENCY_PENALTY:Te,PRESENCE_PENALTY:Ce};var Pt=e=>e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e);var Ut=e=>Object.fromEntries(Object.entries(e).filter(([n,t])=>t!=null));var $=()=>typeof window!="undefined"&&typeof window.document!="undefined"&&typeof navigator!="undefined";var Kt=e=>{let n=e.replace(/-/g,"+").replace(/_/g,"/"),t=globalThis.atob(n);return Uint8Array.from(t,o=>o.codePointAt(0))},Gt=e=>{let n="";for(let t=0;t<e.length;t++)n+=String.fromCodePoint(e[t]);return globalThis.btoa(n)},Nt=e=>{if($()){let n=atob(e),t=new Uint8Array(n.length);for(let s=0;s<n.length;s++)t[s]=n.charCodeAt(s);return new TextDecoder("utf-8").decode(t)}else return Buffer.from(e,"base64").toString("utf-8")},Ft=e=>e.split(";")[0].split("/")[1];var Yt=e=>e==null?void 0:e.replace(/\/$/,"");
7
7
 
8
8
  exports.CONFIG = Dt;
9
9
  exports.ChatModelSchema = ht;
@@ -25,7 +25,7 @@ exports.MultiStringConfigItemSchema = se;
25
25
  exports.MultiStringConfigItemTypeLiteral = d;
26
26
  exports.ObjectSchemaConfigItem = _e;
27
27
  exports.ObjectSchemaConfigItemDef = M;
28
- exports.ObjectSchemaConfigItemSchema = me;
28
+ exports.ObjectSchemaConfigItemSchema = ce;
29
29
  exports.ObjectSchemaConfigItemTypeLiteral = I;
30
30
  exports.Params = Rt;
31
31
  exports.ProviderError = v;
@@ -39,15 +39,16 @@ exports.SelectBooleanConfigItemSchema = pe;
39
39
  exports.SelectBooleanConfigItemTypeLiteral = b;
40
40
  exports.SelectStringConfigItem = Je;
41
41
  exports.SelectStringConfigItemDef = w;
42
- exports.SelectStringConfigItemSchema = ce;
42
+ exports.SelectStringConfigItemSchema = me;
43
43
  exports.SelectStringConfigItemTypeLiteral = S;
44
44
  exports.Url = vt;
45
45
  exports.convertBase64ToUint8Array = Kt;
46
46
  exports.convertUint8ArrayToBase64 = Gt;
47
47
  exports.encodedBase64ToString = Nt;
48
48
  exports.getErrorMessage = Pt;
49
+ exports.getMimeTypeFromBase64 = Ft;
49
50
  exports.isRunningInBrowser = $;
50
51
  exports.removeUndefinedEntries = Ut;
51
- exports.urlWithoutTrailingSlash = Ht;
52
+ exports.urlWithoutTrailingSlash = Yt;
52
53
  //# sourceMappingURL=index.js.map
53
54
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors/provider.error.ts","../src/errors/model.error.ts","../src/errors/model-response.error.ts","../src/errors/invalid-model-request.error.ts","../src/errors/invalid-config.error.ts","../src/errors/invalid-messages.error.ts","../src/errors/invalid-tools.error.ts","../src/errors/invalid-embedding-requests.error.ts","../src/types/config/multi-string-config-item.ts","../src/types/config/range-config-item.ts","../src/types/config/select-string-config-item.ts","../src/types/config/object-schema-config-item.ts","../src/types/config/select-boolean-config-item.ts","../src/types/config/config-item.ts","../src/model/chat-model/chat-model.schema.v1.ts","../src/model/embedding-model/embedding-model.schema.v1.ts","../src/types/headers.ts","../src/types/params.ts","../src/types/url.ts","../src/utils/common-config.ts","../src/utils/get-error-message.ts","../src/utils/remove-undefined-entries.ts","../src/utils/is-running-in-browser.ts","../src/utils/base64.ts","../src/utils/url.ts"],"names":["ProviderErrorLiteral","ProviderError","_ProviderError","GatewayBaseError","info","cause","error","ModelErrorLiteral","ModelError","_ModelError","ModelResponseErrorLiteral","ModelResponseError","_ModelResponseError","InvalidModelRequestErrorLiteral","InvalidModelRequestError","_InvalidModelRequestError","InvalidConfigErrorLiteral","InvalidConfigError","_InvalidConfigError","InvalidMessagesErrorLiteral","InvalidMessagesError","_InvalidMessagesError","InvalidToolsErrorLiteral","InvalidToolsError","_InvalidToolsError","InvalidEmbeddingRequestsErrorLiteral","InvalidEmbeddingRequestsError","_InvalidEmbeddingRequestsError","MultiStringConfigItemTypeLiteral","MultiStringConfigItemDef","z","MultiStringConfigItemSchema","max","MultiStringConfigItem","data","__spreadValues","RangeConfigItemTypeLiteral","RangeConfigItemDef","RangeConfigItemSchema","min","step","defaultValue","RangeConfigItem","SelectStringConfigItemTypeLiteral","SelectStringConfigItemDef","SelectStringConfigItemSchema","choices","SelectStringConfigItem","ObjectSchemaConfigItemTypeLiteral","ObjectSchemaConfigItemDef","ObjectSchemaConfigItemSchema","schema","ObjectSchemaConfigItem","SelectBooleanConfigItemTypeLiteral","SelectBooleanConfigItemDef","SelectBooleanConfigItemSchema","SelectBooleanConfigItem","ConfigItemLiterals","ConfigItemEnum","ConfigItemDef","ChatModelSchema","Roles","RoleEnum","Modalities","ModalityEnum","config","_a","_b","defKeys","schemaKeys","key","EmbeddingModelSchema","EmbeddingModalityEnum","Headers","Params","Url","TEMPERATURE","MAX_TOKENS","STOP","TOP_P","TOP_K","FREQUENCY_PENALTY","PRESENCE_PENALTY","CONFIG","getErrorMessage","removeUndefinedEntries","record","_","value","isRunningInBrowser","convertBase64ToUint8Array","base64String","base64Url","latin1string","byte","convertUint8ArrayToBase64","array","i","encodedBase64ToString","base64","binaryString","bytes","urlWithoutTrailingSlash","url"],"mappings":";;;;;AAAA,IAAA,CAAA,CAAA,MAAA,CAAA,cAAA,CAAA,IAAA,CAAA,CAAA,MAAA,CAAA,qBAAA,CAAA,IAAA,CAAA,CAAA,MAAA,CAAA,SAAA,CAAA,cAAA,CAAA,CAAA,CAAA,MAAA,CAAA,SAAA,CAAA,oBAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,UAAA,CAAA,CAAA,CAAA,CAAA,YAAA,CAAA,CAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,CAAA,KAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,IAAA,IAAA,CAAA,IAAA,CAAA,GAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,C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,EAAA","file":"index.js","sourcesContent":["import { GatewayBaseError } from \"@adaline/types\";\n\nconst ProviderErrorLiteral = \"ProviderError\" as const;\nexport class ProviderError extends GatewayBaseError {\n readonly name = ProviderErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, ProviderErrorLiteral);\n this.info = info;\n this.cause = cause;\n }\n\n static isProviderError(error: unknown): error is ProviderError {\n return error instanceof ProviderError;\n }\n}","import { GatewayBaseError } from \"@adaline/types\";\n\nconst ModelErrorLiteral = \"ModelError\" as const;\nexport class ModelError extends GatewayBaseError {\n readonly name = ModelErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, ModelErrorLiteral);\n this.info = info;\n this.cause = cause;\n }\n\n static isModelError(error: unknown): error is ModelError {\n return error instanceof ModelError;\n }\n}","import { GatewayBaseError } from \"@adaline/types\";\n\nconst ModelResponseErrorLiteral = \"ModelResponseError\" as const;\nexport class ModelResponseError extends GatewayBaseError {\n readonly name = ModelResponseErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, ModelResponseErrorLiteral);\n this.cause = cause;\n this.info = info;\n }\n\n static isModelResponseError(error: unknown): error is ModelResponseError {\n return error instanceof ModelResponseError;\n }\n}\n","import { GatewayBaseError } from \"@adaline/types\";\n\nconst InvalidModelRequestErrorLiteral = \"InvalidModelRequestError\" as const;\nexport class InvalidModelRequestError extends GatewayBaseError {\n readonly name = InvalidModelRequestErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, InvalidModelRequestErrorLiteral);\n this.cause = cause;\n this.info = info;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static isInvalidModelRequestError(error: unknown): error is InvalidModelRequestError {\n return error instanceof InvalidModelRequestError;\n }\n}\n","import { GatewayBaseError } from \"@adaline/types\";\n\nconst InvalidConfigErrorLiteral = \"InvalidConfigError\" as const;\nexport class InvalidConfigError extends GatewayBaseError {\n readonly name = InvalidConfigErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, InvalidConfigErrorLiteral);\n this.cause = cause;\n this.info = info;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static isInvalidConfigError(error: unknown): error is InvalidConfigError {\n return error instanceof InvalidConfigError;\n }\n}\n","import { GatewayBaseError } from \"@adaline/types\";\n\nconst InvalidMessagesErrorLiteral = \"InvalidMessagesError\" as const;\nexport class InvalidMessagesError extends GatewayBaseError {\n readonly name = InvalidMessagesErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, InvalidMessagesErrorLiteral);\n this.cause = cause;\n this.info = info;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static isInvalidMessagesError(error: unknown): error is InvalidMessagesError {\n return error instanceof InvalidMessagesError;\n }\n}\n","import { GatewayBaseError } from \"@adaline/types\";\n\nconst InvalidToolsErrorLiteral = \"InvalidToolsError\" as const;\nexport class InvalidToolsError extends GatewayBaseError {\n readonly name = InvalidToolsErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, InvalidToolsErrorLiteral);\n this.cause = cause;\n this.info = info;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static isInvalidToolsError(error: unknown): error is InvalidToolsError {\n return error instanceof InvalidToolsError;\n }\n}\n","import { GatewayBaseError } from \"@adaline/types\";\n\nconst InvalidEmbeddingRequestsErrorLiteral = \"InvalidEmbeddingRequestsError\" as const;\nexport class InvalidEmbeddingRequestsError extends GatewayBaseError {\n readonly name = InvalidEmbeddingRequestsErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, InvalidEmbeddingRequestsErrorLiteral);\n this.info = info;\n this.cause = cause;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static isInvalidEmbeddingRequestsError(error: unknown): error is InvalidEmbeddingRequestsError {\n return error instanceof InvalidEmbeddingRequestsError;\n }\n}","import { z } from \"zod\";\n\nconst MultiStringConfigItemTypeLiteral = \"multi-string\" as const;\n\nconst MultiStringConfigItemDef = z.object({\n type: z.literal(MultiStringConfigItemTypeLiteral),\n param: z.string().min(1),\n title: z.string().min(1),\n description: z.string().min(1).max(500),\n max: z.number().int().positive(),\n});\ntype MultiStringConfigItemType = z.infer<typeof MultiStringConfigItemDef>;\n\nconst MultiStringConfigItemSchema = (max: number) => z.array(z.string()).max(max).default([]).optional();\ntype MultiStringConfigItemSchemaType = z.infer<ReturnType<typeof MultiStringConfigItemSchema>>;\n\nconst MultiStringConfigItem = (data: Omit<MultiStringConfigItemType, \"type\">) => {\n return {\n def: MultiStringConfigItemDef.parse({\n type: MultiStringConfigItemTypeLiteral,\n ...data,\n }),\n schema: MultiStringConfigItemSchema(data.max),\n };\n};\n\nexport {\n MultiStringConfigItem,\n MultiStringConfigItemDef,\n MultiStringConfigItemSchema,\n MultiStringConfigItemTypeLiteral,\n type MultiStringConfigItemSchemaType,\n type MultiStringConfigItemType,\n};\n","import { z } from \"zod\";\n\nconst RangeConfigItemTypeLiteral = \"range\" as const;\n\nconst RangeConfigItemDef = z.object({\n type: z.literal(RangeConfigItemTypeLiteral),\n param: z.string().min(1),\n title: z.string().min(1),\n description: z.string().min(1).max(500),\n min: z.number().int(),\n max: z.number().int(),\n step: z.number().positive(),\n default: z.number().int(),\n});\ntype RangeConfigItemDefType = z.infer<typeof RangeConfigItemDef>;\n\nconst RangeConfigItemSchema = (min: number, max: number, step: number, defaultValue: number) =>\n z.number().min(min).max(max).step(step).default(defaultValue).optional();\ntype RangeConfigItemSchemaType = z.infer<ReturnType<typeof RangeConfigItemSchema>>;\n\nconst RangeConfigItem = (data: Omit<RangeConfigItemDefType, \"type\">) => {\n return {\n def: RangeConfigItemDef.parse({\n type: RangeConfigItemTypeLiteral,\n ...data,\n }),\n schema: RangeConfigItemSchema(data.min, data.max, data.step, data.default),\n };\n};\n\nexport {\n RangeConfigItem,\n RangeConfigItemDef,\n RangeConfigItemSchema,\n RangeConfigItemTypeLiteral,\n type RangeConfigItemDefType,\n type RangeConfigItemSchemaType,\n};\n","import { z } from \"zod\";\n\nconst SelectStringConfigItemTypeLiteral = \"select-string\" as const;\n\nconst SelectStringConfigItemDef = z.object({\n type: z.literal(SelectStringConfigItemTypeLiteral),\n param: z.string().min(1),\n title: z.string().min(1),\n description: z.string().min(1).max(500),\n default: z.string().min(1), // TODO: should be optional, not choosing any value from choices is also a valid choice. Eg. Anthropic embeddings input_type, truncation, encoding_format\n choices: z.array(z.string().min(1)),\n});\ntype SelectStringConfigItemDefType = z.infer<typeof SelectStringConfigItemDef>;\n\nconst SelectStringConfigItemSchema = (defaultValue: string, choices: string[]) =>\n z\n .enum(choices as [string, ...string[]])\n .default(defaultValue)\n .optional();\ntype SelectStringConfigItemSchemaType = z.infer<ReturnType<typeof SelectStringConfigItemSchema>>;\n\nconst SelectStringConfigItem = (data: Omit<SelectStringConfigItemDefType, \"type\">) => {\n return {\n def: SelectStringConfigItemDef.parse({\n type: SelectStringConfigItemTypeLiteral,\n ...data,\n }),\n schema: SelectStringConfigItemSchema(data.default, data.choices),\n };\n};\n\nexport {\n SelectStringConfigItem,\n SelectStringConfigItemDef,\n SelectStringConfigItemSchema,\n SelectStringConfigItemTypeLiteral,\n type SelectStringConfigItemDefType,\n type SelectStringConfigItemSchemaType,\n};\n","import { z } from \"zod\";\n\nconst ObjectSchemaConfigItemTypeLiteral = \"object-schema\" as const;\n\nconst ObjectSchemaConfigItemDef = z.object({\n type: z.literal(ObjectSchemaConfigItemTypeLiteral),\n param: z.string().min(1),\n title: z.string().min(1),\n description: z.string().min(1).max(500),\n objectSchema: z.any(),\n});\ntype ObjectSchemaConfigItemType = z.infer<typeof ObjectSchemaConfigItemDef>;\n\nconst ObjectSchemaConfigItemSchema = <S extends z.ZodRawShape>(schema: z.ZodObject<S>) => schema;\ntype ObjectSchemaConfigItemSchemaType<S extends z.ZodRawShape = z.ZodRawShape> = z.infer<ReturnType<typeof ObjectSchemaConfigItemSchema<S>>>;\n\nconst ObjectSchemaConfigItem = (data: Omit<ObjectSchemaConfigItemType, \"type\">) => {\n return {\n def: ObjectSchemaConfigItemDef.parse({\n type: ObjectSchemaConfigItemTypeLiteral,\n ...data,\n }),\n schema: ObjectSchemaConfigItemSchema(data.objectSchema),\n };\n};\n\nexport {\n ObjectSchemaConfigItem,\n ObjectSchemaConfigItemDef,\n ObjectSchemaConfigItemSchema,\n ObjectSchemaConfigItemTypeLiteral,\n type ObjectSchemaConfigItemType,\n type ObjectSchemaConfigItemSchemaType,\n};","import { z } from \"zod\";\n\nconst SelectBooleanConfigItemTypeLiteral = \"select-boolean\" as const;\n\nconst SelectBooleanConfigItemDef = z.object({\n type: z.literal(SelectBooleanConfigItemTypeLiteral),\n param: z.string().min(1),\n title: z.string().min(1),\n description: z.string().min(1).max(500),\n default: z.boolean().nullable(),\n});\ntype SelectBooleanConfigItemDefType = z.infer<typeof SelectBooleanConfigItemDef>;\n\nconst SelectBooleanConfigItemSchema = (defaultValue: boolean | null) =>\n z\n .boolean()\n .nullable()\n .default(defaultValue) \n .optional();\ntype SelectBooleanConfigItemSchemaType = z.infer<ReturnType<typeof SelectBooleanConfigItemSchema>>;\n\nconst SelectBooleanConfigItem = (data: Omit<SelectBooleanConfigItemDefType, \"type\">) => {\n return {\n def: SelectBooleanConfigItemDef.parse({\n type: SelectBooleanConfigItemTypeLiteral,\n ...data,\n }),\n schema: SelectBooleanConfigItemSchema(data.default),\n };\n};\n\nexport {\n SelectBooleanConfigItem,\n SelectBooleanConfigItemDef,\n SelectBooleanConfigItemSchema,\n SelectBooleanConfigItemTypeLiteral,\n type SelectBooleanConfigItemDefType,\n type SelectBooleanConfigItemSchemaType,\n};\n","import { z } from \"zod\";\n\nimport { MultiStringConfigItemDef, MultiStringConfigItemTypeLiteral } from \"./multi-string-config-item\";\nimport { RangeConfigItemDef, RangeConfigItemTypeLiteral } from \"./range-config-item\";\nimport { SelectStringConfigItemDef, SelectStringConfigItemTypeLiteral } from \"./select-string-config-item\";\nimport { ObjectSchemaConfigItemDef, ObjectSchemaConfigItemTypeLiteral } from \"./object-schema-config-item\";\nimport { SelectBooleanConfigItemDef, SelectBooleanConfigItemTypeLiteral } from \"./select-boolean-config-item\";\n\nconst ConfigItemLiterals = [\n RangeConfigItemTypeLiteral, \n MultiStringConfigItemTypeLiteral, \n SelectStringConfigItemTypeLiteral,\n ObjectSchemaConfigItemTypeLiteral,\n SelectBooleanConfigItemTypeLiteral,\n] as const;\nconst ConfigItemEnum = z.enum(ConfigItemLiterals);\ntype ConfigItemEnumType = z.infer<typeof ConfigItemEnum>;\n\nconst ConfigItemDef = z.discriminatedUnion(\"type\", [\n RangeConfigItemDef, \n MultiStringConfigItemDef, \n SelectStringConfigItemDef,\n SelectBooleanConfigItemDef,\n ObjectSchemaConfigItemDef,\n]);\ntype ConfigItemDefType = z.infer<typeof ConfigItemDef>;\n\nexport { ConfigItemDef, ConfigItemEnum, ConfigItemLiterals, type ConfigItemDefType, type ConfigItemEnumType };\n","import { z } from \"zod\";\n\nimport { ModalityEnum, RoleEnum } from \"@adaline/types\";\n\nimport { ConfigItemDef } from \"../../types/config\";\n\nconst ChatModelSchema = <\n R extends z.ZodEnum<[string, ...string[]]> = typeof RoleEnum,\n M extends z.ZodEnum<[string, ...string[]]> = typeof ModalityEnum\n>(\n Roles: R = RoleEnum as unknown as R, \n Modalities: M = ModalityEnum as unknown as M\n) =>\n z.object({\n name: z.string().min(1),\n description: z.string().min(1),\n roles: z.record(Roles, z.string().min(1).optional()),\n modalities: z.array(Modalities).nonempty(),\n maxInputTokens: z.number().int().positive().min(1),\n maxOutputTokens: z.number().int().positive().min(1),\n config: z\n .object({\n def: z.record(z.string().min(1), ConfigItemDef),\n schema: z.instanceof(z.ZodObject),\n })\n .refine(\n (config) => {\n const defKeys = Object.keys(config.def);\n const schemaKeys = Object.keys(config.schema?.shape ?? {});\n return defKeys.every((key) => schemaKeys.includes(key)) && schemaKeys.every((key) => defKeys.includes(key));\n },\n {\n message: \"Keys in 'config.def' must exactly match keys in 'config.schema'\",\n }\n ),\n });\ntype ChatModelSchemaType<\n R extends z.ZodEnum<[string, ...string[]]> = typeof RoleEnum,\n M extends z.ZodEnum<[string, ...string[]]> = typeof ModalityEnum\n> = z.infer<ReturnType<typeof ChatModelSchema<R, M>>>;\n\nexport { \n ChatModelSchema, \n type ChatModelSchemaType \n};\n","import { z } from \"zod\";\n\nimport { EmbeddingModalityEnum } from \"@adaline/types\";\n\nimport { ConfigItemDef } from \"../../types/config\";\n\n// TODO: add embedding model properties (dimensions, etc)\nconst EmbeddingModelSchema = <\n M extends z.ZodEnum<[string, ...string[]]> = typeof EmbeddingModalityEnum,\n>(\n Modalities: M = EmbeddingModalityEnum as unknown as M\n) => z.object({\n name: z.string().min(1),\n description: z.string().min(1),\n modalities: z.array(Modalities).nonempty(),\n maxInputTokens: z.number().int().positive().min(1), // TODO: rename property\n maxOutputTokens: z.number().int().positive().min(1), // TODO: rename property\n config: z\n .object({\n def: z.record(z.string().min(1), ConfigItemDef),\n schema: z.instanceof(z.ZodObject),\n })\n .refine(\n (config) => {\n const defKeys = Object.keys(config.def);\n const schemaKeys = Object.keys(config.schema?.shape ?? {});\n return defKeys.every((key) => schemaKeys.includes(key)) && schemaKeys.every((key) => defKeys.includes(key));\n },\n {\n message: \"Keys in 'config.def' must exactly match keys in 'config.schema'\",\n }\n ),\n});\ntype EmbeddingModelSchemaType<\n M extends z.ZodEnum<[string, ...string[]]> = typeof EmbeddingModalityEnum,\n> = z.infer<ReturnType<typeof EmbeddingModelSchema<M>>>;\n\nexport { \n EmbeddingModelSchema, \n type EmbeddingModelSchemaType \n};\n","import { z } from \"zod\";\n\nconst Headers = z.record(z.string());\ntype HeadersType = z.infer<typeof Headers>;\n\nexport { Headers, type HeadersType };\n","import { z } from \"zod\";\n\nconst Params = z.record(z.union([\n z.boolean(),\n z.string(), \n z.number(), \n z.object({}),\n z.array(z.any()), // TODO: any or undefined?\n z.null(), \n z.undefined(), \n]));\ntype ParamsType = z.infer<typeof Params>;\n\nexport { Params, type ParamsType };\n","import { z } from \"zod\";\n\nconst Url = z.string().url();\ntype UrlType = z.infer<typeof Url>;\n\nexport { Url, type UrlType };\n","// TODO: add a schema for common config items\nconst TEMPERATURE = {\n type: \"range\",\n title: \"Temperature\",\n description:\n \"Adjusts the model's creativity level. With a setting of 0, the model strictly picks the most probable next word. For endeavors that benefit from a dash of inventiveness, consider dialing it up to 0.7 or higher, enabling the model to produce text that's unexpectedly fresh.\",\n} as const;\n\nconst MAX_TOKENS = {\n type: \"range\",\n title: \"Max tokens\",\n description:\n \"Specify the total tokens for generation, where one token approximates four English characters. Setting this to 0 defaults to the model's maximum capacity.\",\n} as const;\n\nconst STOP = (max: number) =>\n ({\n type: \"multi\",\n title: \"Stop sequence\",\n description: `Enter up to ${max} sequences that will halt additional text output. The generated text will exclude these sequences.`,\n }) as const;\n\nconst TOP_P = {\n type: \"range\",\n title: \"Top P\",\n description:\n \"Selects a subset of likely tokens for generation, restricting choices to the top-P fraction of possibilities, such as the top 10% when P=0.1. This approach can limit the variety of the output. By default, it's set to 1, indicating no restriction. It's advised to adjust this parameter or temperature to modulate output diversity, but not to modify both simultaneously.\",\n} as const;\n\nconst TOP_K = {\n type: \"range\",\n title: \"Top K\",\n description:\n \"Select only from the highest K probabilities for each following word, effectively eliminating the less likely 'long tail' options.\",\n} as const;\n\nconst FREQUENCY_PENALTY = {\n type: \"range\",\n title: \"Frequency penalty\",\n description:\n \"Minimize redundancy. By assigning a penalty to frequently used tokens within the text, the likelihood of repeating identical phrases is reduced. The default setting for this penalty is zero.\",\n} as const;\n\nconst PRESENCE_PENALTY = {\n type: \"range\",\n title: \"Presence penalty\",\n description:\n \"Enhance the introduction of novel subjects by reducing the preference for tokens that have already appeared in the text, thus boosting the chances of exploring fresh topics. The standard setting for this is zero.\",\n} as const;\n\n\n\nconst CONFIG = {\n TEMPERATURE,\n MAX_TOKENS,\n STOP,\n TOP_P,\n TOP_K,\n FREQUENCY_PENALTY,\n PRESENCE_PENALTY,\n};\n\nexport { CONFIG };\n","const getErrorMessage = (error: unknown | undefined): string => {\n if (error == null) return \"unknown error\";\n if (typeof error === \"string\") return error;\n if (error instanceof Error) return error.message;\n return JSON.stringify(error);\n};\n\nexport { getErrorMessage };\n","const removeUndefinedEntries = <T = unknown>(record: Record<string, T | undefined>): Record<string, T> => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n return Object.fromEntries(Object.entries(record).filter(([_, value]) => value != null)) as Record<string, T>;\n};\n\nexport { removeUndefinedEntries };\n","const isRunningInBrowser = () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return typeof window !== \"undefined\" && typeof window.document !== \"undefined\" && typeof navigator !== \"undefined\";\n};\n\nexport { isRunningInBrowser };\n","import { isRunningInBrowser } from \"./is-running-in-browser\";\n\nconst convertBase64ToUint8Array = (base64String: string): Uint8Array => {\n const base64Url = base64String.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const latin1string = globalThis.atob(base64Url);\n return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0)!);\n};\n\nconst convertUint8ArrayToBase64 = (array: Uint8Array): string => {\n let latin1string = \"\";\n\n // Note: regular for loop to support older JavaScript versions that\n // do not support for..of on Uint8Array\n for (let i = 0; i < array.length; i++) {\n latin1string += String.fromCodePoint(array[i]);\n }\n\n return globalThis.btoa(latin1string);\n};\n\nconst encodedBase64ToString = (base64: string): string => {\n if (isRunningInBrowser()) {\n const binaryString = atob(base64);\n const bytes = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) { bytes[i] = binaryString.charCodeAt(i); }\n const decoder = new TextDecoder(\"utf-8\");\n return decoder.decode(bytes);\n } else {\n return Buffer.from(base64, \"base64\").toString(\"utf-8\");\n }\n}\n\nexport { convertBase64ToUint8Array, convertUint8ArrayToBase64, encodedBase64ToString };\n","const urlWithoutTrailingSlash = (url: string): string => {\n return url?.replace(/\\/$/, \"\");\n};\n\nexport { urlWithoutTrailingSlash };\n"]}
1
+ {"version":3,"sources":["../src/errors/provider.error.ts","../src/errors/model.error.ts","../src/errors/model-response.error.ts","../src/errors/invalid-model-request.error.ts","../src/errors/invalid-config.error.ts","../src/errors/invalid-messages.error.ts","../src/errors/invalid-tools.error.ts","../src/errors/invalid-embedding-requests.error.ts","../src/types/config/multi-string-config-item.ts","../src/types/config/range-config-item.ts","../src/types/config/select-string-config-item.ts","../src/types/config/object-schema-config-item.ts","../src/types/config/select-boolean-config-item.ts","../src/types/config/config-item.ts","../src/model/chat-model/chat-model.schema.v1.ts","../src/model/embedding-model/embedding-model.schema.v1.ts","../src/types/headers.ts","../src/types/params.ts","../src/types/url.ts","../src/utils/common-config.ts","../src/utils/get-error-message.ts","../src/utils/remove-undefined-entries.ts","../src/utils/is-running-in-browser.ts","../src/utils/base64.ts","../src/utils/url.ts"],"names":["ProviderErrorLiteral","ProviderError","_ProviderError","GatewayBaseError","info","cause","error","ModelErrorLiteral","ModelError","_ModelError","ModelResponseErrorLiteral","ModelResponseError","_ModelResponseError","InvalidModelRequestErrorLiteral","InvalidModelRequestError","_InvalidModelRequestError","InvalidConfigErrorLiteral","InvalidConfigError","_InvalidConfigError","InvalidMessagesErrorLiteral","InvalidMessagesError","_InvalidMessagesError","InvalidToolsErrorLiteral","InvalidToolsError","_InvalidToolsError","InvalidEmbeddingRequestsErrorLiteral","InvalidEmbeddingRequestsError","_InvalidEmbeddingRequestsError","MultiStringConfigItemTypeLiteral","MultiStringConfigItemDef","z","MultiStringConfigItemSchema","max","MultiStringConfigItem","data","__spreadValues","RangeConfigItemTypeLiteral","RangeConfigItemDef","RangeConfigItemSchema","min","step","defaultValue","RangeConfigItem","SelectStringConfigItemTypeLiteral","SelectStringConfigItemDef","SelectStringConfigItemSchema","choices","SelectStringConfigItem","ObjectSchemaConfigItemTypeLiteral","ObjectSchemaConfigItemDef","ObjectSchemaConfigItemSchema","schema","ObjectSchemaConfigItem","SelectBooleanConfigItemTypeLiteral","SelectBooleanConfigItemDef","SelectBooleanConfigItemSchema","SelectBooleanConfigItem","ConfigItemLiterals","ConfigItemEnum","ConfigItemDef","ChatModelSchema","Roles","RoleEnum","Modalities","ModalityEnum","config","_a","_b","defKeys","schemaKeys","key","EmbeddingModelSchema","EmbeddingModalityEnum","Headers","Params","Url","TEMPERATURE","MAX_TOKENS","STOP","TOP_P","TOP_K","FREQUENCY_PENALTY","PRESENCE_PENALTY","CONFIG","getErrorMessage","removeUndefinedEntries","record","_","value","isRunningInBrowser","convertBase64ToUint8Array","base64String","base64Url","latin1string","byte","convertUint8ArrayToBase64","array","i","encodedBase64ToString","base64","binaryString","bytes","getMimeTypeFromBase64","urlWithoutTrailingSlash","url"],"mappings":";;;;;AAAA,IAAA,CAAA,CAAA,MAAA,CAAA,cAAA,CAAA,IAAA,CAAA,CAAA,MAAA,CAAA,qBAAA,CAAA,IAAA,CAAA,CAAA,MAAA,CAAA,SAAA,CAAA,cAAA,CAAA,CAAA,CAAA,MAAA,CAAA,SAAA,CAAA,oBAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,UAAA,CAAA,CAAA,CAAA,CAAA,YAAA,CAAA,CAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,CAAA,KAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,IAAA,IAAA,CAAA,I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ACNA,CAAO,CAAA,KAAA,CAAM,GAAG,CAAE,CAAA,CAAC,EACV,KAAM,CAAA,GAAG,EAAE,CAAC,MClCxCI,EAA2BC,CAAAA,CAAAA,EACxBA,GAAA,IAAAA,CAAAA,KAAAA,CAAAA,CAAAA,CAAAA,CAAK,QAAQ,KAAO,CAAA,EAAA","file":"index.js","sourcesContent":["import { GatewayBaseError } from \"@adaline/types\";\n\nconst ProviderErrorLiteral = \"ProviderError\" as const;\nexport class ProviderError extends GatewayBaseError {\n readonly name = ProviderErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, ProviderErrorLiteral);\n this.info = info;\n this.cause = cause;\n }\n\n static isProviderError(error: unknown): error is ProviderError {\n return error instanceof ProviderError;\n }\n}","import { GatewayBaseError } from \"@adaline/types\";\n\nconst ModelErrorLiteral = \"ModelError\" as const;\nexport class ModelError extends GatewayBaseError {\n readonly name = ModelErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, ModelErrorLiteral);\n this.info = info;\n this.cause = cause;\n }\n\n static isModelError(error: unknown): error is ModelError {\n return error instanceof ModelError;\n }\n}","import { GatewayBaseError } from \"@adaline/types\";\n\nconst ModelResponseErrorLiteral = \"ModelResponseError\" as const;\nexport class ModelResponseError extends GatewayBaseError {\n readonly name = ModelResponseErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, ModelResponseErrorLiteral);\n this.cause = cause;\n this.info = info;\n }\n\n static isModelResponseError(error: unknown): error is ModelResponseError {\n return error instanceof ModelResponseError;\n }\n}\n","import { GatewayBaseError } from \"@adaline/types\";\n\nconst InvalidModelRequestErrorLiteral = \"InvalidModelRequestError\" as const;\nexport class InvalidModelRequestError extends GatewayBaseError {\n readonly name = InvalidModelRequestErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, InvalidModelRequestErrorLiteral);\n this.cause = cause;\n this.info = info;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static isInvalidModelRequestError(error: unknown): error is InvalidModelRequestError {\n return error instanceof InvalidModelRequestError;\n }\n}\n","import { GatewayBaseError } from \"@adaline/types\";\n\nconst InvalidConfigErrorLiteral = \"InvalidConfigError\" as const;\nexport class InvalidConfigError extends GatewayBaseError {\n readonly name = InvalidConfigErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, InvalidConfigErrorLiteral);\n this.cause = cause;\n this.info = info;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static isInvalidConfigError(error: unknown): error is InvalidConfigError {\n return error instanceof InvalidConfigError;\n }\n}\n","import { GatewayBaseError } from \"@adaline/types\";\n\nconst InvalidMessagesErrorLiteral = \"InvalidMessagesError\" as const;\nexport class InvalidMessagesError extends GatewayBaseError {\n readonly name = InvalidMessagesErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, InvalidMessagesErrorLiteral);\n this.cause = cause;\n this.info = info;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static isInvalidMessagesError(error: unknown): error is InvalidMessagesError {\n return error instanceof InvalidMessagesError;\n }\n}\n","import { GatewayBaseError } from \"@adaline/types\";\n\nconst InvalidToolsErrorLiteral = \"InvalidToolsError\" as const;\nexport class InvalidToolsError extends GatewayBaseError {\n readonly name = InvalidToolsErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, InvalidToolsErrorLiteral);\n this.cause = cause;\n this.info = info;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static isInvalidToolsError(error: unknown): error is InvalidToolsError {\n return error instanceof InvalidToolsError;\n }\n}\n","import { GatewayBaseError } from \"@adaline/types\";\n\nconst InvalidEmbeddingRequestsErrorLiteral = \"InvalidEmbeddingRequestsError\" as const;\nexport class InvalidEmbeddingRequestsError extends GatewayBaseError {\n readonly name = InvalidEmbeddingRequestsErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, InvalidEmbeddingRequestsErrorLiteral);\n this.info = info;\n this.cause = cause;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static isInvalidEmbeddingRequestsError(error: unknown): error is InvalidEmbeddingRequestsError {\n return error instanceof InvalidEmbeddingRequestsError;\n }\n}","import { z } from \"zod\";\n\nconst MultiStringConfigItemTypeLiteral = \"multi-string\" as const;\n\nconst MultiStringConfigItemDef = z.object({\n type: z.literal(MultiStringConfigItemTypeLiteral),\n param: z.string().min(1),\n title: z.string().min(1),\n description: z.string().min(1).max(500),\n max: z.number().int().positive(),\n});\ntype MultiStringConfigItemType = z.infer<typeof MultiStringConfigItemDef>;\n\nconst MultiStringConfigItemSchema = (max: number) => z.array(z.string()).max(max).default([]).optional();\ntype MultiStringConfigItemSchemaType = z.infer<ReturnType<typeof MultiStringConfigItemSchema>>;\n\nconst MultiStringConfigItem = (data: Omit<MultiStringConfigItemType, \"type\">) => {\n return {\n def: MultiStringConfigItemDef.parse({\n type: MultiStringConfigItemTypeLiteral,\n ...data,\n }),\n schema: MultiStringConfigItemSchema(data.max),\n };\n};\n\nexport {\n MultiStringConfigItem,\n MultiStringConfigItemDef,\n MultiStringConfigItemSchema,\n MultiStringConfigItemTypeLiteral,\n type MultiStringConfigItemSchemaType,\n type MultiStringConfigItemType,\n};\n","import { z } from \"zod\";\n\nconst RangeConfigItemTypeLiteral = \"range\" as const;\n\nconst RangeConfigItemDef = z.object({\n type: z.literal(RangeConfigItemTypeLiteral),\n param: z.string().min(1),\n title: z.string().min(1),\n description: z.string().min(1).max(500),\n min: z.number().int(),\n max: z.number().int(),\n step: z.number().positive(),\n default: z.number().int(),\n});\ntype RangeConfigItemDefType = z.infer<typeof RangeConfigItemDef>;\n\nconst RangeConfigItemSchema = (min: number, max: number, step: number, defaultValue: number) =>\n z.number().min(min).max(max).step(step).default(defaultValue).optional();\ntype RangeConfigItemSchemaType = z.infer<ReturnType<typeof RangeConfigItemSchema>>;\n\nconst RangeConfigItem = (data: Omit<RangeConfigItemDefType, \"type\">) => {\n return {\n def: RangeConfigItemDef.parse({\n type: RangeConfigItemTypeLiteral,\n ...data,\n }),\n schema: RangeConfigItemSchema(data.min, data.max, data.step, data.default),\n };\n};\n\nexport {\n RangeConfigItem,\n RangeConfigItemDef,\n RangeConfigItemSchema,\n RangeConfigItemTypeLiteral,\n type RangeConfigItemDefType,\n type RangeConfigItemSchemaType,\n};\n","import { z } from \"zod\";\n\nconst SelectStringConfigItemTypeLiteral = \"select-string\" as const;\n\nconst SelectStringConfigItemDef = z.object({\n type: z.literal(SelectStringConfigItemTypeLiteral),\n param: z.string().min(1),\n title: z.string().min(1),\n description: z.string().min(1).max(500),\n default: z.string().min(1), // TODO: should be optional, not choosing any value from choices is also a valid choice. Eg. Anthropic embeddings input_type, truncation, encoding_format\n choices: z.array(z.string().min(1)),\n});\ntype SelectStringConfigItemDefType = z.infer<typeof SelectStringConfigItemDef>;\n\nconst SelectStringConfigItemSchema = (defaultValue: string, choices: string[]) =>\n z\n .enum(choices as [string, ...string[]])\n .default(defaultValue)\n .optional();\ntype SelectStringConfigItemSchemaType = z.infer<ReturnType<typeof SelectStringConfigItemSchema>>;\n\nconst SelectStringConfigItem = (data: Omit<SelectStringConfigItemDefType, \"type\">) => {\n return {\n def: SelectStringConfigItemDef.parse({\n type: SelectStringConfigItemTypeLiteral,\n ...data,\n }),\n schema: SelectStringConfigItemSchema(data.default, data.choices),\n };\n};\n\nexport {\n SelectStringConfigItem,\n SelectStringConfigItemDef,\n SelectStringConfigItemSchema,\n SelectStringConfigItemTypeLiteral,\n type SelectStringConfigItemDefType,\n type SelectStringConfigItemSchemaType,\n};\n","import { z } from \"zod\";\n\nconst ObjectSchemaConfigItemTypeLiteral = \"object-schema\" as const;\n\nconst ObjectSchemaConfigItemDef = z.object({\n type: z.literal(ObjectSchemaConfigItemTypeLiteral),\n param: z.string().min(1),\n title: z.string().min(1),\n description: z.string().min(1).max(500),\n objectSchema: z.any(),\n});\ntype ObjectSchemaConfigItemType = z.infer<typeof ObjectSchemaConfigItemDef>;\n\nconst ObjectSchemaConfigItemSchema = <S extends z.ZodRawShape>(schema: z.ZodObject<S>) => schema;\ntype ObjectSchemaConfigItemSchemaType<S extends z.ZodRawShape = z.ZodRawShape> = z.infer<ReturnType<typeof ObjectSchemaConfigItemSchema<S>>>;\n\nconst ObjectSchemaConfigItem = (data: Omit<ObjectSchemaConfigItemType, \"type\">) => {\n return {\n def: ObjectSchemaConfigItemDef.parse({\n type: ObjectSchemaConfigItemTypeLiteral,\n ...data,\n }),\n schema: ObjectSchemaConfigItemSchema(data.objectSchema),\n };\n};\n\nexport {\n ObjectSchemaConfigItem,\n ObjectSchemaConfigItemDef,\n ObjectSchemaConfigItemSchema,\n ObjectSchemaConfigItemTypeLiteral,\n type ObjectSchemaConfigItemType,\n type ObjectSchemaConfigItemSchemaType,\n};","import { z } from \"zod\";\n\nconst SelectBooleanConfigItemTypeLiteral = \"select-boolean\" as const;\n\nconst SelectBooleanConfigItemDef = z.object({\n type: z.literal(SelectBooleanConfigItemTypeLiteral),\n param: z.string().min(1),\n title: z.string().min(1),\n description: z.string().min(1).max(500),\n default: z.boolean().nullable(),\n});\ntype SelectBooleanConfigItemDefType = z.infer<typeof SelectBooleanConfigItemDef>;\n\nconst SelectBooleanConfigItemSchema = (defaultValue: boolean | null) =>\n z\n .boolean()\n .nullable()\n .default(defaultValue) \n .optional();\ntype SelectBooleanConfigItemSchemaType = z.infer<ReturnType<typeof SelectBooleanConfigItemSchema>>;\n\nconst SelectBooleanConfigItem = (data: Omit<SelectBooleanConfigItemDefType, \"type\">) => {\n return {\n def: SelectBooleanConfigItemDef.parse({\n type: SelectBooleanConfigItemTypeLiteral,\n ...data,\n }),\n schema: SelectBooleanConfigItemSchema(data.default),\n };\n};\n\nexport {\n SelectBooleanConfigItem,\n SelectBooleanConfigItemDef,\n SelectBooleanConfigItemSchema,\n SelectBooleanConfigItemTypeLiteral,\n type SelectBooleanConfigItemDefType,\n type SelectBooleanConfigItemSchemaType,\n};\n","import { z } from \"zod\";\n\nimport { MultiStringConfigItemDef, MultiStringConfigItemTypeLiteral } from \"./multi-string-config-item\";\nimport { RangeConfigItemDef, RangeConfigItemTypeLiteral } from \"./range-config-item\";\nimport { SelectStringConfigItemDef, SelectStringConfigItemTypeLiteral } from \"./select-string-config-item\";\nimport { ObjectSchemaConfigItemDef, ObjectSchemaConfigItemTypeLiteral } from \"./object-schema-config-item\";\nimport { SelectBooleanConfigItemDef, SelectBooleanConfigItemTypeLiteral } from \"./select-boolean-config-item\";\n\nconst ConfigItemLiterals = [\n RangeConfigItemTypeLiteral, \n MultiStringConfigItemTypeLiteral, \n SelectStringConfigItemTypeLiteral,\n ObjectSchemaConfigItemTypeLiteral,\n SelectBooleanConfigItemTypeLiteral,\n] as const;\nconst ConfigItemEnum = z.enum(ConfigItemLiterals);\ntype ConfigItemEnumType = z.infer<typeof ConfigItemEnum>;\n\nconst ConfigItemDef = z.discriminatedUnion(\"type\", [\n RangeConfigItemDef, \n MultiStringConfigItemDef, \n SelectStringConfigItemDef,\n SelectBooleanConfigItemDef,\n ObjectSchemaConfigItemDef,\n]);\ntype ConfigItemDefType = z.infer<typeof ConfigItemDef>;\n\nexport { ConfigItemDef, ConfigItemEnum, ConfigItemLiterals, type ConfigItemDefType, type ConfigItemEnumType };\n","import { z } from \"zod\";\n\nimport { ModalityEnum, RoleEnum } from \"@adaline/types\";\n\nimport { ConfigItemDef } from \"../../types/config\";\n\nconst ChatModelSchema = <\n R extends z.ZodEnum<[string, ...string[]]> = typeof RoleEnum,\n M extends z.ZodEnum<[string, ...string[]]> = typeof ModalityEnum\n>(\n Roles: R = RoleEnum as unknown as R, \n Modalities: M = ModalityEnum as unknown as M\n) =>\n z.object({\n name: z.string().min(1),\n description: z.string().min(1),\n roles: z.record(Roles, z.string().min(1).optional()),\n modalities: z.array(Modalities).nonempty(),\n maxInputTokens: z.number().int().positive().min(1),\n maxOutputTokens: z.number().int().positive().min(1),\n config: z\n .object({\n def: z.record(z.string().min(1), ConfigItemDef),\n schema: z.instanceof(z.ZodObject),\n })\n .refine(\n (config) => {\n const defKeys = Object.keys(config.def);\n const schemaKeys = Object.keys(config.schema?.shape ?? {});\n return defKeys.every((key) => schemaKeys.includes(key)) && schemaKeys.every((key) => defKeys.includes(key));\n },\n {\n message: \"Keys in 'config.def' must exactly match keys in 'config.schema'\",\n }\n ),\n });\ntype ChatModelSchemaType<\n R extends z.ZodEnum<[string, ...string[]]> = typeof RoleEnum,\n M extends z.ZodEnum<[string, ...string[]]> = typeof ModalityEnum\n> = z.infer<ReturnType<typeof ChatModelSchema<R, M>>>;\n\nexport { \n ChatModelSchema, \n type ChatModelSchemaType \n};\n","import { z } from \"zod\";\n\nimport { EmbeddingModalityEnum } from \"@adaline/types\";\n\nimport { ConfigItemDef } from \"../../types/config\";\n\n// TODO: add embedding model properties (dimensions, etc)\nconst EmbeddingModelSchema = <\n M extends z.ZodEnum<[string, ...string[]]> = typeof EmbeddingModalityEnum,\n>(\n Modalities: M = EmbeddingModalityEnum as unknown as M\n) => z.object({\n name: z.string().min(1),\n description: z.string().min(1),\n modalities: z.array(Modalities).nonempty(),\n maxInputTokens: z.number().int().positive().min(1), // TODO: rename property\n maxOutputTokens: z.number().int().positive().min(1), // TODO: rename property\n config: z\n .object({\n def: z.record(z.string().min(1), ConfigItemDef),\n schema: z.instanceof(z.ZodObject),\n })\n .refine(\n (config) => {\n const defKeys = Object.keys(config.def);\n const schemaKeys = Object.keys(config.schema?.shape ?? {});\n return defKeys.every((key) => schemaKeys.includes(key)) && schemaKeys.every((key) => defKeys.includes(key));\n },\n {\n message: \"Keys in 'config.def' must exactly match keys in 'config.schema'\",\n }\n ),\n});\ntype EmbeddingModelSchemaType<\n M extends z.ZodEnum<[string, ...string[]]> = typeof EmbeddingModalityEnum,\n> = z.infer<ReturnType<typeof EmbeddingModelSchema<M>>>;\n\nexport { \n EmbeddingModelSchema, \n type EmbeddingModelSchemaType \n};\n","import { z } from \"zod\";\n\nconst Headers = z.record(z.string());\ntype HeadersType = z.infer<typeof Headers>;\n\nexport { Headers, type HeadersType };\n","import { z } from \"zod\";\n\nconst Params = z.record(z.union([\n z.boolean(),\n z.string(), \n z.number(), \n z.object({}),\n z.array(z.any()), // TODO: any or undefined?\n z.null(), \n z.undefined(), \n]));\ntype ParamsType = z.infer<typeof Params>;\n\nexport { Params, type ParamsType };\n","import { z } from \"zod\";\n\nconst Url = z.string().url();\ntype UrlType = z.infer<typeof Url>;\n\nexport { Url, type UrlType };\n","// TODO: add a schema for common config items\nconst TEMPERATURE = {\n type: \"range\",\n title: \"Temperature\",\n description:\n \"Adjusts the model's creativity level. With a setting of 0, the model strictly picks the most probable next word. For endeavors that benefit from a dash of inventiveness, consider dialing it up to 0.7 or higher, enabling the model to produce text that's unexpectedly fresh.\",\n} as const;\n\nconst MAX_TOKENS = {\n type: \"range\",\n title: \"Max tokens\",\n description:\n \"Specify the total tokens for generation, where one token approximates four English characters. Setting this to 0 defaults to the model's maximum capacity.\",\n} as const;\n\nconst STOP = (max: number) =>\n ({\n type: \"multi\",\n title: \"Stop sequence\",\n description: `Enter up to ${max} sequences that will halt additional text output. The generated text will exclude these sequences.`,\n }) as const;\n\nconst TOP_P = {\n type: \"range\",\n title: \"Top P\",\n description:\n \"Selects a subset of likely tokens for generation, restricting choices to the top-P fraction of possibilities, such as the top 10% when P=0.1. This approach can limit the variety of the output. By default, it's set to 1, indicating no restriction. It's advised to adjust this parameter or temperature to modulate output diversity, but not to modify both simultaneously.\",\n} as const;\n\nconst TOP_K = {\n type: \"range\",\n title: \"Top K\",\n description:\n \"Select only from the highest K probabilities for each following word, effectively eliminating the less likely 'long tail' options.\",\n} as const;\n\nconst FREQUENCY_PENALTY = {\n type: \"range\",\n title: \"Frequency penalty\",\n description:\n \"Minimize redundancy. By assigning a penalty to frequently used tokens within the text, the likelihood of repeating identical phrases is reduced. The default setting for this penalty is zero.\",\n} as const;\n\nconst PRESENCE_PENALTY = {\n type: \"range\",\n title: \"Presence penalty\",\n description:\n \"Enhance the introduction of novel subjects by reducing the preference for tokens that have already appeared in the text, thus boosting the chances of exploring fresh topics. The standard setting for this is zero.\",\n} as const;\n\n\n\nconst CONFIG = {\n TEMPERATURE,\n MAX_TOKENS,\n STOP,\n TOP_P,\n TOP_K,\n FREQUENCY_PENALTY,\n PRESENCE_PENALTY,\n};\n\nexport { CONFIG };\n","const getErrorMessage = (error: unknown | undefined): string => {\n if (error == null) return \"unknown error\";\n if (typeof error === \"string\") return error;\n if (error instanceof Error) return error.message;\n return JSON.stringify(error);\n};\n\nexport { getErrorMessage };\n","const removeUndefinedEntries = <T = unknown>(record: Record<string, T | undefined>): Record<string, T> => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n return Object.fromEntries(Object.entries(record).filter(([_, value]) => value != null)) as Record<string, T>;\n};\n\nexport { removeUndefinedEntries };\n","const isRunningInBrowser = () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return typeof window !== \"undefined\" && typeof window.document !== \"undefined\" && typeof navigator !== \"undefined\";\n};\n\nexport { isRunningInBrowser };\n","import { isRunningInBrowser } from \"./is-running-in-browser\";\n\nconst convertBase64ToUint8Array = (base64String: string): Uint8Array => {\n const base64Url = base64String.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const latin1string = globalThis.atob(base64Url);\n return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0)!);\n};\n\nconst convertUint8ArrayToBase64 = (array: Uint8Array): string => {\n let latin1string = \"\";\n\n // Note: regular for loop to support older JavaScript versions that\n // do not support for..of on Uint8Array\n for (let i = 0; i < array.length; i++) {\n latin1string += String.fromCodePoint(array[i]);\n }\n\n return globalThis.btoa(latin1string);\n};\n\nconst encodedBase64ToString = (base64: string): string => {\n if (isRunningInBrowser()) {\n const binaryString = atob(base64);\n const bytes = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) { bytes[i] = binaryString.charCodeAt(i); }\n const decoder = new TextDecoder(\"utf-8\");\n return decoder.decode(bytes);\n } else {\n return Buffer.from(base64, \"base64\").toString(\"utf-8\");\n }\n}\n\nconst getMimeTypeFromBase64 = (base64: string): string => {\n const mimeTypePrefix = base64.split(\";\")[0];\n const mimeType = mimeTypePrefix.split(\"/\")[1];\n return mimeType;\n}\n\nexport { convertBase64ToUint8Array, convertUint8ArrayToBase64, encodedBase64ToString, getMimeTypeFromBase64 };\n","const urlWithoutTrailingSlash = (url: string): string => {\n return url?.replace(/\\/$/, \"\");\n};\n\nexport { urlWithoutTrailingSlash };\n"]}
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { GatewayBaseError, RoleEnum, ModalityEnum, EmbeddingModalityEnum } from '@adaline/types';
2
2
  import { z as z$1 } from 'zod';
3
3
 
4
- var J=Object.defineProperty;var R=Object.getOwnPropertySymbols;var Q=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable;var O=(e,n,t)=>n in e?J(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,a=(e,n)=>{for(var t in n||(n={}))Q.call(n,t)&&O(e,t,n[t]);if(R)for(var t of R(n))X.call(n,t)&&O(e,t,n[t]);return e};var j="ProviderError",v=class e extends GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},j);this.name=j;this.info=t,this.cause=o;}static isProviderError(t){return t instanceof e}};var z="ModelError",D=class e extends GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},z);this.name=z;this.info=t,this.cause=o;}static isModelError(t){return t instanceof e}};var B="ModelResponseError",P=class e extends GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},B);this.name=B;this.cause=o,this.info=t;}static isModelResponseError(t){return t instanceof e}};var L="InvalidModelRequestError",U=class e extends GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},L);this.name=L;this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(t){return t instanceof e}};var A="InvalidConfigError",Z=class e extends GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},A);this.name=A;this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(t){return t instanceof e}};var q="InvalidMessagesError",K=class e extends GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},q);this.name=q;this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(t){return t instanceof e}};var G="InvalidToolsError",N=class e extends GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},G);this.name=G;this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(t){return t instanceof e}};var F="InvalidEmbeddingRequestsError",H=class e extends GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},F);this.name=F;this.info=t,this.cause=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(t){return t instanceof e}};var d="multi-string",E=z$1.object({type:z$1.literal(d),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),max:z$1.number().int().positive()}),se=e=>z$1.array(z$1.string()).max(e).default([]).optional(),Ke=e=>({def:E.parse(a({type:d},e)),schema:se(e.max)});var h="range",x=z$1.object({type:z$1.literal(h),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),min:z$1.number().int(),max:z$1.number().int(),step:z$1.number().positive(),default:z$1.number().int()}),ae=(e,n,t,o)=>z$1.number().min(e).max(n).step(t).default(o).optional(),He=e=>({def:x.parse(a({type:h},e)),schema:ae(e.min,e.max,e.step,e.default)});var S="select-string",w=z$1.object({type:z$1.literal(S),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),default:z$1.string().min(1),choices:z$1.array(z$1.string().min(1))}),ce=(e,n)=>z$1.enum(n).default(e).optional(),Je=e=>({def:w.parse(a({type:S},e)),schema:ce(e.default,e.choices)});var I="object-schema",M=z$1.object({type:z$1.literal(I),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),objectSchema:z$1.any()}),me=e=>e,_e=e=>({def:M.parse(a({type:I},e)),schema:me(e.objectSchema)});var b="select-boolean",k=z$1.object({type:z$1.literal(b),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),default:z$1.boolean().nullable()}),pe=e=>z$1.boolean().nullable().default(e).optional(),ot=e=>({def:k.parse(a({type:b},e)),schema:pe(e.default)});var fe=[h,d,S,I,b],lt=z$1.enum(fe),T=z$1.discriminatedUnion("type",[x,E,w,k,M]);var ht=(e=RoleEnum,n=ModalityEnum)=>z$1.object({name:z$1.string().min(1),description:z$1.string().min(1),roles:z$1.record(e,z$1.string().min(1).optional()),modalities:z$1.array(n).nonempty(),maxInputTokens:z$1.number().int().positive().min(1),maxOutputTokens:z$1.number().int().positive().min(1),config:z$1.object({def:z$1.record(z$1.string().min(1),T),schema:z$1.instanceof(z$1.ZodObject)}).refine(t=>{var u,g;let o=Object.keys(t.def),s=Object.keys((g=(u=t.schema)==null?void 0:u.shape)!=null?g:{});return o.every(C=>s.includes(C))&&s.every(C=>o.includes(C))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})});var Ct=(e=EmbeddingModalityEnum)=>z$1.object({name:z$1.string().min(1),description:z$1.string().min(1),modalities:z$1.array(e).nonempty(),maxInputTokens:z$1.number().int().positive().min(1),maxOutputTokens:z$1.number().int().positive().min(1),config:z$1.object({def:z$1.record(z$1.string().min(1),T),schema:z$1.instanceof(z$1.ZodObject)}).refine(n=>{var s,u;let t=Object.keys(n.def),o=Object.keys((u=(s=n.schema)==null?void 0:s.shape)!=null?u:{});return t.every(g=>o.includes(g))&&o.every(g=>t.includes(g))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})});var wt=z$1.record(z$1.string());var Rt=z$1.record(z$1.union([z$1.boolean(),z$1.string(),z$1.number(),z$1.object({}),z$1.array(z$1.any()),z$1.null(),z$1.undefined()]));var vt=z$1.string().url();var de={type:"range",title:"Temperature",description:"Adjusts the model's creativity level. With a setting of 0, the model strictly picks the most probable next word. For endeavors that benefit from a dash of inventiveness, consider dialing it up to 0.7 or higher, enabling the model to produce text that's unexpectedly fresh."},he={type:"range",title:"Max tokens",description:"Specify the total tokens for generation, where one token approximates four English characters. Setting this to 0 defaults to the model's maximum capacity."},Se=e=>({type:"multi",title:"Stop sequence",description:`Enter up to ${e} sequences that will halt additional text output. The generated text will exclude these sequences.`}),Ie={type:"range",title:"Top P",description:"Selects a subset of likely tokens for generation, restricting choices to the top-P fraction of possibilities, such as the top 10% when P=0.1. This approach can limit the variety of the output. By default, it's set to 1, indicating no restriction. It's advised to adjust this parameter or temperature to modulate output diversity, but not to modify both simultaneously."},be={type:"range",title:"Top K",description:"Select only from the highest K probabilities for each following word, effectively eliminating the less likely 'long tail' options."},Te={type:"range",title:"Frequency penalty",description:"Minimize redundancy. By assigning a penalty to frequently used tokens within the text, the likelihood of repeating identical phrases is reduced. The default setting for this penalty is zero."},Ce={type:"range",title:"Presence penalty",description:"Enhance the introduction of novel subjects by reducing the preference for tokens that have already appeared in the text, thus boosting the chances of exploring fresh topics. The standard setting for this is zero."},Dt={TEMPERATURE:de,MAX_TOKENS:he,STOP:Se,TOP_P:Ie,TOP_K:be,FREQUENCY_PENALTY:Te,PRESENCE_PENALTY:Ce};var Pt=e=>e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e);var Ut=e=>Object.fromEntries(Object.entries(e).filter(([n,t])=>t!=null));var $=()=>typeof window!="undefined"&&typeof window.document!="undefined"&&typeof navigator!="undefined";var Kt=e=>{let n=e.replace(/-/g,"+").replace(/_/g,"/"),t=globalThis.atob(n);return Uint8Array.from(t,o=>o.codePointAt(0))},Gt=e=>{let n="";for(let t=0;t<e.length;t++)n+=String.fromCodePoint(e[t]);return globalThis.btoa(n)},Nt=e=>{if($()){let n=atob(e),t=new Uint8Array(n.length);for(let s=0;s<n.length;s++)t[s]=n.charCodeAt(s);return new TextDecoder("utf-8").decode(t)}else return Buffer.from(e,"base64").toString("utf-8")};var Ht=e=>e==null?void 0:e.replace(/\/$/,"");
4
+ var J=Object.defineProperty;var R=Object.getOwnPropertySymbols;var Q=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable;var O=(e,n,t)=>n in e?J(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,a=(e,n)=>{for(var t in n||(n={}))Q.call(n,t)&&O(e,t,n[t]);if(R)for(var t of R(n))X.call(n,t)&&O(e,t,n[t]);return e};var j="ProviderError",v=class e extends GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},j);this.name=j;this.info=t,this.cause=o;}static isProviderError(t){return t instanceof e}};var z="ModelError",D=class e extends GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},z);this.name=z;this.info=t,this.cause=o;}static isModelError(t){return t instanceof e}};var B="ModelResponseError",P=class e extends GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},B);this.name=B;this.cause=o,this.info=t;}static isModelResponseError(t){return t instanceof e}};var L="InvalidModelRequestError",U=class e extends GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},L);this.name=L;this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(t){return t instanceof e}};var A="InvalidConfigError",Z=class e extends GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},A);this.name=A;this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(t){return t instanceof e}};var q="InvalidMessagesError",K=class e extends GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},q);this.name=q;this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(t){return t instanceof e}};var G="InvalidToolsError",N=class e extends GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},G);this.name=G;this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(t){return t instanceof e}};var F="InvalidEmbeddingRequestsError",H=class e extends GatewayBaseError{constructor({info:t,cause:o}){super({info:t,cause:o},F);this.name=F;this.info=t,this.cause=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(t){return t instanceof e}};var d="multi-string",E=z$1.object({type:z$1.literal(d),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),max:z$1.number().int().positive()}),se=e=>z$1.array(z$1.string()).max(e).default([]).optional(),Ke=e=>({def:E.parse(a({type:d},e)),schema:se(e.max)});var h="range",x=z$1.object({type:z$1.literal(h),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),min:z$1.number().int(),max:z$1.number().int(),step:z$1.number().positive(),default:z$1.number().int()}),ae=(e,n,t,o)=>z$1.number().min(e).max(n).step(t).default(o).optional(),He=e=>({def:x.parse(a({type:h},e)),schema:ae(e.min,e.max,e.step,e.default)});var S="select-string",w=z$1.object({type:z$1.literal(S),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),default:z$1.string().min(1),choices:z$1.array(z$1.string().min(1))}),me=(e,n)=>z$1.enum(n).default(e).optional(),Je=e=>({def:w.parse(a({type:S},e)),schema:me(e.default,e.choices)});var I="object-schema",M=z$1.object({type:z$1.literal(I),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),objectSchema:z$1.any()}),ce=e=>e,_e=e=>({def:M.parse(a({type:I},e)),schema:ce(e.objectSchema)});var b="select-boolean",k=z$1.object({type:z$1.literal(b),param:z$1.string().min(1),title:z$1.string().min(1),description:z$1.string().min(1).max(500),default:z$1.boolean().nullable()}),pe=e=>z$1.boolean().nullable().default(e).optional(),ot=e=>({def:k.parse(a({type:b},e)),schema:pe(e.default)});var fe=[h,d,S,I,b],lt=z$1.enum(fe),T=z$1.discriminatedUnion("type",[x,E,w,k,M]);var ht=(e=RoleEnum,n=ModalityEnum)=>z$1.object({name:z$1.string().min(1),description:z$1.string().min(1),roles:z$1.record(e,z$1.string().min(1).optional()),modalities:z$1.array(n).nonempty(),maxInputTokens:z$1.number().int().positive().min(1),maxOutputTokens:z$1.number().int().positive().min(1),config:z$1.object({def:z$1.record(z$1.string().min(1),T),schema:z$1.instanceof(z$1.ZodObject)}).refine(t=>{var u,g;let o=Object.keys(t.def),s=Object.keys((g=(u=t.schema)==null?void 0:u.shape)!=null?g:{});return o.every(C=>s.includes(C))&&s.every(C=>o.includes(C))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})});var Ct=(e=EmbeddingModalityEnum)=>z$1.object({name:z$1.string().min(1),description:z$1.string().min(1),modalities:z$1.array(e).nonempty(),maxInputTokens:z$1.number().int().positive().min(1),maxOutputTokens:z$1.number().int().positive().min(1),config:z$1.object({def:z$1.record(z$1.string().min(1),T),schema:z$1.instanceof(z$1.ZodObject)}).refine(n=>{var s,u;let t=Object.keys(n.def),o=Object.keys((u=(s=n.schema)==null?void 0:s.shape)!=null?u:{});return t.every(g=>o.includes(g))&&o.every(g=>t.includes(g))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})});var wt=z$1.record(z$1.string());var Rt=z$1.record(z$1.union([z$1.boolean(),z$1.string(),z$1.number(),z$1.object({}),z$1.array(z$1.any()),z$1.null(),z$1.undefined()]));var vt=z$1.string().url();var de={type:"range",title:"Temperature",description:"Adjusts the model's creativity level. With a setting of 0, the model strictly picks the most probable next word. For endeavors that benefit from a dash of inventiveness, consider dialing it up to 0.7 or higher, enabling the model to produce text that's unexpectedly fresh."},he={type:"range",title:"Max tokens",description:"Specify the total tokens for generation, where one token approximates four English characters. Setting this to 0 defaults to the model's maximum capacity."},Se=e=>({type:"multi",title:"Stop sequence",description:`Enter up to ${e} sequences that will halt additional text output. The generated text will exclude these sequences.`}),Ie={type:"range",title:"Top P",description:"Selects a subset of likely tokens for generation, restricting choices to the top-P fraction of possibilities, such as the top 10% when P=0.1. This approach can limit the variety of the output. By default, it's set to 1, indicating no restriction. It's advised to adjust this parameter or temperature to modulate output diversity, but not to modify both simultaneously."},be={type:"range",title:"Top K",description:"Select only from the highest K probabilities for each following word, effectively eliminating the less likely 'long tail' options."},Te={type:"range",title:"Frequency penalty",description:"Minimize redundancy. By assigning a penalty to frequently used tokens within the text, the likelihood of repeating identical phrases is reduced. The default setting for this penalty is zero."},Ce={type:"range",title:"Presence penalty",description:"Enhance the introduction of novel subjects by reducing the preference for tokens that have already appeared in the text, thus boosting the chances of exploring fresh topics. The standard setting for this is zero."},Dt={TEMPERATURE:de,MAX_TOKENS:he,STOP:Se,TOP_P:Ie,TOP_K:be,FREQUENCY_PENALTY:Te,PRESENCE_PENALTY:Ce};var Pt=e=>e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e);var Ut=e=>Object.fromEntries(Object.entries(e).filter(([n,t])=>t!=null));var $=()=>typeof window!="undefined"&&typeof window.document!="undefined"&&typeof navigator!="undefined";var Kt=e=>{let n=e.replace(/-/g,"+").replace(/_/g,"/"),t=globalThis.atob(n);return Uint8Array.from(t,o=>o.codePointAt(0))},Gt=e=>{let n="";for(let t=0;t<e.length;t++)n+=String.fromCodePoint(e[t]);return globalThis.btoa(n)},Nt=e=>{if($()){let n=atob(e),t=new Uint8Array(n.length);for(let s=0;s<n.length;s++)t[s]=n.charCodeAt(s);return new TextDecoder("utf-8").decode(t)}else return Buffer.from(e,"base64").toString("utf-8")},Ft=e=>e.split(";")[0].split("/")[1];var Yt=e=>e==null?void 0:e.replace(/\/$/,"");
5
5
 
6
- export { Dt as CONFIG, ht as ChatModelSchema, T as ConfigItemDef, lt as ConfigItemEnum, fe as ConfigItemLiterals, Ct as EmbeddingModelSchema, wt as Headers, Z as InvalidConfigError, H as InvalidEmbeddingRequestsError, K as InvalidMessagesError, U as InvalidModelRequestError, N as InvalidToolsError, D as ModelError, P as ModelResponseError, Ke as MultiStringConfigItem, E as MultiStringConfigItemDef, se as MultiStringConfigItemSchema, d as MultiStringConfigItemTypeLiteral, _e as ObjectSchemaConfigItem, M as ObjectSchemaConfigItemDef, me as ObjectSchemaConfigItemSchema, I as ObjectSchemaConfigItemTypeLiteral, Rt as Params, v as ProviderError, He as RangeConfigItem, x as RangeConfigItemDef, ae as RangeConfigItemSchema, h as RangeConfigItemTypeLiteral, ot as SelectBooleanConfigItem, k as SelectBooleanConfigItemDef, pe as SelectBooleanConfigItemSchema, b as SelectBooleanConfigItemTypeLiteral, Je as SelectStringConfigItem, w as SelectStringConfigItemDef, ce as SelectStringConfigItemSchema, S as SelectStringConfigItemTypeLiteral, vt as Url, Kt as convertBase64ToUint8Array, Gt as convertUint8ArrayToBase64, Nt as encodedBase64ToString, Pt as getErrorMessage, $ as isRunningInBrowser, Ut as removeUndefinedEntries, Ht as urlWithoutTrailingSlash };
6
+ export { Dt as CONFIG, ht as ChatModelSchema, T as ConfigItemDef, lt as ConfigItemEnum, fe as ConfigItemLiterals, Ct as EmbeddingModelSchema, wt as Headers, Z as InvalidConfigError, H as InvalidEmbeddingRequestsError, K as InvalidMessagesError, U as InvalidModelRequestError, N as InvalidToolsError, D as ModelError, P as ModelResponseError, Ke as MultiStringConfigItem, E as MultiStringConfigItemDef, se as MultiStringConfigItemSchema, d as MultiStringConfigItemTypeLiteral, _e as ObjectSchemaConfigItem, M as ObjectSchemaConfigItemDef, ce as ObjectSchemaConfigItemSchema, I as ObjectSchemaConfigItemTypeLiteral, Rt as Params, v as ProviderError, He as RangeConfigItem, x as RangeConfigItemDef, ae as RangeConfigItemSchema, h as RangeConfigItemTypeLiteral, ot as SelectBooleanConfigItem, k as SelectBooleanConfigItemDef, pe as SelectBooleanConfigItemSchema, b as SelectBooleanConfigItemTypeLiteral, Je as SelectStringConfigItem, w as SelectStringConfigItemDef, me as SelectStringConfigItemSchema, S as SelectStringConfigItemTypeLiteral, vt as Url, Kt as convertBase64ToUint8Array, Gt as convertUint8ArrayToBase64, Nt as encodedBase64ToString, Pt as getErrorMessage, Ft as getMimeTypeFromBase64, $ as isRunningInBrowser, Ut as removeUndefinedEntries, Yt as urlWithoutTrailingSlash };
7
7
  //# sourceMappingURL=index.mjs.map
8
8
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/errors/provider.error.ts","../src/errors/model.error.ts","../src/errors/model-response.error.ts","../src/errors/invalid-model-request.error.ts","../src/errors/invalid-config.error.ts","../src/errors/invalid-messages.error.ts","../src/errors/invalid-tools.error.ts","../src/errors/invalid-embedding-requests.error.ts","../src/types/config/multi-string-config-item.ts","../src/types/config/range-config-item.ts","../src/types/config/select-string-config-item.ts","../src/types/config/object-schema-config-item.ts","../src/types/config/select-boolean-config-item.ts","../src/types/config/config-item.ts","../src/model/chat-model/chat-model.schema.v1.ts","../src/model/embedding-model/embedding-model.schema.v1.ts","../src/types/headers.ts","../src/types/params.ts","../src/types/url.ts","../src/utils/common-config.ts","../src/utils/get-error-message.ts","../src/utils/remove-undefined-entries.ts","../src/utils/is-running-in-browser.ts","../src/utils/base64.ts","../src/utils/url.ts"],"names":["ProviderErrorLiteral","ProviderError","_ProviderError","GatewayBaseError","info","cause","error","ModelErrorLiteral","ModelError","_ModelError","ModelResponseErrorLiteral","ModelResponseError","_ModelResponseError","InvalidModelRequestErrorLiteral","InvalidModelRequestError","_InvalidModelRequestError","InvalidConfigErrorLiteral","InvalidConfigError","_InvalidConfigError","InvalidMessagesErrorLiteral","InvalidMessagesError","_InvalidMessagesError","InvalidToolsErrorLiteral","InvalidToolsError","_InvalidToolsError","InvalidEmbeddingRequestsErrorLiteral","InvalidEmbeddingRequestsError","_InvalidEmbeddingRequestsError","MultiStringConfigItemTypeLiteral","MultiStringConfigItemDef","z","MultiStringConfigItemSchema","max","MultiStringConfigItem","data","__spreadValues","RangeConfigItemTypeLiteral","RangeConfigItemDef","RangeConfigItemSchema","min","step","defaultValue","RangeConfigItem","SelectStringConfigItemTypeLiteral","SelectStringConfigItemDef","SelectStringConfigItemSchema","choices","SelectStringConfigItem","ObjectSchemaConfigItemTypeLiteral","ObjectSchemaConfigItemDef","ObjectSchemaConfigItemSchema","schema","ObjectSchemaConfigItem","SelectBooleanConfigItemTypeLiteral","SelectBooleanConfigItemDef","SelectBooleanConfigItemSchema","SelectBooleanConfigItem","ConfigItemLiterals","ConfigItemEnum","ConfigItemDef","ChatModelSchema","Roles","RoleEnum","Modalities","ModalityEnum","config","_a","_b","defKeys","schemaKeys","key","EmbeddingModelSchema","EmbeddingModalityEnum","Headers","Params","Url","TEMPERATURE","MAX_TOKENS","STOP","TOP_P","TOP_K","FREQUENCY_PENALTY","PRESENCE_PENALTY","CONFIG","getErrorMessage","removeUndefinedEntries","record","_","value","isRunningInBrowser","convertBase64ToUint8Array","base64String","base64Url","latin1string","byte","convertUint8ArrayToBase64","array","i","encodedBase64ToString","base64","binaryString","bytes","urlWithoutTrailingSlash","url"],"mappings":";;;AAAA,IAAA,CAAA,CAAA,MAAA,CAAA,cAAA,CAAA,IAAA,CAAA,CAAA,MAAA,CAAA,qBAAA,CAAA,IAAA,CAAA,CAAA,MAAA,CAAA,SAAA,CAAA,cAAA,CAAA,CAAA,CAAA,MAAA,CAAA,SAAA,CAAA,oBAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,UAAA,CAAA,CAAA,CAAA,CAAA,YAAA,CAAA,CAAA,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,CAAA,KAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA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AAAA,CAAAA,CAAQ,QAAQ,CAAE,CAAA,QAAA,CAAS,OAAO,CAEzD,MC9BMG,EAA2BC,CAAAA,CAAAA,EACxBA,GAAA,IAAAA,CAAAA,KAAAA,CAAAA,CAAAA,CAAAA,CAAK,QAAQ,KAAO,CAAA,EAAA","file":"index.mjs","sourcesContent":["import { GatewayBaseError } from \"@adaline/types\";\n\nconst ProviderErrorLiteral = \"ProviderError\" as const;\nexport class ProviderError extends GatewayBaseError {\n readonly name = ProviderErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, ProviderErrorLiteral);\n this.info = info;\n this.cause = cause;\n }\n\n static isProviderError(error: unknown): error is ProviderError {\n return error instanceof ProviderError;\n }\n}","import { GatewayBaseError } from \"@adaline/types\";\n\nconst ModelErrorLiteral = \"ModelError\" as const;\nexport class ModelError extends GatewayBaseError {\n readonly name = ModelErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, ModelErrorLiteral);\n this.info = info;\n this.cause = cause;\n }\n\n static isModelError(error: unknown): error is ModelError {\n return error instanceof ModelError;\n }\n}","import { GatewayBaseError } from \"@adaline/types\";\n\nconst ModelResponseErrorLiteral = \"ModelResponseError\" as const;\nexport class ModelResponseError extends GatewayBaseError {\n readonly name = ModelResponseErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, ModelResponseErrorLiteral);\n this.cause = cause;\n this.info = info;\n }\n\n static isModelResponseError(error: unknown): error is ModelResponseError {\n return error instanceof ModelResponseError;\n }\n}\n","import { GatewayBaseError } from \"@adaline/types\";\n\nconst InvalidModelRequestErrorLiteral = \"InvalidModelRequestError\" as const;\nexport class InvalidModelRequestError extends GatewayBaseError {\n readonly name = InvalidModelRequestErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, InvalidModelRequestErrorLiteral);\n this.cause = cause;\n this.info = info;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static isInvalidModelRequestError(error: unknown): error is InvalidModelRequestError {\n return error instanceof InvalidModelRequestError;\n }\n}\n","import { GatewayBaseError } from \"@adaline/types\";\n\nconst InvalidConfigErrorLiteral = \"InvalidConfigError\" as const;\nexport class InvalidConfigError extends GatewayBaseError {\n readonly name = InvalidConfigErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, InvalidConfigErrorLiteral);\n this.cause = cause;\n this.info = info;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static isInvalidConfigError(error: unknown): error is InvalidConfigError {\n return error instanceof InvalidConfigError;\n }\n}\n","import { GatewayBaseError } from \"@adaline/types\";\n\nconst InvalidMessagesErrorLiteral = \"InvalidMessagesError\" as const;\nexport class InvalidMessagesError extends GatewayBaseError {\n readonly name = InvalidMessagesErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, InvalidMessagesErrorLiteral);\n this.cause = cause;\n this.info = info;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static isInvalidMessagesError(error: unknown): error is InvalidMessagesError {\n return error instanceof InvalidMessagesError;\n }\n}\n","import { GatewayBaseError } from \"@adaline/types\";\n\nconst InvalidToolsErrorLiteral = \"InvalidToolsError\" as const;\nexport class InvalidToolsError extends GatewayBaseError {\n readonly name = InvalidToolsErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, InvalidToolsErrorLiteral);\n this.cause = cause;\n this.info = info;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static isInvalidToolsError(error: unknown): error is InvalidToolsError {\n return error instanceof InvalidToolsError;\n }\n}\n","import { GatewayBaseError } from \"@adaline/types\";\n\nconst InvalidEmbeddingRequestsErrorLiteral = \"InvalidEmbeddingRequestsError\" as const;\nexport class InvalidEmbeddingRequestsError extends GatewayBaseError {\n readonly name = InvalidEmbeddingRequestsErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, InvalidEmbeddingRequestsErrorLiteral);\n this.info = info;\n this.cause = cause;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static isInvalidEmbeddingRequestsError(error: unknown): error is InvalidEmbeddingRequestsError {\n return error instanceof InvalidEmbeddingRequestsError;\n }\n}","import { z } from \"zod\";\n\nconst MultiStringConfigItemTypeLiteral = \"multi-string\" as const;\n\nconst MultiStringConfigItemDef = z.object({\n type: z.literal(MultiStringConfigItemTypeLiteral),\n param: z.string().min(1),\n title: z.string().min(1),\n description: z.string().min(1).max(500),\n max: z.number().int().positive(),\n});\ntype MultiStringConfigItemType = z.infer<typeof MultiStringConfigItemDef>;\n\nconst MultiStringConfigItemSchema = (max: number) => z.array(z.string()).max(max).default([]).optional();\ntype MultiStringConfigItemSchemaType = z.infer<ReturnType<typeof MultiStringConfigItemSchema>>;\n\nconst MultiStringConfigItem = (data: Omit<MultiStringConfigItemType, \"type\">) => {\n return {\n def: MultiStringConfigItemDef.parse({\n type: MultiStringConfigItemTypeLiteral,\n ...data,\n }),\n schema: MultiStringConfigItemSchema(data.max),\n };\n};\n\nexport {\n MultiStringConfigItem,\n MultiStringConfigItemDef,\n MultiStringConfigItemSchema,\n MultiStringConfigItemTypeLiteral,\n type MultiStringConfigItemSchemaType,\n type MultiStringConfigItemType,\n};\n","import { z } from \"zod\";\n\nconst RangeConfigItemTypeLiteral = \"range\" as const;\n\nconst RangeConfigItemDef = z.object({\n type: z.literal(RangeConfigItemTypeLiteral),\n param: z.string().min(1),\n title: z.string().min(1),\n description: z.string().min(1).max(500),\n min: z.number().int(),\n max: z.number().int(),\n step: z.number().positive(),\n default: z.number().int(),\n});\ntype RangeConfigItemDefType = z.infer<typeof RangeConfigItemDef>;\n\nconst RangeConfigItemSchema = (min: number, max: number, step: number, defaultValue: number) =>\n z.number().min(min).max(max).step(step).default(defaultValue).optional();\ntype RangeConfigItemSchemaType = z.infer<ReturnType<typeof RangeConfigItemSchema>>;\n\nconst RangeConfigItem = (data: Omit<RangeConfigItemDefType, \"type\">) => {\n return {\n def: RangeConfigItemDef.parse({\n type: RangeConfigItemTypeLiteral,\n ...data,\n }),\n schema: RangeConfigItemSchema(data.min, data.max, data.step, data.default),\n };\n};\n\nexport {\n RangeConfigItem,\n RangeConfigItemDef,\n RangeConfigItemSchema,\n RangeConfigItemTypeLiteral,\n type RangeConfigItemDefType,\n type RangeConfigItemSchemaType,\n};\n","import { z } from \"zod\";\n\nconst SelectStringConfigItemTypeLiteral = \"select-string\" as const;\n\nconst SelectStringConfigItemDef = z.object({\n type: z.literal(SelectStringConfigItemTypeLiteral),\n param: z.string().min(1),\n title: z.string().min(1),\n description: z.string().min(1).max(500),\n default: z.string().min(1), // TODO: should be optional, not choosing any value from choices is also a valid choice. Eg. Anthropic embeddings input_type, truncation, encoding_format\n choices: z.array(z.string().min(1)),\n});\ntype SelectStringConfigItemDefType = z.infer<typeof SelectStringConfigItemDef>;\n\nconst SelectStringConfigItemSchema = (defaultValue: string, choices: string[]) =>\n z\n .enum(choices as [string, ...string[]])\n .default(defaultValue)\n .optional();\ntype SelectStringConfigItemSchemaType = z.infer<ReturnType<typeof SelectStringConfigItemSchema>>;\n\nconst SelectStringConfigItem = (data: Omit<SelectStringConfigItemDefType, \"type\">) => {\n return {\n def: SelectStringConfigItemDef.parse({\n type: SelectStringConfigItemTypeLiteral,\n ...data,\n }),\n schema: SelectStringConfigItemSchema(data.default, data.choices),\n };\n};\n\nexport {\n SelectStringConfigItem,\n SelectStringConfigItemDef,\n SelectStringConfigItemSchema,\n SelectStringConfigItemTypeLiteral,\n type SelectStringConfigItemDefType,\n type SelectStringConfigItemSchemaType,\n};\n","import { z } from \"zod\";\n\nconst ObjectSchemaConfigItemTypeLiteral = \"object-schema\" as const;\n\nconst ObjectSchemaConfigItemDef = z.object({\n type: z.literal(ObjectSchemaConfigItemTypeLiteral),\n param: z.string().min(1),\n title: z.string().min(1),\n description: z.string().min(1).max(500),\n objectSchema: z.any(),\n});\ntype ObjectSchemaConfigItemType = z.infer<typeof ObjectSchemaConfigItemDef>;\n\nconst ObjectSchemaConfigItemSchema = <S extends z.ZodRawShape>(schema: z.ZodObject<S>) => schema;\ntype ObjectSchemaConfigItemSchemaType<S extends z.ZodRawShape = z.ZodRawShape> = z.infer<ReturnType<typeof ObjectSchemaConfigItemSchema<S>>>;\n\nconst ObjectSchemaConfigItem = (data: Omit<ObjectSchemaConfigItemType, \"type\">) => {\n return {\n def: ObjectSchemaConfigItemDef.parse({\n type: ObjectSchemaConfigItemTypeLiteral,\n ...data,\n }),\n schema: ObjectSchemaConfigItemSchema(data.objectSchema),\n };\n};\n\nexport {\n ObjectSchemaConfigItem,\n ObjectSchemaConfigItemDef,\n ObjectSchemaConfigItemSchema,\n ObjectSchemaConfigItemTypeLiteral,\n type ObjectSchemaConfigItemType,\n type ObjectSchemaConfigItemSchemaType,\n};","import { z } from \"zod\";\n\nconst SelectBooleanConfigItemTypeLiteral = \"select-boolean\" as const;\n\nconst SelectBooleanConfigItemDef = z.object({\n type: z.literal(SelectBooleanConfigItemTypeLiteral),\n param: z.string().min(1),\n title: z.string().min(1),\n description: z.string().min(1).max(500),\n default: z.boolean().nullable(),\n});\ntype SelectBooleanConfigItemDefType = z.infer<typeof SelectBooleanConfigItemDef>;\n\nconst SelectBooleanConfigItemSchema = (defaultValue: boolean | null) =>\n z\n .boolean()\n .nullable()\n .default(defaultValue) \n .optional();\ntype SelectBooleanConfigItemSchemaType = z.infer<ReturnType<typeof SelectBooleanConfigItemSchema>>;\n\nconst SelectBooleanConfigItem = (data: Omit<SelectBooleanConfigItemDefType, \"type\">) => {\n return {\n def: SelectBooleanConfigItemDef.parse({\n type: SelectBooleanConfigItemTypeLiteral,\n ...data,\n }),\n schema: SelectBooleanConfigItemSchema(data.default),\n };\n};\n\nexport {\n SelectBooleanConfigItem,\n SelectBooleanConfigItemDef,\n SelectBooleanConfigItemSchema,\n SelectBooleanConfigItemTypeLiteral,\n type SelectBooleanConfigItemDefType,\n type SelectBooleanConfigItemSchemaType,\n};\n","import { z } from \"zod\";\n\nimport { MultiStringConfigItemDef, MultiStringConfigItemTypeLiteral } from \"./multi-string-config-item\";\nimport { RangeConfigItemDef, RangeConfigItemTypeLiteral } from \"./range-config-item\";\nimport { SelectStringConfigItemDef, SelectStringConfigItemTypeLiteral } from \"./select-string-config-item\";\nimport { ObjectSchemaConfigItemDef, ObjectSchemaConfigItemTypeLiteral } from \"./object-schema-config-item\";\nimport { SelectBooleanConfigItemDef, SelectBooleanConfigItemTypeLiteral } from \"./select-boolean-config-item\";\n\nconst ConfigItemLiterals = [\n RangeConfigItemTypeLiteral, \n MultiStringConfigItemTypeLiteral, \n SelectStringConfigItemTypeLiteral,\n ObjectSchemaConfigItemTypeLiteral,\n SelectBooleanConfigItemTypeLiteral,\n] as const;\nconst ConfigItemEnum = z.enum(ConfigItemLiterals);\ntype ConfigItemEnumType = z.infer<typeof ConfigItemEnum>;\n\nconst ConfigItemDef = z.discriminatedUnion(\"type\", [\n RangeConfigItemDef, \n MultiStringConfigItemDef, \n SelectStringConfigItemDef,\n SelectBooleanConfigItemDef,\n ObjectSchemaConfigItemDef,\n]);\ntype ConfigItemDefType = z.infer<typeof ConfigItemDef>;\n\nexport { ConfigItemDef, ConfigItemEnum, ConfigItemLiterals, type ConfigItemDefType, type ConfigItemEnumType };\n","import { z } from \"zod\";\n\nimport { ModalityEnum, RoleEnum } from \"@adaline/types\";\n\nimport { ConfigItemDef } from \"../../types/config\";\n\nconst ChatModelSchema = <\n R extends z.ZodEnum<[string, ...string[]]> = typeof RoleEnum,\n M extends z.ZodEnum<[string, ...string[]]> = typeof ModalityEnum\n>(\n Roles: R = RoleEnum as unknown as R, \n Modalities: M = ModalityEnum as unknown as M\n) =>\n z.object({\n name: z.string().min(1),\n description: z.string().min(1),\n roles: z.record(Roles, z.string().min(1).optional()),\n modalities: z.array(Modalities).nonempty(),\n maxInputTokens: z.number().int().positive().min(1),\n maxOutputTokens: z.number().int().positive().min(1),\n config: z\n .object({\n def: z.record(z.string().min(1), ConfigItemDef),\n schema: z.instanceof(z.ZodObject),\n })\n .refine(\n (config) => {\n const defKeys = Object.keys(config.def);\n const schemaKeys = Object.keys(config.schema?.shape ?? {});\n return defKeys.every((key) => schemaKeys.includes(key)) && schemaKeys.every((key) => defKeys.includes(key));\n },\n {\n message: \"Keys in 'config.def' must exactly match keys in 'config.schema'\",\n }\n ),\n });\ntype ChatModelSchemaType<\n R extends z.ZodEnum<[string, ...string[]]> = typeof RoleEnum,\n M extends z.ZodEnum<[string, ...string[]]> = typeof ModalityEnum\n> = z.infer<ReturnType<typeof ChatModelSchema<R, M>>>;\n\nexport { \n ChatModelSchema, \n type ChatModelSchemaType \n};\n","import { z } from \"zod\";\n\nimport { EmbeddingModalityEnum } from \"@adaline/types\";\n\nimport { ConfigItemDef } from \"../../types/config\";\n\n// TODO: add embedding model properties (dimensions, etc)\nconst EmbeddingModelSchema = <\n M extends z.ZodEnum<[string, ...string[]]> = typeof EmbeddingModalityEnum,\n>(\n Modalities: M = EmbeddingModalityEnum as unknown as M\n) => z.object({\n name: z.string().min(1),\n description: z.string().min(1),\n modalities: z.array(Modalities).nonempty(),\n maxInputTokens: z.number().int().positive().min(1), // TODO: rename property\n maxOutputTokens: z.number().int().positive().min(1), // TODO: rename property\n config: z\n .object({\n def: z.record(z.string().min(1), ConfigItemDef),\n schema: z.instanceof(z.ZodObject),\n })\n .refine(\n (config) => {\n const defKeys = Object.keys(config.def);\n const schemaKeys = Object.keys(config.schema?.shape ?? {});\n return defKeys.every((key) => schemaKeys.includes(key)) && schemaKeys.every((key) => defKeys.includes(key));\n },\n {\n message: \"Keys in 'config.def' must exactly match keys in 'config.schema'\",\n }\n ),\n});\ntype EmbeddingModelSchemaType<\n M extends z.ZodEnum<[string, ...string[]]> = typeof EmbeddingModalityEnum,\n> = z.infer<ReturnType<typeof EmbeddingModelSchema<M>>>;\n\nexport { \n EmbeddingModelSchema, \n type EmbeddingModelSchemaType \n};\n","import { z } from \"zod\";\n\nconst Headers = z.record(z.string());\ntype HeadersType = z.infer<typeof Headers>;\n\nexport { Headers, type HeadersType };\n","import { z } from \"zod\";\n\nconst Params = z.record(z.union([\n z.boolean(),\n z.string(), \n z.number(), \n z.object({}),\n z.array(z.any()), // TODO: any or undefined?\n z.null(), \n z.undefined(), \n]));\ntype ParamsType = z.infer<typeof Params>;\n\nexport { Params, type ParamsType };\n","import { z } from \"zod\";\n\nconst Url = z.string().url();\ntype UrlType = z.infer<typeof Url>;\n\nexport { Url, type UrlType };\n","// TODO: add a schema for common config items\nconst TEMPERATURE = {\n type: \"range\",\n title: \"Temperature\",\n description:\n \"Adjusts the model's creativity level. With a setting of 0, the model strictly picks the most probable next word. For endeavors that benefit from a dash of inventiveness, consider dialing it up to 0.7 or higher, enabling the model to produce text that's unexpectedly fresh.\",\n} as const;\n\nconst MAX_TOKENS = {\n type: \"range\",\n title: \"Max tokens\",\n description:\n \"Specify the total tokens for generation, where one token approximates four English characters. Setting this to 0 defaults to the model's maximum capacity.\",\n} as const;\n\nconst STOP = (max: number) =>\n ({\n type: \"multi\",\n title: \"Stop sequence\",\n description: `Enter up to ${max} sequences that will halt additional text output. The generated text will exclude these sequences.`,\n }) as const;\n\nconst TOP_P = {\n type: \"range\",\n title: \"Top P\",\n description:\n \"Selects a subset of likely tokens for generation, restricting choices to the top-P fraction of possibilities, such as the top 10% when P=0.1. This approach can limit the variety of the output. By default, it's set to 1, indicating no restriction. It's advised to adjust this parameter or temperature to modulate output diversity, but not to modify both simultaneously.\",\n} as const;\n\nconst TOP_K = {\n type: \"range\",\n title: \"Top K\",\n description:\n \"Select only from the highest K probabilities for each following word, effectively eliminating the less likely 'long tail' options.\",\n} as const;\n\nconst FREQUENCY_PENALTY = {\n type: \"range\",\n title: \"Frequency penalty\",\n description:\n \"Minimize redundancy. By assigning a penalty to frequently used tokens within the text, the likelihood of repeating identical phrases is reduced. The default setting for this penalty is zero.\",\n} as const;\n\nconst PRESENCE_PENALTY = {\n type: \"range\",\n title: \"Presence penalty\",\n description:\n \"Enhance the introduction of novel subjects by reducing the preference for tokens that have already appeared in the text, thus boosting the chances of exploring fresh topics. The standard setting for this is zero.\",\n} as const;\n\n\n\nconst CONFIG = {\n TEMPERATURE,\n MAX_TOKENS,\n STOP,\n TOP_P,\n TOP_K,\n FREQUENCY_PENALTY,\n PRESENCE_PENALTY,\n};\n\nexport { CONFIG };\n","const getErrorMessage = (error: unknown | undefined): string => {\n if (error == null) return \"unknown error\";\n if (typeof error === \"string\") return error;\n if (error instanceof Error) return error.message;\n return JSON.stringify(error);\n};\n\nexport { getErrorMessage };\n","const removeUndefinedEntries = <T = unknown>(record: Record<string, T | undefined>): Record<string, T> => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n return Object.fromEntries(Object.entries(record).filter(([_, value]) => value != null)) as Record<string, T>;\n};\n\nexport { removeUndefinedEntries };\n","const isRunningInBrowser = () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return typeof window !== \"undefined\" && typeof window.document !== \"undefined\" && typeof navigator !== \"undefined\";\n};\n\nexport { isRunningInBrowser };\n","import { isRunningInBrowser } from \"./is-running-in-browser\";\n\nconst convertBase64ToUint8Array = (base64String: string): Uint8Array => {\n const base64Url = base64String.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const latin1string = globalThis.atob(base64Url);\n return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0)!);\n};\n\nconst convertUint8ArrayToBase64 = (array: Uint8Array): string => {\n let latin1string = \"\";\n\n // Note: regular for loop to support older JavaScript versions that\n // do not support for..of on Uint8Array\n for (let i = 0; i < array.length; i++) {\n latin1string += String.fromCodePoint(array[i]);\n }\n\n return globalThis.btoa(latin1string);\n};\n\nconst encodedBase64ToString = (base64: string): string => {\n if (isRunningInBrowser()) {\n const binaryString = atob(base64);\n const bytes = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) { bytes[i] = binaryString.charCodeAt(i); }\n const decoder = new TextDecoder(\"utf-8\");\n return decoder.decode(bytes);\n } else {\n return Buffer.from(base64, \"base64\").toString(\"utf-8\");\n }\n}\n\nexport { convertBase64ToUint8Array, convertUint8ArrayToBase64, encodedBase64ToString };\n","const urlWithoutTrailingSlash = (url: string): string => {\n return url?.replace(/\\/$/, \"\");\n};\n\nexport { urlWithoutTrailingSlash };\n"]}
1
+ {"version":3,"sources":["../src/errors/provider.error.ts","../src/errors/model.error.ts","../src/errors/model-response.error.ts","../src/errors/invalid-model-request.error.ts","../src/errors/invalid-config.error.ts","../src/errors/invalid-messages.error.ts","../src/errors/invalid-tools.error.ts","../src/errors/invalid-embedding-requests.error.ts","../src/types/config/multi-string-config-item.ts","../src/types/config/range-config-item.ts","../src/types/config/select-string-config-item.ts","../src/types/config/object-schema-config-item.ts","../src/types/config/select-boolean-config-item.ts","../src/types/config/config-item.ts","../src/model/chat-model/chat-model.schema.v1.ts","../src/model/embedding-model/embedding-model.schema.v1.ts","../src/types/headers.ts","../src/types/params.ts","../src/types/url.ts","../src/utils/common-config.ts","../src/utils/get-error-message.ts","../src/utils/remove-undefined-entries.ts","../src/utils/is-running-in-browser.ts","../src/utils/base64.ts","../src/utils/url.ts"],"names":["ProviderErrorLiteral","ProviderError","_ProviderError","GatewayBaseError","info","cause","error","ModelErrorLiteral","ModelError","_ModelError","ModelResponseErrorLiteral","ModelResponseError","_ModelResponseError","InvalidModelRequestErrorLiteral","InvalidModelRequestError","_InvalidModelRequestError","InvalidConfigErrorLiteral","InvalidConfigError","_InvalidConfigError","InvalidMessagesErrorLiteral","InvalidMessagesError","_InvalidMessagesError","InvalidToolsErrorLiteral","InvalidToolsError","_InvalidToolsError","InvalidEmbeddingRequestsErrorLiteral","InvalidEmbeddingRequestsError","_InvalidEmbeddingRequestsError","MultiStringConfigItemTypeLiteral","MultiStringConfigItemDef","z","MultiStringConfigItemSchema","max","MultiStringConfigItem","data","__spreadValues","RangeConfigItemTypeLiteral","RangeConfigItemDef","RangeConfigItemSchema","min","step","defaultValue","RangeConfigItem","SelectStringConfigItemTypeLiteral","SelectStringConfigItemDef","SelectStringConfigItemSchema","choices","SelectStringConfigItem","ObjectSchemaConfigItemTypeLiteral","ObjectSchemaConfigItemDef","ObjectSchemaConfigItemSchema","schema","ObjectSchemaConfigItem","SelectBooleanConfigItemTypeLiteral","SelectBooleanConfigItemDef","SelectBooleanConfigItemSchema","SelectBooleanConfigItem","ConfigItemLiterals","ConfigItemEnum","ConfigItemDef","ChatModelSchema","Roles","RoleEnum","Modalities","ModalityEnum","config","_a","_b","defKeys","schemaKeys","key","EmbeddingModelSchema","EmbeddingModalityEnum","Headers","Params","Url","TEMPERATURE","MAX_TOKENS","STOP","TOP_P","TOP_K","FREQUENCY_PENALTY","PRESENCE_PENALTY","CONFIG","getErrorMessage","removeUndefinedEntries","record","_","value","isRunningInBrowser","convertBase64ToUint8Array","base64String","base64Url","latin1string","byte","convertUint8ArrayToBase64","array","i","encodedBase64ToString","base64","binaryString","bytes","getMimeTypeFromBase64","urlWithoutTrailingSlash","url"],"mappings":";;;AAAA,IAAA,CAAA,CAAA,MAAA,CAAA,cAAA,CAAA,IAAA,CAAA,CAAA,MAAA,CAAA,qBAAA,CAAA,IAAA,CAAA,CAAA,MAAA,CAAA,SAAA,CAAA,cAAA,CAAA,CAAA,CAAA,MAAA,CAAA,SAAA,CAAA,oBAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,UAAA,CAAA,CAAA,CAAA,CAAA,YAAA,CAAA,CAAA,CAAA,CAAA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AEpF,OADgB,IAAI,YAAY,OAAO,CAAA,CACxB,OAAOI,CAAK,CAC7B,MACS,OAAA,MAAA,CAAO,KAAKF,CAAQ,CAAA,QAAQ,EAAE,QAAS,CAAA,OAAO,CAEzD,CAEMG,CAAAA,EAAAA,CAAyBH,GACNA,CAAO,CAAA,KAAA,CAAM,GAAG,CAAE,CAAA,CAAC,EACV,KAAM,CAAA,GAAG,EAAE,CAAC,MClCxCI,EAA2BC,CAAAA,CAAAA,EACxBA,GAAA,IAAAA,CAAAA,KAAAA,CAAAA,CAAAA,CAAAA,CAAK,QAAQ,KAAO,CAAA,EAAA","file":"index.mjs","sourcesContent":["import { GatewayBaseError } from \"@adaline/types\";\n\nconst ProviderErrorLiteral = \"ProviderError\" as const;\nexport class ProviderError extends GatewayBaseError {\n readonly name = ProviderErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, ProviderErrorLiteral);\n this.info = info;\n this.cause = cause;\n }\n\n static isProviderError(error: unknown): error is ProviderError {\n return error instanceof ProviderError;\n }\n}","import { GatewayBaseError } from \"@adaline/types\";\n\nconst ModelErrorLiteral = \"ModelError\" as const;\nexport class ModelError extends GatewayBaseError {\n readonly name = ModelErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, ModelErrorLiteral);\n this.info = info;\n this.cause = cause;\n }\n\n static isModelError(error: unknown): error is ModelError {\n return error instanceof ModelError;\n }\n}","import { GatewayBaseError } from \"@adaline/types\";\n\nconst ModelResponseErrorLiteral = \"ModelResponseError\" as const;\nexport class ModelResponseError extends GatewayBaseError {\n readonly name = ModelResponseErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, ModelResponseErrorLiteral);\n this.cause = cause;\n this.info = info;\n }\n\n static isModelResponseError(error: unknown): error is ModelResponseError {\n return error instanceof ModelResponseError;\n }\n}\n","import { GatewayBaseError } from \"@adaline/types\";\n\nconst InvalidModelRequestErrorLiteral = \"InvalidModelRequestError\" as const;\nexport class InvalidModelRequestError extends GatewayBaseError {\n readonly name = InvalidModelRequestErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, InvalidModelRequestErrorLiteral);\n this.cause = cause;\n this.info = info;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static isInvalidModelRequestError(error: unknown): error is InvalidModelRequestError {\n return error instanceof InvalidModelRequestError;\n }\n}\n","import { GatewayBaseError } from \"@adaline/types\";\n\nconst InvalidConfigErrorLiteral = \"InvalidConfigError\" as const;\nexport class InvalidConfigError extends GatewayBaseError {\n readonly name = InvalidConfigErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, InvalidConfigErrorLiteral);\n this.cause = cause;\n this.info = info;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static isInvalidConfigError(error: unknown): error is InvalidConfigError {\n return error instanceof InvalidConfigError;\n }\n}\n","import { GatewayBaseError } from \"@adaline/types\";\n\nconst InvalidMessagesErrorLiteral = \"InvalidMessagesError\" as const;\nexport class InvalidMessagesError extends GatewayBaseError {\n readonly name = InvalidMessagesErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, InvalidMessagesErrorLiteral);\n this.cause = cause;\n this.info = info;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static isInvalidMessagesError(error: unknown): error is InvalidMessagesError {\n return error instanceof InvalidMessagesError;\n }\n}\n","import { GatewayBaseError } from \"@adaline/types\";\n\nconst InvalidToolsErrorLiteral = \"InvalidToolsError\" as const;\nexport class InvalidToolsError extends GatewayBaseError {\n readonly name = InvalidToolsErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, InvalidToolsErrorLiteral);\n this.cause = cause;\n this.info = info;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static isInvalidToolsError(error: unknown): error is InvalidToolsError {\n return error instanceof InvalidToolsError;\n }\n}\n","import { GatewayBaseError } from \"@adaline/types\";\n\nconst InvalidEmbeddingRequestsErrorLiteral = \"InvalidEmbeddingRequestsError\" as const;\nexport class InvalidEmbeddingRequestsError extends GatewayBaseError {\n readonly name = InvalidEmbeddingRequestsErrorLiteral;\n readonly info: string;\n readonly cause: unknown;\n\n constructor({ info, cause }: { info: string; cause: unknown }) {\n super({ info, cause }, InvalidEmbeddingRequestsErrorLiteral);\n this.info = info;\n this.cause = cause;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static isInvalidEmbeddingRequestsError(error: unknown): error is InvalidEmbeddingRequestsError {\n return error instanceof InvalidEmbeddingRequestsError;\n }\n}","import { z } from \"zod\";\n\nconst MultiStringConfigItemTypeLiteral = \"multi-string\" as const;\n\nconst MultiStringConfigItemDef = z.object({\n type: z.literal(MultiStringConfigItemTypeLiteral),\n param: z.string().min(1),\n title: z.string().min(1),\n description: z.string().min(1).max(500),\n max: z.number().int().positive(),\n});\ntype MultiStringConfigItemType = z.infer<typeof MultiStringConfigItemDef>;\n\nconst MultiStringConfigItemSchema = (max: number) => z.array(z.string()).max(max).default([]).optional();\ntype MultiStringConfigItemSchemaType = z.infer<ReturnType<typeof MultiStringConfigItemSchema>>;\n\nconst MultiStringConfigItem = (data: Omit<MultiStringConfigItemType, \"type\">) => {\n return {\n def: MultiStringConfigItemDef.parse({\n type: MultiStringConfigItemTypeLiteral,\n ...data,\n }),\n schema: MultiStringConfigItemSchema(data.max),\n };\n};\n\nexport {\n MultiStringConfigItem,\n MultiStringConfigItemDef,\n MultiStringConfigItemSchema,\n MultiStringConfigItemTypeLiteral,\n type MultiStringConfigItemSchemaType,\n type MultiStringConfigItemType,\n};\n","import { z } from \"zod\";\n\nconst RangeConfigItemTypeLiteral = \"range\" as const;\n\nconst RangeConfigItemDef = z.object({\n type: z.literal(RangeConfigItemTypeLiteral),\n param: z.string().min(1),\n title: z.string().min(1),\n description: z.string().min(1).max(500),\n min: z.number().int(),\n max: z.number().int(),\n step: z.number().positive(),\n default: z.number().int(),\n});\ntype RangeConfigItemDefType = z.infer<typeof RangeConfigItemDef>;\n\nconst RangeConfigItemSchema = (min: number, max: number, step: number, defaultValue: number) =>\n z.number().min(min).max(max).step(step).default(defaultValue).optional();\ntype RangeConfigItemSchemaType = z.infer<ReturnType<typeof RangeConfigItemSchema>>;\n\nconst RangeConfigItem = (data: Omit<RangeConfigItemDefType, \"type\">) => {\n return {\n def: RangeConfigItemDef.parse({\n type: RangeConfigItemTypeLiteral,\n ...data,\n }),\n schema: RangeConfigItemSchema(data.min, data.max, data.step, data.default),\n };\n};\n\nexport {\n RangeConfigItem,\n RangeConfigItemDef,\n RangeConfigItemSchema,\n RangeConfigItemTypeLiteral,\n type RangeConfigItemDefType,\n type RangeConfigItemSchemaType,\n};\n","import { z } from \"zod\";\n\nconst SelectStringConfigItemTypeLiteral = \"select-string\" as const;\n\nconst SelectStringConfigItemDef = z.object({\n type: z.literal(SelectStringConfigItemTypeLiteral),\n param: z.string().min(1),\n title: z.string().min(1),\n description: z.string().min(1).max(500),\n default: z.string().min(1), // TODO: should be optional, not choosing any value from choices is also a valid choice. Eg. Anthropic embeddings input_type, truncation, encoding_format\n choices: z.array(z.string().min(1)),\n});\ntype SelectStringConfigItemDefType = z.infer<typeof SelectStringConfigItemDef>;\n\nconst SelectStringConfigItemSchema = (defaultValue: string, choices: string[]) =>\n z\n .enum(choices as [string, ...string[]])\n .default(defaultValue)\n .optional();\ntype SelectStringConfigItemSchemaType = z.infer<ReturnType<typeof SelectStringConfigItemSchema>>;\n\nconst SelectStringConfigItem = (data: Omit<SelectStringConfigItemDefType, \"type\">) => {\n return {\n def: SelectStringConfigItemDef.parse({\n type: SelectStringConfigItemTypeLiteral,\n ...data,\n }),\n schema: SelectStringConfigItemSchema(data.default, data.choices),\n };\n};\n\nexport {\n SelectStringConfigItem,\n SelectStringConfigItemDef,\n SelectStringConfigItemSchema,\n SelectStringConfigItemTypeLiteral,\n type SelectStringConfigItemDefType,\n type SelectStringConfigItemSchemaType,\n};\n","import { z } from \"zod\";\n\nconst ObjectSchemaConfigItemTypeLiteral = \"object-schema\" as const;\n\nconst ObjectSchemaConfigItemDef = z.object({\n type: z.literal(ObjectSchemaConfigItemTypeLiteral),\n param: z.string().min(1),\n title: z.string().min(1),\n description: z.string().min(1).max(500),\n objectSchema: z.any(),\n});\ntype ObjectSchemaConfigItemType = z.infer<typeof ObjectSchemaConfigItemDef>;\n\nconst ObjectSchemaConfigItemSchema = <S extends z.ZodRawShape>(schema: z.ZodObject<S>) => schema;\ntype ObjectSchemaConfigItemSchemaType<S extends z.ZodRawShape = z.ZodRawShape> = z.infer<ReturnType<typeof ObjectSchemaConfigItemSchema<S>>>;\n\nconst ObjectSchemaConfigItem = (data: Omit<ObjectSchemaConfigItemType, \"type\">) => {\n return {\n def: ObjectSchemaConfigItemDef.parse({\n type: ObjectSchemaConfigItemTypeLiteral,\n ...data,\n }),\n schema: ObjectSchemaConfigItemSchema(data.objectSchema),\n };\n};\n\nexport {\n ObjectSchemaConfigItem,\n ObjectSchemaConfigItemDef,\n ObjectSchemaConfigItemSchema,\n ObjectSchemaConfigItemTypeLiteral,\n type ObjectSchemaConfigItemType,\n type ObjectSchemaConfigItemSchemaType,\n};","import { z } from \"zod\";\n\nconst SelectBooleanConfigItemTypeLiteral = \"select-boolean\" as const;\n\nconst SelectBooleanConfigItemDef = z.object({\n type: z.literal(SelectBooleanConfigItemTypeLiteral),\n param: z.string().min(1),\n title: z.string().min(1),\n description: z.string().min(1).max(500),\n default: z.boolean().nullable(),\n});\ntype SelectBooleanConfigItemDefType = z.infer<typeof SelectBooleanConfigItemDef>;\n\nconst SelectBooleanConfigItemSchema = (defaultValue: boolean | null) =>\n z\n .boolean()\n .nullable()\n .default(defaultValue) \n .optional();\ntype SelectBooleanConfigItemSchemaType = z.infer<ReturnType<typeof SelectBooleanConfigItemSchema>>;\n\nconst SelectBooleanConfigItem = (data: Omit<SelectBooleanConfigItemDefType, \"type\">) => {\n return {\n def: SelectBooleanConfigItemDef.parse({\n type: SelectBooleanConfigItemTypeLiteral,\n ...data,\n }),\n schema: SelectBooleanConfigItemSchema(data.default),\n };\n};\n\nexport {\n SelectBooleanConfigItem,\n SelectBooleanConfigItemDef,\n SelectBooleanConfigItemSchema,\n SelectBooleanConfigItemTypeLiteral,\n type SelectBooleanConfigItemDefType,\n type SelectBooleanConfigItemSchemaType,\n};\n","import { z } from \"zod\";\n\nimport { MultiStringConfigItemDef, MultiStringConfigItemTypeLiteral } from \"./multi-string-config-item\";\nimport { RangeConfigItemDef, RangeConfigItemTypeLiteral } from \"./range-config-item\";\nimport { SelectStringConfigItemDef, SelectStringConfigItemTypeLiteral } from \"./select-string-config-item\";\nimport { ObjectSchemaConfigItemDef, ObjectSchemaConfigItemTypeLiteral } from \"./object-schema-config-item\";\nimport { SelectBooleanConfigItemDef, SelectBooleanConfigItemTypeLiteral } from \"./select-boolean-config-item\";\n\nconst ConfigItemLiterals = [\n RangeConfigItemTypeLiteral, \n MultiStringConfigItemTypeLiteral, \n SelectStringConfigItemTypeLiteral,\n ObjectSchemaConfigItemTypeLiteral,\n SelectBooleanConfigItemTypeLiteral,\n] as const;\nconst ConfigItemEnum = z.enum(ConfigItemLiterals);\ntype ConfigItemEnumType = z.infer<typeof ConfigItemEnum>;\n\nconst ConfigItemDef = z.discriminatedUnion(\"type\", [\n RangeConfigItemDef, \n MultiStringConfigItemDef, \n SelectStringConfigItemDef,\n SelectBooleanConfigItemDef,\n ObjectSchemaConfigItemDef,\n]);\ntype ConfigItemDefType = z.infer<typeof ConfigItemDef>;\n\nexport { ConfigItemDef, ConfigItemEnum, ConfigItemLiterals, type ConfigItemDefType, type ConfigItemEnumType };\n","import { z } from \"zod\";\n\nimport { ModalityEnum, RoleEnum } from \"@adaline/types\";\n\nimport { ConfigItemDef } from \"../../types/config\";\n\nconst ChatModelSchema = <\n R extends z.ZodEnum<[string, ...string[]]> = typeof RoleEnum,\n M extends z.ZodEnum<[string, ...string[]]> = typeof ModalityEnum\n>(\n Roles: R = RoleEnum as unknown as R, \n Modalities: M = ModalityEnum as unknown as M\n) =>\n z.object({\n name: z.string().min(1),\n description: z.string().min(1),\n roles: z.record(Roles, z.string().min(1).optional()),\n modalities: z.array(Modalities).nonempty(),\n maxInputTokens: z.number().int().positive().min(1),\n maxOutputTokens: z.number().int().positive().min(1),\n config: z\n .object({\n def: z.record(z.string().min(1), ConfigItemDef),\n schema: z.instanceof(z.ZodObject),\n })\n .refine(\n (config) => {\n const defKeys = Object.keys(config.def);\n const schemaKeys = Object.keys(config.schema?.shape ?? {});\n return defKeys.every((key) => schemaKeys.includes(key)) && schemaKeys.every((key) => defKeys.includes(key));\n },\n {\n message: \"Keys in 'config.def' must exactly match keys in 'config.schema'\",\n }\n ),\n });\ntype ChatModelSchemaType<\n R extends z.ZodEnum<[string, ...string[]]> = typeof RoleEnum,\n M extends z.ZodEnum<[string, ...string[]]> = typeof ModalityEnum\n> = z.infer<ReturnType<typeof ChatModelSchema<R, M>>>;\n\nexport { \n ChatModelSchema, \n type ChatModelSchemaType \n};\n","import { z } from \"zod\";\n\nimport { EmbeddingModalityEnum } from \"@adaline/types\";\n\nimport { ConfigItemDef } from \"../../types/config\";\n\n// TODO: add embedding model properties (dimensions, etc)\nconst EmbeddingModelSchema = <\n M extends z.ZodEnum<[string, ...string[]]> = typeof EmbeddingModalityEnum,\n>(\n Modalities: M = EmbeddingModalityEnum as unknown as M\n) => z.object({\n name: z.string().min(1),\n description: z.string().min(1),\n modalities: z.array(Modalities).nonempty(),\n maxInputTokens: z.number().int().positive().min(1), // TODO: rename property\n maxOutputTokens: z.number().int().positive().min(1), // TODO: rename property\n config: z\n .object({\n def: z.record(z.string().min(1), ConfigItemDef),\n schema: z.instanceof(z.ZodObject),\n })\n .refine(\n (config) => {\n const defKeys = Object.keys(config.def);\n const schemaKeys = Object.keys(config.schema?.shape ?? {});\n return defKeys.every((key) => schemaKeys.includes(key)) && schemaKeys.every((key) => defKeys.includes(key));\n },\n {\n message: \"Keys in 'config.def' must exactly match keys in 'config.schema'\",\n }\n ),\n});\ntype EmbeddingModelSchemaType<\n M extends z.ZodEnum<[string, ...string[]]> = typeof EmbeddingModalityEnum,\n> = z.infer<ReturnType<typeof EmbeddingModelSchema<M>>>;\n\nexport { \n EmbeddingModelSchema, \n type EmbeddingModelSchemaType \n};\n","import { z } from \"zod\";\n\nconst Headers = z.record(z.string());\ntype HeadersType = z.infer<typeof Headers>;\n\nexport { Headers, type HeadersType };\n","import { z } from \"zod\";\n\nconst Params = z.record(z.union([\n z.boolean(),\n z.string(), \n z.number(), \n z.object({}),\n z.array(z.any()), // TODO: any or undefined?\n z.null(), \n z.undefined(), \n]));\ntype ParamsType = z.infer<typeof Params>;\n\nexport { Params, type ParamsType };\n","import { z } from \"zod\";\n\nconst Url = z.string().url();\ntype UrlType = z.infer<typeof Url>;\n\nexport { Url, type UrlType };\n","// TODO: add a schema for common config items\nconst TEMPERATURE = {\n type: \"range\",\n title: \"Temperature\",\n description:\n \"Adjusts the model's creativity level. With a setting of 0, the model strictly picks the most probable next word. For endeavors that benefit from a dash of inventiveness, consider dialing it up to 0.7 or higher, enabling the model to produce text that's unexpectedly fresh.\",\n} as const;\n\nconst MAX_TOKENS = {\n type: \"range\",\n title: \"Max tokens\",\n description:\n \"Specify the total tokens for generation, where one token approximates four English characters. Setting this to 0 defaults to the model's maximum capacity.\",\n} as const;\n\nconst STOP = (max: number) =>\n ({\n type: \"multi\",\n title: \"Stop sequence\",\n description: `Enter up to ${max} sequences that will halt additional text output. The generated text will exclude these sequences.`,\n }) as const;\n\nconst TOP_P = {\n type: \"range\",\n title: \"Top P\",\n description:\n \"Selects a subset of likely tokens for generation, restricting choices to the top-P fraction of possibilities, such as the top 10% when P=0.1. This approach can limit the variety of the output. By default, it's set to 1, indicating no restriction. It's advised to adjust this parameter or temperature to modulate output diversity, but not to modify both simultaneously.\",\n} as const;\n\nconst TOP_K = {\n type: \"range\",\n title: \"Top K\",\n description:\n \"Select only from the highest K probabilities for each following word, effectively eliminating the less likely 'long tail' options.\",\n} as const;\n\nconst FREQUENCY_PENALTY = {\n type: \"range\",\n title: \"Frequency penalty\",\n description:\n \"Minimize redundancy. By assigning a penalty to frequently used tokens within the text, the likelihood of repeating identical phrases is reduced. The default setting for this penalty is zero.\",\n} as const;\n\nconst PRESENCE_PENALTY = {\n type: \"range\",\n title: \"Presence penalty\",\n description:\n \"Enhance the introduction of novel subjects by reducing the preference for tokens that have already appeared in the text, thus boosting the chances of exploring fresh topics. The standard setting for this is zero.\",\n} as const;\n\n\n\nconst CONFIG = {\n TEMPERATURE,\n MAX_TOKENS,\n STOP,\n TOP_P,\n TOP_K,\n FREQUENCY_PENALTY,\n PRESENCE_PENALTY,\n};\n\nexport { CONFIG };\n","const getErrorMessage = (error: unknown | undefined): string => {\n if (error == null) return \"unknown error\";\n if (typeof error === \"string\") return error;\n if (error instanceof Error) return error.message;\n return JSON.stringify(error);\n};\n\nexport { getErrorMessage };\n","const removeUndefinedEntries = <T = unknown>(record: Record<string, T | undefined>): Record<string, T> => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n return Object.fromEntries(Object.entries(record).filter(([_, value]) => value != null)) as Record<string, T>;\n};\n\nexport { removeUndefinedEntries };\n","const isRunningInBrowser = () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return typeof window !== \"undefined\" && typeof window.document !== \"undefined\" && typeof navigator !== \"undefined\";\n};\n\nexport { isRunningInBrowser };\n","import { isRunningInBrowser } from \"./is-running-in-browser\";\n\nconst convertBase64ToUint8Array = (base64String: string): Uint8Array => {\n const base64Url = base64String.replace(/-/g, \"+\").replace(/_/g, \"/\");\n const latin1string = globalThis.atob(base64Url);\n return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0)!);\n};\n\nconst convertUint8ArrayToBase64 = (array: Uint8Array): string => {\n let latin1string = \"\";\n\n // Note: regular for loop to support older JavaScript versions that\n // do not support for..of on Uint8Array\n for (let i = 0; i < array.length; i++) {\n latin1string += String.fromCodePoint(array[i]);\n }\n\n return globalThis.btoa(latin1string);\n};\n\nconst encodedBase64ToString = (base64: string): string => {\n if (isRunningInBrowser()) {\n const binaryString = atob(base64);\n const bytes = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) { bytes[i] = binaryString.charCodeAt(i); }\n const decoder = new TextDecoder(\"utf-8\");\n return decoder.decode(bytes);\n } else {\n return Buffer.from(base64, \"base64\").toString(\"utf-8\");\n }\n}\n\nconst getMimeTypeFromBase64 = (base64: string): string => {\n const mimeTypePrefix = base64.split(\";\")[0];\n const mimeType = mimeTypePrefix.split(\"/\")[1];\n return mimeType;\n}\n\nexport { convertBase64ToUint8Array, convertUint8ArrayToBase64, encodedBase64ToString, getMimeTypeFromBase64 };\n","const urlWithoutTrailingSlash = (url: string): string => {\n return url?.replace(/\\/$/, \"\");\n};\n\nexport { urlWithoutTrailingSlash };\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaline/provider",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "private": false,
@@ -46,7 +46,7 @@
46
46
  ],
47
47
  "dependencies": {
48
48
  "zod": "^3.23.8",
49
- "@adaline/types": "0.7.0"
49
+ "@adaline/types": "0.8.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@adaline/tsconfig": "0.6.0",