@adaline/together-ai 0.13.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +34 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -115,7 +115,7 @@ declare const TogetherAIChatModelConfigs: {
|
|
|
115
115
|
param: string;
|
|
116
116
|
title: string;
|
|
117
117
|
description: string;
|
|
118
|
-
default: string
|
|
118
|
+
default: string;
|
|
119
119
|
choices: string[];
|
|
120
120
|
};
|
|
121
121
|
readonly responseSchema: {
|
|
@@ -130,7 +130,7 @@ declare const TogetherAIChatModelConfigs: {
|
|
|
130
130
|
param: string;
|
|
131
131
|
title: string;
|
|
132
132
|
description: string;
|
|
133
|
-
default: string
|
|
133
|
+
default: string;
|
|
134
134
|
choices: string[];
|
|
135
135
|
};
|
|
136
136
|
};
|
|
@@ -355,7 +355,7 @@ declare const ChatModelBaseConfigDef: (maxOutputTokens: number, maxSequences: nu
|
|
|
355
355
|
param: string;
|
|
356
356
|
title: string;
|
|
357
357
|
description: string;
|
|
358
|
-
default: string
|
|
358
|
+
default: string;
|
|
359
359
|
choices: string[];
|
|
360
360
|
};
|
|
361
361
|
readonly responseSchema: {
|
|
@@ -370,7 +370,7 @@ declare const ChatModelBaseConfigDef: (maxOutputTokens: number, maxSequences: nu
|
|
|
370
370
|
param: string;
|
|
371
371
|
title: string;
|
|
372
372
|
description: string;
|
|
373
|
-
default: string
|
|
373
|
+
default: string;
|
|
374
374
|
choices: string[];
|
|
375
375
|
};
|
|
376
376
|
};
|
|
@@ -518,7 +518,7 @@ declare const toolChoice: {
|
|
|
518
518
|
param: string;
|
|
519
519
|
title: string;
|
|
520
520
|
description: string;
|
|
521
|
-
default: string
|
|
521
|
+
default: string;
|
|
522
522
|
choices: string[];
|
|
523
523
|
};
|
|
524
524
|
schema: zod.ZodOptional<zod.ZodDefault<zod.ZodNullable<zod.ZodEnum<[string, ...string[]]>>>>;
|
|
@@ -529,7 +529,7 @@ declare const responseFormat: {
|
|
|
529
529
|
param: string;
|
|
530
530
|
title: string;
|
|
531
531
|
description: string;
|
|
532
|
-
default: string
|
|
532
|
+
default: string;
|
|
533
533
|
choices: string[];
|
|
534
534
|
};
|
|
535
535
|
schema: zod.ZodOptional<zod.ZodDefault<zod.ZodNullable<zod.ZodEnum<[string, ...string[]]>>>>;
|
|
@@ -589,11 +589,12 @@ declare const BaseChatModelSchema: {
|
|
|
589
589
|
param: string;
|
|
590
590
|
title: string;
|
|
591
591
|
description: string;
|
|
592
|
-
default: string
|
|
592
|
+
default: string;
|
|
593
593
|
choices: string[];
|
|
594
594
|
}>;
|
|
595
595
|
schema: zod.ZodObject<zod.ZodRawShape, zod.UnknownKeysParam, zod.ZodTypeAny, unknown, unknown>;
|
|
596
596
|
};
|
|
597
|
+
maxReasoningTokens?: number | undefined;
|
|
597
598
|
};
|
|
598
599
|
|
|
599
600
|
declare const TogetherAIChatRequest: z.ZodObject<{
|
|
@@ -1123,7 +1124,7 @@ declare const BaseEmbeddingModelSchema: {
|
|
|
1123
1124
|
param: string;
|
|
1124
1125
|
title: string;
|
|
1125
1126
|
description: string;
|
|
1126
|
-
default: string
|
|
1127
|
+
default: string;
|
|
1127
1128
|
choices: string[];
|
|
1128
1129
|
}>;
|
|
1129
1130
|
schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
|
package/dist/index.d.ts
CHANGED
|
@@ -115,7 +115,7 @@ declare const TogetherAIChatModelConfigs: {
|
|
|
115
115
|
param: string;
|
|
116
116
|
title: string;
|
|
117
117
|
description: string;
|
|
118
|
-
default: string
|
|
118
|
+
default: string;
|
|
119
119
|
choices: string[];
|
|
120
120
|
};
|
|
121
121
|
readonly responseSchema: {
|
|
@@ -130,7 +130,7 @@ declare const TogetherAIChatModelConfigs: {
|
|
|
130
130
|
param: string;
|
|
131
131
|
title: string;
|
|
132
132
|
description: string;
|
|
133
|
-
default: string
|
|
133
|
+
default: string;
|
|
134
134
|
choices: string[];
|
|
135
135
|
};
|
|
136
136
|
};
|
|
@@ -355,7 +355,7 @@ declare const ChatModelBaseConfigDef: (maxOutputTokens: number, maxSequences: nu
|
|
|
355
355
|
param: string;
|
|
356
356
|
title: string;
|
|
357
357
|
description: string;
|
|
358
|
-
default: string
|
|
358
|
+
default: string;
|
|
359
359
|
choices: string[];
|
|
360
360
|
};
|
|
361
361
|
readonly responseSchema: {
|
|
@@ -370,7 +370,7 @@ declare const ChatModelBaseConfigDef: (maxOutputTokens: number, maxSequences: nu
|
|
|
370
370
|
param: string;
|
|
371
371
|
title: string;
|
|
372
372
|
description: string;
|
|
373
|
-
default: string
|
|
373
|
+
default: string;
|
|
374
374
|
choices: string[];
|
|
375
375
|
};
|
|
376
376
|
};
|
|
@@ -518,7 +518,7 @@ declare const toolChoice: {
|
|
|
518
518
|
param: string;
|
|
519
519
|
title: string;
|
|
520
520
|
description: string;
|
|
521
|
-
default: string
|
|
521
|
+
default: string;
|
|
522
522
|
choices: string[];
|
|
523
523
|
};
|
|
524
524
|
schema: zod.ZodOptional<zod.ZodDefault<zod.ZodNullable<zod.ZodEnum<[string, ...string[]]>>>>;
|
|
@@ -529,7 +529,7 @@ declare const responseFormat: {
|
|
|
529
529
|
param: string;
|
|
530
530
|
title: string;
|
|
531
531
|
description: string;
|
|
532
|
-
default: string
|
|
532
|
+
default: string;
|
|
533
533
|
choices: string[];
|
|
534
534
|
};
|
|
535
535
|
schema: zod.ZodOptional<zod.ZodDefault<zod.ZodNullable<zod.ZodEnum<[string, ...string[]]>>>>;
|
|
@@ -589,11 +589,12 @@ declare const BaseChatModelSchema: {
|
|
|
589
589
|
param: string;
|
|
590
590
|
title: string;
|
|
591
591
|
description: string;
|
|
592
|
-
default: string
|
|
592
|
+
default: string;
|
|
593
593
|
choices: string[];
|
|
594
594
|
}>;
|
|
595
595
|
schema: zod.ZodObject<zod.ZodRawShape, zod.UnknownKeysParam, zod.ZodTypeAny, unknown, unknown>;
|
|
596
596
|
};
|
|
597
|
+
maxReasoningTokens?: number | undefined;
|
|
597
598
|
};
|
|
598
599
|
|
|
599
600
|
declare const TogetherAIChatRequest: z.ZodObject<{
|
|
@@ -1123,7 +1124,7 @@ declare const BaseEmbeddingModelSchema: {
|
|
|
1123
1124
|
param: string;
|
|
1124
1125
|
title: string;
|
|
1125
1126
|
description: string;
|
|
1126
|
-
default: string
|
|
1127
|
+
default: string;
|
|
1127
1128
|
choices: string[];
|
|
1128
1129
|
}>;
|
|
1129
1130
|
schema: z.ZodObject<z.ZodRawShape, z.UnknownKeysParam, z.ZodTypeAny, unknown, unknown>;
|
package/dist/index.js
CHANGED
|
@@ -2,47 +2,47 @@
|
|
|
2
2
|
|
|
3
3
|
var zod = require('zod');
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
Message: ${Gt(o)}`),this.name=J,this.info=t,this.cause=o,this.name=n!=null?n:J,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(t){return t instanceof Be}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},L="system",U="user",v="assistant",$="tool",Vt=[L,U,v,$],W=zod.z.enum(Vt),Yt=[v],Jt=zod.z.enum(Yt),Fe="image",Wt="base64",Zt=["png","jpeg","webp","gif"],Qt=zod.z.object({type:zod.z.literal(Wt),base64:zod.z.string(),media_type:zod.z.enum(Zt)}),Xt="url",eo=zod.z.object({type:zod.z.literal(Xt),url:zod.z.string()}),to=zod.z.discriminatedUnion("type",[Qt,eo]),oo=["low","medium","high","auto"],no=zod.z.enum(oo),ao=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Fe),detail:no,value:to,metadata:a}),R="text",ze=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(R),value:zod.z.string(),metadata:a}),Z="partial-text",De=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Z),value:zod.z.string(),metadata:a}),P="tool-call",He=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(P),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),arguments:zod.z.string(),metadata:a}),Q="partial-tool-call",Ke=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Q),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),arguments:zod.z.string().optional(),metadata:a}),w="tool-response",so=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(w),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),data:zod.z.string(),metadata:a}),ro=[R,Fe,P,w],Ge=zod.z.enum(ro),io=(a=zod.z.undefined(),t=zod.z.undefined(),o=zod.z.undefined(),n=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[ze(a),ao(t),He(o),so(n)]),lo=[Z,Q];zod.z.enum(lo);var mo=(a=zod.z.undefined(),t=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[De(a),Ke(t)]);var X=(a=W,t=zod.z.undefined(),o=zod.z.undefined(),n=zod.z.undefined(),s=zod.z.undefined(),r=zod.z.undefined())=>zod.z.object({role:a,content:zod.z.array(io(t,o,n,s)),metadata:r}),ee=(a=Jt,t=zod.z.undefined(),o=zod.z.undefined(),n=zod.z.undefined())=>zod.z.object({role:a,partialContent:mo(t,o),metadata:n}),Ve=a=>ze().parse({modality:R,value:a}),Ye=(a,t,o,n)=>He().parse({modality:P,index:a,id:t,name:o,arguments:n});var te=(a,t)=>ee().parse({role:a,partialContent:De().parse({modality:Z,value:t})}),Je=(a,t,o,n,s)=>ee().parse({role:a,partialContent:Ke().parse({modality:Q,index:t,id:o,name:n,arguments:s})});var H=(a=zod.z.record(zod.z.string(),zod.z.any()).optional())=>a,po=["object","array","number","string","boolean","enum"],Le=zod.z.enum(po),co=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([Le,zod.z.array(zod.z.union([Le,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()}),uo=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(co),additionalProperties:zod.z.literal(!1)}),We=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:uo}).optional(),go="function";var ho=zod.z.enum(["object","array","number","string","boolean","null"]),fo=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:ho.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(fo).optional(),required:zod.z.array(zod.z.string()).optional()});var yo=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 To=zod.z.enum(["function"]),bo=zod.z.object({type:To,definition:zod.z.object({schema:yo})}),Co=[go];zod.z.enum(Co);var Ze=(a=zod.z.undefined())=>zod.z.discriminatedUnion("type",[bo.extend({metadata:a})]),A="text",Qe="token",Eo=[A,Qe],Xe=zod.z.enum(Eo),Ro=zod.z.array(zod.z.string().min(1)),Mo=zod.z.array(zod.z.array(zod.z.number().int().nonnegative())),et=(a=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[zod.z.object({modality:zod.z.literal(A),metadata:a,requests:Ro}),zod.z.object({modality:zod.z.literal(Qe),metadata:a,requests:Mo})]),oe="float",Io=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),vo="base64",Po=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.string().base64()}),Ue=zod.z.object({totalTokens:zod.z.number().int().nonnegative()});zod.z.discriminatedUnion("encodingFormat",[zod.z.object({encodingFormat:zod.z.literal(oe),embeddings:zod.z.array(Io),usage:Ue.optional()}),zod.z.object({encodingFormat:zod.z.literal(vo),embeddings:zod.z.array(Po),usage:Ue.optional()})]);var tt=zod.z.object({promptTokens:zod.z.number().nonnegative(),completionTokens:zod.z.number().nonnegative(),totalTokens:zod.z.number().nonnegative()}),$e=zod.z.object({token:zod.z.string(),logProb:zod.z.number(),bytes:zod.z.array(zod.z.number().int()).nullable()}),So=$e.extend({topLogProbs:zod.z.array($e)}),ot=zod.z.array(So);zod.z.object({messages:zod.z.array(X()),usage:tt.optional(),logProbs:ot.optional()});zod.z.object({partialMessages:zod.z.array(ee()),usage:tt.optional(),logProbs:ot.optional()});var _o=Object.defineProperty,nt=Object.getOwnPropertySymbols,xo=Object.prototype.hasOwnProperty,wo=Object.prototype.propertyIsEnumerable,at=(a,t,o)=>t in a?_o(a,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):a[t]=o,F=(a,t)=>{for(var o in t||(t={}))xo.call(t,o)&&at(a,o,t[o]);if(nt)for(var o of nt(t))wo.call(t,o)&&at(a,o,t[o]);return a};var st="ModelResponseError",k=class pt extends q{constructor({info:t,cause:o}){super({info:t,cause:o},st),this.name=st,this.cause=o,this.info=t;}static isModelResponseError(t){return t instanceof pt}},rt="InvalidModelRequestError",B=class ct extends q{constructor({info:t,cause:o}){super({info:t,cause:o},rt),this.name=rt,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(t){return t instanceof ct}},it="InvalidConfigError",_=class ut extends q{constructor({info:t,cause:o}){super({info:t,cause:o},it),this.name=it,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(t){return t instanceof ut}},lt="InvalidMessagesError",I=class gt extends q{constructor({info:t,cause:o}){super({info:t,cause:o},lt),this.name=lt,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(t){return t instanceof gt}},mt="InvalidToolsError",ne=class ht extends q{constructor({info:t,cause:o}){super({info:t,cause:o},mt),this.name=mt,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(t){return t instanceof ht}},dt="InvalidEmbeddingRequestsError",ae=class ft extends q{constructor({info:t,cause:o}){super({info:t,cause:o},dt),this.name=dt,this.info=t,this.cause=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(t){return t instanceof ft}},se="multi-string",yt=zod.z.object({type:zod.z.literal(se),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()}),Ao=a=>zod.z.array(zod.z.string()).max(a).default([]).optional(),Tt=a=>({def:yt.parse(F({type:se},a)),schema:Ao(a.max)}),re="object-schema",bt=zod.z.object({type:zod.z.literal(re),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),objectSchema:zod.z.any()}),jo=a=>a.optional(),Ct=a=>({def:bt.parse(F({type:re},a)),schema:jo(a.objectSchema)}),ie="range",Et=zod.z.object({type:zod.z.literal(ie),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()}),qo=(a,t,o,n)=>zod.z.number().min(a).max(t).step(o).default(n).optional(),x=a=>({def:Et.parse(F({type:ie},a)),schema:qo(a.min,a.max,a.step,a.default)}),le="select-boolean",Rt=zod.z.object({type:zod.z.literal(le),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()}),ko=a=>zod.z.boolean().nullable().default(a).optional(),Mt=a=>({def:Rt.parse(F({type:le},a)),schema:ko(a.default)}),me="select-string",It=zod.z.object({type:zod.z.literal(me),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))}),Oo=(a,t)=>zod.z.enum(t).nullable().default(a).optional(),de=a=>({def:It.parse(F({type:me},a)),schema:Oo(a.default,a.choices)}),No=[ie,se,me,re,le];zod.z.enum(No);var vt=zod.z.discriminatedUnion("type",[Et,yt,It,Rt,bt]),Pt=(a=W,t=Ge)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(a,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(o=>{var n,s;let r=Object.keys(o.def),l=Object.keys((s=(n=o.schema)==null?void 0:n.shape)!=null?s:{});return r.every(m=>l.includes(m))&&l.every(m=>r.includes(m))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})}),St=(a=Xe)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),modalities:zod.z.array(a).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 o,n;let s=Object.keys(t.def),r=Object.keys((n=(o=t.schema)==null?void 0:o.shape)!=null?n:{});return s.every(l=>r.includes(l))&&r.every(l=>s.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 Lo={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."},Uo={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."},$o=a=>({type:"multi",title:"Stop sequence",description:`Enter up to ${a} sequences that will halt additional text output. The generated text will exclude these sequences.`}),Bo={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."},Fo={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."},zo={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."},Do={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."},Ho={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."},Ko={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."},Go={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."},Vo={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."},Yo={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."},Jo={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."},Wo={type:"boolean",title:"Echo",description:"If true, the response will contain the prompt."},Zo={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."},Qo={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."},Xo={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."},h={TEMPERATURE:Lo,MAX_TOKENS:Uo,STOP:$o,TOP_A:Bo,TOP_P:Fo,TOP_K:zo,MIN_P:Do,FREQUENCY_PENALTY:Ho,PRESENCE_PENALTY:Ko,REPETITION_PENALTY:Vo,SEED:Go,LOG_PROBS:Yo,TOP_LOG_PROBS:Jo,ECHO:Wo,RESPONSE_FORMAT:Zo,RESPONSE_FORMAT_WITH_SCHEMA:Qo,RESPONSE_SCHEMA:Xo};var K=a=>Object.fromEntries(Object.entries(a).filter(([t,o])=>o!=null));var O=a=>a==null?void 0:a.replace(/\/$/,"");var pe=x({param:"temperature",title:h.TEMPERATURE.title,description:h.TEMPERATURE.description,min:0,max:1,step:.01,default:1}),ce=a=>x({param:"max_tokens",title:h.MAX_TOKENS.title,description:h.MAX_TOKENS.description,min:0,max:a,step:1,default:0}),ue=a=>Tt({param:"stop",title:h.STOP(a).title,description:h.STOP(a).description,max:a}),ge=x({param:"top_k",title:h.TOP_K.title,description:h.TOP_K.description,min:0,max:1e4,step:1,default:0}),he=x({param:"top_p",title:h.TOP_P.title,description:h.TOP_P.description,min:0,max:1,step:.01,default:1}),fe=x({param:"min_p",title:h.MIN_P.title,description:h.MIN_P.description,min:0,max:1,step:.01,default:0}),ye=x({param:"frequency_penalty",title:h.FREQUENCY_PENALTY.title,description:h.FREQUENCY_PENALTY.description,min:-2,max:2,step:.01,default:0}),Te=x({param:"presence_penalty",title:h.PRESENCE_PENALTY.title,description:h.PRESENCE_PENALTY.description,min:-2,max:2,step:.01,default:0}),be=x({param:"repetition_penalty",title:h.REPETITION_PENALTY.title,description:h.REPETITION_PENALTY.description,min:0,max:1e4,step:.01,default:0}),Ce=x({param:"seed",title:h.SEED.title,description:h.SEED.description,min:0,max:1e6,step:1,default:0}),Ee=Mt({param:"logprobs",title:h.LOG_PROBS.title,description:h.LOG_PROBS.description,default:!1}),Re=de({param:"tool_choice",title:"Tool choice",description:"Controls which (if any) tool is called by the model. 'none' means the model will not call a function. 'auto' means the model can pick between generating a message or calling a tool.",default:"auto",choices:["auto","required","none"]}),Me=de({param:"response_format",title:h.RESPONSE_FORMAT.title,description:h.RESPONSE_FORMAT.description,default:"text",choices:["text","json_object"]}),Ie=Ct({param:"response_schema",title:h.RESPONSE_SCHEMA.title,description:h.RESPONSE_SCHEMA.description,objectSchema:We});var _t=(a,t)=>zod.z.object({temperature:pe.schema,maxTokens:ce(a).schema,stop:ue(t).schema,topP:he.schema,topK:ge.schema,minP:fe.schema,frequencyPenalty:ye.schema,presencePenalty:Te.schema,repetitionPenalty:be.schema,seed:Ce.schema.transform(o=>o===0?void 0:o),logProbs:Ee.schema,toolChoice:Re.schema,responseSchema:Ie.schema,responseFormat:Me.schema}),xt=(a,t)=>({temperature:pe.def,maxTokens:ce(a).def,stop:ue(t).def,topP:he.def,topK:ge.def,minP:fe.def,frequencyPenalty:ye.def,presencePenalty:Te.def,repetitionPenalty:be.def,seed:Ce.def,logProbs:Ee.def,toolChoice:Re.def,responseSchema:Ie.def,responseFormat:Me.def});var ve={base:(a,t)=>({def:xt(a,t),schema:_t(a,t)})};var wt=zod.z.enum([L,U,v,$]),At={system:L,user:U,assistant:v,tool:$};var jt=[R,P,w],qt=zod.z.enum([R,P,w]);var nn=zod.z.object({token_ids:zod.z.array(zod.z.number()),tokens:zod.z.array(zod.z.string()),token_logprobs:zod.z.array(zod.z.number())}),an=zod.z.array(zod.z.object({id:zod.z.string().min(1),type:zod.z.enum(["function"]),function:zod.z.object({name:zod.z.string(),arguments:zod.z.string()})})),kt=zod.z.object({id:zod.z.string(),object:zod.z.literal("chat.completion"),created:zod.z.number(),model:zod.z.string(),prompt:zod.z.any(),choices:zod.z.array(zod.z.object({index:zod.z.number(),message:zod.z.object({role:zod.z.string(),content:zod.z.string().nullable().optional(),tool_calls:an.optional()}),logprobs:nn.nullable().optional(),seed:zod.z.number().nullable().optional(),finish_reason:zod.z.string()})),usage:zod.z.object({prompt_tokens:zod.z.number(),completion_tokens:zod.z.number(),total_tokens:zod.z.number()}).nullable().optional()}),sn=zod.z.array(zod.z.object({index:zod.z.number().int(),id:zod.z.string().min(1).optional(),type:zod.z.enum(["function"]).optional(),function:zod.z.object({name:zod.z.string().min(1).optional(),arguments:zod.z.string().optional()}).optional()})),Ot=zod.z.object({id:zod.z.string(),object:zod.z.string(),created:zod.z.number(),model:zod.z.string(),choices:zod.z.array(zod.z.object({index:zod.z.number(),delta:zod.z.object({token_id:zod.z.number().nullable().optional(),role:zod.z.string().nullable().optional(),content:zod.z.string().nullable().optional(),tool_calls:sn.nullable().optional()}).or(zod.z.object({})),logprobs:zod.z.any().nullable().optional(),seed:zod.z.number().nullable().optional(),finish_reason:zod.z.string().nullable(),text:zod.z.string().nullable().optional()})),usage:zod.z.object({prompt_tokens:zod.z.number(),completion_tokens:zod.z.number(),total_tokens:zod.z.number()}).nullable().optional()});var rn=zod.z.object({type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1).optional(),strict:zod.z.boolean().optional(),parameters:zod.z.any()})}),ln=zod.z.enum(["none","auto","required"]),mn=zod.z.object({type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1)})}),dn=zod.z.object({type:zod.z.enum(["text","json_object"])}).or(zod.z.object({type:zod.z.literal("json_schema"),json_schema:zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1).optional(),strict:zod.z.boolean().optional(),schema:zod.z.any()})})),Pe=zod.z.string(),pn=zod.z.object({id:zod.z.string().min(1),type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1),arguments:zod.z.string().min(1)})}),cn=zod.z.object({role:zod.z.literal("system"),content:Pe}),un=zod.z.object({role:zod.z.literal("user"),content:Pe}),gn=zod.z.object({role:zod.z.literal("assistant"),content:Pe.optional(),tool_calls:zod.z.array(pn).min(1).optional()}),hn=zod.z.object({role:zod.z.literal("tool"),tool_call_id:zod.z.string().min(1),content:zod.z.string().min(1)}),fn=zod.z.union([cn,un,gn,hn]),Nt=zod.z.object({model:zod.z.string().min(1).optional(),messages:zod.z.array(fn).min(1),frequency_penalty:zod.z.number().min(-2).max(2).nullable().optional(),logprobs:zod.z.number().min(0).max(1).nullable().optional(),max_tokens:zod.z.number().min(0).nullable().optional(),presence_penalty:zod.z.number().min(-2).max(2).nullable().optional(),repetition_penalty:zod.z.number().min(0).max(2).nullable().optional(),response_format:dn.optional(),seed:zod.z.number().optional(),stop:zod.z.string().or(zod.z.array(zod.z.string()).max(4)).nullable().optional(),temperature:zod.z.number().min(0).max(1).nullable().optional(),top_p:zod.z.number().min(0).max(1).nullable().optional(),top_k:zod.z.number().min(0).max(1e4).nullable().optional(),min_p:zod.z.number().min(0).max(1).nullable().optional(),echo:zod.z.boolean().nullable().optional(),tools:zod.z.array(rn).optional(),tool_choice:ln.or(mn).optional()});var Se=Pt(wt,qt).parse({name:"__base__",description:"Base chat model for Together AI",maxInputTokens:128e3,maxOutputTokens:128e3,roles:At,modalities:jt,config:{def:ve.base(128e3,4).def,schema:ve.base(128e3,4).schema}});var yn="together-ai",N=class{constructor(){this.version="v1";this.name=yn;}chatModelLiterals(){return ["__base__"]}chatModelSchemas(){return {__base__:Se}}chatModel(t){let o=G,n=xe.parse(t);return new o(Se,n)}embeddingModelLiterals(){return ["__base__"]}embeddingModelSchemas(){return {__base__:_e}}embeddingModel(t){let o=V,n=we.parse(t);return new o(_e,n)}};N.baseUrl="https://api.together.xyz/v1";var xe=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string()}),G=class{constructor(t,o){this.version="v1";let n=xe.parse(o);this.modelSchema=t,this.modelName=n.modelName,this.apiKey=n.apiKey,this.baseUrl=O(N.baseUrl),this.streamChatUrl=O(`${this.baseUrl}/chat/completions`),this.completeChatUrl=O(`${this.baseUrl}/chat/completions`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"}}getDefaultParams(){return {model:this.modelName}}getRetryDelay(t){return {shouldRetry:!0,delayMs:0}}getTokenCount(t){return t.reduce((o,n)=>o+n.content.map(s=>s.modality==="text"?s.value:"").join(" ").length,0)}transformModelRequest(t){let o=Nt.safeParse(t);if(!o.success)throw new B({info:"Invalid model request",cause:o.error});let n=o.data,s=n.model;if(n.tool_choice&&(!n.tools||n.tools.length===0))throw new B({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let r={};n.response_format&&(r.responseFormat=n.response_format.type,n.response_format.type==="json_schema"&&(r.responseSchema={name:n.response_format.json_schema.name,description:n.response_format.json_schema.description||"",strict:n.response_format.json_schema.strict,schema:n.response_format.json_schema.schema})),n.tool_choice&&(typeof n.tool_choice=="string"?r.toolChoice=n.tool_choice:r.toolChoice=n.tool_choice.function.name),r.seed=n.seed,r.maxTokens=n.max_tokens,r.temperature=n.temperature,r.topP=n.top_p,r.minP=n.min_p,r.topK=n.top_k,r.repetitionPenalty=n.repetition_penalty,r.presencePenalty=n.presence_penalty,r.frequencyPenalty=n.frequency_penalty,r.repetitionPenalty=n.repetition_penalty,r.stop=n.stop,r.logProbs=n.logprobs!==0,r.echo=n.echo;let l=H().parse(K(r)),m=[],c={};n.messages.forEach(u=>{let f=u.role;switch(f){case"system":m.push({role:f,content:[{modality:R,value:u.content}]});break;case"user":m.push({role:f,content:[{modality:R,value:u.content}]});break;case"assistant":{let y=[];if(!u.content&&!u.tool_calls)throw new B({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("one of'content' or 'tool_calls' must be provided")});u.content&&y.push({modality:R,value:u.content}),u.tool_calls&&u.tool_calls.forEach((S,E)=>{let j={modality:P,id:S.id,index:E,name:S.function.name,arguments:S.function.arguments};y.push(j),c[j.id]=j;}),m.push({role:f,content:y});}break;case"tool":{let y=u;m.push({role:f,content:[{modality:w,id:y.tool_call_id,index:c[y.tool_call_id].index,name:c[y.tool_call_id].name,data:y.content}]});}break}});let g=[];return n.tools&&n.tools.forEach(u=>{g.push({type:"function",definition:{schema:{name:u.function.name,description:u.function.description||"",strict:u.function.strict,parameters:u.function.parameters}}});}),{modelName:s,config:l,messages:m,tools:g.length>0?g:void 0}}transformConfig(t,o,n){let s=t.toolChoice;delete t.toolChoice;let r=this.modelSchema.config.schema.safeParse(t);if(!r.success)throw new _({info:`Invalid config for model : '${this.modelName}'`,cause:r.error});let l=r.data;s!==void 0&&(l.toolChoice=s),Object.keys(l).forEach(c=>{if(!(c in this.modelSchema.config.def))throw new _({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${c}',
|
|
7
|
-
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let m=Object.keys(l).reduce((c,g)=>{let u=this.modelSchema.config.def[g],f=u.param,y=l[g];return f==="max_tokens"&&u.type==="range"&&y===0?c[f]=u.max:f==="logprobs"&&u.type==="select-boolean"?y===!0?c[f]=1:c[f]=0:c[f]=y,c},{});if(m.top_logprobs&&!m.logprobs)throw new
|
|
8
|
-
one of [${g.choices.join(", ")}]`)})}}if("response_format"in m&&m.response_format!==void 0){let c=m.response_format;if(c==="json_schema")if("response_schema"in m)m.response_format={type:"json_schema",json_schema:m.response_schema},delete m.response_schema;else throw new
|
|
5
|
+
var Gt=Object.defineProperty;var ke=Object.getOwnPropertySymbols;var Vt=Object.prototype.hasOwnProperty,Yt=Object.prototype.propertyIsEnumerable;var D=(a,t)=>(t=Symbol[a])?t:Symbol.for("Symbol."+a),Wt=a=>{throw TypeError(a)};var Oe=(a,t,o)=>t in a?Gt(a,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):a[t]=o,b=(a,t)=>{for(var o in t||(t={}))Vt.call(t,o)&&Oe(a,o,t[o]);if(ke)for(var o of ke(t))Yt.call(t,o)&&Oe(a,o,t[o]);return a};var C=(a,t,o)=>new Promise((n,s)=>{var r=c=>{try{m(o.next(c));}catch(g){s(g);}},l=c=>{try{m(o.throw(c));}catch(g){s(g);}},m=c=>c.done?n(c.value):Promise.resolve(c.value).then(r,l);m((o=o.apply(a,t)).next());}),Ne=function(a,t){this[0]=a,this[1]=t;},Y=(a,t,o)=>{var n=(l,m,c,g)=>{try{var u=o[l](m),f=(m=u.value)instanceof Ne,y=u.done;Promise.resolve(f?m[0]:m).then(T=>f?n(l==="return"?l:"next",m[1]?{done:T.done,value:T.value}:T,c,g):c({value:T,done:y})).catch(T=>n("throw",T,c,g));}catch(T){g(T);}},s=l=>r[l]=m=>new Promise((c,g)=>n(l,m,c,g)),r={};return o=o.apply(a,t),r[D("asyncIterator")]=()=>r,s("next"),s("throw"),s("return"),r},Le=a=>{var t=a[D("asyncIterator")],o=!1,n,s={};return t==null?(t=a[D("iterator")](),n=r=>s[r]=l=>t[r](l)):(t=t.call(a),n=r=>s[r]=l=>{if(o){if(o=!1,r==="throw")throw l;return l}return o=!0,{done:!1,value:new Ne(new Promise(m=>{var c=t[r](l);c instanceof Object||Wt("Object expected"),m(c);}),1)}}),s[D("iterator")]=()=>s,n("next"),"throw"in t?n("throw"):s.throw=r=>{throw r},"return"in t&&n("return"),s};var Jt=a=>{let t=new WeakSet;return JSON.stringify(a,(o,n)=>{if(typeof n=="object"&&n!==null){if(t.has(n))return;t.add(n);}return n})},Xt=a=>a==null?"unknown error":typeof a=="string"?a:a instanceof Error?a.message:Jt(a),W="GatewayBaseError",q=class Fe extends Error{constructor({info:t,cause:o},n){super(`[${n!=null?n:W}]: ${t}
|
|
6
|
+
Message: ${Xt(o)}`),this.name=W,this.info=t,this.cause=o,this.name=n!=null?n:W,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(t){return t instanceof Fe}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},L="system",U="user",v="assistant",$="tool",Zt=[L,U,v,$],X=zod.z.enum(Zt),Qt=[v],eo=zod.z.enum(Qt),ze="image",to="base64",oo=["png","jpeg","webp","gif"],no=zod.z.object({type:zod.z.literal(to),base64:zod.z.string(),media_type:zod.z.enum(oo)}),ao="url",so=zod.z.object({type:zod.z.literal(ao),url:zod.z.string()}),ro=zod.z.discriminatedUnion("type",[no,so]),io=["low","medium","high","auto"],lo=zod.z.enum(io),mo=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(ze),detail:lo,value:ro,metadata:a}),De="reasoning",He="partial-reasoning",Ke="thinking",po="redacted",J=zod.z.object({type:zod.z.literal(Ke),thinking:zod.z.string(),signature:zod.z.string()}),Ge=zod.z.object({type:zod.z.literal(po),data:zod.z.string()}),co=zod.z.discriminatedUnion("type",[J,Ge]),uo=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(De),value:co,metadata:a}),go=zod.z.object({type:zod.z.literal(Ke),thinking:J.shape.thinking.optional(),signature:J.shape.signature.optional()}),ho=zod.z.discriminatedUnion("type",[go,Ge]),fo=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(He),value:ho,metadata:a}),E="text",Ve=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(E),value:zod.z.string(),metadata:a}),Z="partial-text",Ye=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Z),value:zod.z.string(),metadata:a}),P="tool-call",We=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(P),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),arguments:zod.z.string(),metadata:a}),Q="partial-tool-call",Je=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Q),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),arguments:zod.z.string().optional(),metadata:a}),w="tool-response",yo=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(w),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),data:zod.z.string(),metadata:a}),To=[E,ze,P,w,De],Xe=zod.z.enum(To),bo=(a=zod.z.undefined(),t=zod.z.undefined(),o=zod.z.undefined(),n=zod.z.undefined(),s=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[Ve(a),mo(t),We(o),yo(n),uo(s)]),Co=[Z,Q,He];zod.z.enum(Co);var Ro=(a=zod.z.undefined(),t=zod.z.undefined(),o=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[Ye(a),Je(t),fo(o)]);var ee=(a=X,t=zod.z.undefined(),o=zod.z.undefined(),n=zod.z.undefined(),s=zod.z.undefined(),r=zod.z.undefined(),l=zod.z.undefined())=>zod.z.object({role:a,content:zod.z.array(bo(t,o,n,s,l)),metadata:r}),te=(a=eo,t=zod.z.undefined(),o=zod.z.undefined(),n=zod.z.undefined(),s=zod.z.undefined())=>zod.z.object({role:a,partialContent:Ro(t,o,n),metadata:s}),Ze=a=>Ve().parse({modality:E,value:a}),Qe=(a,t,o,n)=>We().parse({modality:P,index:a,id:t,name:o,arguments:n});var oe=(a,t)=>te().parse({role:a,partialContent:Ye().parse({modality:Z,value:t})}),et=(a,t,o,n,s)=>te().parse({role:a,partialContent:Je().parse({modality:Q,index:t,id:o,name:n,arguments:s})});var H=(a=zod.z.record(zod.z.string(),zod.z.any()).optional())=>a,Eo=["object","array","number","string","boolean","enum"],Ue=zod.z.enum(Eo),Mo=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([Ue,zod.z.array(zod.z.union([Ue,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()}),Io=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(Mo),additionalProperties:zod.z.literal(!1)}),tt=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:Io}).optional(),vo="function";var Po=zod.z.enum(["object","array","number","string","boolean","null"]),So=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:Po.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(So).optional(),required:zod.z.array(zod.z.string()).optional()});var xo=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 _o=zod.z.enum(["function"]),wo=zod.z.object({type:_o,definition:zod.z.object({schema:xo})}),Ao=[vo];zod.z.enum(Ao);var ot=(a=zod.z.undefined())=>zod.z.discriminatedUnion("type",[wo.extend({metadata:a})]),A="text",nt="token",jo=[A,nt],at=zod.z.enum(jo),qo=zod.z.array(zod.z.string().min(1)),ko=zod.z.array(zod.z.array(zod.z.number().int().nonnegative())),st=(a=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[zod.z.object({modality:zod.z.literal(A),metadata:a,requests:qo}),zod.z.object({modality:zod.z.literal(nt),metadata:a,requests:ko})]),ne="float",Oo=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),No="base64",Lo=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.string().base64()}),$e=zod.z.object({totalTokens:zod.z.number().int().nonnegative()});zod.z.discriminatedUnion("encodingFormat",[zod.z.object({encodingFormat:zod.z.literal(ne),embeddings:zod.z.array(Oo),usage:$e.optional()}),zod.z.object({encodingFormat:zod.z.literal(No),embeddings:zod.z.array(Lo),usage:$e.optional()})]);var rt=zod.z.object({promptTokens:zod.z.number().nonnegative(),completionTokens:zod.z.number().nonnegative(),totalTokens:zod.z.number().nonnegative()}),Be=zod.z.object({token:zod.z.string(),logProb:zod.z.number(),bytes:zod.z.array(zod.z.number().int()).nullable()}),Uo=Be.extend({topLogProbs:zod.z.array(Be)}),it=zod.z.array(Uo);zod.z.object({messages:zod.z.array(ee()),usage:rt.optional(),logProbs:it.optional()});zod.z.object({partialMessages:zod.z.array(te()),usage:rt.optional(),logProbs:it.optional()});var $o=Object.defineProperty,lt=Object.getOwnPropertySymbols,Bo=Object.prototype.hasOwnProperty,Fo=Object.prototype.propertyIsEnumerable,mt=(a,t,o)=>t in a?$o(a,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):a[t]=o,F=(a,t)=>{for(var o in t||(t={}))Bo.call(t,o)&&mt(a,o,t[o]);if(lt)for(var o of lt(t))Fo.call(t,o)&&mt(a,o,t[o]);return a};var dt="ModelResponseError",k=class ft extends q{constructor({info:t,cause:o}){super({info:t,cause:o},dt),this.name=dt,this.cause=o,this.info=t;}static isModelResponseError(t){return t instanceof ft}},pt="InvalidModelRequestError",B=class yt extends q{constructor({info:t,cause:o}){super({info:t,cause:o},pt),this.name=pt,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(t){return t instanceof yt}},ct="InvalidConfigError",x=class Tt extends q{constructor({info:t,cause:o}){super({info:t,cause:o},ct),this.name=ct,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(t){return t instanceof Tt}},ut="InvalidMessagesError",I=class bt extends q{constructor({info:t,cause:o}){super({info:t,cause:o},ut),this.name=ut,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(t){return t instanceof bt}},gt="InvalidToolsError",ae=class Ct extends q{constructor({info:t,cause:o}){super({info:t,cause:o},gt),this.name=gt,this.cause=o,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(t){return t instanceof Ct}},ht="InvalidEmbeddingRequestsError",se=class Rt extends q{constructor({info:t,cause:o}){super({info:t,cause:o},ht),this.name=ht,this.info=t,this.cause=o,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(t){return t instanceof Rt}},re="multi-string",Et=zod.z.object({type:zod.z.literal(re),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()}),zo=a=>zod.z.array(zod.z.string()).max(a).default([]).optional(),Mt=a=>({def:Et.parse(F({type:re},a)),schema:zo(a.max)}),ie="object-schema",It=zod.z.object({type:zod.z.literal(ie),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),objectSchema:zod.z.any()}),Do=a=>a.optional(),vt=a=>({def:It.parse(F({type:ie},a)),schema:Do(a.objectSchema)}),le="range",Pt=zod.z.object({type:zod.z.literal(le),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()}),Ho=(a,t,o,n)=>zod.z.number().min(a).max(t).step(o).default(n).optional(),_=a=>({def:Pt.parse(F({type:le},a)),schema:Ho(a.min,a.max,a.step,a.default)}),me="select-boolean",St=zod.z.object({type:zod.z.literal(me),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()}),Ko=a=>zod.z.boolean().nullable().default(a).optional(),xt=a=>({def:St.parse(F({type:me},a)),schema:Ko(a.default)}),de="select-string",_t=zod.z.object({type:zod.z.literal(de),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),default:zod.z.string(),choices:zod.z.array(zod.z.string())}),Go=(a,t)=>zod.z.enum(t).nullable().default(a).optional(),pe=a=>({def:_t.parse(F({type:de},a)),schema:Go(a.default,a.choices)}),Vo=[le,re,de,ie,me];zod.z.enum(Vo);var wt=zod.z.discriminatedUnion("type",[Pt,Et,_t,St,It]),At=(a=X,t=Xe)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(a,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),maxReasoningTokens:zod.z.number().int().positive().min(1).optional(),config:zod.z.object({def:zod.z.record(zod.z.string().min(1),wt),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(o=>{var n,s;let r=Object.keys(o.def),l=Object.keys((s=(n=o.schema)==null?void 0:n.shape)!=null?s:{});return r.every(m=>l.includes(m))&&l.every(m=>r.includes(m))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})}),jt=(a=at)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),modalities:zod.z.array(a).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),wt),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(t=>{var o,n;let s=Object.keys(t.def),r=Object.keys((n=(o=t.schema)==null?void 0:o.shape)!=null?n:{});return s.every(l=>r.includes(l))&&r.every(l=>s.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 Yo={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."},Wo={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."},Jo={type:"range",title:"Max reasoning tokens",description:"Specify the total tokens for reasoning, where one token approximates four English characters."},Xo=a=>({type:"multi",title:"Stop sequence",description:`Enter up to ${a} sequences that will halt additional text output. The generated text will exclude these sequences.`}),Zo={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."},Qo={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."},en={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."},tn={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."},on={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."},nn={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."},an={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."},sn={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."},rn={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."},ln={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."},mn={type:"boolean",title:"Echo",description:"If true, the response will contain the prompt."},dn={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."},pn={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."},cn={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."},h={TEMPERATURE:Yo,MAX_TOKENS:Wo,STOP:Xo,TOP_A:Zo,TOP_P:Qo,TOP_K:en,MIN_P:tn,FREQUENCY_PENALTY:on,PRESENCE_PENALTY:nn,REPETITION_PENALTY:sn,SEED:an,LOG_PROBS:rn,TOP_LOG_PROBS:ln,ECHO:mn,RESPONSE_FORMAT:dn,RESPONSE_FORMAT_WITH_SCHEMA:pn,RESPONSE_SCHEMA:cn,MAX_REASONING_TOKENS:Jo};var K=a=>Object.fromEntries(Object.entries(a).filter(([t,o])=>o!=null));var O=a=>a==null?void 0:a.replace(/\/$/,"");var ce=_({param:"temperature",title:h.TEMPERATURE.title,description:h.TEMPERATURE.description,min:0,max:1,step:.01,default:1}),ue=a=>_({param:"max_tokens",title:h.MAX_TOKENS.title,description:h.MAX_TOKENS.description,min:0,max:a,step:1,default:0}),ge=a=>Mt({param:"stop",title:h.STOP(a).title,description:h.STOP(a).description,max:a}),he=_({param:"top_k",title:h.TOP_K.title,description:h.TOP_K.description,min:0,max:1e4,step:1,default:0}),fe=_({param:"top_p",title:h.TOP_P.title,description:h.TOP_P.description,min:0,max:1,step:.01,default:1}),ye=_({param:"min_p",title:h.MIN_P.title,description:h.MIN_P.description,min:0,max:1,step:.01,default:0}),Te=_({param:"frequency_penalty",title:h.FREQUENCY_PENALTY.title,description:h.FREQUENCY_PENALTY.description,min:-2,max:2,step:.01,default:0}),be=_({param:"presence_penalty",title:h.PRESENCE_PENALTY.title,description:h.PRESENCE_PENALTY.description,min:-2,max:2,step:.01,default:0}),Ce=_({param:"repetition_penalty",title:h.REPETITION_PENALTY.title,description:h.REPETITION_PENALTY.description,min:0,max:1e4,step:.01,default:0}),Re=_({param:"seed",title:h.SEED.title,description:h.SEED.description,min:0,max:1e6,step:1,default:0}),Ee=xt({param:"logprobs",title:h.LOG_PROBS.title,description:h.LOG_PROBS.description,default:!1}),Me=pe({param:"tool_choice",title:"Tool choice",description:"Controls which (if any) tool is called by the model. 'none' means the model will not call a function. 'auto' means the model can pick between generating a message or calling a tool.",default:"auto",choices:["auto","required","none"]}),Ie=pe({param:"response_format",title:h.RESPONSE_FORMAT.title,description:h.RESPONSE_FORMAT.description,default:"text",choices:["text","json_object"]}),ve=vt({param:"response_schema",title:h.RESPONSE_SCHEMA.title,description:h.RESPONSE_SCHEMA.description,objectSchema:tt});var qt=(a,t)=>zod.z.object({temperature:ce.schema,maxTokens:ue(a).schema,stop:ge(t).schema,topP:fe.schema,topK:he.schema,minP:ye.schema,frequencyPenalty:Te.schema,presencePenalty:be.schema,repetitionPenalty:Ce.schema,seed:Re.schema.transform(o=>o===0?void 0:o),logProbs:Ee.schema,toolChoice:Me.schema,responseSchema:ve.schema,responseFormat:Ie.schema}),kt=(a,t)=>({temperature:ce.def,maxTokens:ue(a).def,stop:ge(t).def,topP:fe.def,topK:he.def,minP:ye.def,frequencyPenalty:Te.def,presencePenalty:be.def,repetitionPenalty:Ce.def,seed:Re.def,logProbs:Ee.def,toolChoice:Me.def,responseSchema:ve.def,responseFormat:Ie.def});var Pe={base:(a,t)=>({def:kt(a,t),schema:qt(a,t)})};var Ot=zod.z.enum([L,U,v,$]),Nt={system:L,user:U,assistant:v,tool:$};var Lt=[E,P,w],Ut=zod.z.enum([E,P,w]);var fn=zod.z.object({token_ids:zod.z.array(zod.z.number()),tokens:zod.z.array(zod.z.string()),token_logprobs:zod.z.array(zod.z.number())}),yn=zod.z.array(zod.z.object({id:zod.z.string().min(1),type:zod.z.enum(["function"]),function:zod.z.object({name:zod.z.string(),arguments:zod.z.string()})})),$t=zod.z.object({id:zod.z.string(),object:zod.z.literal("chat.completion"),created:zod.z.number(),model:zod.z.string(),prompt:zod.z.any(),choices:zod.z.array(zod.z.object({index:zod.z.number(),message:zod.z.object({role:zod.z.string(),content:zod.z.string().nullable().optional(),tool_calls:yn.optional()}),logprobs:fn.nullable().optional(),seed:zod.z.number().nullable().optional(),finish_reason:zod.z.string()})),usage:zod.z.object({prompt_tokens:zod.z.number(),completion_tokens:zod.z.number(),total_tokens:zod.z.number()}).nullable().optional()}),Tn=zod.z.array(zod.z.object({index:zod.z.number().int(),id:zod.z.string().min(1).optional(),type:zod.z.enum(["function"]).optional(),function:zod.z.object({name:zod.z.string().min(1).optional(),arguments:zod.z.string().optional()}).optional()})),Bt=zod.z.object({id:zod.z.string(),object:zod.z.string(),created:zod.z.number(),model:zod.z.string(),choices:zod.z.array(zod.z.object({index:zod.z.number(),delta:zod.z.object({token_id:zod.z.number().nullable().optional(),role:zod.z.string().nullable().optional(),content:zod.z.string().nullable().optional(),tool_calls:Tn.nullable().optional()}).or(zod.z.object({})),logprobs:zod.z.any().nullable().optional(),seed:zod.z.number().nullable().optional(),finish_reason:zod.z.string().nullable(),text:zod.z.string().nullable().optional()})),usage:zod.z.object({prompt_tokens:zod.z.number(),completion_tokens:zod.z.number(),total_tokens:zod.z.number()}).nullable().optional()});var bn=zod.z.object({type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1).optional(),strict:zod.z.boolean().optional(),parameters:zod.z.any()})}),Cn=zod.z.enum(["none","auto","required"]),Rn=zod.z.object({type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1)})}),En=zod.z.object({type:zod.z.enum(["text","json_object"])}).or(zod.z.object({type:zod.z.literal("json_schema"),json_schema:zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1).optional(),strict:zod.z.boolean().optional(),schema:zod.z.any()})})),Se=zod.z.string(),Mn=zod.z.object({id:zod.z.string().min(1),type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1),arguments:zod.z.string().min(1)})}),In=zod.z.object({role:zod.z.literal("system"),content:Se}),vn=zod.z.object({role:zod.z.literal("user"),content:Se}),Pn=zod.z.object({role:zod.z.literal("assistant"),content:Se.optional(),tool_calls:zod.z.array(Mn).min(1).optional()}),Sn=zod.z.object({role:zod.z.literal("tool"),tool_call_id:zod.z.string().min(1),content:zod.z.string().min(1)}),xn=zod.z.union([In,vn,Pn,Sn]),Ft=zod.z.object({model:zod.z.string().min(1).optional(),messages:zod.z.array(xn).min(1),frequency_penalty:zod.z.number().min(-2).max(2).nullable().optional(),logprobs:zod.z.number().min(0).max(1).nullable().optional(),max_tokens:zod.z.number().min(0).nullable().optional(),presence_penalty:zod.z.number().min(-2).max(2).nullable().optional(),repetition_penalty:zod.z.number().min(0).max(2).nullable().optional(),response_format:En.optional(),seed:zod.z.number().optional(),stop:zod.z.string().or(zod.z.array(zod.z.string()).max(4)).nullable().optional(),temperature:zod.z.number().min(0).max(1).nullable().optional(),top_p:zod.z.number().min(0).max(1).nullable().optional(),top_k:zod.z.number().min(0).max(1e4).nullable().optional(),min_p:zod.z.number().min(0).max(1).nullable().optional(),echo:zod.z.boolean().nullable().optional(),tools:zod.z.array(bn).optional(),tool_choice:Cn.or(Rn).optional()});var xe=At(Ot,Ut).parse({name:"__base__",description:"Base chat model for Together AI",maxInputTokens:128e3,maxOutputTokens:128e3,roles:Nt,modalities:Lt,config:{def:Pe.base(128e3,4).def,schema:Pe.base(128e3,4).schema}});var _n="together-ai",N=class{constructor(){this.version="v1";this.name=_n;}chatModelLiterals(){return ["__base__"]}chatModelSchemas(){return {__base__:xe}}chatModel(t){let o=G,n=we.parse(t);return new o(xe,n)}embeddingModelLiterals(){return ["__base__"]}embeddingModelSchemas(){return {__base__:_e}}embeddingModel(t){let o=V,n=Ae.parse(t);return new o(_e,n)}};N.baseUrl="https://api.together.xyz/v1";var we=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string()}),G=class{constructor(t,o){this.version="v1";let n=we.parse(o);this.modelSchema=t,this.modelName=n.modelName,this.apiKey=n.apiKey,this.baseUrl=O(N.baseUrl),this.streamChatUrl=O(`${this.baseUrl}/chat/completions`),this.completeChatUrl=O(`${this.baseUrl}/chat/completions`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"}}getDefaultParams(){return {model:this.modelName}}getRetryDelay(t){return {shouldRetry:!0,delayMs:0}}getTokenCount(t){return t.reduce((o,n)=>o+n.content.map(s=>s.modality==="text"?s.value:"").join(" ").length,0)}transformModelRequest(t){let o=Ft.safeParse(t);if(!o.success)throw new B({info:"Invalid model request",cause:o.error});let n=o.data,s=n.model;if(n.tool_choice&&(!n.tools||n.tools.length===0))throw new B({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let r={};n.response_format&&(r.responseFormat=n.response_format.type,n.response_format.type==="json_schema"&&(r.responseSchema={name:n.response_format.json_schema.name,description:n.response_format.json_schema.description||"",strict:n.response_format.json_schema.strict,schema:n.response_format.json_schema.schema})),n.tool_choice&&(typeof n.tool_choice=="string"?r.toolChoice=n.tool_choice:r.toolChoice=n.tool_choice.function.name),r.seed=n.seed,r.maxTokens=n.max_tokens,r.temperature=n.temperature,r.topP=n.top_p,r.minP=n.min_p,r.topK=n.top_k,r.repetitionPenalty=n.repetition_penalty,r.presencePenalty=n.presence_penalty,r.frequencyPenalty=n.frequency_penalty,r.repetitionPenalty=n.repetition_penalty,r.stop=n.stop,r.logProbs=n.logprobs!==0,r.echo=n.echo;let l=H().parse(K(r)),m=[],c={};n.messages.forEach(u=>{let f=u.role;switch(f){case"system":m.push({role:f,content:[{modality:E,value:u.content}]});break;case"user":m.push({role:f,content:[{modality:E,value:u.content}]});break;case"assistant":{let y=[];if(!u.content&&!u.tool_calls)throw new B({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("one of'content' or 'tool_calls' must be provided")});u.content&&y.push({modality:E,value:u.content}),u.tool_calls&&u.tool_calls.forEach((S,R)=>{let j={modality:P,id:S.id,index:R,name:S.function.name,arguments:S.function.arguments};y.push(j),c[j.id]=j;}),m.push({role:f,content:y});}break;case"tool":{let y=u;m.push({role:f,content:[{modality:w,id:y.tool_call_id,index:c[y.tool_call_id].index,name:c[y.tool_call_id].name,data:y.content}]});}break}});let g=[];return n.tools&&n.tools.forEach(u=>{g.push({type:"function",definition:{schema:{name:u.function.name,description:u.function.description||"",strict:u.function.strict,parameters:u.function.parameters}}});}),{modelName:s,config:l,messages:m,tools:g.length>0?g:void 0}}transformConfig(t,o,n){let s=t.toolChoice;delete t.toolChoice;let r=this.modelSchema.config.schema.safeParse(t);if(!r.success)throw new x({info:`Invalid config for model : '${this.modelName}'`,cause:r.error});let l=r.data;s!==void 0&&(l.toolChoice=s),Object.keys(l).forEach(c=>{if(!(c in this.modelSchema.config.def))throw new x({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${c}',
|
|
7
|
+
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let m=Object.keys(l).reduce((c,g)=>{let u=this.modelSchema.config.def[g],f=u.param,y=l[g];return f==="max_tokens"&&u.type==="range"&&y===0?c[f]=u.max:f==="logprobs"&&u.type==="select-boolean"?y===!0?c[f]=1:c[f]=0:c[f]=y,c},{});if(m.top_logprobs&&!m.logprobs)throw new x({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'logprobs' must be 'true' when 'top_logprobs' is specified")});if("tool_choice"in m&&m.tool_choice!==void 0){let c=m.tool_choice;if(!n||n&&n.length===0)throw new x({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(n&&n.length>0){let g=this.modelSchema.config.def.toolChoice;if(!g.choices.includes(c))if(n.map(u=>u.definition.schema.name).includes(c))m.tool_choice={type:"function",function:{name:c}};else throw new x({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`toolChoice : '${c}' is not part of provided 'tools' names or
|
|
8
|
+
one of [${g.choices.join(", ")}]`)})}}if("response_format"in m&&m.response_format!==void 0){let c=m.response_format;if(c==="json_schema")if("response_schema"in m)m.response_format={type:"json_schema",json_schema:m.response_schema},delete m.response_schema;else throw new x({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'responseSchema' is required in config when 'responseFormat' is 'json_schema'")});else m.response_format={type:c};}return m}transformMessages(t){if(!t||t&&t.length===0)return {messages:[]};let o=t.map(s=>{let r=ee().safeParse(s);if(!r.success)throw new I({info:"Invalid messages",cause:r.error});return r.data});return o.forEach(s=>{s.content.forEach(r=>{if(!this.modelSchema.modalities.includes(r.modality))throw new I({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${r.modality}',
|
|
9
9
|
available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),o.forEach(s=>{if(!Object.keys(this.modelSchema.roles).includes(s.role))throw new I({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${s.role}',
|
|
10
|
-
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}),{messages:o.map(s=>{switch(s.role){case L:{let r="";return s.content.forEach(l=>{if(l.modality===
|
|
11
|
-
`;else throw new I({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${l.modality}'`)})}),{role:this.modelSchema.roles[s.role],content:r}}case v:{let r="",l=[];return s.content.forEach(m=>{if(m.modality===
|
|
12
|
-
`;else if(m.modality===P)l.push({id:m.id,type:"function",function:{name:m.name,arguments:m.arguments}});else throw new I({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${m.modality}'`)})}),b({role:this.modelSchema.roles[s.role],content:r},l.length>0?{tool_calls:l}:{})}case U:{let r="";return s.content.forEach(l=>{if(l.modality===
|
|
10
|
+
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}),{messages:o.map(s=>{switch(s.role){case L:{let r="";return s.content.forEach(l=>{if(l.modality===E)r+=l.value+`
|
|
11
|
+
`;else throw new I({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${l.modality}'`)})}),{role:this.modelSchema.roles[s.role],content:r}}case v:{let r="",l=[];return s.content.forEach(m=>{if(m.modality===E)r+=m.value+`
|
|
12
|
+
`;else if(m.modality===P)l.push({id:m.id,type:"function",function:{name:m.name,arguments:m.arguments}});else throw new I({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${m.modality}'`)})}),b({role:this.modelSchema.roles[s.role],content:r},l.length>0?{tool_calls:l}:{})}case U:{let r="";return s.content.forEach(l=>{if(l.modality===E)r+=l.value+`
|
|
13
13
|
`;else throw new I({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' cannot have content with modality : '${l.modality}'`)})}),{role:this.modelSchema.roles[s.role],content:r}}case $:{if(s.content.length!==1)throw new I({info:`Invalid message for role : '${s.role}'`,cause:new Error(`role : '${s.role}' must have exactly one content item`)});if(s.content[0].modality!==w)throw new I({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' must have content with modality : '${w}'`)});let r=s.content[0];return {role:this.modelSchema.roles[s.role],tool_call_id:r.id,content:r.data}}default:throw new I({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${s.role}' is not supported,
|
|
14
|
-
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}})}}transformTools(t){if(!this.modelSchema.modalities.includes(P))throw new
|
|
15
|
-
`,l);if(g===-1){r=n.substring(l);break}else {let u=n.substring(l,g).trim();u&&s.push(u),l=g+1;}}for(let g of s){if(g==="data: [DONE]")return;if(g.startsWith("data: ")){let u=g.substring(6);try{let f=JSON.parse(u),y=
|
|
16
|
-
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(s).reduce((l,m)=>{let g=this.modelSchema.config.def[m].param,u=s[m];return l[g]=u,l},{})}transformEmbeddingRequests(t){let o=
|
|
14
|
+
available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}})}}transformTools(t){if(!this.modelSchema.modalities.includes(P))throw new ae({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${P}'`)});return !t||t&&t.length===0?{tools:[]}:{tools:t.map(s=>{let r=ot().safeParse(s);if(!r.success)throw new ae({info:"Invalid tools",cause:r.error});return r.data}).map(s=>({type:"function",function:s.definition.schema}))}}getCompleteChatUrl(t,o,n){return C(this,null,function*(){return new Promise(s=>{s(this.completeChatUrl);})})}getCompleteChatHeaders(t,o,n){return C(this,null,function*(){return new Promise(s=>{s(this.getDefaultHeaders());})})}getCompleteChatData(t,o,n){return C(this,null,function*(){let s=this.transformConfig(t,o,n),r=this.transformMessages(o);if(r.messages&&r.messages.length===0)throw new I({info:"Messages are required",cause:new Error("Messages are required")});let l=n?this.transformTools(n):{};return new Promise(m=>{m(b(b(b(b({},this.getDefaultParams()),s),r),l));})})}transformCompleteChatResponse(t){let o=$t.safeParse(t);if(o.success){if(o.data.choices.length===0)throw new k({info:"Invalid response from model",cause:new Error(`No choices in response : ${JSON.stringify(o.data)}`)});let n=o.data,s=[{role:v,content:[]}],r=n.choices[0].message;r.content&&s[0].content.push(Ze(r.content)),r.tool_calls&&r.tool_calls.forEach((g,u)=>{s[0].content.push(Qe(u,g.id,g.function.name,g.function.arguments));});let l;n.usage&&(l={promptTokens:n.usage.prompt_tokens,completionTokens:n.usage.completion_tokens,totalTokens:n.usage.total_tokens});let m=[],c=n.choices[0].logprobs;return c&&c.tokens.forEach((g,u)=>{m.push({token:g,logProb:c.token_logprobs[u],bytes:null,topLogProbs:[]});}),{messages:s,usage:l,logProbs:m}}throw new k({info:"Invalid response from model",cause:o.error})}getStreamChatUrl(t,o,n){return C(this,null,function*(){return new Promise(s=>{s(this.streamChatUrl);})})}getStreamChatHeaders(t,o,n){return C(this,null,function*(){return new Promise(s=>{s(this.getDefaultHeaders());})})}getStreamChatData(t,o,n){return C(this,null,function*(){let s=this.transformConfig(t,o,n),r=this.transformMessages(o);if(r.messages&&r.messages.length===0)throw new I({info:"Messages are required",cause:new Error("Messages are required")});let l=n?this.transformTools(n):{};return new Promise(m=>{m(b(b(b(b({stream:!0,stream_options:{include_usage:!0}},this.getDefaultParams()),s),r),l));})})}transformStreamChatResponseChunk(t,o){return Y(this,null,function*(){var m,c;let n=o+t,s=[],r="",l=0;for(;l<n.length;){let g=n.indexOf(`
|
|
15
|
+
`,l);if(g===-1){r=n.substring(l);break}else {let u=n.substring(l,g).trim();u&&s.push(u),l=g+1;}}for(let g of s){if(g==="data: [DONE]")return;if(g.startsWith("data: ")){let u=g.substring(6);try{let f=JSON.parse(u),y=Bt.safeParse(f);if(y.success){let T={partialMessages:[]},S=y.data;if(S.choices.length>0){let R=S.choices[0].delta;if(R!==void 0&&Object.keys(R).length!==0){if("content"in R&&R.content!==null)T.partialMessages.push(oe(v,R.content));else if("refusal"in R&&R.refusal!==null)T.partialMessages.push(oe(v,R.refusal));else if("tool_calls"in R&&Array.isArray(R.tool_calls)&&R.tool_calls.length>0){let j=R.tool_calls[0];T.partialMessages.push(et(v,j.index,j.id,(m=j.function)==null?void 0:m.name,(c=j.function)==null?void 0:c.arguments));}}}S.usage&&(T.usage={promptTokens:S.usage.prompt_tokens,completionTokens:S.usage.completion_tokens,totalTokens:S.usage.total_tokens}),yield {partialResponse:T,buffer:r};}else throw new k({info:"Invalid response from model",cause:y.error})}catch(f){throw new k({info:`Malformed JSON received in stream: ${u}`,cause:f})}}}yield {partialResponse:{partialMessages:[]},buffer:r};})}transformProxyStreamChatResponseChunk(t,o,n,s,r){return Y(this,null,function*(){yield*Le(this.transformStreamChatResponseChunk(t,o));})}getProxyStreamChatUrl(t,o,n){return C(this,null,function*(){return new Promise(s=>{s(this.streamChatUrl);})})}getProxyCompleteChatUrl(t,o,n){return C(this,null,function*(){return new Promise(s=>{s(this.completeChatUrl);})})}getProxyCompleteChatHeaders(t,o,n){return C(this,null,function*(){if(!o)return {};let s=b({},o);return delete s.host,delete s["content-length"],s})}getProxyStreamChatHeaders(t,o,n){return C(this,null,function*(){return yield this.getProxyCompleteChatHeaders(t,o,n)})}};var zt=[A],Dt=zod.z.enum([A]);var Ht=zod.z.object({object:zod.z.literal("list"),model:zod.z.string(),data:zod.z.array(zod.z.object({index:zod.z.number(),object:zod.z.literal("embedding"),embedding:zod.z.array(zod.z.number()).or(zod.z.string().base64())})),usage:zod.z.object({prompt_tokens:zod.z.number().nonnegative(),total_tokens:zod.z.number().nonnegative()}).optional()});var An=zod.z.string().min(1).or(zod.z.array(zod.z.string().min(1)).min(1)),Kt=zod.z.object({model:zod.z.string().min(1).optional(),input:An});var Ae=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string()}),V=class{constructor(t,o){this.version="v1";let n=Ae.parse(o);this.modelSchema=t,this.modelName=n.modelName,this.apiKey=n.apiKey,this.baseUrl=O(N.baseUrl),this.getEmbeddingsUrl=O(`${this.baseUrl}/embeddings`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"}}getDefaultParams(){return {model:this.modelName}}getRetryDelay(t){return {shouldRetry:!0,delayMs:0}}getTokenCount(t){return t.requests.reduce((o,n)=>o+n.length,0)}transformModelRequest(t){let o=Kt.safeParse(t);if(!o.success)throw new B({info:"Invalid model request",cause:o.error});let n=o.data,s=n.model,r={},l=H().parse(K(r)),m={modality:A,requests:[...n.input]};return {modelName:s,config:l,embeddingRequests:m}}transformConfig(t,o){let n=this.modelSchema.config.schema.safeParse(t);if(!n.success)throw new x({info:`Invalid config for model : '${this.modelName}'`,cause:n.error});let s=n.data;return Object.keys(s).forEach(l=>{if(!this.modelSchema.config.def[l])throw new x({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${l}',
|
|
16
|
+
available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(s).reduce((l,m)=>{let g=this.modelSchema.config.def[m].param,u=s[m];return l[g]=u,l},{})}transformEmbeddingRequests(t){let o=st().safeParse(t);if(!o.success)throw new se({info:"Invalid embedding requests",cause:o.error});if(t.modality!==A)throw new se({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Only '${A}' modality is supported for model : '${this.modelName}'`)});return {input:o.data.requests}}getGetEmbeddingsUrl(t,o){return C(this,null,function*(){return new Promise(n=>{n(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(t,o){return C(this,null,function*(){return new Promise(n=>{n(this.getDefaultHeaders());})})}getGetEmbeddingsData(t,o){return C(this,null,function*(){return new Promise(n=>{n(b(b(b({},this.getDefaultParams()),this.transformConfig(t,o)),this.transformEmbeddingRequests(o)));})})}transformGetEmbeddingsResponse(t){var n;let o=Ht.safeParse(t);if(o.success){let s=o.data,r=s.data.map(l=>({index:l.index,embedding:l.embedding}));return {encodingFormat:ne,embeddings:r,usage:{totalTokens:(n=s.usage)==null?void 0:n.total_tokens}}}throw new k({info:"Invalid response from model",cause:o.error})}};var _e=jt(Dt).parse({name:"__base__",description:"Base embedding model for Together AI",maxInputTokens:128e3,maxOutputTokens:128e3,modalities:zt,config:{def:{},schema:zod.z.object({})}});
|
|
17
17
|
|
|
18
18
|
exports.BaseChatModel = G;
|
|
19
|
-
exports.BaseChatModelOptions =
|
|
20
|
-
exports.BaseChatModelSchema =
|
|
19
|
+
exports.BaseChatModelOptions = we;
|
|
20
|
+
exports.BaseChatModelSchema = xe;
|
|
21
21
|
exports.BaseEmbeddingModel = V;
|
|
22
|
-
exports.BaseEmbeddingModelOptions =
|
|
22
|
+
exports.BaseEmbeddingModelOptions = Ae;
|
|
23
23
|
exports.BaseEmbeddingModelSchema = _e;
|
|
24
|
-
exports.ChatModelBaseConfigDef =
|
|
25
|
-
exports.ChatModelBaseConfigSchema =
|
|
24
|
+
exports.ChatModelBaseConfigDef = kt;
|
|
25
|
+
exports.ChatModelBaseConfigSchema = qt;
|
|
26
26
|
exports.TogetherAI = N;
|
|
27
|
-
exports.TogetherAIChatModelConfigs =
|
|
28
|
-
exports.TogetherAIEmbeddingModelModalities =
|
|
29
|
-
exports.TogetherAIEmbeddingModelModalitiesEnum =
|
|
30
|
-
exports.TogetherAIEmbeddingRequest =
|
|
31
|
-
exports.TogetherAIEmbeddingRequestInput =
|
|
32
|
-
exports.TogetherAIGetEmbeddingsResponse =
|
|
33
|
-
exports.frequencyPenalty =
|
|
27
|
+
exports.TogetherAIChatModelConfigs = Pe;
|
|
28
|
+
exports.TogetherAIEmbeddingModelModalities = zt;
|
|
29
|
+
exports.TogetherAIEmbeddingModelModalitiesEnum = Dt;
|
|
30
|
+
exports.TogetherAIEmbeddingRequest = Kt;
|
|
31
|
+
exports.TogetherAIEmbeddingRequestInput = An;
|
|
32
|
+
exports.TogetherAIGetEmbeddingsResponse = Ht;
|
|
33
|
+
exports.frequencyPenalty = Te;
|
|
34
34
|
exports.logProbs = Ee;
|
|
35
|
-
exports.maxTokens =
|
|
36
|
-
exports.minP =
|
|
37
|
-
exports.presencePenalty =
|
|
38
|
-
exports.repetitionPenalty =
|
|
39
|
-
exports.responseFormat =
|
|
40
|
-
exports.responseSchema =
|
|
41
|
-
exports.seed =
|
|
42
|
-
exports.stop =
|
|
43
|
-
exports.temperature =
|
|
44
|
-
exports.toolChoice =
|
|
45
|
-
exports.topK =
|
|
46
|
-
exports.topP =
|
|
35
|
+
exports.maxTokens = ue;
|
|
36
|
+
exports.minP = ye;
|
|
37
|
+
exports.presencePenalty = be;
|
|
38
|
+
exports.repetitionPenalty = Ce;
|
|
39
|
+
exports.responseFormat = Ie;
|
|
40
|
+
exports.responseSchema = ve;
|
|
41
|
+
exports.seed = Re;
|
|
42
|
+
exports.stop = ge;
|
|
43
|
+
exports.temperature = ce;
|
|
44
|
+
exports.toolChoice = Me;
|
|
45
|
+
exports.topK = he;
|
|
46
|
+
exports.topP = fe;
|
|
47
47
|
//# sourceMappingURL=index.js.map
|
|
48
48
|
//# sourceMappingURL=index.js.map
|