@ampt/ai 2.0.1 → 2.0.4
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 +29921 -17318
- package/dist/index.d.ts +102 -7
- package/dist/index.js +34871 -22276
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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';
|
|
4
|
+
declare function models(): Promise<string[]>;
|
|
3
5
|
declare enum ModelType {
|
|
6
|
+
Embeddings = "embeddings",
|
|
4
7
|
Language = "language",
|
|
5
8
|
Image = "image"
|
|
6
9
|
}
|
|
10
|
+
type EmbeddingsInferenceCostFunction = (body: Uint8Array) => number;
|
|
7
11
|
type LanguageInferenceCostFunction = (inputSize: number, outputSize: number) => number;
|
|
8
12
|
type ImageInferenceCostFunction = (width: number, height: number, steps: number) => number;
|
|
9
|
-
type InferenceCostFunction = LanguageInferenceCostFunction | ImageInferenceCostFunction;
|
|
13
|
+
type InferenceCostFunction = EmbeddingsInferenceCostFunction | LanguageInferenceCostFunction | ImageInferenceCostFunction;
|
|
10
14
|
interface ModelInfo {
|
|
11
15
|
name: string;
|
|
12
16
|
type: ModelType;
|
|
@@ -24,7 +28,68 @@ interface ImageModelInfo extends ModelInfo {
|
|
|
24
28
|
type: ModelType.Image;
|
|
25
29
|
inferenceUsage: ImageInferenceCostFunction;
|
|
26
30
|
}
|
|
27
|
-
|
|
31
|
+
interface EmbeddingsModelInfo extends ModelInfo {
|
|
32
|
+
type: ModelType.Embeddings;
|
|
33
|
+
inferenceUsage: EmbeddingsInferenceCostFunction;
|
|
34
|
+
}
|
|
35
|
+
type ModelInfoMap = {
|
|
36
|
+
[id in ModelId]: EmbeddingsModelInfo | LanguageModelInfo | ImageModelInfo;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Model pricing info:
|
|
40
|
+
*
|
|
41
|
+
* Note: we track usage in micro-cents/uc (1,000,000ths of a cent, or 100,000,000ths of a dollar) because
|
|
42
|
+
* the quota system only works with integers.
|
|
43
|
+
*
|
|
44
|
+
* AI21 Jurassic-2 Mid:
|
|
45
|
+
* - $0.0125 per 1000 input tokens: 1250 uc per token
|
|
46
|
+
* - $0.0125 per 1000 output tokens: 1250 uc per token
|
|
47
|
+
*
|
|
48
|
+
* AI21 Jurassic-2 Ultra:
|
|
49
|
+
* - $0.0188 per 1000 input tokens: 1880 uc per token
|
|
50
|
+
* - $0.0188 per 1000 output tokens: 1880 uc per token
|
|
51
|
+
*
|
|
52
|
+
* Claude Instant:
|
|
53
|
+
* - $0.00163 per 1000 input tokens: 163 uc per token
|
|
54
|
+
* - $0.00551 per 1000 output tokens: 551 uc per token
|
|
55
|
+
*
|
|
56
|
+
* Claude:
|
|
57
|
+
* - $0.01102 per 1000 input tokens: 1102 uc per token
|
|
58
|
+
* - $0.03268 per 1000 output tokens: 3268 uc per token
|
|
59
|
+
*
|
|
60
|
+
* Cohere Command:
|
|
61
|
+
* - $0.0015 per 1000 input tokens: 150 uc per token
|
|
62
|
+
* - $0.0020 per 1000 output tokens: 200 uc per token
|
|
63
|
+
*
|
|
64
|
+
* Cohere Command Light:
|
|
65
|
+
* - $0.0003 per 1000 input tokens: 30 uc per token
|
|
66
|
+
* - $0.0006 per 1000 output tokens: 60 uc per token
|
|
67
|
+
*
|
|
68
|
+
* Cohere Embed - English:
|
|
69
|
+
* - $0.0001 for 1000 input tokens: 10 uc per token
|
|
70
|
+
*
|
|
71
|
+
* Cohere Embed - Multilingual:
|
|
72
|
+
* - $0.0001 for 1000 input tokens: 10 uc per token
|
|
73
|
+
*
|
|
74
|
+
* Meta Llama 2 Chat (13B):
|
|
75
|
+
* - $0.00075 per 1000 input tokens: 75 uc per token
|
|
76
|
+
* - $0.001 per 1000 output tokens: 100 uc per token
|
|
77
|
+
*
|
|
78
|
+
* Stable Diffusion XL:
|
|
79
|
+
*
|
|
80
|
+
* small format (512x512 or smaller):
|
|
81
|
+
* - standard quality: 1800000 per image
|
|
82
|
+
* - high quality: 3600000 per image
|
|
83
|
+
*
|
|
84
|
+
* large format (larger than 512x512):
|
|
85
|
+
* - standard quality: 3600000 per image (2x more expensive than small format)
|
|
86
|
+
* - high quality: 7200000 per image (2x more expensive than small format)
|
|
87
|
+
*
|
|
88
|
+
* Amazon Titan Embeddings:
|
|
89
|
+
* - $0.0001 for 1000 input tokens: 10 uc per token
|
|
90
|
+
*/
|
|
91
|
+
declare const modelInfoMap: ModelInfoMap;
|
|
92
|
+
declare function getModelInfo(id: ModelId): Promise<EmbeddingsModelInfo | LanguageModelInfo | ImageModelInfo>;
|
|
28
93
|
|
|
29
94
|
interface InvokeOptions {
|
|
30
95
|
modelId: ModelId;
|
|
@@ -40,6 +105,9 @@ interface InvokeOptions {
|
|
|
40
105
|
declare function invoke(options: InvokeOptions): Promise<Response>;
|
|
41
106
|
|
|
42
107
|
type MessageRole = 'assistant' | 'human';
|
|
108
|
+
interface ResponseWithBody extends Response {
|
|
109
|
+
body: ReadableStream<any>;
|
|
110
|
+
}
|
|
43
111
|
/**
|
|
44
112
|
* A message to send to the model
|
|
45
113
|
* @param role The role of the message (assistant or human)
|
|
@@ -53,11 +121,11 @@ declare class ChatMessage {
|
|
|
53
121
|
content: string;
|
|
54
122
|
});
|
|
55
123
|
}
|
|
56
|
-
declare function buildPrompt(messages: ChatMessage[]): string;
|
|
57
124
|
interface ChatOptions {
|
|
58
|
-
modelId?:
|
|
125
|
+
modelId?: ChatModelId;
|
|
59
126
|
maxTokens?: number;
|
|
60
127
|
}
|
|
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';
|
|
61
129
|
/**
|
|
62
130
|
* Send messages to the model and return the completion
|
|
63
131
|
* @param messages Array of messages to send to the model
|
|
@@ -68,6 +136,16 @@ declare namespace chat {
|
|
|
68
136
|
var models: () => Promise<ModelId[]>;
|
|
69
137
|
}
|
|
70
138
|
|
|
139
|
+
type EmbedModelId = 'amazon.titan-embed-text-v1' | 'cohere.embed-english-v3' | 'cohere.embed-multilingual-v3';
|
|
140
|
+
type Embedding = number[];
|
|
141
|
+
interface EmbedOptions {
|
|
142
|
+
modelId?: EmbedModelId;
|
|
143
|
+
}
|
|
144
|
+
declare function embed(input: string, options?: EmbedOptions): Promise<Embedding>;
|
|
145
|
+
declare namespace embed {
|
|
146
|
+
var models: () => Promise<string[]>;
|
|
147
|
+
}
|
|
148
|
+
|
|
71
149
|
interface RenderOptions {
|
|
72
150
|
width?: number;
|
|
73
151
|
height?: number;
|
|
@@ -81,4 +159,21 @@ declare namespace render {
|
|
|
81
159
|
var models: () => Promise<string[]>;
|
|
82
160
|
}
|
|
83
161
|
|
|
84
|
-
|
|
162
|
+
interface SummarizeOptions {
|
|
163
|
+
modelId?: SummarizeModelId;
|
|
164
|
+
maxTokens?: number;
|
|
165
|
+
}
|
|
166
|
+
type SummarizeModelId = 'anthropic.claude-instant-v1' | 'anthropic.claude-v1' | 'anthropic.claude-v2';
|
|
167
|
+
declare function summarize(input: string, options?: SummarizeOptions): Promise<Response>;
|
|
168
|
+
declare namespace summarize {
|
|
169
|
+
var models: () => Promise<ModelId[]>;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
interface TranslateOptions {
|
|
173
|
+
sourceLanguage: string;
|
|
174
|
+
targetLanguage: string;
|
|
175
|
+
}
|
|
176
|
+
declare const client: Translate;
|
|
177
|
+
declare function translate(input: string, options: TranslateOptions): Promise<Response>;
|
|
178
|
+
|
|
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 };
|