@adaline/bedrock 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/README.md CHANGED
@@ -5,5 +5,3 @@
5
5
  ![ESLint](https://img.shields.io/badge/ESLint-passing-brightgreen.svg)
6
6
  ![NPM](https://img.shields.io/npm/l/@adaline/bedrock)
7
7
  [![NPM version](https://img.shields.io/npm/v/@adaline/bedrock.svg)](https://npmjs.org/package/@adaline/bedrock)
8
-
9
- ##
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { ProviderV1, ChatModelV1, ChatModelSchemaType, EmbeddingModelV1, EmbeddingModelSchemaType, UrlType, HeadersType, ParamsType } from '@adaline/provider';
1
+ import { ProviderV1, ChatModelSchemaType, ChatModelV1, EmbeddingModelSchemaType, EmbeddingModelV1, UrlType, HeadersType, ParamsType } from '@adaline/provider';
2
2
  import { z } from 'zod';
3
- import { ConfigType, MessageType, ToolType, PartialChatResponseType } from '@adaline/types';
4
3
  import { BaseChatModel } from '@adaline/anthropic';
4
+ import { ConfigType, MessageType, ToolType, PartialChatResponseType } from '@adaline/types';
5
5
 
6
6
  declare class Bedrock<O extends Record<string, any> = Record<string, any>> implements ProviderV1<O> {
7
7
  readonly version: "v1";
@@ -11,24 +11,25 @@ declare class Bedrock<O extends Record<string, any> = Record<string, any>> imple
11
11
  private readonly chatModelFactories;
12
12
  private readonly embeddingModelFactories;
13
13
  chatModelLiterals(): string[];
14
- chatModel(name: string, options: O): ChatModelV1;
15
- chatModelSchema(name: string): ChatModelSchemaType;
16
14
  chatModelSchemas(): Record<string, ChatModelSchemaType>;
15
+ chatModel(options: O): ChatModelV1;
17
16
  embeddingModelLiterals(): string[];
18
- embeddingModel(name: string, options: O): EmbeddingModelV1;
19
- embeddingModelSchema(name: string): EmbeddingModelSchemaType;
20
17
  embeddingModelSchemas(): Record<string, EmbeddingModelSchemaType>;
18
+ embeddingModel(options: O): EmbeddingModelV1;
21
19
  }
22
20
 
23
21
  declare const BaseChatModelAnthropicOptions: z.ZodObject<{
22
+ modelName: z.ZodString;
24
23
  awsRegion: z.ZodString;
25
24
  awsAccessKeyId: z.ZodString;
26
25
  awsSecretAccessKey: z.ZodString;
27
26
  }, "strip", z.ZodTypeAny, {
27
+ modelName: string;
28
28
  awsRegion: string;
29
29
  awsAccessKeyId: string;
30
30
  awsSecretAccessKey: string;
31
31
  }, {
32
+ modelName: string;
32
33
  awsRegion: string;
33
34
  awsAccessKeyId: string;
34
35
  awsSecretAccessKey: string;
@@ -37,6 +38,7 @@ type BaseChatModelAnthropicOptionsType = z.infer<typeof BaseChatModelAnthropicOp
37
38
  declare class BaseChatModelAnthropic extends BaseChatModel {
38
39
  readonly version: "v1";
39
40
  modelSchema: ChatModelSchemaType;
41
+ modelName: string;
40
42
  private readonly awsUrl;
41
43
  private readonly awsService;
42
44
  private readonly awsRegion;
@@ -73,46 +75,49 @@ declare const BedrockClaude3Haiku20240307Schema: {
73
75
  description: string;
74
76
  max: number;
75
77
  } | {
76
- type: "range";
78
+ type: "object-schema";
77
79
  param: string;
78
80
  title: string;
79
81
  description: string;
80
- max: number;
81
- min: number;
82
- step: number;
83
- default: number;
82
+ objectSchema?: any;
84
83
  } | {
85
- type: "select-string";
84
+ type: "range";
86
85
  param: string;
87
86
  title: string;
88
87
  description: string;
89
- default: string | null;
90
- choices: string[];
88
+ max: number;
89
+ default: number;
90
+ min: number;
91
+ step: number;
91
92
  } | {
92
- type: "object-schema";
93
+ type: "select-boolean";
93
94
  param: string;
94
95
  title: string;
95
96
  description: string;
96
- objectSchema?: any;
97
+ default: boolean | null;
97
98
  } | {
98
- type: "select-boolean";
99
+ type: "select-string";
99
100
  param: string;
100
101
  title: string;
101
102
  description: string;
102
- default: boolean | null;
103
+ default: string | null;
104
+ choices: string[];
103
105
  }>;
104
106
  schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
105
107
  };
106
108
  };
107
109
  declare const BedrockClaude3Haiku20240307Options: z.ZodObject<{
110
+ modelName: z.ZodString;
108
111
  awsRegion: z.ZodString;
109
112
  awsAccessKeyId: z.ZodString;
110
113
  awsSecretAccessKey: z.ZodString;
111
114
  }, "strip", z.ZodTypeAny, {
115
+ modelName: string;
112
116
  awsRegion: string;
113
117
  awsAccessKeyId: string;
114
118
  awsSecretAccessKey: string;
115
119
  }, {
120
+ modelName: string;
116
121
  awsRegion: string;
117
122
  awsAccessKeyId: string;
118
123
  awsSecretAccessKey: string;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { ProviderV1, ChatModelV1, ChatModelSchemaType, EmbeddingModelV1, EmbeddingModelSchemaType, UrlType, HeadersType, ParamsType } from '@adaline/provider';
1
+ import { ProviderV1, ChatModelSchemaType, ChatModelV1, EmbeddingModelSchemaType, EmbeddingModelV1, UrlType, HeadersType, ParamsType } from '@adaline/provider';
2
2
  import { z } from 'zod';
3
- import { ConfigType, MessageType, ToolType, PartialChatResponseType } from '@adaline/types';
4
3
  import { BaseChatModel } from '@adaline/anthropic';
4
+ import { ConfigType, MessageType, ToolType, PartialChatResponseType } from '@adaline/types';
5
5
 
6
6
  declare class Bedrock<O extends Record<string, any> = Record<string, any>> implements ProviderV1<O> {
7
7
  readonly version: "v1";
@@ -11,24 +11,25 @@ declare class Bedrock<O extends Record<string, any> = Record<string, any>> imple
11
11
  private readonly chatModelFactories;
12
12
  private readonly embeddingModelFactories;
13
13
  chatModelLiterals(): string[];
14
- chatModel(name: string, options: O): ChatModelV1;
15
- chatModelSchema(name: string): ChatModelSchemaType;
16
14
  chatModelSchemas(): Record<string, ChatModelSchemaType>;
15
+ chatModel(options: O): ChatModelV1;
17
16
  embeddingModelLiterals(): string[];
18
- embeddingModel(name: string, options: O): EmbeddingModelV1;
19
- embeddingModelSchema(name: string): EmbeddingModelSchemaType;
20
17
  embeddingModelSchemas(): Record<string, EmbeddingModelSchemaType>;
18
+ embeddingModel(options: O): EmbeddingModelV1;
21
19
  }
22
20
 
23
21
  declare const BaseChatModelAnthropicOptions: z.ZodObject<{
22
+ modelName: z.ZodString;
24
23
  awsRegion: z.ZodString;
25
24
  awsAccessKeyId: z.ZodString;
26
25
  awsSecretAccessKey: z.ZodString;
27
26
  }, "strip", z.ZodTypeAny, {
27
+ modelName: string;
28
28
  awsRegion: string;
29
29
  awsAccessKeyId: string;
30
30
  awsSecretAccessKey: string;
31
31
  }, {
32
+ modelName: string;
32
33
  awsRegion: string;
33
34
  awsAccessKeyId: string;
34
35
  awsSecretAccessKey: string;
@@ -37,6 +38,7 @@ type BaseChatModelAnthropicOptionsType = z.infer<typeof BaseChatModelAnthropicOp
37
38
  declare class BaseChatModelAnthropic extends BaseChatModel {
38
39
  readonly version: "v1";
39
40
  modelSchema: ChatModelSchemaType;
41
+ modelName: string;
40
42
  private readonly awsUrl;
41
43
  private readonly awsService;
42
44
  private readonly awsRegion;
@@ -73,46 +75,49 @@ declare const BedrockClaude3Haiku20240307Schema: {
73
75
  description: string;
74
76
  max: number;
75
77
  } | {
76
- type: "range";
78
+ type: "object-schema";
77
79
  param: string;
78
80
  title: string;
79
81
  description: string;
80
- max: number;
81
- min: number;
82
- step: number;
83
- default: number;
82
+ objectSchema?: any;
84
83
  } | {
85
- type: "select-string";
84
+ type: "range";
86
85
  param: string;
87
86
  title: string;
88
87
  description: string;
89
- default: string | null;
90
- choices: string[];
88
+ max: number;
89
+ default: number;
90
+ min: number;
91
+ step: number;
91
92
  } | {
92
- type: "object-schema";
93
+ type: "select-boolean";
93
94
  param: string;
94
95
  title: string;
95
96
  description: string;
96
- objectSchema?: any;
97
+ default: boolean | null;
97
98
  } | {
98
- type: "select-boolean";
99
+ type: "select-string";
99
100
  param: string;
100
101
  title: string;
101
102
  description: string;
102
- default: boolean | null;
103
+ default: string | null;
104
+ choices: string[];
103
105
  }>;
104
106
  schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
105
107
  };
106
108
  };
107
109
  declare const BedrockClaude3Haiku20240307Options: z.ZodObject<{
110
+ modelName: z.ZodString;
108
111
  awsRegion: z.ZodString;
109
112
  awsAccessKeyId: z.ZodString;
110
113
  awsSecretAccessKey: z.ZodString;
111
114
  }, "strip", z.ZodTypeAny, {
115
+ modelName: string;
112
116
  awsRegion: string;
113
117
  awsAccessKeyId: string;
114
118
  awsSecretAccessKey: string;
115
119
  }, {
120
+ modelName: string;
116
121
  awsRegion: string;
117
122
  awsAccessKeyId: string;
118
123
  awsSecretAccessKey: string;
package/dist/index.js CHANGED
@@ -5,31 +5,27 @@ var sha256Js = require('@aws-crypto/sha256-js');
5
5
  var protocolHttp = require('@smithy/protocol-http');
6
6
  var signatureV4 = require('@smithy/signature-v4');
7
7
 
8
- var Mo=Object.defineProperty;var xe=Object.getOwnPropertySymbols,Eo=Object.getPrototypeOf,Po=Object.prototype.hasOwnProperty,Io=Object.prototype.propertyIsEnumerable,Ro=Reflect.get;var _o=(t,o)=>(o=Symbol[t])?o:Symbol.for("Symbol."+t);var ke=(t,o,a)=>o in t?Mo(t,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[o]=a,k=(t,o)=>{for(var a in o||(o={}))Po.call(o,a)&&ke(t,a,o[a]);if(xe)for(var a of xe(o))Io.call(o,a)&&ke(t,a,o[a]);return t};var Y=(t,o,a)=>Ro(Eo(t),a,o);var _=(t,o,a)=>new Promise((i,r)=>{var s=c=>{try{d(a.next(c));}catch(u){r(u);}},l=c=>{try{d(a.throw(c));}catch(u){r(u);}},d=c=>c.done?i(c.value):Promise.resolve(c.value).then(s,l);d((a=a.apply(t,o)).next());}),re=function(t,o){this[0]=t,this[1]=o;},je=(t,o,a)=>{var i=(l,d,c,u)=>{try{var h=a[l](d),g=(d=h.value)instanceof re,C=h.done;Promise.resolve(g?d[0]:d).then(p=>g?i(l==="return"?l:"next",d[1]?{done:p.done,value:p.value}:p,c,u):c({value:p,done:C})).catch(p=>i("throw",p,c,u));}catch(p){u(p);}},r=l=>s[l]=d=>new Promise((c,u)=>i(l,d,c,u)),s={};return a=a.apply(t,o),s[_o("asyncIterator")]=()=>s,r("next"),r("throw"),r("return"),s};var Ao=t=>{let o=new WeakSet;return JSON.stringify(t,(a,i)=>{if(typeof i=="object"&&i!==null){if(o.has(i))return;o.add(i);}return i})},$o=t=>t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:Ao(t),le="GatewayBaseError",de=class Pe extends Error{constructor({info:o,cause:a},i){super(`[${i!=null?i:le}]: ${o}
9
- Message: ${$o(a)}`),this.name=le,this.info=o,this.cause=a,this.name=i!=null?i:le,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(o){return o instanceof Pe}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},Lo="system",qo="user",Ie="assistant",Uo="tool",Fo=[Lo,qo,Ie,Uo],me=zod.z.enum(Fo),Bo=[Ie],No=zod.z.enum(Bo),Re="image",Do="base64",Ko=["png","jpeg","webp","gif"],Ho=zod.z.object({type:zod.z.literal(Do),base64:zod.z.string(),media_type:zod.z.enum(Ko)}),Vo="url",zo=zod.z.object({type:zod.z.literal(Vo),url:zod.z.string()}),Jo=zod.z.discriminatedUnion("type",[Ho,zo]),Go=["low","medium","high","auto"],Wo=zod.z.enum(Go),Zo=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Re),detail:Wo,value:Jo,metadata:t}),_e="text",Yo=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(_e),value:zod.z.string(),metadata:t}),Ae="partial-text",Qo=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Ae),value:zod.z.string(),metadata:t}),$e="tool-call",Xo=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal($e),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),arguments:zod.z.string(),metadata:t}),Le="partial-tool-call",ea=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Le),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),arguments:zod.z.string().optional(),metadata:t}),qe="tool-response",ta=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(qe),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),data:zod.z.string(),metadata:t}),oa=[_e,Re,$e,qe],Ue=zod.z.enum(oa),aa=(t=zod.z.undefined(),o=zod.z.undefined(),a=zod.z.undefined(),i=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[Yo(t),Zo(o),Xo(a),ta(i)]),na=[Ae,Le];zod.z.enum(na);var ia=(t=zod.z.undefined(),o=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[Qo(t),ea(o)]);var sa=(t=me,o=zod.z.undefined(),a=zod.z.undefined(),i=zod.z.undefined(),r=zod.z.undefined(),s=zod.z.undefined())=>zod.z.object({role:t,content:zod.z.array(aa(o,a,i,r)),metadata:s}),ra=(t=No,o=zod.z.undefined(),a=zod.z.undefined(),i=zod.z.undefined())=>zod.z.object({role:t,partialContent:ia(o,a),metadata:i});var la=["object","array","number","string","boolean","enum"],Oe=zod.z.enum(la),da=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([Oe,zod.z.array(zod.z.union([Oe,zod.z.literal("null")]))]).optional(),default:zod.z.any().optional(),title:zod.z.string().optional(),description:zod.z.string().max(4096).optional(),properties:zod.z.record(zod.z.any()).optional(),required:zod.z.array(zod.z.string()).optional(),minItems:zod.z.number().int().min(0).optional(),maxItems:zod.z.number().int().optional(),items:zod.z.record(zod.z.any()).optional(),enum:zod.z.array(zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()])).optional(),minimum:zod.z.number().optional(),maximum:zod.z.number().optional(),minLength:zod.z.number().int().min(0).optional(),maxLength:zod.z.number().int().optional(),$ref:zod.z.string().optional()}),ma=zod.z.object({type:zod.z.enum(["object"]),required:zod.z.array(zod.z.string()),$defs:zod.z.record(zod.z.any()).optional(),properties:zod.z.record(da),additionalProperties:zod.z.literal(!1)});zod.z.object({name:zod.z.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:zod.z.string().max(4096),strict:zod.z.boolean().optional(),schema:ma}).optional();var ca="function";var ua=zod.z.enum(["object","array","number","string","boolean","null"]),pa=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:ua.optional(),default:zod.z.any().optional(),title:zod.z.string().optional(),description:zod.z.string().max(4096).optional(),properties:zod.z.record(zod.z.any()).optional(),required:zod.z.array(zod.z.string()).optional(),minItems:zod.z.number().int().min(0).optional(),maxItems:zod.z.number().int().optional(),items:zod.z.record(zod.z.any()).optional(),enum:zod.z.array(zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()])).optional(),minimum:zod.z.number().optional(),maximum:zod.z.number().optional(),minLength:zod.z.number().int().min(0).optional(),maxLength:zod.z.number().int().optional()});zod.z.object({type:zod.z.enum(["object"]),title:zod.z.string().optional(),$defs:zod.z.record(zod.z.any()).optional(),properties:zod.z.record(pa).optional(),required:zod.z.array(zod.z.string()).optional()});var ha=zod.z.object({name:zod.z.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:zod.z.string().max(4096),parameters:zod.z.any(),strict:zod.z.boolean().optional()});var ga=zod.z.enum(["function"]);zod.z.object({type:ga,definition:zod.z.object({schema:ha})});var fa=[ca];zod.z.enum(fa);var ya="text",ba="token",va=[ya,ba];zod.z.enum(va);zod.z.array(zod.z.string().min(1));zod.z.array(zod.z.array(zod.z.number().int().nonnegative()));var Sa="float",Ca=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),Ta="base64",xa=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.string().base64()}),Me=zod.z.object({totalTokens:zod.z.number().int().nonnegative()});zod.z.discriminatedUnion("encodingFormat",[zod.z.object({encodingFormat:zod.z.literal(Sa),embeddings:zod.z.array(Ca),usage:Me.optional()}),zod.z.object({encodingFormat:zod.z.literal(Ta),embeddings:zod.z.array(xa),usage:Me.optional()})]);var Fe=zod.z.object({promptTokens:zod.z.number().nonnegative(),completionTokens:zod.z.number().nonnegative(),totalTokens:zod.z.number().nonnegative()}),Ee=zod.z.object({token:zod.z.string(),logProb:zod.z.number(),bytes:zod.z.array(zod.z.number().int()).nullable()}),ka=Ee.extend({topLogProbs:zod.z.array(Ee)}),Be=zod.z.array(ka);zod.z.object({messages:zod.z.array(sa()),usage:Fe.optional(),logProbs:Be.optional()});zod.z.object({partialMessages:zod.z.array(ra()),usage:Fe.optional(),logProbs:Be.optional()});var Ne="ProviderError",z=class Ke extends de{constructor({info:o,cause:a}){super({info:o,cause:a},Ne),this.name=Ne,this.info=o,this.cause=a;}static isProviderError(o){return o instanceof Ke}};var De="ModelResponseError",He=class Ve extends de{constructor({info:o,cause:a}){super({info:o,cause:a},De),this.name=De,this.cause=a,this.info=o;}static isModelResponseError(o){return o instanceof Ve}};var ze="multi-string",ja=zod.z.object({type:zod.z.literal(ze),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()});var Je="range",Oa=zod.z.object({type:zod.z.literal(Je),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()});var Ge="select-string",Ma=zod.z.object({type:zod.z.literal(Ge),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).nullable(),choices:zod.z.array(zod.z.string().min(1))});var We="object-schema",Ea=zod.z.object({type:zod.z.literal(We),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),objectSchema:zod.z.any()});var Ze="select-boolean",Pa=zod.z.object({type:zod.z.literal(Ze),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()});var Ia=[Je,ze,Ge,We,Ze];zod.z.enum(Ia);var Ra=zod.z.discriminatedUnion("type",[Oa,ja,Ma,Pa,Ea]),Ye=(t=me,o=Ue)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(t,zod.z.string().min(1).optional()),modalities:zod.z.array(o).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),Ra),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(a=>{var i,r;let s=Object.keys(a.def),l=Object.keys((r=(i=a.schema)==null?void 0:i.shape)!=null?r:{});return s.every(d=>l.includes(d))&&l.every(d=>s.includes(d))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})});zod.z.record(zod.z.string());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()]));zod.z.string().url();var _a=()=>typeof window!="undefined"&&typeof window.document!="undefined"&&typeof navigator!="undefined";var Qe=t=>{if(_a()){let o=atob(t),a=new Uint8Array(o.length);for(let i=0;i<o.length;i++)a[i]=o.charCodeAt(i);return new TextDecoder("utf-8").decode(a)}else return Buffer.from(t,"base64").toString("utf-8")};var Aa=Object.defineProperty,$a=Object.defineProperties,La=Object.getOwnPropertyDescriptors,Xe=Object.getOwnPropertySymbols,qa=Object.prototype.hasOwnProperty,Ua=Object.prototype.propertyIsEnumerable,Fa=(t,o)=>(o=Symbol[t])?o:Symbol.for("Symbol."+t),et=(t,o,a)=>o in t?Aa(t,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[o]=a,f=(t,o)=>{for(var a in o||(o={}))qa.call(o,a)&&et(t,a,o[a]);if(Xe)for(var a of Xe(o))Ua.call(o,a)&&et(t,a,o[a]);return t},tt=(t,o)=>$a(t,La(o)),O=(t,o,a)=>new Promise((i,r)=>{var s=c=>{try{d(a.next(c));}catch(u){r(u);}},l=c=>{try{d(a.throw(c));}catch(u){r(u);}},d=c=>c.done?i(c.value):Promise.resolve(c.value).then(s,l);d((a=a.apply(t,o)).next());}),Ba=function(t,o){this[0]=t,this[1]=o;},Na=(t,o,a)=>{var i=(l,d,c,u)=>{try{var h=a[l](d),g=(d=h.value)instanceof Ba,C=h.done;Promise.resolve(g?d[0]:d).then(p=>g?i(l==="return"?l:"next",d[1]?{done:p.done,value:p.value}:p,c,u):c({value:p,done:C})).catch(p=>i("throw",p,c,u));}catch(p){u(p);}},r=l=>s[l]=d=>new Promise((c,u)=>i(l,d,c,u)),s={};return a=a.apply(t,o),s[Fa("asyncIterator")]=()=>s,r("next"),r("throw"),r("return"),s},Da=t=>{let o=new WeakSet;return JSON.stringify(t,(a,i)=>{if(typeof i=="object"&&i!==null){if(o.has(i))return;o.add(i);}return i})},Ka=t=>t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:Da(t),ce="GatewayBaseError",P=class bt extends Error{constructor({info:o,cause:a},i){super(`[${i!=null?i:ce}]: ${o}
10
- Message: ${Ka(a)}`),this.name=ce,this.info=o,this.cause=a,this.name=i!=null?i:ce,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(o){return o instanceof bt}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},G="system",E="user",w="assistant",Ha="tool",Va=[G,E,w,Ha],vt=zod.z.enum(Va),za=[w],Ja=zod.z.enum(za),A="image",wt="base64",Ga=["png","jpeg","webp","gif"],Wa=zod.z.object({type:zod.z.literal(wt),base64:zod.z.string(),media_type:zod.z.enum(Ga)}),Za="url",Ya=zod.z.object({type:zod.z.literal(Za),url:zod.z.string()}),Qa=zod.z.discriminatedUnion("type",[Wa,Ya]),Xa=["low","medium","high","auto"],en=zod.z.enum(Xa),tn=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(A),detail:en,value:Qa,metadata:t}),y="text",St=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(y),value:zod.z.string(),metadata:t}),pe="partial-text",Ct=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(pe),value:zod.z.string(),metadata:t}),x="tool-call",Tt=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(x),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),arguments:zod.z.string(),metadata:t}),he="partial-tool-call",xt=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(he),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),arguments:zod.z.string().optional(),metadata:t}),$="tool-response",on=(t=zod.z.undefined())=>zod.z.object({modality:zod.z.literal($),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),data:zod.z.string(),metadata:t}),an=[y,A,x,$],nn=zod.z.enum(an),sn=(t=zod.z.undefined(),o=zod.z.undefined(),a=zod.z.undefined(),i=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[St(t),tn(o),Tt(a),on(i)]),rn=[pe,he];zod.z.enum(rn);var ln=(t=zod.z.undefined(),o=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[Ct(t),xt(o)]),kt=(t=vt,o=zod.z.undefined(),a=zod.z.undefined(),i=zod.z.undefined(),r=zod.z.undefined(),s=zod.z.undefined())=>zod.z.object({role:t,content:zod.z.array(sn(o,a,i,r)),metadata:s}),ge=(t=Ja,o=zod.z.undefined(),a=zod.z.undefined(),i=zod.z.undefined())=>zod.z.object({role:t,partialContent:ln(o,a),metadata:i}),dn=t=>St().parse({modality:y,value:t}),mn=(t,o,a,i)=>Tt().parse({modality:x,index:t,id:o,name:a,arguments:i}),ot=(t,o)=>ge().parse({role:t,partialContent:Ct().parse({modality:pe,value:o})}),at=(t,o,a,i,r)=>ge().parse({role:t,partialContent:xt().parse({modality:he,index:o,id:a,name:i,arguments:r})}),jt=(t=zod.z.record(zod.z.string(),zod.z.any()).optional())=>t,cn=["object","array","number","string","boolean","enum"],nt=zod.z.enum(cn),un=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([nt,zod.z.array(zod.z.union([nt,zod.z.literal("null")]))]).optional(),default:zod.z.any().optional(),title:zod.z.string().optional(),description:zod.z.string().max(4096).optional(),properties:zod.z.record(zod.z.any()).optional(),required:zod.z.array(zod.z.string()).optional(),minItems:zod.z.number().int().min(0).optional(),maxItems:zod.z.number().int().optional(),items:zod.z.record(zod.z.any()).optional(),enum:zod.z.array(zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()])).optional(),minimum:zod.z.number().optional(),maximum:zod.z.number().optional(),minLength:zod.z.number().int().min(0).optional(),maxLength:zod.z.number().int().optional(),$ref:zod.z.string().optional()}),pn=zod.z.object({type:zod.z.enum(["object"]),required:zod.z.array(zod.z.string()),$defs:zod.z.record(zod.z.any()).optional(),properties:zod.z.record(un),additionalProperties:zod.z.literal(!1)});zod.z.object({name:zod.z.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:zod.z.string().max(4096),strict:zod.z.boolean().optional(),schema:pn}).optional();var hn="function",gn=zod.z.enum(["object","array","number","string","boolean","null"]),fn=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:gn.optional(),default:zod.z.any().optional(),title:zod.z.string().optional(),description:zod.z.string().max(4096).optional(),properties:zod.z.record(zod.z.any()).optional(),required:zod.z.array(zod.z.string()).optional(),minItems:zod.z.number().int().min(0).optional(),maxItems:zod.z.number().int().optional(),items:zod.z.record(zod.z.any()).optional(),enum:zod.z.array(zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()])).optional(),minimum:zod.z.number().optional(),maximum:zod.z.number().optional(),minLength:zod.z.number().int().min(0).optional(),maxLength:zod.z.number().int().optional()});zod.z.object({type:zod.z.enum(["object"]),title:zod.z.string().optional(),$defs:zod.z.record(zod.z.any()).optional(),properties:zod.z.record(fn).optional(),required:zod.z.array(zod.z.string()).optional()});var yn=zod.z.object({name:zod.z.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:zod.z.string().max(4096),parameters:zod.z.any(),strict:zod.z.boolean().optional()}),bn=zod.z.enum(["function"]),vn=zod.z.object({type:bn,definition:zod.z.object({schema:yn})}),wn=[hn];zod.z.enum(wn);var Sn=(t=zod.z.undefined())=>zod.z.discriminatedUnion("type",[vn.extend({metadata:t})]),L="text",Ot="token",Cn=[L,Ot],Tn=zod.z.enum(Cn),xn=zod.z.array(zod.z.string().min(1)),kn=zod.z.array(zod.z.array(zod.z.number().int().nonnegative())),jn=(t=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[zod.z.object({modality:zod.z.literal(L),metadata:t,requests:xn}),zod.z.object({modality:zod.z.literal(Ot),metadata:t,requests:kn})]),Mt="float",On=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),Et="base64",Mn=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.string().base64()}),it=zod.z.object({totalTokens:zod.z.number().int().nonnegative()});zod.z.discriminatedUnion("encodingFormat",[zod.z.object({encodingFormat:zod.z.literal(Mt),embeddings:zod.z.array(On),usage:it.optional()}),zod.z.object({encodingFormat:zod.z.literal(Et),embeddings:zod.z.array(Mn),usage:it.optional()})]);var Pt=zod.z.object({promptTokens:zod.z.number().nonnegative(),completionTokens:zod.z.number().nonnegative(),totalTokens:zod.z.number().nonnegative()}),st=zod.z.object({token:zod.z.string(),logProb:zod.z.number(),bytes:zod.z.array(zod.z.number().int()).nullable()}),En=st.extend({topLogProbs:zod.z.array(st)}),It=zod.z.array(En);zod.z.object({messages:zod.z.array(kt()),usage:Pt.optional(),logProbs:It.optional()});zod.z.object({partialMessages:zod.z.array(ge()),usage:Pt.optional(),logProbs:It.optional()});var Pn=Object.defineProperty,rt=Object.getOwnPropertySymbols,In=Object.prototype.hasOwnProperty,Rn=Object.prototype.propertyIsEnumerable,lt=(t,o,a)=>o in t?Pn(t,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[o]=a,ee=(t,o)=>{for(var a in o||(o={}))In.call(o,a)&&lt(t,a,o[a]);if(rt)for(var a of rt(o))Rn.call(o,a)&&lt(t,a,o[a]);return t},dt="ProviderError",Q=class Rt extends P{constructor({info:o,cause:a}){super({info:o,cause:a},dt),this.name=dt,this.info=o,this.cause=a;}static isProviderError(o){return o instanceof Rt}},mt="ModelResponseError",j=class _t extends P{constructor({info:o,cause:a}){super({info:o,cause:a},mt),this.name=mt,this.cause=a,this.info=o;}static isModelResponseError(o){return o instanceof _t}},ct="InvalidModelRequestError",ue=class At extends P{constructor({info:o,cause:a}){super({info:o,cause:a},ct),this.name=ct,this.cause=a,this.info=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(o){return o instanceof At}},ut="InvalidConfigError",M=class $t extends P{constructor({info:o,cause:a}){super({info:o,cause:a},ut),this.name=ut,this.cause=a,this.info=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(o){return o instanceof $t}},pt="InvalidMessagesError",b=class Lt extends P{constructor({info:o,cause:a}){super({info:o,cause:a},pt),this.name=pt,this.cause=a,this.info=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(o){return o instanceof Lt}},ht="InvalidToolsError",gt=class qt extends P{constructor({info:o,cause:a}){super({info:o,cause:a},ht),this.name=ht,this.cause=a,this.info=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(o){return o instanceof qt}},ft="InvalidEmbeddingRequestsError",yt=class Ut extends P{constructor({info:o,cause:a}){super({info:o,cause:a},ft),this.name=ft,this.info=o,this.cause=a,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(o){return o instanceof Ut}},fe="multi-string",Ft=zod.z.object({type:zod.z.literal(fe),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()}),_n=t=>zod.z.array(zod.z.string()).max(t).default([]).optional(),An=t=>({def:Ft.parse(ee({type:fe},t)),schema:_n(t.max)}),ye="range",Bt=zod.z.object({type:zod.z.literal(ye),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()}),$n=(t,o,a,i)=>zod.z.number().min(t).max(o).step(a).default(i).optional(),te=t=>({def:Bt.parse(ee({type:ye},t)),schema:$n(t.min,t.max,t.step,t.default)}),be="select-string",Nt=zod.z.object({type:zod.z.literal(be),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).nullable(),choices:zod.z.array(zod.z.string().min(1))}),Ln=(t,o)=>zod.z.enum(o).nullable().default(t).optional(),ve=t=>({def:Nt.parse(ee({type:be},t)),schema:Ln(t.default,t.choices)}),Dt="object-schema",qn=zod.z.object({type:zod.z.literal(Dt),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),objectSchema:zod.z.any()}),we="select-boolean",Kt=zod.z.object({type:zod.z.literal(we),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()}),Un=t=>zod.z.boolean().nullable().default(t).optional(),Fn=t=>({def:Kt.parse(ee({type:we},t)),schema:Un(t.default)}),Bn=[ye,fe,be,Dt,we];zod.z.enum(Bn);var Ht=zod.z.discriminatedUnion("type",[Bt,Ft,Nt,Kt,qn]),oe=(t=vt,o=nn)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(t,zod.z.string().min(1).optional()),modalities:zod.z.array(o).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),Ht),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(a=>{var i,r;let s=Object.keys(a.def),l=Object.keys((r=(i=a.schema)==null?void 0:i.shape)!=null?r:{});return s.every(d=>l.includes(d))&&l.every(d=>s.includes(d))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})}),q=(t=Tn)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),modalities:zod.z.array(t).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),Ht),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(o=>{var a,i;let r=Object.keys(o.def),s=Object.keys((i=(a=o.schema)==null?void 0:a.shape)!=null?i:{});return r.every(l=>s.includes(l))&&s.every(l=>r.includes(l))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})});zod.z.record(zod.z.string());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()]));zod.z.string().url();var Nn={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."},Dn={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."},Kn=t=>({type:"multi",title:"Stop sequence",description:`Enter up to ${t} sequences that will halt additional text output. The generated text will exclude these sequences.`}),Hn={type:"range",title:"Top A",description:"Considers only the top tokens that have 'sufficiently high' probabilities relative to the most likely token, functioning like a dynamic Top-P. A lower Top-A value narrows down the token choices based on the highest probability token, while a higher Top-A value refines the filtering without necessarily impacting the creativity of the output."},Vn={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."},zn={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."},Jn={type:"range",title:"Min P",description:"Specifies the minimum probability a token must have to be considered, in relation to the probability of the most likely token. (This value varies based on the confidence level of the top token.) For example, if Min-P is set to 0.1, only tokens with at least 1/10th the probability of the highest-ranked token will be considered."},Gn={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."},Wn={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."},Zn={type:"range",title:"Seed",description:"When seed is fixed to a specific value, the model makes a best effort to provide the same response for repeated requests. Deterministic output isn't guaranteed. Also, changing the model or parameter settings, such as the temperature, can cause variations in the response even when you use the same seed value. By default, a random seed value is used."},Yn={type:"range",title:"Repetition penalty",description:"Reduces the likelihood of repeating tokens from the input. Increasing this value makes the model less prone to repetition, but setting it too high may lead to less coherent output, often resulting in run-on sentences missing smaller words. The token penalty is scaled according to the original token's probability."},Qn={type:"boolean",title:"Log probs",description:"Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned."},Xn={type:"range",title:"Top log probs",description:"The number of most likely tokens to return at each token position, each with an associated log probability. 'logprobs' must be set to true if this parameter is used."},ei={type:"boolean",title:"Echo",description:"If true, the response will contain the prompt."},ti={type:"select",title:"Response format",description:"Choose the response format of your model. For JSON, you must include the string 'JSON' in some form within your system / user prompt."},oi={type:"select",title:"Response format",description:"Choose the response format of your model. 'json_object' colloquially known as JSON mode, instructs the model to respond with a valid JSON (must include the term 'json' in prompt). 'json_schema' colloquially known as structured outputs, allows you to specify a strict response schema that the model will adhere to."},ai={type:"object",title:"Response schema",description:"When response format is set to 'json_schema', the model will return a JSON object of the specified schema."},T={TEMPERATURE:Nn,MAX_TOKENS:Dn,STOP:Kn,TOP_A:Hn,TOP_P:Vn,TOP_K:zn,MIN_P:Jn,FREQUENCY_PENALTY:Gn,PRESENCE_PENALTY:Wn,REPETITION_PENALTY:Yn,SEED:Zn,LOG_PROBS:Qn,TOP_LOG_PROBS:Xn,ECHO:ei,RESPONSE_FORMAT:ti,RESPONSE_FORMAT_WITH_SCHEMA:oi,RESPONSE_SCHEMA:ai},Vt=t=>Object.fromEntries(Object.entries(t).filter(([o,a])=>a!=null)),J=t=>t==null?void 0:t.replace(/\/$/,""),zt=te({param:"temperature",title:T.TEMPERATURE.title,description:T.TEMPERATURE.description,min:0,max:1,step:.01,default:1}),Jt=t=>te({param:"max_tokens",title:T.MAX_TOKENS.title,description:T.MAX_TOKENS.description,min:0,max:t,step:1,default:0}),Gt=t=>An({param:"stop_sequences",title:T.STOP(t).title,description:T.STOP(t).description,max:t}),Wt=te({param:"top_p",title:T.TOP_P.title,description:T.TOP_P.description,min:0,max:1,step:.01,default:1}),Zt=te({param:"top_k",title:T.TOP_K.title,description:T.TOP_K.description,min:0,max:1,step:.01,default:1}),Yt=ve({param:"tool_choice",title:"Tool choice",description:"Controls which (if any) tool is called by the model. 'any' means the model will call any of the provided tools. 'auto' means the model can pick between generating a message or calling a tool.",default:"auto",choices:["auto","any"]}),ni=(t,o)=>zod.z.object({temperature:zt.schema,maxTokens:Jt(t).schema,stop:Gt(o).schema,topP:Wt.schema,topK:Zt.schema,toolChoice:Yt.schema}),ii=(t,o)=>({temperature:zt.def,maxTokens:Jt(t).def,stop:Gt(o).def,topP:Wt.def,topK:Zt.def,toolChoice:Yt.def}),Qt=ve({param:"encoding_format",title:"Encoding format",description:"Select the encoding format for the word embedding.",default:null,choices:["base64"]}),Xt=ve({param:"input_type",title:"Input type",description:"Select the input type for the word embedding.",default:null,choices:["query","document"]}),eo=Fn({param:"truncation",title:"Truncation",description:"Select the truncation for the word embedding.",default:!0}),si=()=>zod.z.object({encodingFormat:Qt.schema,inputType:Xt.schema,truncation:eo.schema}),ri=()=>({encodingFormat:Qt.def,inputType:Xt.def,truncation:eo.def}),S={base:(t,o)=>({def:ii(t,o),schema:ni(t,o)})},v={base:()=>({def:ri(),schema:si()})},U=zod.z.enum([G,E,w]),F={system:G,user:E,assistant:w},B=[y,A,x,$],N=zod.z.enum([y,A,x,$]),li=zod.z.object({type:zod.z.literal("text"),text:zod.z.string()}),di=zod.z.object({type:zod.z.literal("tool_use"),id:zod.z.string(),name:zod.z.string(),input:zod.z.record(zod.z.any())}),mi=zod.z.object({content:zod.z.array(zod.z.discriminatedUnion("type",[li,di])),id:zod.z.string(),model:zod.z.string(),role:zod.z.string(),stop_reason:zod.z.string(),stop_sequence:zod.z.null(),type:zod.z.literal("message"),usage:zod.z.object({input_tokens:zod.z.number(),output_tokens:zod.z.number(),cache_creation_input_tokens:zod.z.number().nullish(),cache_read_input_tokens:zod.z.number().nullish()})}),ci=zod.z.object({type:zod.z.literal("message_start"),message:zod.z.object({id:zod.z.string(),type:zod.z.literal("message"),role:zod.z.string(),model:zod.z.string(),stop_reason:zod.z.string().nullable(),stop_sequence:zod.z.string().nullable(),content:zod.z.array(zod.z.any()),usage:zod.z.object({input_tokens:zod.z.number(),output_tokens:zod.z.number()})})}),ui=zod.z.object({type:zod.z.literal("message_delta"),delta:zod.z.object({stop_reason:zod.z.string().nullable(),stop_sequence:zod.z.string().nullable()}),usage:zod.z.object({output_tokens:zod.z.number()})}),pi=zod.z.object({type:zod.z.literal("text"),text:zod.z.string()}),hi=zod.z.object({type:zod.z.literal("tool_use"),id:zod.z.string(),name:zod.z.string(),input:zod.z.object({})}),gi=zod.z.object({type:zod.z.literal("content_block_start"),index:zod.z.number(),content_block:zod.z.discriminatedUnion("type",[pi,hi])}),fi=zod.z.object({type:zod.z.literal("text_delta"),text:zod.z.string()}),yi=zod.z.object({type:zod.z.literal("input_json_delta"),partial_json:zod.z.string()}),bi=zod.z.object({type:zod.z.literal("content_block_delta"),index:zod.z.number(),delta:zod.z.discriminatedUnion("type",[fi,yi])}),vi=zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1).optional(),input_schema:zod.z.any()}),wi=zod.z.object({type:zod.z.enum(["auto","any"])}),Si=zod.z.object({type:zod.z.literal("tool"),name:zod.z.string().min(1)}),Se=zod.z.object({text:zod.z.string().min(1),type:zod.z.literal("text")}),to=zod.z.object({type:zod.z.literal("image"),source:zod.z.object({type:zod.z.literal("base64"),media_type:zod.z.enum(["image/jpeg","image/png","image/gif","image/webp"]),data:zod.z.string().base64()})});zod.z.object({id:zod.z.string().min(1),type:zod.z.literal("tool_use"),name:zod.z.string().min(1),input:zod.z.record(zod.z.any())});var oo=zod.z.object({type:zod.z.literal("tool_result"),tool_use_id:zod.z.string().min(1),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([Se,to])).min(1))}),Ci=zod.z.object({role:zod.z.literal("user"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([Se,to,oo])).min(1))}),Ti=zod.z.object({role:zod.z.literal("assistant"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([Se,oo])).min(1))}),xi=zod.z.union([Ci,Ti]),ki=zod.z.object({model:zod.z.string().min(1).optional(),messages:zod.z.array(xi).min(1),system:zod.z.string().min(1).optional(),max_tokens:zod.z.number().min(0).optional(),stop_sequences:zod.z.array(zod.z.string().min(1)).optional(),temperature:zod.z.number().min(0).max(1).optional(),tool_choice:zod.z.union([wi,Si]).optional(),tools:zod.z.array(vi).min(1).optional(),top_p:zod.z.number().min(0).max(1).optional(),top_k:zod.z.number().min(0).optional()}),ji="anthropic",X=class{constructor(){this.version="v1",this.name=ji,this.chatModelFactories={[ao]:{model:Ei,modelOptions:Mi,modelSchema:no},[io]:{model:Ri,modelOptions:Ii,modelSchema:so},[ro]:{model:$i,modelOptions:Ai,modelSchema:lo},[mo]:{model:Ui,modelOptions:qi,modelSchema:co}},this.embeddingModelFactories={[Co]:{model:is,modelOptions:ns,modelSchema:To},[wo]:{model:os,modelOptions:ts,modelSchema:So},[uo]:{model:Hi,modelOptions:Ki,modelSchema:po},[ho]:{model:Ji,modelOptions:zi,modelSchema:go},[fo]:{model:Zi,modelOptions:Wi,modelSchema:yo},[bo]:{model:Xi,modelOptions:Qi,modelSchema:vo}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModel(t,o){if(!(t in this.chatModelFactories))throw new Q({info:`Anthropic chat model: ${t} not found`,cause:new Error(`Anthropic chat model: ${t} not found, available chat models:
11
- ${this.chatModelLiterals().join(", ")}`)});let a=this.chatModelFactories[t].model,i=f({},o),r=this.chatModelFactories[t].modelOptions.parse(i);return new a(r)}chatModelSchema(t){if(!(t in this.chatModelFactories))throw new Q({info:`Anthropic chat model: ${t} not found`,cause:new Error(`Anthropic chat model: ${t} not found, available chat models:
12
- ${this.chatModelLiterals().join(", ")}`)});return this.chatModelFactories[t].modelSchema}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((t,o)=>(t[o]=this.chatModelFactories[o].modelSchema,t),{})}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModel(t,o){if(!(t in this.embeddingModelFactories))throw new Q({info:`Anthropic embedding model: ${t} not found`,cause:new Error(`Anthropic embedding model: ${t} not found, available embedding models:
13
- ${this.embeddingModelLiterals().join(", ")}`)});let a=this.embeddingModelFactories[t].model,i=f({},o),r=this.embeddingModelFactories[t].modelOptions.parse(i);return new a(r)}embeddingModelSchema(t){if(!(t in this.embeddingModelFactories))throw new Q({info:`Anthropic embedding model: ${t} not found`,cause:new Error(`Anthropic embedding model: ${t} not found, available embedding models:
14
- ${this.embeddingModelLiterals().join(", ")}`)});return this.embeddingModelFactories[t].modelSchema}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((t,o)=>(t[o]=this.embeddingModelFactories[o].modelSchema,t),{})}};X.chatBaseUrl="https://api.anthropic.com/v1",X.embeddingBaseUrl="https://api.anthropic.com/v1";var W=zod.z.object({apiKey:zod.z.string(),completeChatUrl:zod.z.string().url().optional(),streamChatUrl:zod.z.string().url().optional()}),D=class{constructor(t,o){this.version="v1";let a=W.parse(o);this.modelSchema=t,this.apiKey=a.apiKey,this.baseUrl=J(X.chatBaseUrl),this.completeChatUrl=J(a.completeChatUrl||`${this.baseUrl}/messages`),this.streamChatUrl=J(a.streamChatUrl||`${this.baseUrl}/messages`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"x-api-key":`${this.apiKey}`,"anthropic-version":"2023-06-01","content-type":"application/json",source:"adaline.ai"}}getDefaultParams(){return {model:this.modelSchema.name}}getRetryDelay(t){let o=0,a=!0;return t["x-should-retry"]&&(a=t["x-should-retry"].toLowerCase()!=="false"),t["retry-after"]&&(o=parseInt(t["retry-after"])*1e3),{shouldRetry:a,delayMs:o}}getTokenCount(t){return t.reduce((o,a)=>o+a.content.map(i=>i.modality==="text"?i.value:"").join(" ").length,0)}transformModelRequest(t){let o=ki.safeParse(t);if(!o.success)throw new ue({info:"Invalid model request",cause:o.error});let a=o.data,i=a.model;if(a.tool_choice&&(!a.tools||a.tools.length===0))throw new ue({info:`Invalid model request for model : '${this.modelSchema.name}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let r={};a.tool_choice&&(a.tool_choice.type==="tool"?r.toolChoice=a.tool_choice.name:r.toolChoice=a.tool_choice.type),r.maxTokens=a.max_tokens,r.temperature=a.temperature,r.topP=a.top_p,r.topK=a.top_k,r.stop=a.stop_sequences;let s=jt().parse(Vt(r)),l=[],d={};a.system&&l.push({role:G,content:[{modality:y,value:a.system}]}),a.messages.forEach(u=>{let h=u.role;switch(h){case"user":{let g=u.content;if(typeof g=="string")l.push({role:h,content:[{modality:y,value:g}]});else {let C=g.map(p=>{if(p.type==="text")return {modality:y,value:p.text};if(p.type==="image"){let se="auto",Z=p.source.media_type.split("/")[1];return {modality:A,detail:se,value:{type:wt,media_type:Z,base64:p.source.data}}}else return {modality:$,id:p.tool_use_id,index:d[p.tool_use_id].index,name:d[p.tool_use_id].name,data:typeof p.content=="string"?p.content:JSON.stringify(p.content)}});l.push({role:h,content:C});}}break;case"assistant":{let g=u.content;if(typeof g=="string")l.push({role:h,content:[{modality:y,value:g}]});else {let C=g.map((p,se)=>{if(p.type==="text")return {modality:y,value:p.text};{let Z={modality:x,id:p.id,index:se,name:p.name,arguments:JSON.stringify(p.input)};return d[p.id]=Z,Z}});l.push({role:h,content:C});}}break}});let c=[];return a.tools&&a.tools.forEach(u=>{c.push({type:"function",definition:{schema:{name:u.name,description:u.description||"",parameters:u.input_schema}}});}),{modelName:i,config:s,messages:l,tools:c.length>0?c:void 0}}transformConfig(t,o,a){let i=t.toolChoice;delete t.toolChoice;let r=this.modelSchema.config.schema.safeParse(t);if(!r.success)throw new M({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:r.error});let s=r.data;i!==void 0&&(s.toolChoice=i),Object.keys(s).forEach(d=>{if(!(d in this.modelSchema.config.def))throw new M({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error(`Invalid config key : '${d}',
15
- available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let l=Object.keys(s).reduce((d,c)=>{let u=this.modelSchema.config.def[c],h=u.param,g=s[c];return h==="max_tokens"&&u.type==="range"&&g===0?d[h]=u.max:d[h]=g,d},{});if(!l.max_tokens)throw new M({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error(`'max_tokens' is required for model : '${this.modelSchema.name}'`)});if("tool_choice"in l&&l.tool_choice!==void 0){let d=l.tool_choice;if(!a||a&&a.length===0)throw new M({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(a&&a.length>0){let c=this.modelSchema.config.def.toolChoice;if(!c.choices.includes(d))if(a.map(u=>u.definition.schema.name).includes(d))l.tool_choice={type:"tool",name:d};else throw new M({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error(`toolChoice : '${d}' is not part of provided 'tools' names or
16
- one of [${c.choices.join(", ")}]`)})}}return l}transformMessages(t){if(!t||t&&t.length===0)return {messages:[]};let o=t.map(s=>{let l=kt().safeParse(s);if(!l.success)throw new b({info:"Invalid messages",cause:l.error});return l.data});o.forEach(s=>{s.content.forEach(l=>{if(!this.modelSchema.modalities.includes(l.modality))throw new b({info:`Invalid message content for model : '${this.modelSchema.name}'`,cause:new Error(`model : '${this.modelSchema.name}' does not support modality : '${l.modality}',
17
- available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),o.forEach(s=>{if(!Object.keys(this.modelSchema.roles).includes(s.role))throw new b({info:`Invalid message content for model : '${this.modelSchema.name}'`,cause:new Error(`model : '${this.modelSchema.name}' does not support role : '${s.role}',
18
- available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})});let a="",i=[];if(o.forEach(s=>{switch(s.role){case G:s.content.forEach(l=>{if(l.modality===y)a+=l.value;else throw new b({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelSchema.name}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${l.modality}'`)})});break;case w:{let l=[];s.content.forEach(d=>{if(d.modality===y)l.push({type:"text",text:d.value});else if(d.modality===x)l.push({type:"tool_use",id:d.id,name:d.name,input:JSON.parse(d.arguments)});else throw new b({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelSchema.name}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${d.modality}'`)})}),i.push({role:this.modelSchema.roles[s.role],content:l});}break;case E:{let l=[];s.content.forEach(d=>{if(d.modality===y)l.push({type:"text",text:d.value});else if(d.modality===A){if(d.value.type==="base64")l.push({type:"image",source:{type:"base64",media_type:`image/${d.value.media_type}`,data:d.value.base64}});else if(d.value.type==="url")throw new b({info:`Invalid message 'modality' for model : ${this.modelSchema.name}`,cause:new Error(`model: '${this.modelSchema.name}' does not support image content type: '${d.value.type}'`)})}else if(d.modality===$)l.push({type:"tool_result",tool_use_id:d.id,content:d.data});else throw new b({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelSchema.name}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${d.modality}'`)})}),i.push({role:this.modelSchema.roles[s.role],content:l});}break;default:throw new b({info:`Invalid message 'role' for model : ${this.modelSchema.name}`,cause:new Error(`role : '${s.role}' is not supported,
19
- available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}}),i[0].role!==this.modelSchema.roles[E])throw new b({info:`Invalid message 'role' for model : ${this.modelSchema.name}`,cause:new Error(`model : '${this.modelSchema.name}' requires first message to be from user`)});let r=s=>s===this.modelSchema.roles[E]?this.modelSchema.roles[w]:this.modelSchema.roles[E];for(let s=1;s<i.length;s++)if(i[s].role!==r(i[s-1].role))throw new b({info:`Invalid message format for model : ${this.modelSchema.name}`,cause:new Error(`model : '${this.modelSchema.name}' requires messages to alternate between user and assistant`)});return {system:a,messages:i}}transformTools(t){if(!this.modelSchema.modalities.includes(x))throw new gt({info:`Invalid tool 'modality' for model : ${this.modelSchema.name}`,cause:new Error(`model : '${this.modelSchema.name}' does not support tool modality : '${x}'`)});return !t||t&&t.length===0?{tools:[]}:{tools:t.map(o=>{let a=Sn().safeParse(o);if(!a.success)throw new gt({info:"Invalid tools",cause:a.error});return a.data}).map(o=>({name:o.definition.schema.name,description:o.definition.schema.description,function:o.definition.schema}))}}getCompleteChatUrl(t,o,a){return O(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getCompleteChatHeaders(t,o,a){return O(this,null,function*(){let i=this.getDefaultHeaders();return a&&a.length>0&&(i=tt(f({},i),{"anthropic-beta":"tools-2024-05-16"})),new Promise(r=>{r(i);})})}getCompleteChatData(t,o,a){return O(this,null,function*(){let i=this.transformConfig(t,o,a),r=this.transformMessages(o);if(r.messages&&r.messages.length===0)throw new b({info:"Messages are required",cause:new Error("Messages are required")});let s=a?this.transformTools(a):{};return new Promise(l=>{l(f(f(f(f({},this.getDefaultParams()),i),r),s));})})}transformCompleteChatResponse(t){let o=mi.safeParse(t);if(o.success){let a=o.data,i=a.content.map((l,d)=>{if(l.type==="text")return dn(l.text);if(l.type==="tool_use")return mn(d,l.id,l.name,JSON.stringify(l.input))}),r=[{role:w,content:i}],s={promptTokens:a.usage.input_tokens,completionTokens:a.usage.output_tokens,totalTokens:a.usage.input_tokens+a.usage.output_tokens};return {messages:r,usage:s,logProbs:[]}}throw new j({info:"Invalid response from model",cause:o.error})}getStreamChatUrl(t,o,a){return O(this,null,function*(){return new Promise(i=>{i(this.streamChatUrl);})})}getStreamChatHeaders(t,o,a){let i=this.getDefaultHeaders();return a&&a.length>0&&(i=tt(f({},i),{"anthropic-beta":"tools-2024-05-16"})),new Promise(r=>{r(i);})}getStreamChatData(t,o,a){return O(this,null,function*(){let i=this.transformConfig(t,o,a),r=this.transformMessages(o);if(r.messages&&r.messages.length===0)throw new b({info:"Messages are required",cause:new Error("Messages are required")});let s=a?this.transformTools(a):{};return new Promise(l=>{l(f(f(f(f({stream:!0},this.getDefaultParams()),i),r),s));})})}transformStreamChatResponseChunk(t,o){return Na(this,null,function*(){let a=(o+t).split(`
20
- `).filter(i=>i.trim()!=="");for(let i of a)if(i.startsWith("data: {")&&i.endsWith("}")){let r;try{r=JSON.parse(i.substring(6));}catch(s){throw new j({info:"Malformed JSON received in stream",cause:new Error(`Malformed JSON received in stream : ${r}`)})}if("type"in r){if(r.type==="message_stop")return;if(r.type==="message_start"){let s=ci.safeParse(r);if(s.success){let l=s.data;yield {partialResponse:{partialMessages:[],usage:{promptTokens:l.message.usage.input_tokens,completionTokens:l.message.usage.output_tokens,totalTokens:l.message.usage.input_tokens+l.message.usage.output_tokens}},buffer:o};}else throw new j({info:"Invalid response from model",cause:s.error})}else if(r.type==="message_delta"){let s=ui.safeParse(r);if(s.success){let l=s.data;yield {partialResponse:{partialMessages:[],usage:{promptTokens:0,completionTokens:l.usage.output_tokens,totalTokens:l.usage.output_tokens}},buffer:o};}else throw new j({info:"Invalid response from model",cause:s.error})}else if(r.type==="content_block_start"){let s=gi.safeParse(r);if(s.success){let l=s.data,d=[];l.content_block.type==="text"?d.push(ot(w,l.content_block.text)):l.content_block.type==="tool_use"&&d.push(at(w,l.index,l.content_block.id,l.content_block.name,"")),yield {partialResponse:{partialMessages:d},buffer:o};}else throw new j({info:"Invalid response from model",cause:s.error})}else if(r.type==="content_block_delta"){let s=bi.safeParse(r);if(s.success){let l=s.data,d=[];l.delta.type==="text_delta"?d.push(ot(w,l.delta.text)):l.delta.type==="input_json_delta"&&d.push(at(w,l.index,"","",l.delta.partial_json)),yield {partialResponse:{partialMessages:d},buffer:o};}else throw new j({info:"Invalid response from model",cause:s.error})}}else throw new j({info:"Invalid JSON received in stream",cause:new Error(`Invalid JSON received in stream, expected 'type' property,
21
- received : ${JSON.stringify(r)}`)})}})}},ao="claude-3-haiku-20240307",Oi="Fastest and most compact model for near-instant responsiveness. Quick and accurate targeted performance.",no=oe(U,N).parse({name:ao,description:Oi,maxInputTokens:2e5,maxOutputTokens:4096,roles:F,modalities:B,config:{def:S.base(4096,4).def,schema:S.base(4096,4).schema}}),Mi=W,Ei=class extends D{constructor(t){super(no,t);}},io="claude-3-sonnet-20240229",Pi="Balance of intelligence and speed. Strong utility, balanced for scaled deployments.",so=oe(U,N).parse({name:io,description:Pi,maxInputTokens:2e5,maxOutputTokens:4096,roles:F,modalities:B,config:{def:S.base(4096,4).def,schema:S.base(4096,4).schema}}),Ii=W,Ri=class extends D{constructor(t){super(so,t);}},ro="claude-3-opus-20240229",_i="Powerful model for highly complex tasks. Top-level performance, intelligence, fluency, and understanding.",lo=oe(U,N).parse({name:ro,description:_i,maxInputTokens:2e5,maxOutputTokens:4096,roles:F,modalities:B,config:{def:S.base(4096,4).def,schema:S.base(4096,4).schema}}),Ai=W,$i=class extends D{constructor(t){super(lo,t);}},mo="claude-3-5-sonnet-20240620",Li="Most intelligent model. Highest level of intelligence and capability.",co=oe(U,N).parse({name:mo,description:Li,maxInputTokens:2e5,maxOutputTokens:8192,roles:F,modalities:B,config:{def:S.base(8192,4).def,schema:S.base(8192,4).schema}}),qi=W,Ui=class extends D{constructor(t){super(co,t);}},K=[L],H=zod.z.enum([L]),Fi=zod.z.object({object:zod.z.literal("list"),model:zod.z.string(),data:zod.z.array(zod.z.object({index:zod.z.number(),object:zod.z.literal("embedding"),embedding:zod.z.array(zod.z.number()).or(zod.z.string().base64())})),usage:zod.z.object({total_tokens:zod.z.number()})}),Bi=zod.z.string().min(1).or(zod.z.array(zod.z.string().min(1)).min(1)),Ni=zod.z.object({model:zod.z.string().min(1).optional(),input:Bi,encoding_format:zod.z.enum(["base64"]).nullable().optional(),input_type:zod.z.enum(["query","document"]).nullable().optional(),truncation:zod.z.boolean().optional()}),I=zod.z.object({apiKey:zod.z.string(),getEmbeddingsUrl:zod.z.string().url().optional()}),V=class{constructor(t,o){this.version="v1";let a=I.parse(o);this.modelSchema=t,this.apiKey=a.apiKey,this.baseUrl=J(X.embeddingBaseUrl),this.getEmbeddingsUrl=J(a.getEmbeddingsUrl||`${this.baseUrl}/embeddings`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json",source:"adaline.ai"}}getDefaultParams(){return {model:this.modelSchema.name}}getTokenCount(t){return t.requests.reduce((o,a)=>o+a.length,0)}getRetryDelay(t){return {shouldRetry:!0,delayMs:0}}transformModelRequest(t){let o=Ni.safeParse(t);if(!o.success)throw new ue({info:"Invalid model request",cause:o.error});let a=o.data,i=a.model,r={encodingFormat:a.encoding_format,inputType:a.input_type,truncation:a.truncation},s=jt().parse(Vt(r)),l;return typeof a.input=="string"?l={modality:L,requests:[a.input]}:l={modality:L,requests:a.input},{modelName:i,config:s,embeddingRequests:l}}transformConfig(t,o){let a=this.modelSchema.config.schema.safeParse(t);if(!a.success)throw new M({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:a.error});let i=a.data;return Object.keys(i).forEach(r=>{if(!this.modelSchema.config.def[r])throw new M({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error(`Invalid config key : '${r}',
22
- available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(i).reduce((r,s)=>{let l=this.modelSchema.config.def[s].param,d=i[s];return r[l]=d,r},{})}transformEmbeddingRequests(t){let o=jn().safeParse(t);if(!o.success)throw new yt({info:"Invalid embedding requests",cause:o.error});if(o.data.requests.length>128)throw new yt({info:`Invalid embedding requests for model : '${this.modelSchema.name}'`,cause:new Error(`Max requests for model : '${this.modelSchema.name}' is 128`)});return {input:o.data.requests}}getGetEmbeddingsUrl(t,o){return O(this,null,function*(){return new Promise(a=>{a(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(t,o){return O(this,null,function*(){return new Promise(a=>{a(this.getDefaultHeaders());})})}getGetEmbeddingsData(t,o){return O(this,null,function*(){return new Promise(a=>{a(f(f(f({},this.getDefaultParams()),this.transformConfig(t,o)),this.transformEmbeddingRequests(o)));})})}transformGetEmbeddingsResponse(t){let o,a=Fi.safeParse(t);if(a.success){let i=a.data;o=typeof i.data[0].embedding=="string"?Et:Mt;let r=i.data.map(s=>typeof s.embedding=="string"?{index:s.index,embedding:s.embedding}:{index:s.index,embedding:s.embedding});return {encodingFormat:o,embeddings:r,usage:{totalTokens:i.usage.total_tokens}}}throw new j({info:"Invalid response from model",cause:a.error})}},uo="voyage-code-2",Di="Optimized for code retrieval.",po=q(H).parse({name:uo,description:Di,modalities:K,maxInputTokens:16e3,maxOutputTokens:16e3,config:{def:v.base().def,schema:v.base().schema}}),Ki=I,Hi=class extends V{constructor(t){super(po,t);}},ho="voyage-law-2",Vi="Optimized for legal and long-context retrieval and RAG. Also improved performance across all domains.",go=q(H).parse({name:ho,description:Vi,modalities:K,maxInputTokens:16e3,maxOutputTokens:16e3,config:{def:v.base().def,schema:v.base().schema}}),zi=I,Ji=class extends V{constructor(t){super(go,t);}},fo="voyage-multilingual-2",Gi="Optimized for multilingual retrieval and RAG.",yo=q(H).parse({name:fo,description:Gi,modalities:K,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:v.base().def,schema:v.base().schema}}),Wi=I,Zi=class extends V{constructor(t){super(yo,t);}},bo="voyage-finance-2",Yi="Optimized for finance retrieval and RAG.",vo=q(H).parse({name:bo,description:Yi,modalities:K,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:v.base().def,schema:v.base().schema}}),Qi=I,Xi=class extends V{constructor(t){super(vo,t);}},wo="voyage-3-lite",es="Optimized for latency and cost.",So=q(H).parse({name:wo,description:es,modalities:K,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:v.base().def,schema:v.base().schema}}),ts=I,os=class extends V{constructor(t){super(So,t);}},Co="voyage-3",as="Optimized for quality.",To=q(H).parse({name:Co,description:as,modalities:K,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:v.base().def,schema:v.base().schema}}),ns=I,is=class extends V{constructor(t){super(To,t);}};var Ce=zod.z.object({awsRegion:zod.z.string(),awsAccessKeyId:zod.z.string(),awsSecretAccessKey:zod.z.string()}),ne=class t extends D{constructor(a,i){let r=Ce.parse(i);super(a,{apiKey:"random-api-key"});this.version="v1";this.modelSchema=a,this.awsRegion=r.awsRegion,this.awsUrl=R.awsUrl(this.awsRegion),this.awsService=R.awsService,this.awsAccessKeyId=r.awsAccessKeyId,this.awsSecretAccessKey=r.awsSecretAccessKey;}getDefaultBaseUrl(){return this.awsUrl}getDefaultHeaders(){return {Accept:"application/json","Content-Type":"application/json",host:this.awsUrl.split("://")[1]}}getDefaultParams(){return {anthropic_version:"bedrock-2023-05-31"}}getCompleteChatUrl(a,i,r){return new Promise(s=>{s(`${this.awsUrl}/model/${this.modelSchema.name}/invoke`);})}getCompleteChatHeaders(a,i,r){return _(this,null,function*(){let s=new URL(yield this.getCompleteChatUrl(a,i,r)),l={accessKeyId:this.awsAccessKeyId,secretAccessKey:this.awsSecretAccessKey},d=this.getDefaultHeaders(),c=this.getCompleteChatData(a||{},i||[],r),u=new protocolHttp.HttpRequest({hostname:s.hostname,path:s.pathname,protocol:s.protocol,method:"POST",body:JSON.stringify(c),headers:d});return (yield new signatureV4.SignatureV4({credentials:l,service:this.awsService,region:this.awsRegion,sha256:sha256Js.Sha256}).sign(u)).headers})}getCompleteChatData(a,i,r){return _(this,null,function*(){let s=k(k({},this.getDefaultParams()),Y(t.prototype,this,"getCompleteChatData").call(this,a,i,r));return new Promise(l=>{l(s);})})}getStreamChatUrl(a,i,r){return _(this,null,function*(){return new Promise(s=>{s(`${this.awsUrl}/model/${this.modelSchema.name}/invoke-with-response-stream`);})})}getStreamChatHeaders(a,i,r){return _(this,null,function*(){let s=new URL(yield this.getStreamChatUrl(a,i,r)),l={accessKeyId:this.awsAccessKeyId,secretAccessKey:this.awsSecretAccessKey},d=this.getDefaultHeaders(),c=this.getCompleteChatData(a||{},i||[],r),u=new protocolHttp.HttpRequest({hostname:s.hostname,path:s.pathname,protocol:s.protocol,method:"POST",body:JSON.stringify(c),headers:d});return (yield new signatureV4.SignatureV4({credentials:l,service:this.awsService,region:this.awsRegion,sha256:sha256Js.Sha256}).sign(u)).headers})}getStreamChatData(a,i,r){return _(this,null,function*(){let s=k(k({},this.getDefaultParams()),Y(t.prototype,this,"getStreamChatData").call(this,a,i,r));return "stream"in s&&delete s.stream,s})}transformStreamChatResponseChunk(a,i){return je(this,null,function*(){let r=a.toString(),s=/{\s*"bytes"\s*:\s*"[\w=+/]+".*?}/g,l=r.match(s)||[];for(let d of l){let c=d.indexOf("{"),u=d.indexOf("}");if(c!==-1&&u!==-1&&c<u){let h;try{h=JSON.parse(d.slice(c,u+1));}catch(p){throw new He({info:"Malformed JSON received in stream",cause:new Error(`Malformed JSON received in stream : ${h}`)})}let g=Qe(h.bytes),C=(yield new re(Y(t.prototype,this,"transformStreamChatResponseChunk").call(this,`data: ${g}`,i).next())).value;C&&(yield C);}}})}};var ss="anthropic.claude-3-haiku-20240307-v1:0",rs="Claude 3 Haiku is a large-scale multimodal model trained by Anthropic. It is the successor to Claude 3 and is designed to be more powerful and capable than its predecessor.",Te=Ye(U,N).parse({name:ss,description:rs,maxInputTokens:128e3,maxOutputTokens:128e3,roles:F,modalities:B,config:{def:S.base(128e3,4).def,schema:S.base(128e3,4).schema}}),Oo=Ce,ie=class extends ne{constructor(o){super(Te,o);}};var ls="bedrock",R=class{constructor(){this.version="v1";this.name=ls;this.chatModelFactories={"claude-3-haiku-20240307":{model:ie,modelOptions:Oo,modelSchema:Te}};this.embeddingModelFactories={};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModel(o,a){if(!(o in this.chatModelFactories))throw new z({info:`Bedrock chat model: ${o} not found`,cause:new Error(`Bedrock chat model: ${o} not found, available chat models:
23
- ${this.chatModelLiterals().join(", ")}`)});let i=this.chatModelFactories[o].model,r=k({},a),s=this.chatModelFactories[o].modelOptions.parse(r);return new i(s)}chatModelSchema(o){if(!(o in this.chatModelFactories))throw new z({info:`Bedrock chat model: ${o} not found`,cause:new Error(`Bedrock chat model: ${o} not found, available chat models:
24
- ${this.chatModelLiterals().join(", ")}`)});return this.chatModelFactories[o].modelSchema}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((o,a)=>(o[a]=this.chatModelFactories[a].modelSchema,o),{})}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModel(o,a){if(!(o in this.embeddingModelFactories))throw new z({info:`Bedrock embedding model: ${o} not found`,cause:new Error(`Bedrock embedding model: ${o} not found, available embedding models:
25
- ${this.embeddingModelLiterals().join(", ")}`)});let i=this.embeddingModelFactories[o].model,r=k({},a),s=this.embeddingModelFactories[o].modelOptions.parse(r);return new i(s)}embeddingModelSchema(o){if(!(o in this.embeddingModelFactories))throw new z({info:`Bedrock embedding model: ${o} not found`,cause:new Error(`Bedrock embedding model: ${o} not found, available embedding models:
26
- ${this.embeddingModelLiterals().join(", ")}`)});return this.embeddingModelFactories[o].modelSchema}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((o,a)=>(o[a]=this.embeddingModelFactories[a].modelSchema,o),{})}};R.awsService="bedrock",R.awsUrl=o=>`https://bedrock.${o}.amazonaws.com`;
8
+ var Mo=Object.defineProperty,Po=Object.defineProperties;var Io=Object.getOwnPropertyDescriptors;var Oe=Object.getOwnPropertySymbols,_o=Object.getPrototypeOf,Ro=Object.prototype.hasOwnProperty,No=Object.prototype.propertyIsEnumerable,Ao=Reflect.get;var qo=(o,t)=>(t=Symbol[o])?t:Symbol.for("Symbol."+o);var je=(o,t,a)=>t in o?Mo(o,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):o[t]=a,S=(o,t)=>{for(var a in t||(t={}))Ro.call(t,a)&&je(o,a,t[a]);if(Oe)for(var a of Oe(t))No.call(t,a)&&je(o,a,t[a]);return o},le=(o,t)=>Po(o,Io(t));var Q=(o,t,a)=>Ao(_o(o),a,t);var R=(o,t,a)=>new Promise((i,r)=>{var s=c=>{try{d(a.next(c));}catch(u){r(u);}},l=c=>{try{d(a.throw(c));}catch(u){r(u);}},d=c=>c.done?i(c.value):Promise.resolve(c.value).then(s,l);d((a=a.apply(o,t)).next());}),de=function(o,t){this[0]=o,this[1]=t;},Ee=(o,t,a)=>{var i=(l,d,c,u)=>{try{var h=a[l](d),g=(d=h.value)instanceof de,T=h.done;Promise.resolve(g?d[0]:d).then(p=>g?i(l==="return"?l:"next",d[1]?{done:p.done,value:p.value}:p,c,u):c({value:p,done:T})).catch(p=>i("throw",p,c,u));}catch(p){u(p);}},r=l=>s[l]=d=>new Promise((c,u)=>i(l,d,c,u)),s={};return a=a.apply(o,t),s[qo("asyncIterator")]=()=>s,r("next"),r("throw"),r("return"),s};var $o=o=>{let t=new WeakSet;return JSON.stringify(o,(a,i)=>{if(typeof i=="object"&&i!==null){if(t.has(i))return;t.add(i);}return i})},Lo=o=>o==null?"unknown error":typeof o=="string"?o:o instanceof Error?o.message:$o(o),me="GatewayBaseError",ce=class _e extends Error{constructor({info:t,cause:a},i){super(`[${i!=null?i:me}]: ${t}
9
+ Message: ${Lo(a)}`),this.name=me,this.info=t,this.cause=a,this.name=i!=null?i:me,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(t){return t instanceof _e}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},Uo="system",Bo="user",Re="assistant",Fo="tool",Do=[Uo,Bo,Re,Fo],ue=zod.z.enum(Do),Ko=[Re],Ho=zod.z.enum(Ko),Ne="image",Vo="base64",zo=["png","jpeg","webp","gif"],Jo=zod.z.object({type:zod.z.literal(Vo),base64:zod.z.string(),media_type:zod.z.enum(zo)}),Go="url",Wo=zod.z.object({type:zod.z.literal(Go),url:zod.z.string()}),Zo=zod.z.discriminatedUnion("type",[Jo,Wo]),Yo=["low","medium","high","auto"],Qo=zod.z.enum(Yo),Xo=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Ne),detail:Qo,value:Zo,metadata:o}),Ae="text",ea=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Ae),value:zod.z.string(),metadata:o}),qe="partial-text",ta=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(qe),value:zod.z.string(),metadata:o}),$e="tool-call",oa=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal($e),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),arguments:zod.z.string(),metadata:o}),Le="partial-tool-call",aa=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Le),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),arguments:zod.z.string().optional(),metadata:o}),Ue="tool-response",na=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Ue),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),data:zod.z.string(),metadata:o}),ia=[Ae,Ne,$e,Ue],Be=zod.z.enum(ia),sa=(o=zod.z.undefined(),t=zod.z.undefined(),a=zod.z.undefined(),i=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[ea(o),Xo(t),oa(a),na(i)]),ra=[qe,Le];zod.z.enum(ra);var la=(o=zod.z.undefined(),t=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[ta(o),aa(t)]);var da=(o=ue,t=zod.z.undefined(),a=zod.z.undefined(),i=zod.z.undefined(),r=zod.z.undefined(),s=zod.z.undefined())=>zod.z.object({role:o,content:zod.z.array(sa(t,a,i,r)),metadata:s}),ma=(o=Ho,t=zod.z.undefined(),a=zod.z.undefined(),i=zod.z.undefined())=>zod.z.object({role:o,partialContent:la(t,a),metadata:i});var ca=["object","array","number","string","boolean","enum"],Me=zod.z.enum(ca),ua=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([Me,zod.z.array(zod.z.union([Me,zod.z.literal("null")]))]).optional(),default:zod.z.any().optional(),title:zod.z.string().optional(),description:zod.z.string().max(4096).optional(),properties:zod.z.record(zod.z.any()).optional(),required:zod.z.array(zod.z.string()).optional(),minItems:zod.z.number().int().min(0).optional(),maxItems:zod.z.number().int().optional(),items:zod.z.record(zod.z.any()).optional(),enum:zod.z.array(zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()])).optional(),minimum:zod.z.number().optional(),maximum:zod.z.number().optional(),minLength:zod.z.number().int().min(0).optional(),maxLength:zod.z.number().int().optional(),$ref:zod.z.string().optional()}),pa=zod.z.object({type:zod.z.enum(["object"]),required:zod.z.array(zod.z.string()),$defs:zod.z.record(zod.z.any()).optional(),properties:zod.z.record(ua),additionalProperties:zod.z.literal(!1)});zod.z.object({name:zod.z.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:zod.z.string().max(4096),strict:zod.z.boolean().optional(),schema:pa}).optional();var ha="function";var ga=zod.z.enum(["object","array","number","string","boolean","null"]),fa=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:ga.optional(),default:zod.z.any().optional(),title:zod.z.string().optional(),description:zod.z.string().max(4096).optional(),properties:zod.z.record(zod.z.any()).optional(),required:zod.z.array(zod.z.string()).optional(),minItems:zod.z.number().int().min(0).optional(),maxItems:zod.z.number().int().optional(),items:zod.z.record(zod.z.any()).optional(),enum:zod.z.array(zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()])).optional(),minimum:zod.z.number().optional(),maximum:zod.z.number().optional(),minLength:zod.z.number().int().min(0).optional(),maxLength:zod.z.number().int().optional()});zod.z.object({type:zod.z.enum(["object"]),title:zod.z.string().optional(),$defs:zod.z.record(zod.z.any()).optional(),properties:zod.z.record(fa).optional(),required:zod.z.array(zod.z.string()).optional()});var ya=zod.z.object({name:zod.z.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:zod.z.string().max(4096),parameters:zod.z.any(),strict:zod.z.boolean().optional()});var ba=zod.z.enum(["function"]);zod.z.object({type:ba,definition:zod.z.object({schema:ya})});var va=[ha];zod.z.enum(va);var wa="text",Ca="token",Ta=[wa,Ca];zod.z.enum(Ta);zod.z.array(zod.z.string().min(1));zod.z.array(zod.z.array(zod.z.number().int().nonnegative()));var ka="float",Sa=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),Oa="base64",ja=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.string().base64()}),Pe=zod.z.object({totalTokens:zod.z.number().int().nonnegative()});zod.z.discriminatedUnion("encodingFormat",[zod.z.object({encodingFormat:zod.z.literal(ka),embeddings:zod.z.array(Sa),usage:Pe.optional()}),zod.z.object({encodingFormat:zod.z.literal(Oa),embeddings:zod.z.array(ja),usage:Pe.optional()})]);var Fe=zod.z.object({promptTokens:zod.z.number().nonnegative(),completionTokens:zod.z.number().nonnegative(),totalTokens:zod.z.number().nonnegative()}),Ie=zod.z.object({token:zod.z.string(),logProb:zod.z.number(),bytes:zod.z.array(zod.z.number().int()).nullable()}),Ea=Ie.extend({topLogProbs:zod.z.array(Ie)}),De=zod.z.array(Ea);zod.z.object({messages:zod.z.array(da()),usage:Fe.optional(),logProbs:De.optional()});zod.z.object({partialMessages:zod.z.array(ma()),usage:Fe.optional(),logProbs:De.optional()});var Ke="ProviderError",z=class Ve extends ce{constructor({info:t,cause:a}){super({info:t,cause:a},Ke),this.name=Ke,this.info=t,this.cause=a;}static isProviderError(t){return t instanceof Ve}};var He="ModelResponseError",ze=class Je extends ce{constructor({info:t,cause:a}){super({info:t,cause:a},He),this.name=He,this.cause=a,this.info=t;}static isModelResponseError(t){return t instanceof Je}};var Ge="multi-string",Ma=zod.z.object({type:zod.z.literal(Ge),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()});var We="object-schema",Pa=zod.z.object({type:zod.z.literal(We),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),objectSchema:zod.z.any()});var Ze="range",Ia=zod.z.object({type:zod.z.literal(Ze),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()});var Ye="select-boolean",_a=zod.z.object({type:zod.z.literal(Ye),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()});var Qe="select-string",Ra=zod.z.object({type:zod.z.literal(Qe),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).nullable(),choices:zod.z.array(zod.z.string().min(1))});var Na=[Ze,Ge,Qe,We,Ye];zod.z.enum(Na);var Aa=zod.z.discriminatedUnion("type",[Ia,Ma,Ra,_a,Pa]),Xe=(o=ue,t=Be)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(o,zod.z.string().min(1).optional()),modalities:zod.z.array(t).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),Aa),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(a=>{var i,r;let s=Object.keys(a.def),l=Object.keys((r=(i=a.schema)==null?void 0:i.shape)!=null?r:{});return s.every(d=>l.includes(d))&&l.every(d=>s.includes(d))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})});zod.z.record(zod.z.string());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()]));zod.z.string().url();var qa=()=>typeof window!="undefined"&&typeof window.document!="undefined"&&typeof navigator!="undefined";var et=o=>{if(qa()){let t=atob(o),a=new Uint8Array(t.length);for(let i=0;i<t.length;i++)a[i]=t.charCodeAt(i);return new TextDecoder("utf-8").decode(a)}else return Buffer.from(o,"base64").toString("utf-8")};var $a=Object.defineProperty,La=Object.defineProperties,Ua=Object.getOwnPropertyDescriptors,tt=Object.getOwnPropertySymbols,Ba=Object.prototype.hasOwnProperty,Fa=Object.prototype.propertyIsEnumerable,Da=(o,t)=>(t=Symbol[o])?t:Symbol.for("Symbol."+o),ot=(o,t,a)=>t in o?$a(o,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):o[t]=a,f=(o,t)=>{for(var a in t||(t={}))Ba.call(t,a)&&ot(o,a,t[a]);if(tt)for(var a of tt(t))Fa.call(t,a)&&ot(o,a,t[a]);return o},ee=(o,t)=>La(o,Ua(t)),j=(o,t,a)=>new Promise((i,r)=>{var s=c=>{try{d(a.next(c));}catch(u){r(u);}},l=c=>{try{d(a.throw(c));}catch(u){r(u);}},d=c=>c.done?i(c.value):Promise.resolve(c.value).then(s,l);d((a=a.apply(o,t)).next());}),Ka=function(o,t){this[0]=o,this[1]=t;},Ha=(o,t,a)=>{var i=(l,d,c,u)=>{try{var h=a[l](d),g=(d=h.value)instanceof Ka,T=h.done;Promise.resolve(g?d[0]:d).then(p=>g?i(l==="return"?l:"next",d[1]?{done:p.done,value:p.value}:p,c,u):c({value:p,done:T})).catch(p=>i("throw",p,c,u));}catch(p){u(p);}},r=l=>s[l]=d=>new Promise((c,u)=>i(l,d,c,u)),s={};return a=a.apply(o,t),s[Da("asyncIterator")]=()=>s,r("next"),r("throw"),r("return"),s},Va=o=>{let t=new WeakSet;return JSON.stringify(o,(a,i)=>{if(typeof i=="object"&&i!==null){if(t.has(i))return;t.add(i);}return i})},za=o=>o==null?"unknown error":typeof o=="string"?o:o instanceof Error?o.message:Va(o),pe="GatewayBaseError",P=class vt extends Error{constructor({info:t,cause:a},i){super(`[${i!=null?i:pe}]: ${t}
10
+ Message: ${za(a)}`),this.name=pe,this.info=t,this.cause=a,this.name=i!=null?i:pe,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(t){return t instanceof vt}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},G="system",M="user",w="assistant",Ja="tool",Ga=[G,M,w,Ja],wt=zod.z.enum(Ga),Wa=[w],Za=zod.z.enum(Wa),N="image",Ct="base64",Ya=["png","jpeg","webp","gif"],Qa=zod.z.object({type:zod.z.literal(Ct),base64:zod.z.string(),media_type:zod.z.enum(Ya)}),Xa="url",en=zod.z.object({type:zod.z.literal(Xa),url:zod.z.string()}),tn=zod.z.discriminatedUnion("type",[Qa,en]),on=["low","medium","high","auto"],an=zod.z.enum(on),nn=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(N),detail:an,value:tn,metadata:o}),y="text",Tt=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(y),value:zod.z.string(),metadata:o}),ge="partial-text",xt=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(ge),value:zod.z.string(),metadata:o}),k="tool-call",kt=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(k),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),arguments:zod.z.string(),metadata:o}),fe="partial-tool-call",St=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(fe),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),arguments:zod.z.string().optional(),metadata:o}),A="tool-response",sn=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(A),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),data:zod.z.string(),metadata:o}),rn=[y,N,k,A],ln=zod.z.enum(rn),dn=(o=zod.z.undefined(),t=zod.z.undefined(),a=zod.z.undefined(),i=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[Tt(o),nn(t),kt(a),sn(i)]),mn=[ge,fe];zod.z.enum(mn);var cn=(o=zod.z.undefined(),t=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[xt(o),St(t)]),Ot=(o=wt,t=zod.z.undefined(),a=zod.z.undefined(),i=zod.z.undefined(),r=zod.z.undefined(),s=zod.z.undefined())=>zod.z.object({role:o,content:zod.z.array(dn(t,a,i,r)),metadata:s}),ye=(o=Za,t=zod.z.undefined(),a=zod.z.undefined(),i=zod.z.undefined())=>zod.z.object({role:o,partialContent:cn(t,a),metadata:i}),un=o=>Tt().parse({modality:y,value:o}),pn=(o,t,a,i)=>kt().parse({modality:k,index:o,id:t,name:a,arguments:i}),at=(o,t)=>ye().parse({role:o,partialContent:xt().parse({modality:ge,value:t})}),nt=(o,t,a,i,r)=>ye().parse({role:o,partialContent:St().parse({modality:fe,index:t,id:a,name:i,arguments:r})}),jt=(o=zod.z.record(zod.z.string(),zod.z.any()).optional())=>o,hn=["object","array","number","string","boolean","enum"],it=zod.z.enum(hn),gn=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([it,zod.z.array(zod.z.union([it,zod.z.literal("null")]))]).optional(),default:zod.z.any().optional(),title:zod.z.string().optional(),description:zod.z.string().max(4096).optional(),properties:zod.z.record(zod.z.any()).optional(),required:zod.z.array(zod.z.string()).optional(),minItems:zod.z.number().int().min(0).optional(),maxItems:zod.z.number().int().optional(),items:zod.z.record(zod.z.any()).optional(),enum:zod.z.array(zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()])).optional(),minimum:zod.z.number().optional(),maximum:zod.z.number().optional(),minLength:zod.z.number().int().min(0).optional(),maxLength:zod.z.number().int().optional(),$ref:zod.z.string().optional()}),fn=zod.z.object({type:zod.z.enum(["object"]),required:zod.z.array(zod.z.string()),$defs:zod.z.record(zod.z.any()).optional(),properties:zod.z.record(gn),additionalProperties:zod.z.literal(!1)});zod.z.object({name:zod.z.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:zod.z.string().max(4096),strict:zod.z.boolean().optional(),schema:fn}).optional();var yn="function",bn=zod.z.enum(["object","array","number","string","boolean","null"]),vn=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:bn.optional(),default:zod.z.any().optional(),title:zod.z.string().optional(),description:zod.z.string().max(4096).optional(),properties:zod.z.record(zod.z.any()).optional(),required:zod.z.array(zod.z.string()).optional(),minItems:zod.z.number().int().min(0).optional(),maxItems:zod.z.number().int().optional(),items:zod.z.record(zod.z.any()).optional(),enum:zod.z.array(zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()])).optional(),minimum:zod.z.number().optional(),maximum:zod.z.number().optional(),minLength:zod.z.number().int().min(0).optional(),maxLength:zod.z.number().int().optional()});zod.z.object({type:zod.z.enum(["object"]),title:zod.z.string().optional(),$defs:zod.z.record(zod.z.any()).optional(),properties:zod.z.record(vn).optional(),required:zod.z.array(zod.z.string()).optional()});var wn=zod.z.object({name:zod.z.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:zod.z.string().max(4096),parameters:zod.z.any(),strict:zod.z.boolean().optional()}),Cn=zod.z.enum(["function"]),Tn=zod.z.object({type:Cn,definition:zod.z.object({schema:wn})}),xn=[yn];zod.z.enum(xn);var kn=(o=zod.z.undefined())=>zod.z.discriminatedUnion("type",[Tn.extend({metadata:o})]),q="text",Et="token",Sn=[q,Et],On=zod.z.enum(Sn),jn=zod.z.array(zod.z.string().min(1)),En=zod.z.array(zod.z.array(zod.z.number().int().nonnegative())),Mn=(o=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[zod.z.object({modality:zod.z.literal(q),metadata:o,requests:jn}),zod.z.object({modality:zod.z.literal(Et),metadata:o,requests:En})]),Mt="float",Pn=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),Pt="base64",In=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.string().base64()}),st=zod.z.object({totalTokens:zod.z.number().int().nonnegative()});zod.z.discriminatedUnion("encodingFormat",[zod.z.object({encodingFormat:zod.z.literal(Mt),embeddings:zod.z.array(Pn),usage:st.optional()}),zod.z.object({encodingFormat:zod.z.literal(Pt),embeddings:zod.z.array(In),usage:st.optional()})]);var It=zod.z.object({promptTokens:zod.z.number().nonnegative(),completionTokens:zod.z.number().nonnegative(),totalTokens:zod.z.number().nonnegative()}),rt=zod.z.object({token:zod.z.string(),logProb:zod.z.number(),bytes:zod.z.array(zod.z.number().int()).nullable()}),_n=rt.extend({topLogProbs:zod.z.array(rt)}),_t=zod.z.array(_n);zod.z.object({messages:zod.z.array(Ot()),usage:It.optional(),logProbs:_t.optional()});zod.z.object({partialMessages:zod.z.array(ye()),usage:It.optional(),logProbs:_t.optional()});var Rn=Object.defineProperty,lt=Object.getOwnPropertySymbols,Nn=Object.prototype.hasOwnProperty,An=Object.prototype.propertyIsEnumerable,dt=(o,t,a)=>t in o?Rn(o,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):o[t]=a,oe=(o,t)=>{for(var a in t||(t={}))Nn.call(t,a)&&dt(o,a,t[a]);if(lt)for(var a of lt(t))An.call(t,a)&&dt(o,a,t[a]);return o},mt="ProviderError",X=class Rt extends P{constructor({info:t,cause:a}){super({info:t,cause:a},mt),this.name=mt,this.info=t,this.cause=a;}static isProviderError(t){return t instanceof Rt}},ct="ModelResponseError",O=class Nt extends P{constructor({info:t,cause:a}){super({info:t,cause:a},ct),this.name=ct,this.cause=a,this.info=t;}static isModelResponseError(t){return t instanceof Nt}},ut="InvalidModelRequestError",he=class At extends P{constructor({info:t,cause:a}){super({info:t,cause:a},ut),this.name=ut,this.cause=a,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(t){return t instanceof At}},pt="InvalidConfigError",E=class qt extends P{constructor({info:t,cause:a}){super({info:t,cause:a},pt),this.name=pt,this.cause=a,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(t){return t instanceof qt}},ht="InvalidMessagesError",b=class $t extends P{constructor({info:t,cause:a}){super({info:t,cause:a},ht),this.name=ht,this.cause=a,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(t){return t instanceof $t}},gt="InvalidToolsError",ft=class Lt extends P{constructor({info:t,cause:a}){super({info:t,cause:a},gt),this.name=gt,this.cause=a,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(t){return t instanceof Lt}},yt="InvalidEmbeddingRequestsError",bt=class Ut extends P{constructor({info:t,cause:a}){super({info:t,cause:a},yt),this.name=yt,this.info=t,this.cause=a,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(t){return t instanceof Ut}},be="multi-string",Bt=zod.z.object({type:zod.z.literal(be),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()}),qn=o=>zod.z.array(zod.z.string()).max(o).default([]).optional(),$n=o=>({def:Bt.parse(oe({type:be},o)),schema:qn(o.max)}),Ft="object-schema",Ln=zod.z.object({type:zod.z.literal(Ft),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),objectSchema:zod.z.any()}),ve="range",Dt=zod.z.object({type:zod.z.literal(ve),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()}),Un=(o,t,a,i)=>zod.z.number().min(o).max(t).step(a).default(i).optional(),ae=o=>({def:Dt.parse(oe({type:ve},o)),schema:Un(o.min,o.max,o.step,o.default)}),we="select-boolean",Kt=zod.z.object({type:zod.z.literal(we),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()}),Bn=o=>zod.z.boolean().nullable().default(o).optional(),Fn=o=>({def:Kt.parse(oe({type:we},o)),schema:Bn(o.default)}),Ce="select-string",Ht=zod.z.object({type:zod.z.literal(Ce),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).nullable(),choices:zod.z.array(zod.z.string().min(1))}),Dn=(o,t)=>zod.z.enum(t).nullable().default(o).optional(),Te=o=>({def:Ht.parse(oe({type:Ce},o)),schema:Dn(o.default,o.choices)}),Kn=[ve,be,Ce,Ft,we];zod.z.enum(Kn);var Vt=zod.z.discriminatedUnion("type",[Dt,Bt,Ht,Kt,Ln]),ne=(o=wt,t=ln)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(o,zod.z.string().min(1).optional()),modalities:zod.z.array(t).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),Vt),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(a=>{var i,r;let s=Object.keys(a.def),l=Object.keys((r=(i=a.schema)==null?void 0:i.shape)!=null?r:{});return s.every(d=>l.includes(d))&&l.every(d=>s.includes(d))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})}),$=(o=On)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),modalities:zod.z.array(o).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),Vt),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(t=>{var a,i;let r=Object.keys(t.def),s=Object.keys((i=(a=t.schema)==null?void 0:a.shape)!=null?i:{});return r.every(l=>s.includes(l))&&s.every(l=>r.includes(l))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})});zod.z.record(zod.z.string());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()]));zod.z.string().url();var Hn={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."},Vn={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."},zn=o=>({type:"multi",title:"Stop sequence",description:`Enter up to ${o} sequences that will halt additional text output. The generated text will exclude these sequences.`}),Jn={type:"range",title:"Top A",description:"Considers only the top tokens that have 'sufficiently high' probabilities relative to the most likely token, functioning like a dynamic Top-P. A lower Top-A value narrows down the token choices based on the highest probability token, while a higher Top-A value refines the filtering without necessarily impacting the creativity of the output."},Gn={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."},Wn={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."},Zn={type:"range",title:"Min P",description:"Specifies the minimum probability a token must have to be considered, in relation to the probability of the most likely token. (This value varies based on the confidence level of the top token.) For example, if Min-P is set to 0.1, only tokens with at least 1/10th the probability of the highest-ranked token will be considered."},Yn={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."},Qn={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."},Xn={type:"range",title:"Seed",description:"When seed is fixed to a specific value, the model makes a best effort to provide the same response for repeated requests. Deterministic output isn't guaranteed. Also, changing the model or parameter settings, such as the temperature, can cause variations in the response even when you use the same seed value. By default, a random seed value is used."},ei={type:"range",title:"Repetition penalty",description:"Reduces the likelihood of repeating tokens from the input. Increasing this value makes the model less prone to repetition, but setting it too high may lead to less coherent output, often resulting in run-on sentences missing smaller words. The token penalty is scaled according to the original token's probability."},ti={type:"boolean",title:"Log probs",description:"Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned."},oi={type:"range",title:"Top log probs",description:"The number of most likely tokens to return at each token position, each with an associated log probability. 'logprobs' must be set to true if this parameter is used."},ai={type:"boolean",title:"Echo",description:"If true, the response will contain the prompt."},ni={type:"select",title:"Response format",description:"Choose the response format of your model. For JSON, you must include the string 'JSON' in some form within your system / user prompt."},ii={type:"select",title:"Response format",description:"Choose the response format of your model. 'json_object' colloquially known as JSON mode, instructs the model to respond with a valid JSON (must include the term 'json' in prompt). 'json_schema' colloquially known as structured outputs, allows you to specify a strict response schema that the model will adhere to."},si={type:"object",title:"Response schema",description:"When response format is set to 'json_schema', the model will return a JSON object of the specified schema."},x={TEMPERATURE:Hn,MAX_TOKENS:Vn,STOP:zn,TOP_A:Jn,TOP_P:Gn,TOP_K:Wn,MIN_P:Zn,FREQUENCY_PENALTY:Yn,PRESENCE_PENALTY:Qn,REPETITION_PENALTY:ei,SEED:Xn,LOG_PROBS:ti,TOP_LOG_PROBS:oi,ECHO:ai,RESPONSE_FORMAT:ni,RESPONSE_FORMAT_WITH_SCHEMA:ii,RESPONSE_SCHEMA:si},zt=o=>Object.fromEntries(Object.entries(o).filter(([t,a])=>a!=null)),J=o=>o==null?void 0:o.replace(/\/$/,""),Jt=ae({param:"temperature",title:x.TEMPERATURE.title,description:x.TEMPERATURE.description,min:0,max:1,step:.01,default:1}),Gt=o=>ae({param:"max_tokens",title:x.MAX_TOKENS.title,description:x.MAX_TOKENS.description,min:0,max:o,step:1,default:0}),Wt=o=>$n({param:"stop_sequences",title:x.STOP(o).title,description:x.STOP(o).description,max:o}),Zt=ae({param:"top_p",title:x.TOP_P.title,description:x.TOP_P.description,min:0,max:1,step:.01,default:1}),Yt=ae({param:"top_k",title:x.TOP_K.title,description:x.TOP_K.description,min:0,max:1,step:.01,default:1}),Qt=Te({param:"tool_choice",title:"Tool choice",description:"Controls which (if any) tool is called by the model. 'any' means the model will call any of the provided tools. 'auto' means the model can pick between generating a message or calling a tool.",default:"auto",choices:["auto","any"]}),ri=(o,t)=>zod.z.object({temperature:Jt.schema,maxTokens:Gt(o).schema,stop:Wt(t).schema,topP:Zt.schema,topK:Yt.schema,toolChoice:Qt.schema}),li=(o,t)=>({temperature:Jt.def,maxTokens:Gt(o).def,stop:Wt(t).def,topP:Zt.def,topK:Yt.def,toolChoice:Qt.def}),Xt=Te({param:"encoding_format",title:"Encoding format",description:"Select the encoding format for the word embedding.",default:null,choices:["base64"]}),eo=Te({param:"input_type",title:"Input type",description:"Select the input type for the word embedding.",default:null,choices:["query","document"]}),to=Fn({param:"truncation",title:"Truncation",description:"Select the truncation for the word embedding.",default:!0}),di=()=>zod.z.object({encodingFormat:Xt.schema,inputType:eo.schema,truncation:to.schema}),mi=()=>({encodingFormat:Xt.def,inputType:eo.def,truncation:to.def}),C={base:(o,t)=>({def:li(o,t),schema:ri(o,t)})},v={base:()=>({def:mi(),schema:di()})},L=zod.z.enum([G,M,w]),U={system:G,user:M,assistant:w},B=[y,N,k,A],F=zod.z.enum([y,N,k,A]),ci=zod.z.object({type:zod.z.literal("text"),text:zod.z.string()}),ui=zod.z.object({type:zod.z.literal("tool_use"),id:zod.z.string(),name:zod.z.string(),input:zod.z.record(zod.z.any())}),pi=zod.z.object({content:zod.z.array(zod.z.discriminatedUnion("type",[ci,ui])),id:zod.z.string(),model:zod.z.string(),role:zod.z.string(),stop_reason:zod.z.string(),stop_sequence:zod.z.null(),type:zod.z.literal("message"),usage:zod.z.object({input_tokens:zod.z.number(),output_tokens:zod.z.number(),cache_creation_input_tokens:zod.z.number().nullish(),cache_read_input_tokens:zod.z.number().nullish()})}),hi=zod.z.object({type:zod.z.literal("message_start"),message:zod.z.object({id:zod.z.string(),type:zod.z.literal("message"),role:zod.z.string(),model:zod.z.string(),stop_reason:zod.z.string().nullable(),stop_sequence:zod.z.string().nullable(),content:zod.z.array(zod.z.any()),usage:zod.z.object({input_tokens:zod.z.number(),output_tokens:zod.z.number()})})}),gi=zod.z.object({type:zod.z.literal("message_delta"),delta:zod.z.object({stop_reason:zod.z.string().nullable(),stop_sequence:zod.z.string().nullable()}),usage:zod.z.object({output_tokens:zod.z.number()})}),fi=zod.z.object({type:zod.z.literal("text"),text:zod.z.string()}),yi=zod.z.object({type:zod.z.literal("tool_use"),id:zod.z.string(),name:zod.z.string(),input:zod.z.object({})}),bi=zod.z.object({type:zod.z.literal("content_block_start"),index:zod.z.number(),content_block:zod.z.discriminatedUnion("type",[fi,yi])}),vi=zod.z.object({type:zod.z.literal("text_delta"),text:zod.z.string()}),wi=zod.z.object({type:zod.z.literal("input_json_delta"),partial_json:zod.z.string()}),Ci=zod.z.object({type:zod.z.literal("content_block_delta"),index:zod.z.number(),delta:zod.z.discriminatedUnion("type",[vi,wi])}),Ti=zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1).optional(),input_schema:zod.z.any()}),xi=zod.z.object({type:zod.z.enum(["auto","any"])}),ki=zod.z.object({type:zod.z.literal("tool"),name:zod.z.string().min(1)}),xe=zod.z.object({text:zod.z.string().min(1),type:zod.z.literal("text")}),oo=zod.z.object({type:zod.z.literal("image"),source:zod.z.object({type:zod.z.literal("base64"),media_type:zod.z.enum(["image/jpeg","image/png","image/gif","image/webp"]),data:zod.z.string().base64()})});zod.z.object({id:zod.z.string().min(1),type:zod.z.literal("tool_use"),name:zod.z.string().min(1),input:zod.z.record(zod.z.any())});var ao=zod.z.object({type:zod.z.literal("tool_result"),tool_use_id:zod.z.string().min(1),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([xe,oo])).min(1))}),Si=zod.z.object({role:zod.z.literal("user"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([xe,oo,ao])).min(1))}),Oi=zod.z.object({role:zod.z.literal("assistant"),content:zod.z.string().min(1).or(zod.z.array(zod.z.union([xe,ao])).min(1))}),ji=zod.z.union([Si,Oi]),Ei=zod.z.object({model:zod.z.string().min(1).optional(),messages:zod.z.array(ji).min(1),system:zod.z.string().min(1).optional(),max_tokens:zod.z.number().min(0).optional(),stop_sequences:zod.z.array(zod.z.string().min(1)).optional(),temperature:zod.z.number().min(0).max(1).optional(),tool_choice:zod.z.union([xi,ki]).optional(),tools:zod.z.array(Ti).min(1).optional(),top_p:zod.z.number().min(0).max(1).optional(),top_k:zod.z.number().min(0).optional()}),Mi="anthropic",te=class{constructor(){this.version="v1",this.name=Mi,this.chatModelFactories={[no]:{model:_i,modelOptions:Ii,modelSchema:io},[so]:{model:Ai,modelOptions:Ni,modelSchema:ro},[lo]:{model:Li,modelOptions:$i,modelSchema:mo},[co]:{model:Fi,modelOptions:Bi,modelSchema:uo}},this.embeddingModelFactories={[xo]:{model:ls,modelOptions:rs,modelSchema:ko},[Co]:{model:is,modelOptions:ns,modelSchema:To},[po]:{model:Ji,modelOptions:zi,modelSchema:ho},[go]:{model:Zi,modelOptions:Wi,modelSchema:fo},[yo]:{model:Xi,modelOptions:Qi,modelSchema:bo},[vo]:{model:os,modelOptions:ts,modelSchema:wo}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((o,t)=>(o[t]=this.chatModelFactories[t].modelSchema,o),{})}chatModel(o){let t=o.modelName;if(!t)throw new X({info:"options.modelName is required",cause:new Error("options.modelName is required")});if(!(t in this.chatModelFactories))throw new X({info:`Anthropic chat model: ${t} not found`,cause:new Error(`Anthropic chat model: ${t} not found, available chat models:
11
+ ${this.chatModelLiterals().join(", ")}`)});let a=this.chatModelFactories[t].model,i=ee(f({},o),{modelName:t}),r=this.chatModelFactories[t].modelOptions.parse(i);return new a(r)}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((o,t)=>(o[t]=this.embeddingModelFactories[t].modelSchema,o),{})}embeddingModel(o){let t=o.modelName;if(!t)throw new X({info:"options.modelName is required",cause:new Error("options.modelName is required")});if(!(t in this.embeddingModelFactories))throw new X({info:`Anthropic embedding model: ${t} not found`,cause:new Error(`Anthropic embedding model: ${t} not found, available embedding models:
12
+ ${this.embeddingModelLiterals().join(", ")}`)});let a=this.embeddingModelFactories[t].model,i=ee(f({},o),{modelName:t}),r=this.embeddingModelFactories[t].modelOptions.parse(i);return new a(r)}};te.chatBaseUrl="https://api.anthropic.com/v1",te.embeddingBaseUrl="https://api.anthropic.com/v1";var W=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),completeChatUrl:zod.z.string().url().optional(),streamChatUrl:zod.z.string().url().optional()}),D=class{constructor(o,t){this.version="v1";let a=W.parse(t);this.modelSchema=o,this.modelName=a.modelName,this.apiKey=a.apiKey,this.baseUrl=J(te.chatBaseUrl),this.completeChatUrl=J(a.completeChatUrl||`${this.baseUrl}/messages`),this.streamChatUrl=J(a.streamChatUrl||`${this.baseUrl}/messages`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {"x-api-key":`${this.apiKey}`,"anthropic-version":"2023-06-01","content-type":"application/json",source:"adaline.ai"}}getDefaultParams(){return {model:this.modelName}}getRetryDelay(o){let t=0,a=!0;return o["x-should-retry"]&&(a=o["x-should-retry"].toLowerCase()!=="false"),o["retry-after"]&&(t=parseInt(o["retry-after"])*1e3),{shouldRetry:a,delayMs:t}}getTokenCount(o){return o.reduce((t,a)=>t+a.content.map(i=>i.modality==="text"?i.value:"").join(" ").length,0)}transformModelRequest(o){let t=Ei.safeParse(o);if(!t.success)throw new he({info:"Invalid model request",cause:t.error});let a=t.data,i=a.model;if(a.tool_choice&&(!a.tools||a.tools.length===0))throw new he({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let r={};a.tool_choice&&(a.tool_choice.type==="tool"?r.toolChoice=a.tool_choice.name:r.toolChoice=a.tool_choice.type),r.maxTokens=a.max_tokens,r.temperature=a.temperature,r.topP=a.top_p,r.topK=a.top_k,r.stop=a.stop_sequences;let s=jt().parse(zt(r)),l=[],d={};a.system&&l.push({role:G,content:[{modality:y,value:a.system}]}),a.messages.forEach(u=>{let h=u.role;switch(h){case"user":{let g=u.content;if(typeof g=="string")l.push({role:h,content:[{modality:y,value:g}]});else {let T=g.map(p=>{if(p.type==="text")return {modality:y,value:p.text};if(p.type==="image"){let re="auto",Y=p.source.media_type.split("/")[1];return {modality:N,detail:re,value:{type:Ct,media_type:Y,base64:p.source.data}}}else return {modality:A,id:p.tool_use_id,index:d[p.tool_use_id].index,name:d[p.tool_use_id].name,data:typeof p.content=="string"?p.content:JSON.stringify(p.content)}});l.push({role:h,content:T});}}break;case"assistant":{let g=u.content;if(typeof g=="string")l.push({role:h,content:[{modality:y,value:g}]});else {let T=g.map((p,re)=>{if(p.type==="text")return {modality:y,value:p.text};{let Y={modality:k,id:p.id,index:re,name:p.name,arguments:JSON.stringify(p.input)};return d[p.id]=Y,Y}});l.push({role:h,content:T});}}break}});let c=[];return a.tools&&a.tools.forEach(u=>{c.push({type:"function",definition:{schema:{name:u.name,description:u.description||"",parameters:u.input_schema}}});}),{modelName:i,config:s,messages:l,tools:c.length>0?c:void 0}}transformConfig(o,t,a){let i=o.toolChoice;delete o.toolChoice;let r=this.modelSchema.config.schema.safeParse(o);if(!r.success)throw new E({info:`Invalid config for model : '${this.modelName}'`,cause:r.error});let s=r.data;i!==void 0&&(s.toolChoice=i),Object.keys(s).forEach(d=>{if(!(d in this.modelSchema.config.def))throw new E({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${d}',
13
+ available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let l=Object.keys(s).reduce((d,c)=>{let u=this.modelSchema.config.def[c],h=u.param,g=s[c];return h==="max_tokens"&&u.type==="range"&&g===0?d[h]=u.max:d[h]=g,d},{});if(!l.max_tokens)throw new E({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`'max_tokens' is required for model : '${this.modelName}'`)});if("tool_choice"in l&&l.tool_choice!==void 0){let d=l.tool_choice;if(!a||a&&a.length===0)throw new E({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(a&&a.length>0){let c=this.modelSchema.config.def.toolChoice;if(c.choices.includes(d))l.tool_choice={type:d};else if(a.map(u=>u.definition.schema.name).includes(d))l.tool_choice={type:"tool",name:d};else throw new E({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`toolChoice : '${d}' is not part of provided 'tools' names or
14
+ one of [${c.choices.join(", ")}]`)})}}return l}transformMessages(o){if(!o||o&&o.length===0)return {messages:[]};let t=o.map(s=>{let l=Ot().safeParse(s);if(!l.success)throw new b({info:"Invalid messages",cause:l.error});return l.data});t.forEach(s=>{s.content.forEach(l=>{if(!this.modelSchema.modalities.includes(l.modality))throw new b({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${l.modality}',
15
+ available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),t.forEach(s=>{if(!Object.keys(this.modelSchema.roles).includes(s.role))throw new b({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${s.role}',
16
+ available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})});let a="",i=[];if(t.forEach(s=>{switch(s.role){case G:s.content.forEach(l=>{if(l.modality===y)a+=l.value;else throw new b({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${l.modality}'`)})});break;case w:{let l=[];s.content.forEach(d=>{if(d.modality===y)l.push({type:"text",text:d.value});else if(d.modality===k)l.push({type:"tool_use",id:d.id,name:d.name,input:JSON.parse(d.arguments)});else throw new b({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${d.modality}'`)})}),i.push({role:this.modelSchema.roles[s.role],content:l});}break;case M:{let l=[];s.content.forEach(d=>{if(d.modality===y)l.push({type:"text",text:d.value});else if(d.modality===N){if(d.value.type==="base64")l.push({type:"image",source:{type:"base64",media_type:`image/${d.value.media_type}`,data:d.value.base64}});else if(d.value.type==="url")throw new b({info:`Invalid message 'modality' for model : ${this.modelName}`,cause:new Error(`model: '${this.modelName}' does not support image content type: '${d.value.type}'`)})}else if(d.modality===A)l.push({type:"tool_result",tool_use_id:d.id,content:d.data});else throw new b({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${d.modality}'`)})}),i.push({role:this.modelSchema.roles[s.role],content:l});}break;default:throw new b({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' is not supported,
17
+ available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}}),i[0].role!==this.modelSchema.roles[M])throw new b({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires first message to be from user`)});let r=s=>s===this.modelSchema.roles[M]?this.modelSchema.roles[w]:this.modelSchema.roles[M];for(let s=1;s<i.length;s++)if(i[s].role!==r(i[s-1].role))throw new b({info:`Invalid message format for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' requires messages to alternate between user and assistant`)});return {system:a,messages:i}}transformTools(o){if(!this.modelSchema.modalities.includes(k))throw new ft({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${k}'`)});return !o||o&&o.length===0?{tools:[]}:{tools:o.map(t=>{let a=kn().safeParse(t);if(!a.success)throw new ft({info:"Invalid tools",cause:a.error});return a.data}).map(t=>({name:t.definition.schema.name,description:t.definition.schema.description,input_schema:t.definition.schema.parameters}))}}getCompleteChatUrl(o,t,a){return j(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getCompleteChatHeaders(o,t,a){return j(this,null,function*(){let i=this.getDefaultHeaders();return a&&a.length>0&&(i=ee(f({},i),{"anthropic-beta":"tools-2024-05-16"})),new Promise(r=>{r(i);})})}getCompleteChatData(o,t,a){return j(this,null,function*(){let i=this.transformConfig(o,t,a),r=this.transformMessages(t);if(r.messages&&r.messages.length===0)throw new b({info:"Messages are required",cause:new Error("Messages are required")});let s=a?this.transformTools(a):{};return new Promise(l=>{l(f(f(f(f({},this.getDefaultParams()),i),r),s));})})}transformCompleteChatResponse(o){let t=pi.safeParse(o);if(t.success){let a=t.data,i=a.content.map((l,d)=>{if(l.type==="text")return un(l.text);if(l.type==="tool_use")return pn(d,l.id,l.name,JSON.stringify(l.input))}),r=[{role:w,content:i}],s={promptTokens:a.usage.input_tokens,completionTokens:a.usage.output_tokens,totalTokens:a.usage.input_tokens+a.usage.output_tokens};return {messages:r,usage:s,logProbs:[]}}throw new O({info:"Invalid response from model",cause:t.error})}getStreamChatUrl(o,t,a){return j(this,null,function*(){return new Promise(i=>{i(this.streamChatUrl);})})}getStreamChatHeaders(o,t,a){let i=this.getDefaultHeaders();return a&&a.length>0&&(i=ee(f({},i),{"anthropic-beta":"tools-2024-05-16"})),new Promise(r=>{r(i);})}getStreamChatData(o,t,a){return j(this,null,function*(){let i=this.transformConfig(o,t,a),r=this.transformMessages(t);if(r.messages&&r.messages.length===0)throw new b({info:"Messages are required",cause:new Error("Messages are required")});let s=a?this.transformTools(a):{};return new Promise(l=>{l(f(f(f(f({stream:!0},this.getDefaultParams()),i),r),s));})})}transformStreamChatResponseChunk(o,t){return Ha(this,null,function*(){let a=(t+o).split(`
18
+ `).filter(i=>i.trim()!=="");for(let i of a)if(i.startsWith("data: {")&&i.endsWith("}")){let r;try{r=JSON.parse(i.substring(6));}catch(s){throw new O({info:"Malformed JSON received in stream",cause:new Error(`Malformed JSON received in stream : ${r}`)})}if("type"in r){if(r.type==="message_stop")return;if(r.type==="message_start"){let s=hi.safeParse(r);if(s.success){let l=s.data;yield {partialResponse:{partialMessages:[],usage:{promptTokens:l.message.usage.input_tokens,completionTokens:l.message.usage.output_tokens,totalTokens:l.message.usage.input_tokens+l.message.usage.output_tokens}},buffer:t};}else throw new O({info:"Invalid response from model",cause:s.error})}else if(r.type==="message_delta"){let s=gi.safeParse(r);if(s.success){let l=s.data;yield {partialResponse:{partialMessages:[],usage:{promptTokens:0,completionTokens:l.usage.output_tokens,totalTokens:l.usage.output_tokens}},buffer:t};}else throw new O({info:"Invalid response from model",cause:s.error})}else if(r.type==="content_block_start"){let s=bi.safeParse(r);if(s.success){let l=s.data,d=[];l.content_block.type==="text"?d.push(at(w,l.content_block.text)):l.content_block.type==="tool_use"&&d.push(nt(w,l.index,l.content_block.id,l.content_block.name,"")),yield {partialResponse:{partialMessages:d},buffer:t};}else throw new O({info:"Invalid response from model",cause:s.error})}else if(r.type==="content_block_delta"){let s=Ci.safeParse(r);if(s.success){let l=s.data,d=[];l.delta.type==="text_delta"?d.push(at(w,l.delta.text)):l.delta.type==="input_json_delta"&&d.push(nt(w,l.index,"","",l.delta.partial_json)),yield {partialResponse:{partialMessages:d},buffer:t};}else throw new O({info:"Invalid response from model",cause:s.error})}}else throw new O({info:"Invalid JSON received in stream",cause:new Error(`Invalid JSON received in stream, expected 'type' property,
19
+ received : ${JSON.stringify(r)}`)})}})}},no="claude-3-haiku-20240307",Pi="Fastest and most compact model for near-instant responsiveness. Quick and accurate targeted performance.",io=ne(L,F).parse({name:no,description:Pi,maxInputTokens:2e5,maxOutputTokens:4096,roles:U,modalities:B,config:{def:C.base(4096,4).def,schema:C.base(4096,4).schema}}),Ii=W,_i=class extends D{constructor(o){super(io,o);}},so="claude-3-sonnet-20240229",Ri="Balance of intelligence and speed. Strong utility, balanced for scaled deployments.",ro=ne(L,F).parse({name:so,description:Ri,maxInputTokens:2e5,maxOutputTokens:4096,roles:U,modalities:B,config:{def:C.base(4096,4).def,schema:C.base(4096,4).schema}}),Ni=W,Ai=class extends D{constructor(o){super(ro,o);}},lo="claude-3-opus-20240229",qi="Powerful model for highly complex tasks. Top-level performance, intelligence, fluency, and understanding.",mo=ne(L,F).parse({name:lo,description:qi,maxInputTokens:2e5,maxOutputTokens:4096,roles:U,modalities:B,config:{def:C.base(4096,4).def,schema:C.base(4096,4).schema}}),$i=W,Li=class extends D{constructor(o){super(mo,o);}},co="claude-3-5-sonnet-20240620",Ui="Most intelligent model. Highest level of intelligence and capability.",uo=ne(L,F).parse({name:co,description:Ui,maxInputTokens:2e5,maxOutputTokens:8192,roles:U,modalities:B,config:{def:C.base(8192,4).def,schema:C.base(8192,4).schema}}),Bi=W,Fi=class extends D{constructor(o){super(uo,o);}},K=[q],H=zod.z.enum([q]),Di=zod.z.object({object:zod.z.literal("list"),model:zod.z.string(),data:zod.z.array(zod.z.object({index:zod.z.number(),object:zod.z.literal("embedding"),embedding:zod.z.array(zod.z.number()).or(zod.z.string().base64())})),usage:zod.z.object({total_tokens:zod.z.number()})}),Ki=zod.z.string().min(1).or(zod.z.array(zod.z.string().min(1)).min(1)),Hi=zod.z.object({model:zod.z.string().min(1).optional(),input:Ki,encoding_format:zod.z.enum(["base64"]).nullable().optional(),input_type:zod.z.enum(["query","document"]).nullable().optional(),truncation:zod.z.boolean().optional()}),I=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string(),getEmbeddingsUrl:zod.z.string().url().optional()}),V=class{constructor(o,t){this.version="v1";let a=I.parse(t);this.modelSchema=o,this.modelName=a.modelName,this.apiKey=a.apiKey,this.baseUrl=J(te.embeddingBaseUrl),this.getEmbeddingsUrl=J(a.getEmbeddingsUrl||`${this.baseUrl}/embeddings`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json",source:"adaline.ai"}}getDefaultParams(){return {model:this.modelName}}getTokenCount(o){return o.requests.reduce((t,a)=>t+a.length,0)}getRetryDelay(o){return {shouldRetry:!0,delayMs:0}}transformModelRequest(o){let t=Hi.safeParse(o);if(!t.success)throw new he({info:"Invalid model request",cause:t.error});let a=t.data,i=a.model,r={encodingFormat:a.encoding_format,inputType:a.input_type,truncation:a.truncation},s=jt().parse(zt(r)),l;return typeof a.input=="string"?l={modality:q,requests:[a.input]}:l={modality:q,requests:a.input},{modelName:i,config:s,embeddingRequests:l}}transformConfig(o,t){let a=this.modelSchema.config.schema.safeParse(o);if(!a.success)throw new E({info:`Invalid config for model : '${this.modelName}'`,cause:a.error});let i=a.data;return Object.keys(i).forEach(r=>{if(!this.modelSchema.config.def[r])throw new E({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${r}',
20
+ available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(i).reduce((r,s)=>{let l=this.modelSchema.config.def[s].param,d=i[s];return r[l]=d,r},{})}transformEmbeddingRequests(o){let t=Mn().safeParse(o);if(!t.success)throw new bt({info:"Invalid embedding requests",cause:t.error});if(t.data.requests.length>128)throw new bt({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Max requests for model : '${this.modelName}' is 128`)});return {input:t.data.requests}}getGetEmbeddingsUrl(o,t){return j(this,null,function*(){return new Promise(a=>{a(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(o,t){return j(this,null,function*(){return new Promise(a=>{a(this.getDefaultHeaders());})})}getGetEmbeddingsData(o,t){return j(this,null,function*(){return new Promise(a=>{a(f(f(f({},this.getDefaultParams()),this.transformConfig(o,t)),this.transformEmbeddingRequests(t)));})})}transformGetEmbeddingsResponse(o){let t,a=Di.safeParse(o);if(a.success){let i=a.data;t=typeof i.data[0].embedding=="string"?Pt:Mt;let r=i.data.map(s=>typeof s.embedding=="string"?{index:s.index,embedding:s.embedding}:{index:s.index,embedding:s.embedding});return {encodingFormat:t,embeddings:r,usage:{totalTokens:i.usage.total_tokens}}}throw new O({info:"Invalid response from model",cause:a.error})}},po="voyage-code-2",Vi="Optimized for code retrieval.",ho=$(H).parse({name:po,description:Vi,modalities:K,maxInputTokens:16e3,maxOutputTokens:16e3,config:{def:v.base().def,schema:v.base().schema}}),zi=I,Ji=class extends V{constructor(o){super(ho,o);}},go="voyage-law-2",Gi="Optimized for legal and long-context retrieval and RAG. Also improved performance across all domains.",fo=$(H).parse({name:go,description:Gi,modalities:K,maxInputTokens:16e3,maxOutputTokens:16e3,config:{def:v.base().def,schema:v.base().schema}}),Wi=I,Zi=class extends V{constructor(o){super(fo,o);}},yo="voyage-multilingual-2",Yi="Optimized for multilingual retrieval and RAG.",bo=$(H).parse({name:yo,description:Yi,modalities:K,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:v.base().def,schema:v.base().schema}}),Qi=I,Xi=class extends V{constructor(o){super(bo,o);}},vo="voyage-finance-2",es="Optimized for finance retrieval and RAG.",wo=$(H).parse({name:vo,description:es,modalities:K,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:v.base().def,schema:v.base().schema}}),ts=I,os=class extends V{constructor(o){super(wo,o);}},Co="voyage-3-lite",as="Optimized for latency and cost.",To=$(H).parse({name:Co,description:as,modalities:K,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:v.base().def,schema:v.base().schema}}),ns=I,is=class extends V{constructor(o){super(To,o);}},xo="voyage-3",ss="Optimized for quality.",ko=$(H).parse({name:xo,description:ss,modalities:K,maxInputTokens:32e3,maxOutputTokens:32e3,config:{def:v.base().def,schema:v.base().schema}}),rs=I,ls=class extends V{constructor(o){super(ko,o);}};var ke=zod.z.object({modelName:zod.z.string(),awsRegion:zod.z.string(),awsAccessKeyId:zod.z.string(),awsSecretAccessKey:zod.z.string()}),ie=class o extends D{constructor(a,i){let r=ke.parse(i);super(a,{apiKey:"random-api-key",modelName:r.modelName});this.version="v1";this.modelSchema=a,this.modelName=r.modelName,this.awsRegion=r.awsRegion,this.awsUrl=_.awsUrl(this.awsRegion),this.awsService=_.awsService,this.awsAccessKeyId=r.awsAccessKeyId,this.awsSecretAccessKey=r.awsSecretAccessKey;}getDefaultBaseUrl(){return this.awsUrl}getDefaultHeaders(){return {Accept:"application/json","Content-Type":"application/json",host:this.awsUrl.split("://")[1]}}getDefaultParams(){return {anthropic_version:"bedrock-2023-05-31"}}getCompleteChatUrl(a,i,r){return new Promise(s=>{s(`${this.awsUrl}/model/${this.modelName}/invoke`);})}getCompleteChatHeaders(a,i,r){return R(this,null,function*(){let s=new URL(yield this.getCompleteChatUrl(a,i,r)),l={accessKeyId:this.awsAccessKeyId,secretAccessKey:this.awsSecretAccessKey},d=this.getDefaultHeaders(),c=this.getCompleteChatData(a||{},i||[],r),u=new protocolHttp.HttpRequest({hostname:s.hostname,path:s.pathname,protocol:s.protocol,method:"POST",body:JSON.stringify(c),headers:d});return (yield new signatureV4.SignatureV4({credentials:l,service:this.awsService,region:this.awsRegion,sha256:sha256Js.Sha256}).sign(u)).headers})}getCompleteChatData(a,i,r){return R(this,null,function*(){let s=S(S({},this.getDefaultParams()),Q(o.prototype,this,"getCompleteChatData").call(this,a,i,r));return new Promise(l=>{l(s);})})}getStreamChatUrl(a,i,r){return R(this,null,function*(){return new Promise(s=>{s(`${this.awsUrl}/model/${this.modelName}/invoke-with-response-stream`);})})}getStreamChatHeaders(a,i,r){return R(this,null,function*(){let s=new URL(yield this.getStreamChatUrl(a,i,r)),l={accessKeyId:this.awsAccessKeyId,secretAccessKey:this.awsSecretAccessKey},d=this.getDefaultHeaders(),c=this.getCompleteChatData(a||{},i||[],r),u=new protocolHttp.HttpRequest({hostname:s.hostname,path:s.pathname,protocol:s.protocol,method:"POST",body:JSON.stringify(c),headers:d});return (yield new signatureV4.SignatureV4({credentials:l,service:this.awsService,region:this.awsRegion,sha256:sha256Js.Sha256}).sign(u)).headers})}getStreamChatData(a,i,r){return R(this,null,function*(){let s=S(S({},this.getDefaultParams()),Q(o.prototype,this,"getStreamChatData").call(this,a,i,r));return "stream"in s&&delete s.stream,s})}transformStreamChatResponseChunk(a,i){return Ee(this,null,function*(){let r=a.toString(),s=/{\s*"bytes"\s*:\s*"[\w=+/]+".*?}/g,l=r.match(s)||[];for(let d of l){let c=d.indexOf("{"),u=d.indexOf("}");if(c!==-1&&u!==-1&&c<u){let h;try{h=JSON.parse(d.slice(c,u+1));}catch(p){throw new ze({info:"Malformed JSON received in stream",cause:new Error(`Malformed JSON received in stream : ${h}`)})}let g=et(h.bytes),T=(yield new de(Q(o.prototype,this,"transformStreamChatResponseChunk").call(this,`data: ${g}`,i).next())).value;T&&(yield T);}}})}};var ds="anthropic.claude-3-haiku-20240307-v1:0",ms="Claude 3 Haiku is a large-scale multimodal model trained by Anthropic. It is the successor to Claude 3 and is designed to be more powerful and capable than its predecessor.",Se=Xe(L,F).parse({name:ds,description:ms,maxInputTokens:128e3,maxOutputTokens:128e3,roles:U,modalities:B,config:{def:C.base(128e3,4).def,schema:C.base(128e3,4).schema}}),Eo=ke,se=class extends ie{constructor(t){super(Se,t);}};var cs="bedrock",_=class{constructor(){this.version="v1";this.name=cs;this.chatModelFactories={"claude-3-haiku-20240307":{model:se,modelOptions:Eo,modelSchema:Se}};this.embeddingModelFactories={};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((t,a)=>(t[a]=this.chatModelFactories[a].modelSchema,t),{})}chatModel(t){let a=t.modelName;if(!a)throw new z({info:"options.modelName is required",cause:new Error("options.modelName is required")});if(!(a in this.chatModelFactories))throw new z({info:`Bedrock chat model: ${a} not found`,cause:new Error(`Bedrock chat model: ${a} not found, available chat models:
21
+ ${this.chatModelLiterals().join(", ")}`)});let i=this.chatModelFactories[a].model,r=le(S({},t),{modelName:a}),s=this.chatModelFactories[a].modelOptions.parse(r);return new i(s)}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((t,a)=>(t[a]=this.embeddingModelFactories[a].modelSchema,t),{})}embeddingModel(t){let a=t.modelName;if(!a)throw new z({info:"options.modelName is required",cause:new Error("options.modelName is required")});if(!(a in this.embeddingModelFactories))throw new z({info:`Bedrock embedding model: ${a} not found`,cause:new Error(`Bedrock embedding model: ${a} not found, available embedding models:
22
+ ${this.embeddingModelLiterals().join(", ")}`)});let i=this.embeddingModelFactories[a].model,r=le(S({},t),{modelName:a}),s=this.embeddingModelFactories[a].modelOptions.parse(r);return new i(s)}};_.awsService="bedrock",_.awsUrl=t=>`https://bedrock.${t}.amazonaws.com`;
27
23
 
28
- exports.BaseChatModelAnthropic = ne;
29
- exports.BaseChatModelAnthropicOptions = Ce;
30
- exports.Bedrock = R;
31
- exports.BedrockClaude3Haiku20240307 = ie;
32
- exports.BedrockClaude3Haiku20240307Options = Oo;
33
- exports.BedrockClaude3Haiku20240307Schema = Te;
24
+ exports.BaseChatModelAnthropic = ie;
25
+ exports.BaseChatModelAnthropicOptions = ke;
26
+ exports.Bedrock = _;
27
+ exports.BedrockClaude3Haiku20240307 = se;
28
+ exports.BedrockClaude3Haiku20240307Options = Eo;
29
+ exports.BedrockClaude3Haiku20240307Schema = Se;
34
30
  //# sourceMappingURL=index.js.map
35
31
  //# sourceMappingURL=index.js.map