@ampt/ai 2.0.7 → 2.1.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.cjs +167 -30
- package/dist/index.d.cts +4 -62
- package/dist/index.d.ts +4 -62
- package/dist/index.js +167 -30
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20196,7 +20196,7 @@ function request(url, options) {
|
|
|
20196
20196
|
resolve(result);
|
|
20197
20197
|
}
|
|
20198
20198
|
};
|
|
20199
|
-
const req = import_https.default.request(url, { agent }, (res) => {
|
|
20199
|
+
const req = import_https.default.request(url, { agent, headers: options.headers }, (res) => {
|
|
20200
20200
|
const bufs = [];
|
|
20201
20201
|
res.on("data", (data) => bufs.push(data));
|
|
20202
20202
|
res.on("end", () => {
|
|
@@ -44548,6 +44548,66 @@ var modelInfoMap = {
|
|
|
44548
44548
|
return (json?.inputTextTokenCount ?? 0) * 10;
|
|
44549
44549
|
}
|
|
44550
44550
|
},
|
|
44551
|
+
"amazon.titan-embed-text-v2:0": {
|
|
44552
|
+
name: "Amazon Titan Embeddings V2",
|
|
44553
|
+
type: "embeddings" /* Embeddings */,
|
|
44554
|
+
streaming: false,
|
|
44555
|
+
provider: "Amazon",
|
|
44556
|
+
description: "",
|
|
44557
|
+
version: "v2",
|
|
44558
|
+
inferenceUsage: (body) => {
|
|
44559
|
+
const json = JSON.parse(Buffer.from(body).toString());
|
|
44560
|
+
return (json?.inputTextTokenCount ?? 0) * 2;
|
|
44561
|
+
}
|
|
44562
|
+
},
|
|
44563
|
+
"amazon.titan-text-express-v1": {
|
|
44564
|
+
name: "Amazon Titan Text Express",
|
|
44565
|
+
type: "language" /* Language */,
|
|
44566
|
+
streaming: true,
|
|
44567
|
+
provider: "Amazon",
|
|
44568
|
+
description: "",
|
|
44569
|
+
version: "v1.x",
|
|
44570
|
+
inferenceUsage: (inputSize, outputSize) => {
|
|
44571
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 20 + outputSize / AVERAGE_BYTES_PER_TOKEN * 60);
|
|
44572
|
+
}
|
|
44573
|
+
},
|
|
44574
|
+
"amazon.titan-text-lite-v1": {
|
|
44575
|
+
name: "Amazon Titan Text Lite",
|
|
44576
|
+
type: "language" /* Language */,
|
|
44577
|
+
streaming: true,
|
|
44578
|
+
provider: "Amazon",
|
|
44579
|
+
description: "",
|
|
44580
|
+
version: "v1.x",
|
|
44581
|
+
inferenceUsage: (inputSize, outputSize) => {
|
|
44582
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 15 + outputSize / AVERAGE_BYTES_PER_TOKEN * 20);
|
|
44583
|
+
}
|
|
44584
|
+
},
|
|
44585
|
+
"amazon.titan-text-premier-v1:0": {
|
|
44586
|
+
name: "Amazon Titan Text Premier",
|
|
44587
|
+
type: "language" /* Language */,
|
|
44588
|
+
streaming: true,
|
|
44589
|
+
provider: "Amazon",
|
|
44590
|
+
description: "",
|
|
44591
|
+
version: "v1.x",
|
|
44592
|
+
inferenceUsage: (inputSize, outputSize) => {
|
|
44593
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 50 + outputSize / AVERAGE_BYTES_PER_TOKEN * 150);
|
|
44594
|
+
}
|
|
44595
|
+
},
|
|
44596
|
+
// WIP: Need to change the interface
|
|
44597
|
+
// 'amazon.titan-image-generator-v1': {
|
|
44598
|
+
// name: 'Amazon: Titan Image Generator G1',
|
|
44599
|
+
// type: ModelType.Image,
|
|
44600
|
+
// streaming: false,
|
|
44601
|
+
// provider: 'Amazon',
|
|
44602
|
+
// description:
|
|
44603
|
+
// '',
|
|
44604
|
+
// version: '1.x',
|
|
44605
|
+
// inferenceUsage: (width: number, height: number, steps: number) => {
|
|
44606
|
+
// const large = width * height > 512 * 512
|
|
44607
|
+
// const highQuality = steps > 50
|
|
44608
|
+
// return Math.round((large ? 3600000 : 1800000) * (highQuality ? 2 : 1))
|
|
44609
|
+
// }
|
|
44610
|
+
// },
|
|
44551
44611
|
"anthropic.claude-instant-v1": {
|
|
44552
44612
|
name: "Claude Instant",
|
|
44553
44613
|
type: "language" /* Language */,
|
|
@@ -44556,29 +44616,29 @@ var modelInfoMap = {
|
|
|
44556
44616
|
description: "A faster and cheaper yet still very capable model, which can handle a range of tasks including casual dialogue, text analysis, summarization, and document question-answering.",
|
|
44557
44617
|
version: "v1.2",
|
|
44558
44618
|
inferenceUsage: (inputSize, outputSize) => {
|
|
44559
|
-
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN *
|
|
44619
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 80 + outputSize / AVERAGE_BYTES_PER_TOKEN * 240);
|
|
44560
44620
|
}
|
|
44561
44621
|
},
|
|
44562
|
-
"anthropic.claude-
|
|
44622
|
+
"anthropic.claude-v2": {
|
|
44563
44623
|
name: "Claude",
|
|
44564
44624
|
type: "language" /* Language */,
|
|
44565
44625
|
streaming: true,
|
|
44566
44626
|
provider: "Anthropic",
|
|
44567
|
-
description: "
|
|
44568
|
-
version: "
|
|
44627
|
+
description: "Anthropic's most powerful model, which excels at a wide range of tasks from sophisticated dialogue and creative content generation to detailed instruction following.",
|
|
44628
|
+
version: "v2.0",
|
|
44569
44629
|
inferenceUsage: (inputSize, outputSize) => {
|
|
44570
|
-
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN *
|
|
44630
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 800 + outputSize / AVERAGE_BYTES_PER_TOKEN * 2400);
|
|
44571
44631
|
}
|
|
44572
44632
|
},
|
|
44573
|
-
"anthropic.claude-v2": {
|
|
44633
|
+
"anthropic.claude-v2:1": {
|
|
44574
44634
|
name: "Claude",
|
|
44575
44635
|
type: "language" /* Language */,
|
|
44576
44636
|
streaming: true,
|
|
44577
44637
|
provider: "Anthropic",
|
|
44578
44638
|
description: "Anthropic's most powerful model, which excels at a wide range of tasks from sophisticated dialogue and creative content generation to detailed instruction following.",
|
|
44579
|
-
version: "v2",
|
|
44639
|
+
version: "v2.1",
|
|
44580
44640
|
inferenceUsage: (inputSize, outputSize) => {
|
|
44581
|
-
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN *
|
|
44641
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 800 + outputSize / AVERAGE_BYTES_PER_TOKEN * 2400);
|
|
44582
44642
|
}
|
|
44583
44643
|
},
|
|
44584
44644
|
"anthropic.claude-3-sonnet-20240229-v1:0": {
|
|
@@ -44587,11 +44647,35 @@ var modelInfoMap = {
|
|
|
44587
44647
|
streaming: true,
|
|
44588
44648
|
provider: "Anthropic",
|
|
44589
44649
|
description: "",
|
|
44590
|
-
version: "v1",
|
|
44650
|
+
version: "v1.0",
|
|
44591
44651
|
inferenceUsage: (inputSize, outputSize) => {
|
|
44592
44652
|
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 300 + outputSize / AVERAGE_BYTES_PER_TOKEN * 1500);
|
|
44593
44653
|
}
|
|
44594
44654
|
},
|
|
44655
|
+
"anthropic.claude-3-haiku-20240307-v1:0": {
|
|
44656
|
+
name: "Claude 3 Haiku",
|
|
44657
|
+
type: "language" /* Language */,
|
|
44658
|
+
streaming: true,
|
|
44659
|
+
provider: "Anthropic",
|
|
44660
|
+
description: "",
|
|
44661
|
+
version: "v1.0",
|
|
44662
|
+
inferenceUsage: (inputSize, outputSize) => {
|
|
44663
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 25 + outputSize / AVERAGE_BYTES_PER_TOKEN * 125);
|
|
44664
|
+
}
|
|
44665
|
+
},
|
|
44666
|
+
"anthropic.claude-3-opus-20240229-v1:0": {
|
|
44667
|
+
name: "Claude 3 Opus",
|
|
44668
|
+
region: "us-west-2",
|
|
44669
|
+
// as of 5/10/2024, this is the only region that supports this model
|
|
44670
|
+
type: "language" /* Language */,
|
|
44671
|
+
streaming: true,
|
|
44672
|
+
provider: "Anthropic",
|
|
44673
|
+
description: "",
|
|
44674
|
+
version: "v1.0",
|
|
44675
|
+
inferenceUsage: (inputSize, outputSize) => {
|
|
44676
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 1500 + outputSize / AVERAGE_BYTES_PER_TOKEN * 7500);
|
|
44677
|
+
}
|
|
44678
|
+
},
|
|
44595
44679
|
"cohere.command-text-v14": {
|
|
44596
44680
|
name: "Command",
|
|
44597
44681
|
type: "language" /* Language */,
|
|
@@ -44649,23 +44733,54 @@ var modelInfoMap = {
|
|
|
44649
44733
|
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 75 + outputSize / AVERAGE_BYTES_PER_TOKEN * 100);
|
|
44650
44734
|
}
|
|
44651
44735
|
},
|
|
44652
|
-
"
|
|
44736
|
+
"meta.llama2-70b-chat-v1": {
|
|
44737
|
+
name: "Meta Llama 2 Chat (70B)",
|
|
44738
|
+
type: "language" /* Language */,
|
|
44739
|
+
streaming: true,
|
|
44740
|
+
provider: "Meta",
|
|
44741
|
+
description: "",
|
|
44742
|
+
version: "v1",
|
|
44743
|
+
inferenceUsage: (inputSize, outputSize) => {
|
|
44744
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 195 + outputSize / AVERAGE_BYTES_PER_TOKEN * 256);
|
|
44745
|
+
}
|
|
44746
|
+
},
|
|
44747
|
+
"meta.llama3-8b-instruct-v1:0": {
|
|
44748
|
+
name: "Meta Llama 3 Instruct (8B)",
|
|
44749
|
+
type: "language" /* Language */,
|
|
44750
|
+
streaming: true,
|
|
44751
|
+
provider: "Meta",
|
|
44752
|
+
description: "",
|
|
44753
|
+
version: "v1.x",
|
|
44754
|
+
inferenceUsage: (inputSize, outputSize) => {
|
|
44755
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 40 + outputSize / AVERAGE_BYTES_PER_TOKEN * 60);
|
|
44756
|
+
}
|
|
44757
|
+
},
|
|
44758
|
+
"meta.llama3-70b-instruct-v1:0": {
|
|
44759
|
+
name: "Meta Llama 3 Instruct (70B)",
|
|
44760
|
+
type: "language" /* Language */,
|
|
44761
|
+
streaming: true,
|
|
44762
|
+
provider: "Meta",
|
|
44763
|
+
description: "",
|
|
44764
|
+
version: "v1.x",
|
|
44765
|
+
inferenceUsage: (inputSize, outputSize) => {
|
|
44766
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 265 + outputSize / AVERAGE_BYTES_PER_TOKEN * 350);
|
|
44767
|
+
}
|
|
44768
|
+
},
|
|
44769
|
+
"stability.stable-diffusion-xl-v1": {
|
|
44653
44770
|
name: "Stable Diffusion XL",
|
|
44654
44771
|
type: "image" /* Image */,
|
|
44655
44772
|
streaming: false,
|
|
44656
44773
|
provider: "Stability AI",
|
|
44657
44774
|
description: "Deep learning, text-to-image model used to generate detailed images conditioned on text descriptions, inpainting, outpainting, and generating image-to-image translations.",
|
|
44658
|
-
version: "
|
|
44775
|
+
version: "v1.x",
|
|
44659
44776
|
inferenceUsage: (width, height, steps) => {
|
|
44660
|
-
const large = width * height > 512 * 512;
|
|
44661
44777
|
const highQuality = steps > 50;
|
|
44662
|
-
return Math.round(
|
|
44778
|
+
return Math.round(4e6 * (highQuality ? 2 : 1));
|
|
44663
44779
|
}
|
|
44664
44780
|
},
|
|
44665
44781
|
"mistral.mistral-7b-instruct-v0:2": {
|
|
44666
44782
|
name: "Mistral Instruct (7B)",
|
|
44667
|
-
region:
|
|
44668
|
-
// at time of writing, this is the only region that supports this model
|
|
44783
|
+
// region: 'us-west-2',
|
|
44669
44784
|
type: "language" /* Language */,
|
|
44670
44785
|
streaming: true,
|
|
44671
44786
|
provider: "Mistral",
|
|
@@ -44677,8 +44792,7 @@ var modelInfoMap = {
|
|
|
44677
44792
|
},
|
|
44678
44793
|
"mistral.mixtral-8x7b-instruct-v0:1": {
|
|
44679
44794
|
name: "MixTral Instruct (8x7B)",
|
|
44680
|
-
region:
|
|
44681
|
-
// at time of writing, this is the only region that supports this model
|
|
44795
|
+
// region: 'us-west-2',
|
|
44682
44796
|
type: "language" /* Language */,
|
|
44683
44797
|
streaming: true,
|
|
44684
44798
|
provider: "Mistral",
|
|
@@ -44687,6 +44801,18 @@ var modelInfoMap = {
|
|
|
44687
44801
|
inferenceUsage: (inputSize, outputSize) => {
|
|
44688
44802
|
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 45 + outputSize / AVERAGE_BYTES_PER_TOKEN * 70);
|
|
44689
44803
|
}
|
|
44804
|
+
},
|
|
44805
|
+
"mistral.mistral-large-2402-v1:0": {
|
|
44806
|
+
name: "Mistral Large",
|
|
44807
|
+
// region: 'us-west-2',
|
|
44808
|
+
type: "language" /* Language */,
|
|
44809
|
+
streaming: true,
|
|
44810
|
+
provider: "Mistral",
|
|
44811
|
+
description: "Ideal for text summarization, question and answering, text classification, text completion, and code generation.",
|
|
44812
|
+
version: "v0.1",
|
|
44813
|
+
inferenceUsage: (inputSize, outputSize) => {
|
|
44814
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 800 + outputSize / AVERAGE_BYTES_PER_TOKEN * 2400);
|
|
44815
|
+
}
|
|
44690
44816
|
}
|
|
44691
44817
|
};
|
|
44692
44818
|
function getModelInfo(id) {
|
|
@@ -45043,16 +45169,21 @@ var ChatMessage = class {
|
|
|
45043
45169
|
};
|
|
45044
45170
|
var adapters = {
|
|
45045
45171
|
"anthropic.claude-instant-v1": AnthropicClaudeChatAdapter,
|
|
45046
|
-
"anthropic.claude-v1": AnthropicClaudeChatAdapter,
|
|
45047
45172
|
"anthropic.claude-v2": AnthropicClaudeChatAdapter,
|
|
45048
45173
|
"anthropic.claude-3-sonnet-20240229-v1:0": AnthropicClaudeSonnetChatAdapter,
|
|
45174
|
+
"anthropic.claude-3-haiku-20240307-v1:0": AnthropicClaudeSonnetChatAdapter,
|
|
45175
|
+
"anthropic.claude-3-opus-20240229-v1:0": AnthropicClaudeSonnetChatAdapter,
|
|
45049
45176
|
"ai21.j2-mid-v1": Ai21JurassicChatAdapter,
|
|
45050
45177
|
"ai21.j2-ultra-v1": Ai21JurassicChatAdapter,
|
|
45051
45178
|
"cohere.command-text-v14": CohereCommandChatAdapter,
|
|
45052
45179
|
"cohere.command-light-text-v14": CohereCommandChatAdapter,
|
|
45053
45180
|
"meta.llama2-13b-chat-v1": MetaLlamaChatAdapter,
|
|
45181
|
+
"meta.llama2-70b-chat-v1": MetaLlamaChatAdapter,
|
|
45182
|
+
"meta.llama3-8b-instruct-v1:0": MetaLlamaChatAdapter,
|
|
45183
|
+
"meta.llama3-70b-instruct-v1:0": MetaLlamaChatAdapter,
|
|
45054
45184
|
"mistral.mistral-7b-instruct-v0:2": MixtralAIChatAdapter,
|
|
45055
|
-
"mistral.mixtral-8x7b-instruct-v0:1": MixtralAIChatAdapter
|
|
45185
|
+
"mistral.mixtral-8x7b-instruct-v0:1": MixtralAIChatAdapter,
|
|
45186
|
+
"mistral.mistral-large-2402-v1:0": MixtralAIChatAdapter
|
|
45056
45187
|
};
|
|
45057
45188
|
async function chat(messages, options = {}) {
|
|
45058
45189
|
const modelId = options.modelId ?? "anthropic.claude-instant-v1";
|
|
@@ -45068,16 +45199,21 @@ async function chat(messages, options = {}) {
|
|
|
45068
45199
|
chat.models = async () => {
|
|
45069
45200
|
return [
|
|
45070
45201
|
"anthropic.claude-instant-v1",
|
|
45071
|
-
"anthropic.claude-v1",
|
|
45072
45202
|
"anthropic.claude-v2",
|
|
45073
45203
|
"anthropic.claude-3-sonnet-20240229-v1:0",
|
|
45204
|
+
"anthropic.claude-3-haiku-20240307-v1:0",
|
|
45205
|
+
"anthropic.claude-3-opus-20240229-v1:0",
|
|
45074
45206
|
"ai21.j2-mid-v1",
|
|
45075
45207
|
"ai21.j2-ultra-v1",
|
|
45076
45208
|
"cohere.command-text-v14",
|
|
45077
45209
|
"cohere.command-light-text-v14",
|
|
45078
45210
|
"meta.llama2-13b-chat-v1",
|
|
45211
|
+
"meta.llama2-70b-chat-v1",
|
|
45212
|
+
"meta.llama3-8b-instruct-v1:0",
|
|
45213
|
+
"meta.llama3-70b-instruct-v1:0",
|
|
45079
45214
|
"mistral.mistral-7b-instruct-v0:2",
|
|
45080
|
-
"mistral.mixtral-8x7b-instruct-v0:1"
|
|
45215
|
+
"mistral.mixtral-8x7b-instruct-v0:1",
|
|
45216
|
+
"mistral.mistral-large-2402-v1:0"
|
|
45081
45217
|
];
|
|
45082
45218
|
};
|
|
45083
45219
|
|
|
@@ -45111,11 +45247,12 @@ var CohereEmbedAdapter = class {
|
|
|
45111
45247
|
// src/embed/index.ts
|
|
45112
45248
|
var adapters2 = {
|
|
45113
45249
|
"amazon.titan-embed-text-v1": AmazonTitanEmbedTextAdapter,
|
|
45250
|
+
"amazon.titan-embed-text-v2:0": AmazonTitanEmbedTextAdapter,
|
|
45114
45251
|
"cohere.embed-english-v3": CohereEmbedAdapter,
|
|
45115
45252
|
"cohere.embed-multilingual-v3": CohereEmbedAdapter
|
|
45116
45253
|
};
|
|
45117
45254
|
async function embed(input, options = {}) {
|
|
45118
|
-
const modelId = options.modelId ?? "amazon.titan-embed-text-
|
|
45255
|
+
const modelId = options.modelId ?? "amazon.titan-embed-text-v2:0";
|
|
45119
45256
|
const AdapterClass = adapters2[modelId];
|
|
45120
45257
|
if (!AdapterClass) {
|
|
45121
45258
|
throw new Error(`No adapter found for model ${modelId}`);
|
|
@@ -45131,7 +45268,7 @@ embed.models = async () => {
|
|
|
45131
45268
|
|
|
45132
45269
|
// src/render.ts
|
|
45133
45270
|
async function render(prompt, options = {}) {
|
|
45134
|
-
const modelId = options.modelId ?? "stability.stable-diffusion-xl-
|
|
45271
|
+
const modelId = options.modelId ?? "stability.stable-diffusion-xl-v1";
|
|
45135
45272
|
const body = {
|
|
45136
45273
|
text_prompts: [
|
|
45137
45274
|
{
|
|
@@ -45141,8 +45278,8 @@ async function render(prompt, options = {}) {
|
|
|
45141
45278
|
cfg_scale: options.scale ?? 10,
|
|
45142
45279
|
seed: options.seed ?? 20,
|
|
45143
45280
|
steps: options.steps ?? 50,
|
|
45144
|
-
width: options.width ??
|
|
45145
|
-
height: options.height ??
|
|
45281
|
+
width: options.width ?? 1024,
|
|
45282
|
+
height: options.height ?? 1024
|
|
45146
45283
|
};
|
|
45147
45284
|
const response = await invoke2({ body, modelId });
|
|
45148
45285
|
if (!response.body) {
|
|
@@ -45158,7 +45295,7 @@ async function render(prompt, options = {}) {
|
|
|
45158
45295
|
return new Response(responseBody, { headers: { "Content-Type": "image/png" } });
|
|
45159
45296
|
}
|
|
45160
45297
|
render.models = async () => {
|
|
45161
|
-
return ["stability.stable-diffusion-xl-
|
|
45298
|
+
return ["stability.stable-diffusion-xl-v1"];
|
|
45162
45299
|
};
|
|
45163
45300
|
|
|
45164
45301
|
// src/summarize/adapters/anthropic.claude.sonnet.ts
|
|
@@ -45264,7 +45401,7 @@ var MixtralAISummarizeAdapter = class {
|
|
|
45264
45401
|
// src/summarize/index.ts
|
|
45265
45402
|
var adapters3 = {
|
|
45266
45403
|
"anthropic.claude-instant-v1": AnthropicClaudeSummarizeAdapter,
|
|
45267
|
-
|
|
45404
|
+
// 'anthropic.claude-v1': AnthropicClaudeSummarizeAdapter,
|
|
45268
45405
|
"anthropic.claude-v2": AnthropicClaudeSummarizeAdapter,
|
|
45269
45406
|
"anthropic.claude-3-sonnet-20240229-v1:0": AnthropicClaudeSonnetSummarizeAdapter,
|
|
45270
45407
|
"mistral.mistral-7b-instruct-v0:2": MixtralAISummarizeAdapter,
|
|
@@ -45284,7 +45421,7 @@ async function summarize(input, options = {}) {
|
|
|
45284
45421
|
summarize.models = async () => {
|
|
45285
45422
|
return [
|
|
45286
45423
|
"anthropic.claude-instant-v1",
|
|
45287
|
-
|
|
45424
|
+
// 'anthropic.claude-v1',
|
|
45288
45425
|
"anthropic.claude-v2",
|
|
45289
45426
|
"anthropic.claude-3-sonnet-20240229-v1:0",
|
|
45290
45427
|
"mistral.mistral-7b-instruct-v0:2",
|
|
@@ -55550,7 +55687,7 @@ async function translate(input, options) {
|
|
|
55550
55687
|
// src/index.ts
|
|
55551
55688
|
if (process.env.AMPT_RUNTIME_NAME === "nodejs18-beta") {
|
|
55552
55689
|
console.error(
|
|
55553
|
-
'@ampt/ai requires the nodejs18 runtime. Please add "runtime": "
|
|
55690
|
+
'@ampt/ai requires the nodejs18 runtime or higher. Please add "runtime": "nodejs20" to the "ampt" section of your package.json.'
|
|
55554
55691
|
);
|
|
55555
55692
|
}
|
|
55556
55693
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Translate } from '@aws-sdk/client-translate';
|
|
2
2
|
|
|
3
|
-
type ModelId = '
|
|
3
|
+
type ModelId = 'amazon.titan-text-express-v1' | 'amazon.titan-text-lite-v1' | 'amazon.titan-text-premier-v1:0' | 'amazon.titan-embed-text-v1' | 'amazon.titan-embed-text-v2:0' | 'anthropic.claude-v2' | 'anthropic.claude-v2:1' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'anthropic.claude-instant-v1' | 'ai21.j2-mid-v1' | 'ai21.j2-ultra-v1' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'cohere.embed-english-v3' | 'cohere.embed-multilingual-v3' | 'meta.llama2-13b-chat-v1' | 'meta.llama2-70b-chat-v1' | 'meta.llama3-8b-instruct-v1:0' | 'meta.llama3-70b-instruct-v1:0' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1' | 'mistral.mistral-large-2402-v1:0' | 'stability.stable-diffusion-xl-v1';
|
|
4
4
|
declare function models(): Promise<string[]>;
|
|
5
5
|
declare enum ModelType {
|
|
6
6
|
Embeddings = "embeddings",
|
|
@@ -42,64 +42,6 @@ type ModelInfoMap = {
|
|
|
42
42
|
* Note: we track usage in micro-cents/uc (1,000,000ths of a cent, or 100,000,000ths of a dollar) because
|
|
43
43
|
* the quota system only works with integers.
|
|
44
44
|
*
|
|
45
|
-
* AI21 Jurassic-2 Mid:
|
|
46
|
-
* - $0.0125 per 1000 input tokens: 1250 uc per token
|
|
47
|
-
* - $0.0125 per 1000 output tokens: 1250 uc per token
|
|
48
|
-
*
|
|
49
|
-
* AI21 Jurassic-2 Ultra:
|
|
50
|
-
* - $0.0188 per 1000 input tokens: 1880 uc per token
|
|
51
|
-
* - $0.0188 per 1000 output tokens: 1880 uc per token
|
|
52
|
-
*
|
|
53
|
-
* Claude Instant:
|
|
54
|
-
* - $0.00163 per 1000 input tokens: 163 uc per token
|
|
55
|
-
* - $0.00551 per 1000 output tokens: 551 uc per token
|
|
56
|
-
*
|
|
57
|
-
* Claude:
|
|
58
|
-
* - $0.01102 per 1000 input tokens: 1102 uc per token
|
|
59
|
-
* - $0.03268 per 1000 output tokens: 3268 uc per token
|
|
60
|
-
*
|
|
61
|
-
* Claude 3 Sonnet:
|
|
62
|
-
* - $0.00300 per 1000 input tokens: 300 uc per token
|
|
63
|
-
* - $0.01500 per 1000 output tokens: 1500 uc per token
|
|
64
|
-
*
|
|
65
|
-
* Cohere Command:
|
|
66
|
-
* - $0.0015 per 1000 input tokens: 150 uc per token
|
|
67
|
-
* - $0.0020 per 1000 output tokens: 200 uc per token
|
|
68
|
-
*
|
|
69
|
-
* Cohere Command Light:
|
|
70
|
-
* - $0.0003 per 1000 input tokens: 30 uc per token
|
|
71
|
-
* - $0.0006 per 1000 output tokens: 60 uc per token
|
|
72
|
-
*
|
|
73
|
-
* Cohere Embed - English:
|
|
74
|
-
* - $0.0001 for 1000 input tokens: 10 uc per token
|
|
75
|
-
*
|
|
76
|
-
* Cohere Embed - Multilingual:
|
|
77
|
-
* - $0.0001 for 1000 input tokens: 10 uc per token
|
|
78
|
-
*
|
|
79
|
-
* Meta Llama 2 Chat (13B):
|
|
80
|
-
* - $0.00075 per 1000 input tokens: 75 uc per token
|
|
81
|
-
* - $0.001 per 1000 output tokens: 100 uc per token
|
|
82
|
-
*
|
|
83
|
-
* Mistral 7B:
|
|
84
|
-
* - $.00015 per 1000 input tokens: 15 uc per token
|
|
85
|
-
* - $.0002 per 1000 output tokens: 20 uc per token
|
|
86
|
-
*
|
|
87
|
-
* MixTral 8x7B:
|
|
88
|
-
* - $0.00045 per 1000 input tokens: 45 uc per token
|
|
89
|
-
* - $0.0007 per 1000 output tokens: 70 uc per token
|
|
90
|
-
*
|
|
91
|
-
* Stable Diffusion XL:
|
|
92
|
-
*
|
|
93
|
-
* small format (512x512 or smaller):
|
|
94
|
-
* - standard quality: 1800000 per image
|
|
95
|
-
* - high quality: 3600000 per image
|
|
96
|
-
*
|
|
97
|
-
* large format (larger than 512x512):
|
|
98
|
-
* - standard quality: 3600000 per image (2x more expensive than small format)
|
|
99
|
-
* - high quality: 7200000 per image (2x more expensive than small format)
|
|
100
|
-
*
|
|
101
|
-
* Amazon Titan Embeddings:
|
|
102
|
-
* - $0.0001 for 1000 input tokens: 10 uc per token
|
|
103
45
|
*/
|
|
104
46
|
declare const modelInfoMap: ModelInfoMap;
|
|
105
47
|
declare function getModelInfo(id: ModelId): EmbeddingsModelInfo | LanguageModelInfo | ImageModelInfo;
|
|
@@ -138,7 +80,7 @@ interface ChatOptions {
|
|
|
138
80
|
modelId?: ChatModelId;
|
|
139
81
|
maxTokens?: number;
|
|
140
82
|
}
|
|
141
|
-
type ChatModelId = 'anthropic.claude-instant-v1' | 'anthropic.claude-v1' | 'anthropic.claude-
|
|
83
|
+
type ChatModelId = 'anthropic.claude-instant-v1' | 'anthropic.claude-v2' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'ai21.j2-mid-v1' | 'ai21.j2-ultra-v1' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'meta.llama2-13b-chat-v1' | 'meta.llama2-70b-chat-v1' | 'meta.llama3-8b-instruct-v1:0' | 'meta.llama3-70b-instruct-v1:0' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1' | 'mistral.mistral-large-2402-v1:0';
|
|
142
84
|
/**
|
|
143
85
|
* Send messages to the model and return the completion
|
|
144
86
|
* @param messages Array of messages to send to the model
|
|
@@ -149,7 +91,7 @@ declare namespace chat {
|
|
|
149
91
|
var models: () => Promise<ModelId[]>;
|
|
150
92
|
}
|
|
151
93
|
|
|
152
|
-
type EmbedModelId = 'amazon.titan-embed-text-v1' | 'cohere.embed-english-v3' | 'cohere.embed-multilingual-v3';
|
|
94
|
+
type EmbedModelId = 'amazon.titan-embed-text-v1' | 'amazon.titan-embed-text-v2:0' | 'cohere.embed-english-v3' | 'cohere.embed-multilingual-v3';
|
|
153
95
|
type Embedding = number[];
|
|
154
96
|
interface EmbedOptions {
|
|
155
97
|
modelId?: EmbedModelId;
|
|
@@ -176,7 +118,7 @@ interface SummarizeOptions {
|
|
|
176
118
|
modelId?: SummarizeModelId;
|
|
177
119
|
maxTokens?: number;
|
|
178
120
|
}
|
|
179
|
-
type SummarizeModelId = 'anthropic.claude-instant-v1' | 'anthropic.claude-
|
|
121
|
+
type SummarizeModelId = 'anthropic.claude-instant-v1' | 'anthropic.claude-v2' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1';
|
|
180
122
|
declare function summarize(input: string, options?: SummarizeOptions): Promise<Response>;
|
|
181
123
|
declare namespace summarize {
|
|
182
124
|
var models: () => Promise<ModelId[]>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Translate } from '@aws-sdk/client-translate';
|
|
2
2
|
|
|
3
|
-
type ModelId = '
|
|
3
|
+
type ModelId = 'amazon.titan-text-express-v1' | 'amazon.titan-text-lite-v1' | 'amazon.titan-text-premier-v1:0' | 'amazon.titan-embed-text-v1' | 'amazon.titan-embed-text-v2:0' | 'anthropic.claude-v2' | 'anthropic.claude-v2:1' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'anthropic.claude-instant-v1' | 'ai21.j2-mid-v1' | 'ai21.j2-ultra-v1' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'cohere.embed-english-v3' | 'cohere.embed-multilingual-v3' | 'meta.llama2-13b-chat-v1' | 'meta.llama2-70b-chat-v1' | 'meta.llama3-8b-instruct-v1:0' | 'meta.llama3-70b-instruct-v1:0' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1' | 'mistral.mistral-large-2402-v1:0' | 'stability.stable-diffusion-xl-v1';
|
|
4
4
|
declare function models(): Promise<string[]>;
|
|
5
5
|
declare enum ModelType {
|
|
6
6
|
Embeddings = "embeddings",
|
|
@@ -42,64 +42,6 @@ type ModelInfoMap = {
|
|
|
42
42
|
* Note: we track usage in micro-cents/uc (1,000,000ths of a cent, or 100,000,000ths of a dollar) because
|
|
43
43
|
* the quota system only works with integers.
|
|
44
44
|
*
|
|
45
|
-
* AI21 Jurassic-2 Mid:
|
|
46
|
-
* - $0.0125 per 1000 input tokens: 1250 uc per token
|
|
47
|
-
* - $0.0125 per 1000 output tokens: 1250 uc per token
|
|
48
|
-
*
|
|
49
|
-
* AI21 Jurassic-2 Ultra:
|
|
50
|
-
* - $0.0188 per 1000 input tokens: 1880 uc per token
|
|
51
|
-
* - $0.0188 per 1000 output tokens: 1880 uc per token
|
|
52
|
-
*
|
|
53
|
-
* Claude Instant:
|
|
54
|
-
* - $0.00163 per 1000 input tokens: 163 uc per token
|
|
55
|
-
* - $0.00551 per 1000 output tokens: 551 uc per token
|
|
56
|
-
*
|
|
57
|
-
* Claude:
|
|
58
|
-
* - $0.01102 per 1000 input tokens: 1102 uc per token
|
|
59
|
-
* - $0.03268 per 1000 output tokens: 3268 uc per token
|
|
60
|
-
*
|
|
61
|
-
* Claude 3 Sonnet:
|
|
62
|
-
* - $0.00300 per 1000 input tokens: 300 uc per token
|
|
63
|
-
* - $0.01500 per 1000 output tokens: 1500 uc per token
|
|
64
|
-
*
|
|
65
|
-
* Cohere Command:
|
|
66
|
-
* - $0.0015 per 1000 input tokens: 150 uc per token
|
|
67
|
-
* - $0.0020 per 1000 output tokens: 200 uc per token
|
|
68
|
-
*
|
|
69
|
-
* Cohere Command Light:
|
|
70
|
-
* - $0.0003 per 1000 input tokens: 30 uc per token
|
|
71
|
-
* - $0.0006 per 1000 output tokens: 60 uc per token
|
|
72
|
-
*
|
|
73
|
-
* Cohere Embed - English:
|
|
74
|
-
* - $0.0001 for 1000 input tokens: 10 uc per token
|
|
75
|
-
*
|
|
76
|
-
* Cohere Embed - Multilingual:
|
|
77
|
-
* - $0.0001 for 1000 input tokens: 10 uc per token
|
|
78
|
-
*
|
|
79
|
-
* Meta Llama 2 Chat (13B):
|
|
80
|
-
* - $0.00075 per 1000 input tokens: 75 uc per token
|
|
81
|
-
* - $0.001 per 1000 output tokens: 100 uc per token
|
|
82
|
-
*
|
|
83
|
-
* Mistral 7B:
|
|
84
|
-
* - $.00015 per 1000 input tokens: 15 uc per token
|
|
85
|
-
* - $.0002 per 1000 output tokens: 20 uc per token
|
|
86
|
-
*
|
|
87
|
-
* MixTral 8x7B:
|
|
88
|
-
* - $0.00045 per 1000 input tokens: 45 uc per token
|
|
89
|
-
* - $0.0007 per 1000 output tokens: 70 uc per token
|
|
90
|
-
*
|
|
91
|
-
* Stable Diffusion XL:
|
|
92
|
-
*
|
|
93
|
-
* small format (512x512 or smaller):
|
|
94
|
-
* - standard quality: 1800000 per image
|
|
95
|
-
* - high quality: 3600000 per image
|
|
96
|
-
*
|
|
97
|
-
* large format (larger than 512x512):
|
|
98
|
-
* - standard quality: 3600000 per image (2x more expensive than small format)
|
|
99
|
-
* - high quality: 7200000 per image (2x more expensive than small format)
|
|
100
|
-
*
|
|
101
|
-
* Amazon Titan Embeddings:
|
|
102
|
-
* - $0.0001 for 1000 input tokens: 10 uc per token
|
|
103
45
|
*/
|
|
104
46
|
declare const modelInfoMap: ModelInfoMap;
|
|
105
47
|
declare function getModelInfo(id: ModelId): EmbeddingsModelInfo | LanguageModelInfo | ImageModelInfo;
|
|
@@ -138,7 +80,7 @@ interface ChatOptions {
|
|
|
138
80
|
modelId?: ChatModelId;
|
|
139
81
|
maxTokens?: number;
|
|
140
82
|
}
|
|
141
|
-
type ChatModelId = 'anthropic.claude-instant-v1' | 'anthropic.claude-v1' | 'anthropic.claude-
|
|
83
|
+
type ChatModelId = 'anthropic.claude-instant-v1' | 'anthropic.claude-v2' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'ai21.j2-mid-v1' | 'ai21.j2-ultra-v1' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'meta.llama2-13b-chat-v1' | 'meta.llama2-70b-chat-v1' | 'meta.llama3-8b-instruct-v1:0' | 'meta.llama3-70b-instruct-v1:0' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1' | 'mistral.mistral-large-2402-v1:0';
|
|
142
84
|
/**
|
|
143
85
|
* Send messages to the model and return the completion
|
|
144
86
|
* @param messages Array of messages to send to the model
|
|
@@ -149,7 +91,7 @@ declare namespace chat {
|
|
|
149
91
|
var models: () => Promise<ModelId[]>;
|
|
150
92
|
}
|
|
151
93
|
|
|
152
|
-
type EmbedModelId = 'amazon.titan-embed-text-v1' | 'cohere.embed-english-v3' | 'cohere.embed-multilingual-v3';
|
|
94
|
+
type EmbedModelId = 'amazon.titan-embed-text-v1' | 'amazon.titan-embed-text-v2:0' | 'cohere.embed-english-v3' | 'cohere.embed-multilingual-v3';
|
|
153
95
|
type Embedding = number[];
|
|
154
96
|
interface EmbedOptions {
|
|
155
97
|
modelId?: EmbedModelId;
|
|
@@ -176,7 +118,7 @@ interface SummarizeOptions {
|
|
|
176
118
|
modelId?: SummarizeModelId;
|
|
177
119
|
maxTokens?: number;
|
|
178
120
|
}
|
|
179
|
-
type SummarizeModelId = 'anthropic.claude-instant-v1' | 'anthropic.claude-
|
|
121
|
+
type SummarizeModelId = 'anthropic.claude-instant-v1' | 'anthropic.claude-v2' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1';
|
|
180
122
|
declare function summarize(input: string, options?: SummarizeOptions): Promise<Response>;
|
|
181
123
|
declare namespace summarize {
|
|
182
124
|
var models: () => Promise<ModelId[]>;
|
package/dist/index.js
CHANGED
|
@@ -7125,7 +7125,7 @@ function request(url, options) {
|
|
|
7125
7125
|
resolve(result);
|
|
7126
7126
|
}
|
|
7127
7127
|
};
|
|
7128
|
-
const req = https.request(url, { agent }, (res) => {
|
|
7128
|
+
const req = https.request(url, { agent, headers: options.headers }, (res) => {
|
|
7129
7129
|
const bufs = [];
|
|
7130
7130
|
res.on("data", (data) => bufs.push(data));
|
|
7131
7131
|
res.on("end", () => {
|
|
@@ -31366,6 +31366,66 @@ var modelInfoMap = {
|
|
|
31366
31366
|
return (json?.inputTextTokenCount ?? 0) * 10;
|
|
31367
31367
|
}
|
|
31368
31368
|
},
|
|
31369
|
+
"amazon.titan-embed-text-v2:0": {
|
|
31370
|
+
name: "Amazon Titan Embeddings V2",
|
|
31371
|
+
type: "embeddings" /* Embeddings */,
|
|
31372
|
+
streaming: false,
|
|
31373
|
+
provider: "Amazon",
|
|
31374
|
+
description: "",
|
|
31375
|
+
version: "v2",
|
|
31376
|
+
inferenceUsage: (body) => {
|
|
31377
|
+
const json = JSON.parse(Buffer.from(body).toString());
|
|
31378
|
+
return (json?.inputTextTokenCount ?? 0) * 2;
|
|
31379
|
+
}
|
|
31380
|
+
},
|
|
31381
|
+
"amazon.titan-text-express-v1": {
|
|
31382
|
+
name: "Amazon Titan Text Express",
|
|
31383
|
+
type: "language" /* Language */,
|
|
31384
|
+
streaming: true,
|
|
31385
|
+
provider: "Amazon",
|
|
31386
|
+
description: "",
|
|
31387
|
+
version: "v1.x",
|
|
31388
|
+
inferenceUsage: (inputSize, outputSize) => {
|
|
31389
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 20 + outputSize / AVERAGE_BYTES_PER_TOKEN * 60);
|
|
31390
|
+
}
|
|
31391
|
+
},
|
|
31392
|
+
"amazon.titan-text-lite-v1": {
|
|
31393
|
+
name: "Amazon Titan Text Lite",
|
|
31394
|
+
type: "language" /* Language */,
|
|
31395
|
+
streaming: true,
|
|
31396
|
+
provider: "Amazon",
|
|
31397
|
+
description: "",
|
|
31398
|
+
version: "v1.x",
|
|
31399
|
+
inferenceUsage: (inputSize, outputSize) => {
|
|
31400
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 15 + outputSize / AVERAGE_BYTES_PER_TOKEN * 20);
|
|
31401
|
+
}
|
|
31402
|
+
},
|
|
31403
|
+
"amazon.titan-text-premier-v1:0": {
|
|
31404
|
+
name: "Amazon Titan Text Premier",
|
|
31405
|
+
type: "language" /* Language */,
|
|
31406
|
+
streaming: true,
|
|
31407
|
+
provider: "Amazon",
|
|
31408
|
+
description: "",
|
|
31409
|
+
version: "v1.x",
|
|
31410
|
+
inferenceUsage: (inputSize, outputSize) => {
|
|
31411
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 50 + outputSize / AVERAGE_BYTES_PER_TOKEN * 150);
|
|
31412
|
+
}
|
|
31413
|
+
},
|
|
31414
|
+
// WIP: Need to change the interface
|
|
31415
|
+
// 'amazon.titan-image-generator-v1': {
|
|
31416
|
+
// name: 'Amazon: Titan Image Generator G1',
|
|
31417
|
+
// type: ModelType.Image,
|
|
31418
|
+
// streaming: false,
|
|
31419
|
+
// provider: 'Amazon',
|
|
31420
|
+
// description:
|
|
31421
|
+
// '',
|
|
31422
|
+
// version: '1.x',
|
|
31423
|
+
// inferenceUsage: (width: number, height: number, steps: number) => {
|
|
31424
|
+
// const large = width * height > 512 * 512
|
|
31425
|
+
// const highQuality = steps > 50
|
|
31426
|
+
// return Math.round((large ? 3600000 : 1800000) * (highQuality ? 2 : 1))
|
|
31427
|
+
// }
|
|
31428
|
+
// },
|
|
31369
31429
|
"anthropic.claude-instant-v1": {
|
|
31370
31430
|
name: "Claude Instant",
|
|
31371
31431
|
type: "language" /* Language */,
|
|
@@ -31374,29 +31434,29 @@ var modelInfoMap = {
|
|
|
31374
31434
|
description: "A faster and cheaper yet still very capable model, which can handle a range of tasks including casual dialogue, text analysis, summarization, and document question-answering.",
|
|
31375
31435
|
version: "v1.2",
|
|
31376
31436
|
inferenceUsage: (inputSize, outputSize) => {
|
|
31377
|
-
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN *
|
|
31437
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 80 + outputSize / AVERAGE_BYTES_PER_TOKEN * 240);
|
|
31378
31438
|
}
|
|
31379
31439
|
},
|
|
31380
|
-
"anthropic.claude-
|
|
31440
|
+
"anthropic.claude-v2": {
|
|
31381
31441
|
name: "Claude",
|
|
31382
31442
|
type: "language" /* Language */,
|
|
31383
31443
|
streaming: true,
|
|
31384
31444
|
provider: "Anthropic",
|
|
31385
|
-
description: "
|
|
31386
|
-
version: "
|
|
31445
|
+
description: "Anthropic's most powerful model, which excels at a wide range of tasks from sophisticated dialogue and creative content generation to detailed instruction following.",
|
|
31446
|
+
version: "v2.0",
|
|
31387
31447
|
inferenceUsage: (inputSize, outputSize) => {
|
|
31388
|
-
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN *
|
|
31448
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 800 + outputSize / AVERAGE_BYTES_PER_TOKEN * 2400);
|
|
31389
31449
|
}
|
|
31390
31450
|
},
|
|
31391
|
-
"anthropic.claude-v2": {
|
|
31451
|
+
"anthropic.claude-v2:1": {
|
|
31392
31452
|
name: "Claude",
|
|
31393
31453
|
type: "language" /* Language */,
|
|
31394
31454
|
streaming: true,
|
|
31395
31455
|
provider: "Anthropic",
|
|
31396
31456
|
description: "Anthropic's most powerful model, which excels at a wide range of tasks from sophisticated dialogue and creative content generation to detailed instruction following.",
|
|
31397
|
-
version: "v2",
|
|
31457
|
+
version: "v2.1",
|
|
31398
31458
|
inferenceUsage: (inputSize, outputSize) => {
|
|
31399
|
-
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN *
|
|
31459
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 800 + outputSize / AVERAGE_BYTES_PER_TOKEN * 2400);
|
|
31400
31460
|
}
|
|
31401
31461
|
},
|
|
31402
31462
|
"anthropic.claude-3-sonnet-20240229-v1:0": {
|
|
@@ -31405,11 +31465,35 @@ var modelInfoMap = {
|
|
|
31405
31465
|
streaming: true,
|
|
31406
31466
|
provider: "Anthropic",
|
|
31407
31467
|
description: "",
|
|
31408
|
-
version: "v1",
|
|
31468
|
+
version: "v1.0",
|
|
31409
31469
|
inferenceUsage: (inputSize, outputSize) => {
|
|
31410
31470
|
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 300 + outputSize / AVERAGE_BYTES_PER_TOKEN * 1500);
|
|
31411
31471
|
}
|
|
31412
31472
|
},
|
|
31473
|
+
"anthropic.claude-3-haiku-20240307-v1:0": {
|
|
31474
|
+
name: "Claude 3 Haiku",
|
|
31475
|
+
type: "language" /* Language */,
|
|
31476
|
+
streaming: true,
|
|
31477
|
+
provider: "Anthropic",
|
|
31478
|
+
description: "",
|
|
31479
|
+
version: "v1.0",
|
|
31480
|
+
inferenceUsage: (inputSize, outputSize) => {
|
|
31481
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 25 + outputSize / AVERAGE_BYTES_PER_TOKEN * 125);
|
|
31482
|
+
}
|
|
31483
|
+
},
|
|
31484
|
+
"anthropic.claude-3-opus-20240229-v1:0": {
|
|
31485
|
+
name: "Claude 3 Opus",
|
|
31486
|
+
region: "us-west-2",
|
|
31487
|
+
// as of 5/10/2024, this is the only region that supports this model
|
|
31488
|
+
type: "language" /* Language */,
|
|
31489
|
+
streaming: true,
|
|
31490
|
+
provider: "Anthropic",
|
|
31491
|
+
description: "",
|
|
31492
|
+
version: "v1.0",
|
|
31493
|
+
inferenceUsage: (inputSize, outputSize) => {
|
|
31494
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 1500 + outputSize / AVERAGE_BYTES_PER_TOKEN * 7500);
|
|
31495
|
+
}
|
|
31496
|
+
},
|
|
31413
31497
|
"cohere.command-text-v14": {
|
|
31414
31498
|
name: "Command",
|
|
31415
31499
|
type: "language" /* Language */,
|
|
@@ -31467,23 +31551,54 @@ var modelInfoMap = {
|
|
|
31467
31551
|
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 75 + outputSize / AVERAGE_BYTES_PER_TOKEN * 100);
|
|
31468
31552
|
}
|
|
31469
31553
|
},
|
|
31470
|
-
"
|
|
31554
|
+
"meta.llama2-70b-chat-v1": {
|
|
31555
|
+
name: "Meta Llama 2 Chat (70B)",
|
|
31556
|
+
type: "language" /* Language */,
|
|
31557
|
+
streaming: true,
|
|
31558
|
+
provider: "Meta",
|
|
31559
|
+
description: "",
|
|
31560
|
+
version: "v1",
|
|
31561
|
+
inferenceUsage: (inputSize, outputSize) => {
|
|
31562
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 195 + outputSize / AVERAGE_BYTES_PER_TOKEN * 256);
|
|
31563
|
+
}
|
|
31564
|
+
},
|
|
31565
|
+
"meta.llama3-8b-instruct-v1:0": {
|
|
31566
|
+
name: "Meta Llama 3 Instruct (8B)",
|
|
31567
|
+
type: "language" /* Language */,
|
|
31568
|
+
streaming: true,
|
|
31569
|
+
provider: "Meta",
|
|
31570
|
+
description: "",
|
|
31571
|
+
version: "v1.x",
|
|
31572
|
+
inferenceUsage: (inputSize, outputSize) => {
|
|
31573
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 40 + outputSize / AVERAGE_BYTES_PER_TOKEN * 60);
|
|
31574
|
+
}
|
|
31575
|
+
},
|
|
31576
|
+
"meta.llama3-70b-instruct-v1:0": {
|
|
31577
|
+
name: "Meta Llama 3 Instruct (70B)",
|
|
31578
|
+
type: "language" /* Language */,
|
|
31579
|
+
streaming: true,
|
|
31580
|
+
provider: "Meta",
|
|
31581
|
+
description: "",
|
|
31582
|
+
version: "v1.x",
|
|
31583
|
+
inferenceUsage: (inputSize, outputSize) => {
|
|
31584
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 265 + outputSize / AVERAGE_BYTES_PER_TOKEN * 350);
|
|
31585
|
+
}
|
|
31586
|
+
},
|
|
31587
|
+
"stability.stable-diffusion-xl-v1": {
|
|
31471
31588
|
name: "Stable Diffusion XL",
|
|
31472
31589
|
type: "image" /* Image */,
|
|
31473
31590
|
streaming: false,
|
|
31474
31591
|
provider: "Stability AI",
|
|
31475
31592
|
description: "Deep learning, text-to-image model used to generate detailed images conditioned on text descriptions, inpainting, outpainting, and generating image-to-image translations.",
|
|
31476
|
-
version: "
|
|
31593
|
+
version: "v1.x",
|
|
31477
31594
|
inferenceUsage: (width, height, steps) => {
|
|
31478
|
-
const large = width * height > 512 * 512;
|
|
31479
31595
|
const highQuality = steps > 50;
|
|
31480
|
-
return Math.round(
|
|
31596
|
+
return Math.round(4e6 * (highQuality ? 2 : 1));
|
|
31481
31597
|
}
|
|
31482
31598
|
},
|
|
31483
31599
|
"mistral.mistral-7b-instruct-v0:2": {
|
|
31484
31600
|
name: "Mistral Instruct (7B)",
|
|
31485
|
-
region:
|
|
31486
|
-
// at time of writing, this is the only region that supports this model
|
|
31601
|
+
// region: 'us-west-2',
|
|
31487
31602
|
type: "language" /* Language */,
|
|
31488
31603
|
streaming: true,
|
|
31489
31604
|
provider: "Mistral",
|
|
@@ -31495,8 +31610,7 @@ var modelInfoMap = {
|
|
|
31495
31610
|
},
|
|
31496
31611
|
"mistral.mixtral-8x7b-instruct-v0:1": {
|
|
31497
31612
|
name: "MixTral Instruct (8x7B)",
|
|
31498
|
-
region:
|
|
31499
|
-
// at time of writing, this is the only region that supports this model
|
|
31613
|
+
// region: 'us-west-2',
|
|
31500
31614
|
type: "language" /* Language */,
|
|
31501
31615
|
streaming: true,
|
|
31502
31616
|
provider: "Mistral",
|
|
@@ -31505,6 +31619,18 @@ var modelInfoMap = {
|
|
|
31505
31619
|
inferenceUsage: (inputSize, outputSize) => {
|
|
31506
31620
|
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 45 + outputSize / AVERAGE_BYTES_PER_TOKEN * 70);
|
|
31507
31621
|
}
|
|
31622
|
+
},
|
|
31623
|
+
"mistral.mistral-large-2402-v1:0": {
|
|
31624
|
+
name: "Mistral Large",
|
|
31625
|
+
// region: 'us-west-2',
|
|
31626
|
+
type: "language" /* Language */,
|
|
31627
|
+
streaming: true,
|
|
31628
|
+
provider: "Mistral",
|
|
31629
|
+
description: "Ideal for text summarization, question and answering, text classification, text completion, and code generation.",
|
|
31630
|
+
version: "v0.1",
|
|
31631
|
+
inferenceUsage: (inputSize, outputSize) => {
|
|
31632
|
+
return Math.round(inputSize / AVERAGE_BYTES_PER_TOKEN * 800 + outputSize / AVERAGE_BYTES_PER_TOKEN * 2400);
|
|
31633
|
+
}
|
|
31508
31634
|
}
|
|
31509
31635
|
};
|
|
31510
31636
|
function getModelInfo(id) {
|
|
@@ -31861,16 +31987,21 @@ var ChatMessage = class {
|
|
|
31861
31987
|
};
|
|
31862
31988
|
var adapters = {
|
|
31863
31989
|
"anthropic.claude-instant-v1": AnthropicClaudeChatAdapter,
|
|
31864
|
-
"anthropic.claude-v1": AnthropicClaudeChatAdapter,
|
|
31865
31990
|
"anthropic.claude-v2": AnthropicClaudeChatAdapter,
|
|
31866
31991
|
"anthropic.claude-3-sonnet-20240229-v1:0": AnthropicClaudeSonnetChatAdapter,
|
|
31992
|
+
"anthropic.claude-3-haiku-20240307-v1:0": AnthropicClaudeSonnetChatAdapter,
|
|
31993
|
+
"anthropic.claude-3-opus-20240229-v1:0": AnthropicClaudeSonnetChatAdapter,
|
|
31867
31994
|
"ai21.j2-mid-v1": Ai21JurassicChatAdapter,
|
|
31868
31995
|
"ai21.j2-ultra-v1": Ai21JurassicChatAdapter,
|
|
31869
31996
|
"cohere.command-text-v14": CohereCommandChatAdapter,
|
|
31870
31997
|
"cohere.command-light-text-v14": CohereCommandChatAdapter,
|
|
31871
31998
|
"meta.llama2-13b-chat-v1": MetaLlamaChatAdapter,
|
|
31999
|
+
"meta.llama2-70b-chat-v1": MetaLlamaChatAdapter,
|
|
32000
|
+
"meta.llama3-8b-instruct-v1:0": MetaLlamaChatAdapter,
|
|
32001
|
+
"meta.llama3-70b-instruct-v1:0": MetaLlamaChatAdapter,
|
|
31872
32002
|
"mistral.mistral-7b-instruct-v0:2": MixtralAIChatAdapter,
|
|
31873
|
-
"mistral.mixtral-8x7b-instruct-v0:1": MixtralAIChatAdapter
|
|
32003
|
+
"mistral.mixtral-8x7b-instruct-v0:1": MixtralAIChatAdapter,
|
|
32004
|
+
"mistral.mistral-large-2402-v1:0": MixtralAIChatAdapter
|
|
31874
32005
|
};
|
|
31875
32006
|
async function chat(messages, options = {}) {
|
|
31876
32007
|
const modelId = options.modelId ?? "anthropic.claude-instant-v1";
|
|
@@ -31886,16 +32017,21 @@ async function chat(messages, options = {}) {
|
|
|
31886
32017
|
chat.models = async () => {
|
|
31887
32018
|
return [
|
|
31888
32019
|
"anthropic.claude-instant-v1",
|
|
31889
|
-
"anthropic.claude-v1",
|
|
31890
32020
|
"anthropic.claude-v2",
|
|
31891
32021
|
"anthropic.claude-3-sonnet-20240229-v1:0",
|
|
32022
|
+
"anthropic.claude-3-haiku-20240307-v1:0",
|
|
32023
|
+
"anthropic.claude-3-opus-20240229-v1:0",
|
|
31892
32024
|
"ai21.j2-mid-v1",
|
|
31893
32025
|
"ai21.j2-ultra-v1",
|
|
31894
32026
|
"cohere.command-text-v14",
|
|
31895
32027
|
"cohere.command-light-text-v14",
|
|
31896
32028
|
"meta.llama2-13b-chat-v1",
|
|
32029
|
+
"meta.llama2-70b-chat-v1",
|
|
32030
|
+
"meta.llama3-8b-instruct-v1:0",
|
|
32031
|
+
"meta.llama3-70b-instruct-v1:0",
|
|
31897
32032
|
"mistral.mistral-7b-instruct-v0:2",
|
|
31898
|
-
"mistral.mixtral-8x7b-instruct-v0:1"
|
|
32033
|
+
"mistral.mixtral-8x7b-instruct-v0:1",
|
|
32034
|
+
"mistral.mistral-large-2402-v1:0"
|
|
31899
32035
|
];
|
|
31900
32036
|
};
|
|
31901
32037
|
|
|
@@ -31929,11 +32065,12 @@ var CohereEmbedAdapter = class {
|
|
|
31929
32065
|
// src/embed/index.ts
|
|
31930
32066
|
var adapters2 = {
|
|
31931
32067
|
"amazon.titan-embed-text-v1": AmazonTitanEmbedTextAdapter,
|
|
32068
|
+
"amazon.titan-embed-text-v2:0": AmazonTitanEmbedTextAdapter,
|
|
31932
32069
|
"cohere.embed-english-v3": CohereEmbedAdapter,
|
|
31933
32070
|
"cohere.embed-multilingual-v3": CohereEmbedAdapter
|
|
31934
32071
|
};
|
|
31935
32072
|
async function embed(input, options = {}) {
|
|
31936
|
-
const modelId = options.modelId ?? "amazon.titan-embed-text-
|
|
32073
|
+
const modelId = options.modelId ?? "amazon.titan-embed-text-v2:0";
|
|
31937
32074
|
const AdapterClass = adapters2[modelId];
|
|
31938
32075
|
if (!AdapterClass) {
|
|
31939
32076
|
throw new Error(`No adapter found for model ${modelId}`);
|
|
@@ -31949,7 +32086,7 @@ embed.models = async () => {
|
|
|
31949
32086
|
|
|
31950
32087
|
// src/render.ts
|
|
31951
32088
|
async function render(prompt, options = {}) {
|
|
31952
|
-
const modelId = options.modelId ?? "stability.stable-diffusion-xl-
|
|
32089
|
+
const modelId = options.modelId ?? "stability.stable-diffusion-xl-v1";
|
|
31953
32090
|
const body = {
|
|
31954
32091
|
text_prompts: [
|
|
31955
32092
|
{
|
|
@@ -31959,8 +32096,8 @@ async function render(prompt, options = {}) {
|
|
|
31959
32096
|
cfg_scale: options.scale ?? 10,
|
|
31960
32097
|
seed: options.seed ?? 20,
|
|
31961
32098
|
steps: options.steps ?? 50,
|
|
31962
|
-
width: options.width ??
|
|
31963
|
-
height: options.height ??
|
|
32099
|
+
width: options.width ?? 1024,
|
|
32100
|
+
height: options.height ?? 1024
|
|
31964
32101
|
};
|
|
31965
32102
|
const response = await invoke2({ body, modelId });
|
|
31966
32103
|
if (!response.body) {
|
|
@@ -31976,7 +32113,7 @@ async function render(prompt, options = {}) {
|
|
|
31976
32113
|
return new Response(responseBody, { headers: { "Content-Type": "image/png" } });
|
|
31977
32114
|
}
|
|
31978
32115
|
render.models = async () => {
|
|
31979
|
-
return ["stability.stable-diffusion-xl-
|
|
32116
|
+
return ["stability.stable-diffusion-xl-v1"];
|
|
31980
32117
|
};
|
|
31981
32118
|
|
|
31982
32119
|
// src/summarize/adapters/anthropic.claude.sonnet.ts
|
|
@@ -32082,7 +32219,7 @@ var MixtralAISummarizeAdapter = class {
|
|
|
32082
32219
|
// src/summarize/index.ts
|
|
32083
32220
|
var adapters3 = {
|
|
32084
32221
|
"anthropic.claude-instant-v1": AnthropicClaudeSummarizeAdapter,
|
|
32085
|
-
|
|
32222
|
+
// 'anthropic.claude-v1': AnthropicClaudeSummarizeAdapter,
|
|
32086
32223
|
"anthropic.claude-v2": AnthropicClaudeSummarizeAdapter,
|
|
32087
32224
|
"anthropic.claude-3-sonnet-20240229-v1:0": AnthropicClaudeSonnetSummarizeAdapter,
|
|
32088
32225
|
"mistral.mistral-7b-instruct-v0:2": MixtralAISummarizeAdapter,
|
|
@@ -32102,7 +32239,7 @@ async function summarize(input, options = {}) {
|
|
|
32102
32239
|
summarize.models = async () => {
|
|
32103
32240
|
return [
|
|
32104
32241
|
"anthropic.claude-instant-v1",
|
|
32105
|
-
|
|
32242
|
+
// 'anthropic.claude-v1',
|
|
32106
32243
|
"anthropic.claude-v2",
|
|
32107
32244
|
"anthropic.claude-3-sonnet-20240229-v1:0",
|
|
32108
32245
|
"mistral.mistral-7b-instruct-v0:2",
|
|
@@ -42364,7 +42501,7 @@ async function translate(input, options) {
|
|
|
42364
42501
|
// src/index.ts
|
|
42365
42502
|
if (process.env.AMPT_RUNTIME_NAME === "nodejs18-beta") {
|
|
42366
42503
|
console.error(
|
|
42367
|
-
'@ampt/ai requires the nodejs18 runtime. Please add "runtime": "
|
|
42504
|
+
'@ampt/ai requires the nodejs18 runtime or higher. Please add "runtime": "nodejs20" to the "ampt" section of your package.json.'
|
|
42368
42505
|
);
|
|
42369
42506
|
}
|
|
42370
42507
|
export {
|