@ampt/ai 2.0.5 → 2.0.6
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/{chunk-JPKYSWKV.js → chunk-WCFFSOP5.js} +77 -72
- package/dist/{dist-es-7I2R4JEH.js → dist-es-OBV65GYS.js} +25 -25
- package/dist/index.cjs +1191 -596
- package/dist/index.d.cts +188 -0
- package/dist/index.d.ts +14 -5
- package/dist/index.js +569 -414
- package/package.json +1 -1
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { Translate } from '@aws-sdk/client-translate';
|
|
2
|
+
|
|
3
|
+
type ModelId = 'ai21.j2-mid-v1' | 'ai21.j2-ultra-v1' | 'anthropic.claude-v2' | 'anthropic.claude-instant-v1' | 'anthropic.claude-v1' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'cohere.embed-english-v3' | 'cohere.embed-multilingual-v3' | 'stability.stable-diffusion-xl-v0' | 'amazon.titan-embed-text-v1' | 'meta.llama2-13b-chat-v1' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1';
|
|
4
|
+
declare function models(): Promise<string[]>;
|
|
5
|
+
declare enum ModelType {
|
|
6
|
+
Embeddings = "embeddings",
|
|
7
|
+
Language = "language",
|
|
8
|
+
Image = "image"
|
|
9
|
+
}
|
|
10
|
+
type EmbeddingsInferenceCostFunction = (body: Uint8Array) => number;
|
|
11
|
+
type LanguageInferenceCostFunction = (inputSize: number, outputSize: number) => number;
|
|
12
|
+
type ImageInferenceCostFunction = (width: number, height: number, steps: number) => number;
|
|
13
|
+
type InferenceCostFunction = EmbeddingsInferenceCostFunction | LanguageInferenceCostFunction | ImageInferenceCostFunction;
|
|
14
|
+
interface ModelInfo {
|
|
15
|
+
name: string;
|
|
16
|
+
type: ModelType;
|
|
17
|
+
streaming: boolean;
|
|
18
|
+
provider: string;
|
|
19
|
+
description: string;
|
|
20
|
+
version: string;
|
|
21
|
+
region?: string;
|
|
22
|
+
inferenceUsage: InferenceCostFunction;
|
|
23
|
+
}
|
|
24
|
+
interface LanguageModelInfo extends ModelInfo {
|
|
25
|
+
type: ModelType.Language;
|
|
26
|
+
inferenceUsage: LanguageInferenceCostFunction;
|
|
27
|
+
}
|
|
28
|
+
interface ImageModelInfo extends ModelInfo {
|
|
29
|
+
type: ModelType.Image;
|
|
30
|
+
inferenceUsage: ImageInferenceCostFunction;
|
|
31
|
+
}
|
|
32
|
+
interface EmbeddingsModelInfo extends ModelInfo {
|
|
33
|
+
type: ModelType.Embeddings;
|
|
34
|
+
inferenceUsage: EmbeddingsInferenceCostFunction;
|
|
35
|
+
}
|
|
36
|
+
type ModelInfoMap = {
|
|
37
|
+
[id in ModelId]: EmbeddingsModelInfo | LanguageModelInfo | ImageModelInfo;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Model pricing info:
|
|
41
|
+
*
|
|
42
|
+
* Note: we track usage in micro-cents/uc (1,000,000ths of a cent, or 100,000,000ths of a dollar) because
|
|
43
|
+
* the quota system only works with integers.
|
|
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
|
+
* Cohere Command:
|
|
62
|
+
* - $0.0015 per 1000 input tokens: 150 uc per token
|
|
63
|
+
* - $0.0020 per 1000 output tokens: 200 uc per token
|
|
64
|
+
*
|
|
65
|
+
* Cohere Command Light:
|
|
66
|
+
* - $0.0003 per 1000 input tokens: 30 uc per token
|
|
67
|
+
* - $0.0006 per 1000 output tokens: 60 uc per token
|
|
68
|
+
*
|
|
69
|
+
* Cohere Embed - English:
|
|
70
|
+
* - $0.0001 for 1000 input tokens: 10 uc per token
|
|
71
|
+
*
|
|
72
|
+
* Cohere Embed - Multilingual:
|
|
73
|
+
* - $0.0001 for 1000 input tokens: 10 uc per token
|
|
74
|
+
*
|
|
75
|
+
* Meta Llama 2 Chat (13B):
|
|
76
|
+
* - $0.00075 per 1000 input tokens: 75 uc per token
|
|
77
|
+
* - $0.001 per 1000 output tokens: 100 uc per token
|
|
78
|
+
*
|
|
79
|
+
* Mistral 7B:
|
|
80
|
+
* - $.00015 per 1000 input tokens: 15 uc per token
|
|
81
|
+
* - $.0002 per 1000 output tokens: 20 uc per token
|
|
82
|
+
*
|
|
83
|
+
* MixTral 8x7B:
|
|
84
|
+
* - $0.00045 per 1000 input tokens: 45 uc per token
|
|
85
|
+
* - $0.0007 per 1000 output tokens: 70 uc per token
|
|
86
|
+
*
|
|
87
|
+
* Stable Diffusion XL:
|
|
88
|
+
*
|
|
89
|
+
* small format (512x512 or smaller):
|
|
90
|
+
* - standard quality: 1800000 per image
|
|
91
|
+
* - high quality: 3600000 per image
|
|
92
|
+
*
|
|
93
|
+
* large format (larger than 512x512):
|
|
94
|
+
* - standard quality: 3600000 per image (2x more expensive than small format)
|
|
95
|
+
* - high quality: 7200000 per image (2x more expensive than small format)
|
|
96
|
+
*
|
|
97
|
+
* Amazon Titan Embeddings:
|
|
98
|
+
* - $0.0001 for 1000 input tokens: 10 uc per token
|
|
99
|
+
*/
|
|
100
|
+
declare const modelInfoMap: ModelInfoMap;
|
|
101
|
+
declare function getModelInfo(id: ModelId): EmbeddingsModelInfo | LanguageModelInfo | ImageModelInfo;
|
|
102
|
+
|
|
103
|
+
interface InvokeOptions {
|
|
104
|
+
modelId: ModelId;
|
|
105
|
+
body: any;
|
|
106
|
+
contentType?: string;
|
|
107
|
+
accept?: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Invoke model and return events as a ReadableStream.
|
|
111
|
+
* @param options
|
|
112
|
+
* @returns
|
|
113
|
+
*/
|
|
114
|
+
declare function invoke(options: InvokeOptions): Promise<Response>;
|
|
115
|
+
|
|
116
|
+
type MessageRole = 'assistant' | 'human';
|
|
117
|
+
interface ResponseWithBody extends Response {
|
|
118
|
+
body: ReadableStream<any>;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* A message to send to the model
|
|
122
|
+
* @param role The role of the message (assistant or human)
|
|
123
|
+
* @param content The content of the message
|
|
124
|
+
*/
|
|
125
|
+
declare class ChatMessage {
|
|
126
|
+
role: MessageRole;
|
|
127
|
+
content: string;
|
|
128
|
+
constructor({ content, role }: {
|
|
129
|
+
role: MessageRole;
|
|
130
|
+
content: string;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
interface ChatOptions {
|
|
134
|
+
modelId?: ChatModelId;
|
|
135
|
+
maxTokens?: number;
|
|
136
|
+
}
|
|
137
|
+
type ChatModelId = 'anthropic.claude-instant-v1' | 'anthropic.claude-v1' | 'anthropic.claude-v2' | 'ai21.j2-mid-v1' | 'ai21.j2-ultra-v1' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'meta.llama2-13b-chat-v1' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1';
|
|
138
|
+
/**
|
|
139
|
+
* Send messages to the model and return the completion
|
|
140
|
+
* @param messages Array of messages to send to the model
|
|
141
|
+
* @returns Chat completion as a ReadableStream
|
|
142
|
+
*/
|
|
143
|
+
declare function chat(messages: ChatMessage[], options?: ChatOptions): Promise<Response>;
|
|
144
|
+
declare namespace chat {
|
|
145
|
+
var models: () => Promise<ModelId[]>;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
type EmbedModelId = 'amazon.titan-embed-text-v1' | 'cohere.embed-english-v3' | 'cohere.embed-multilingual-v3';
|
|
149
|
+
type Embedding = number[];
|
|
150
|
+
interface EmbedOptions {
|
|
151
|
+
modelId?: EmbedModelId;
|
|
152
|
+
}
|
|
153
|
+
declare function embed(input: string, options?: EmbedOptions): Promise<Embedding>;
|
|
154
|
+
declare namespace embed {
|
|
155
|
+
var models: () => Promise<string[]>;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
interface RenderOptions {
|
|
159
|
+
width?: number;
|
|
160
|
+
height?: number;
|
|
161
|
+
modelId?: ModelId;
|
|
162
|
+
steps?: number;
|
|
163
|
+
seed?: number;
|
|
164
|
+
scale?: number;
|
|
165
|
+
}
|
|
166
|
+
declare function render(prompt: string, options?: RenderOptions): Promise<Response>;
|
|
167
|
+
declare namespace render {
|
|
168
|
+
var models: () => Promise<string[]>;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
interface SummarizeOptions {
|
|
172
|
+
modelId?: SummarizeModelId;
|
|
173
|
+
maxTokens?: number;
|
|
174
|
+
}
|
|
175
|
+
type SummarizeModelId = 'anthropic.claude-instant-v1' | 'anthropic.claude-v1' | 'anthropic.claude-v2' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1';
|
|
176
|
+
declare function summarize(input: string, options?: SummarizeOptions): Promise<Response>;
|
|
177
|
+
declare namespace summarize {
|
|
178
|
+
var models: () => Promise<ModelId[]>;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
interface TranslateOptions {
|
|
182
|
+
sourceLanguage: string;
|
|
183
|
+
targetLanguage: string;
|
|
184
|
+
}
|
|
185
|
+
declare const client: Translate;
|
|
186
|
+
declare function translate(input: string, options: TranslateOptions): Promise<Response>;
|
|
187
|
+
|
|
188
|
+
export { ChatMessage, type ChatModelId, type ChatOptions, type EmbedModelId, type EmbedOptions, type Embedding, type EmbeddingsModelInfo, type ImageModelInfo, type InvokeOptions, type LanguageModelInfo, type MessageRole, type ModelId, type ModelInfo, ModelType, type RenderOptions, type ResponseWithBody, type SummarizeModelId, type SummarizeOptions, type TranslateOptions, chat, client, embed, getModelInfo, invoke, modelInfoMap, models, render, summarize, translate };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Translate } from '@aws-sdk/client-translate';
|
|
2
2
|
|
|
3
|
-
type ModelId = 'ai21.j2-mid-v1' | 'ai21.j2-ultra-v1' | 'anthropic.claude-v2' | 'anthropic.claude-instant-v1' | 'anthropic.claude-v1' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'cohere.embed-english-v3' | 'cohere.embed-multilingual-v3' | 'stability.stable-diffusion-xl-v0' | 'amazon.titan-embed-text-v1' | 'meta.llama2-13b-chat-v1';
|
|
3
|
+
type ModelId = 'ai21.j2-mid-v1' | 'ai21.j2-ultra-v1' | 'anthropic.claude-v2' | 'anthropic.claude-instant-v1' | 'anthropic.claude-v1' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'cohere.embed-english-v3' | 'cohere.embed-multilingual-v3' | 'stability.stable-diffusion-xl-v0' | 'amazon.titan-embed-text-v1' | 'meta.llama2-13b-chat-v1' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1';
|
|
4
4
|
declare function models(): Promise<string[]>;
|
|
5
5
|
declare enum ModelType {
|
|
6
6
|
Embeddings = "embeddings",
|
|
@@ -18,6 +18,7 @@ interface ModelInfo {
|
|
|
18
18
|
provider: string;
|
|
19
19
|
description: string;
|
|
20
20
|
version: string;
|
|
21
|
+
region?: string;
|
|
21
22
|
inferenceUsage: InferenceCostFunction;
|
|
22
23
|
}
|
|
23
24
|
interface LanguageModelInfo extends ModelInfo {
|
|
@@ -75,6 +76,14 @@ type ModelInfoMap = {
|
|
|
75
76
|
* - $0.00075 per 1000 input tokens: 75 uc per token
|
|
76
77
|
* - $0.001 per 1000 output tokens: 100 uc per token
|
|
77
78
|
*
|
|
79
|
+
* Mistral 7B:
|
|
80
|
+
* - $.00015 per 1000 input tokens: 15 uc per token
|
|
81
|
+
* - $.0002 per 1000 output tokens: 20 uc per token
|
|
82
|
+
*
|
|
83
|
+
* MixTral 8x7B:
|
|
84
|
+
* - $0.00045 per 1000 input tokens: 45 uc per token
|
|
85
|
+
* - $0.0007 per 1000 output tokens: 70 uc per token
|
|
86
|
+
*
|
|
78
87
|
* Stable Diffusion XL:
|
|
79
88
|
*
|
|
80
89
|
* small format (512x512 or smaller):
|
|
@@ -89,7 +98,7 @@ type ModelInfoMap = {
|
|
|
89
98
|
* - $0.0001 for 1000 input tokens: 10 uc per token
|
|
90
99
|
*/
|
|
91
100
|
declare const modelInfoMap: ModelInfoMap;
|
|
92
|
-
declare function getModelInfo(id: ModelId):
|
|
101
|
+
declare function getModelInfo(id: ModelId): EmbeddingsModelInfo | LanguageModelInfo | ImageModelInfo;
|
|
93
102
|
|
|
94
103
|
interface InvokeOptions {
|
|
95
104
|
modelId: ModelId;
|
|
@@ -125,7 +134,7 @@ interface ChatOptions {
|
|
|
125
134
|
modelId?: ChatModelId;
|
|
126
135
|
maxTokens?: number;
|
|
127
136
|
}
|
|
128
|
-
type ChatModelId = 'anthropic.claude-instant-v1' | 'anthropic.claude-v1' | 'anthropic.claude-v2' | 'ai21.j2-mid-v1' | 'ai21.j2-ultra-v1' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'meta.llama2-13b-chat-v1';
|
|
137
|
+
type ChatModelId = 'anthropic.claude-instant-v1' | 'anthropic.claude-v1' | 'anthropic.claude-v2' | 'ai21.j2-mid-v1' | 'ai21.j2-ultra-v1' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'meta.llama2-13b-chat-v1' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1';
|
|
129
138
|
/**
|
|
130
139
|
* Send messages to the model and return the completion
|
|
131
140
|
* @param messages Array of messages to send to the model
|
|
@@ -163,7 +172,7 @@ interface SummarizeOptions {
|
|
|
163
172
|
modelId?: SummarizeModelId;
|
|
164
173
|
maxTokens?: number;
|
|
165
174
|
}
|
|
166
|
-
type SummarizeModelId = 'anthropic.claude-instant-v1' | 'anthropic.claude-v1' | 'anthropic.claude-v2';
|
|
175
|
+
type SummarizeModelId = 'anthropic.claude-instant-v1' | 'anthropic.claude-v1' | 'anthropic.claude-v2' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1';
|
|
167
176
|
declare function summarize(input: string, options?: SummarizeOptions): Promise<Response>;
|
|
168
177
|
declare namespace summarize {
|
|
169
178
|
var models: () => Promise<ModelId[]>;
|
|
@@ -176,4 +185,4 @@ interface TranslateOptions {
|
|
|
176
185
|
declare const client: Translate;
|
|
177
186
|
declare function translate(input: string, options: TranslateOptions): Promise<Response>;
|
|
178
187
|
|
|
179
|
-
export { ChatMessage, ChatModelId, ChatOptions, EmbedModelId, EmbedOptions, Embedding, EmbeddingsModelInfo, ImageModelInfo, InvokeOptions, LanguageModelInfo, MessageRole, ModelId, ModelInfo, ModelType, RenderOptions, ResponseWithBody, SummarizeModelId, SummarizeOptions, TranslateOptions, chat, client, embed, getModelInfo, invoke, modelInfoMap, models, render, summarize, translate };
|
|
188
|
+
export { ChatMessage, type ChatModelId, type ChatOptions, type EmbedModelId, type EmbedOptions, type Embedding, type EmbeddingsModelInfo, type ImageModelInfo, type InvokeOptions, type LanguageModelInfo, type MessageRole, type ModelId, type ModelInfo, ModelType, type RenderOptions, type ResponseWithBody, type SummarizeModelId, type SummarizeOptions, type TranslateOptions, chat, client, embed, getModelInfo, invoke, modelInfoMap, models, render, summarize, translate };
|