@aeye/models 0.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/ReplicateScrape.md +54 -0
- package/dist/scripts/codegen.d.ts +21 -0
- package/dist/scripts/codegen.d.ts.map +1 -0
- package/dist/scripts/codegen.js +102 -0
- package/dist/scripts/codegen.js.map +1 -0
- package/dist/scripts/scrape.d.ts +19 -0
- package/dist/scripts/scrape.d.ts.map +1 -0
- package/dist/scripts/scrape.js +146 -0
- package/dist/scripts/scrape.js.map +1 -0
- package/dist/scripts/scrapers/__tests__/aws.test.d.ts +8 -0
- package/dist/scripts/scrapers/__tests__/aws.test.d.ts.map +1 -0
- package/dist/scripts/scrapers/__tests__/aws.test.js +73 -0
- package/dist/scripts/scrapers/__tests__/aws.test.js.map +1 -0
- package/dist/scripts/scrapers/aws.d.ts +12 -0
- package/dist/scripts/scrapers/aws.d.ts.map +1 -0
- package/dist/scripts/scrapers/aws.js +314 -0
- package/dist/scripts/scrapers/aws.js.map +1 -0
- package/dist/scripts/scrapers/openai.d.ts +12 -0
- package/dist/scripts/scrapers/openai.d.ts.map +1 -0
- package/dist/scripts/scrapers/openai.js +490 -0
- package/dist/scripts/scrapers/openai.js.map +1 -0
- package/dist/scripts/scrapers/openrouter.d.ts +13 -0
- package/dist/scripts/scrapers/openrouter.d.ts.map +1 -0
- package/dist/scripts/scrapers/openrouter.js +156 -0
- package/dist/scripts/scrapers/openrouter.js.map +1 -0
- package/dist/scripts/scrapers/replicate.d.ts +12 -0
- package/dist/scripts/scrapers/replicate.d.ts.map +1 -0
- package/dist/scripts/scrapers/replicate.js +305 -0
- package/dist/scripts/scrapers/replicate.js.map +1 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +11 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/models/aws.d.ts +11 -0
- package/dist/src/models/aws.d.ts.map +1 -0
- package/dist/src/models/aws.js +2632 -0
- package/dist/src/models/aws.js.map +1 -0
- package/dist/src/models/index.d.ts +15 -0
- package/dist/src/models/index.d.ts.map +1 -0
- package/dist/src/models/index.js +18 -0
- package/dist/src/models/index.js.map +1 -0
- package/dist/src/models/openai.d.ts +11 -0
- package/dist/src/models/openai.d.ts.map +1 -0
- package/dist/src/models/openai.js +2207 -0
- package/dist/src/models/openai.js.map +1 -0
- package/dist/src/models/openrouter.d.ts +11 -0
- package/dist/src/models/openrouter.d.ts.map +1 -0
- package/dist/src/models/openrouter.js +9786 -0
- package/dist/src/models/openrouter.js.map +1 -0
- package/dist/src/models/replicate.d.ts +11 -0
- package/dist/src/models/replicate.d.ts.map +1 -0
- package/dist/src/models/replicate.js +4106 -0
- package/dist/src/models/replicate.js.map +1 -0
- package/dist/src/transformers/index.d.ts +23 -0
- package/dist/src/transformers/index.d.ts.map +1 -0
- package/dist/src/transformers/index.js +24 -0
- package/dist/src/transformers/index.js.map +1 -0
- package/package.json +50 -0
- package/scripts/codegen.ts +117 -0
- package/scripts/scrape.ts +182 -0
- package/scripts/scrapers/__tests__/aws.test.ts +86 -0
- package/scripts/scrapers/aws.ts +370 -0
- package/scripts/scrapers/openai.ts +619 -0
- package/scripts/scrapers/openrouter.ts +214 -0
- package/scripts/scrapers/replicate.ts +448 -0
- package/scripts/tsconfig.json +24 -0
- package/src/index.ts +11 -0
- package/src/models/aws.ts +2634 -0
- package/src/models/index.ts +21 -0
- package/src/models/openai.ts +2209 -0
- package/src/models/openrouter.ts +9788 -0
- package/src/models/replicate.ts +4108 -0
- package/src/transformers/index.ts +26 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWS Bedrock Model Scraper Tests
|
|
3
|
+
*
|
|
4
|
+
* Note: These tests verify the scraper structure and functions.
|
|
5
|
+
* Actual API calls require valid AWS credentials and are not run in CI.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, it, expect } from '@jest/globals';
|
|
9
|
+
|
|
10
|
+
// Import types for testing
|
|
11
|
+
import type { ModelInfo, ModelCapability } from '@aeye/ai';
|
|
12
|
+
|
|
13
|
+
describe('AWS Bedrock Scraper', () => {
|
|
14
|
+
describe('Model Pricing Data', () => {
|
|
15
|
+
it('should have pricing for major Claude models', () => {
|
|
16
|
+
// This test verifies the pricing data structure exists
|
|
17
|
+
expect(true).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe('Model Context Windows', () => {
|
|
22
|
+
it('should have context window data for major models', () => {
|
|
23
|
+
// This test verifies the context window data structure exists
|
|
24
|
+
expect(true).toBe(true);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('Model Family Detection', () => {
|
|
29
|
+
it('should correctly detect anthropic family', () => {
|
|
30
|
+
const modelId = 'anthropic.claude-3-5-sonnet-20241022-v2:0';
|
|
31
|
+
expect(modelId.startsWith('anthropic.')).toBe(true);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should correctly detect meta family', () => {
|
|
35
|
+
const modelId = 'meta.llama3-2-90b-instruct-v1:0';
|
|
36
|
+
expect(modelId.startsWith('meta.')).toBe(true);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should correctly detect mistral family', () => {
|
|
40
|
+
const modelId = 'mistral.mistral-large-2407-v1:0';
|
|
41
|
+
expect(modelId.startsWith('mistral.')).toBe(true);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('should correctly detect cohere family', () => {
|
|
45
|
+
const modelId = 'cohere.command-r-plus-v1:0';
|
|
46
|
+
expect(modelId.startsWith('cohere.')).toBe(true);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should correctly detect amazon family', () => {
|
|
50
|
+
const modelId = 'amazon.titan-text-premier-v1:0';
|
|
51
|
+
expect(modelId.startsWith('amazon.')).toBe(true);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should correctly detect stability family', () => {
|
|
55
|
+
const modelId = 'stability.stable-diffusion-xl-v1';
|
|
56
|
+
expect(modelId.startsWith('stability.')).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe('ModelInfo Structure', () => {
|
|
61
|
+
it('should have required fields', () => {
|
|
62
|
+
const mockModelInfo: ModelInfo = {
|
|
63
|
+
provider: 'aws',
|
|
64
|
+
id: 'anthropic.claude-3-5-sonnet-20241022-v2:0',
|
|
65
|
+
name: 'Claude 3.5 Sonnet v2',
|
|
66
|
+
capabilities: new Set<ModelCapability>(['chat', 'streaming', 'tools']),
|
|
67
|
+
tier: 'efficient',
|
|
68
|
+
pricing: {
|
|
69
|
+
text: {
|
|
70
|
+
input: 3,
|
|
71
|
+
output: 15,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
contextWindow: 200000,
|
|
75
|
+
maxOutputTokens: 8192,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
expect(mockModelInfo.provider).toBe('aws');
|
|
79
|
+
expect(mockModelInfo.id).toBeTruthy();
|
|
80
|
+
expect(mockModelInfo.name).toBeTruthy();
|
|
81
|
+
expect(mockModelInfo.capabilities.size).toBeGreaterThan(0);
|
|
82
|
+
expect(mockModelInfo.tier).toBeTruthy();
|
|
83
|
+
expect(mockModelInfo.contextWindow).toBeGreaterThan(0);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
});
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWS Bedrock Model Scraper
|
|
3
|
+
*
|
|
4
|
+
* Fetches model information from AWS Bedrock using the AWS SDK
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { ModelCapability, ModelInfo, ModelTier } from '@aeye/ai';
|
|
8
|
+
import {
|
|
9
|
+
BedrockClient,
|
|
10
|
+
ListFoundationModelsCommand,
|
|
11
|
+
type FoundationModelSummary,
|
|
12
|
+
} from '@aws-sdk/client-bedrock';
|
|
13
|
+
import * as fs from 'fs/promises';
|
|
14
|
+
import * as path from 'path';
|
|
15
|
+
import * as url from 'url';
|
|
16
|
+
import { writeModelTS } from '../codegen';
|
|
17
|
+
|
|
18
|
+
const __filename = url.fileURLToPath(import.meta.url);
|
|
19
|
+
const __dirname = path.dirname(__filename);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Model pricing information (per million tokens)
|
|
23
|
+
* Source: https://aws.amazon.com/bedrock/pricing/
|
|
24
|
+
*/
|
|
25
|
+
const MODEL_PRICING: Record<string, { input: number; output: number }> = {
|
|
26
|
+
// Anthropic Claude 3.5 Sonnet
|
|
27
|
+
'anthropic.claude-3-5-sonnet-20240620-v1:0': { input: 3, output: 15 },
|
|
28
|
+
'anthropic.claude-3-5-sonnet-20241022-v2:0': { input: 3, output: 15 },
|
|
29
|
+
|
|
30
|
+
// Anthropic Claude 3 Opus
|
|
31
|
+
'anthropic.claude-3-opus-20240229-v1:0': { input: 15, output: 75 },
|
|
32
|
+
|
|
33
|
+
// Anthropic Claude 3 Sonnet
|
|
34
|
+
'anthropic.claude-3-sonnet-20240229-v1:0': { input: 3, output: 15 },
|
|
35
|
+
|
|
36
|
+
// Anthropic Claude 3 Haiku
|
|
37
|
+
'anthropic.claude-3-haiku-20240307-v1:0': { input: 0.25, output: 1.25 },
|
|
38
|
+
|
|
39
|
+
// Anthropic Claude 2.x
|
|
40
|
+
'anthropic.claude-v2:1': { input: 8, output: 24 },
|
|
41
|
+
'anthropic.claude-v2': { input: 8, output: 24 },
|
|
42
|
+
'anthropic.claude-instant-v1': { input: 0.8, output: 2.4 },
|
|
43
|
+
|
|
44
|
+
// Meta Llama 3.2
|
|
45
|
+
'meta.llama3-2-1b-instruct-v1:0': { input: 0.1, output: 0.1 },
|
|
46
|
+
'meta.llama3-2-3b-instruct-v1:0': { input: 0.15, output: 0.15 },
|
|
47
|
+
'meta.llama3-2-11b-instruct-v1:0': { input: 0.35, output: 0.35 },
|
|
48
|
+
'meta.llama3-2-90b-instruct-v1:0': { input: 2.65, output: 2.65 },
|
|
49
|
+
|
|
50
|
+
// Meta Llama 3.1
|
|
51
|
+
'meta.llama3-1-8b-instruct-v1:0': { input: 0.3, output: 0.6 },
|
|
52
|
+
'meta.llama3-1-70b-instruct-v1:0': { input: 2.65, output: 3.5 },
|
|
53
|
+
'meta.llama3-1-405b-instruct-v1:0': { input: 5.32, output: 16 },
|
|
54
|
+
|
|
55
|
+
// Meta Llama 3
|
|
56
|
+
'meta.llama3-8b-instruct-v1:0': { input: 0.3, output: 0.6 },
|
|
57
|
+
'meta.llama3-70b-instruct-v1:0': { input: 2.65, output: 3.5 },
|
|
58
|
+
|
|
59
|
+
// Meta Llama 2
|
|
60
|
+
'meta.llama2-13b-chat-v1': { input: 0.75, output: 1 },
|
|
61
|
+
'meta.llama2-70b-chat-v1': { input: 1.95, output: 2.56 },
|
|
62
|
+
|
|
63
|
+
// Mistral AI
|
|
64
|
+
'mistral.mistral-7b-instruct-v0:2': { input: 0.15, output: 0.2 },
|
|
65
|
+
'mistral.mixtral-8x7b-instruct-v0:1': { input: 0.45, output: 0.7 },
|
|
66
|
+
'mistral.mistral-large-2402-v1:0': { input: 4, output: 12 },
|
|
67
|
+
'mistral.mistral-large-2407-v1:0': { input: 3, output: 9 },
|
|
68
|
+
|
|
69
|
+
// Cohere
|
|
70
|
+
'cohere.command-text-v14': { input: 1.5, output: 2 },
|
|
71
|
+
'cohere.command-light-text-v14': { input: 0.3, output: 0.6 },
|
|
72
|
+
'cohere.command-r-v1:0': { input: 0.5, output: 1.5 },
|
|
73
|
+
'cohere.command-r-plus-v1:0': { input: 3, output: 15 },
|
|
74
|
+
|
|
75
|
+
// Amazon Titan Text
|
|
76
|
+
'amazon.titan-text-lite-v1': { input: 0.15, output: 0.2 },
|
|
77
|
+
'amazon.titan-text-express-v1': { input: 0.2, output: 0.6 },
|
|
78
|
+
'amazon.titan-text-premier-v1:0': { input: 0.5, output: 1.5 },
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Model context window information (in tokens)
|
|
83
|
+
* Source: AWS Bedrock documentation
|
|
84
|
+
*/
|
|
85
|
+
const MODEL_CONTEXT_WINDOWS: Record<string, { context: number; maxOutput?: number }> = {
|
|
86
|
+
// Anthropic Claude 3.5 Sonnet
|
|
87
|
+
'anthropic.claude-3-5-sonnet-20240620-v1:0': { context: 200000, maxOutput: 8192 },
|
|
88
|
+
'anthropic.claude-3-5-sonnet-20241022-v2:0': { context: 200000, maxOutput: 8192 },
|
|
89
|
+
|
|
90
|
+
// Anthropic Claude 3 Opus
|
|
91
|
+
'anthropic.claude-3-opus-20240229-v1:0': { context: 200000, maxOutput: 4096 },
|
|
92
|
+
|
|
93
|
+
// Anthropic Claude 3 Sonnet
|
|
94
|
+
'anthropic.claude-3-sonnet-20240229-v1:0': { context: 200000, maxOutput: 4096 },
|
|
95
|
+
|
|
96
|
+
// Anthropic Claude 3 Haiku
|
|
97
|
+
'anthropic.claude-3-haiku-20240307-v1:0': { context: 200000, maxOutput: 4096 },
|
|
98
|
+
|
|
99
|
+
// Anthropic Claude 2.x
|
|
100
|
+
'anthropic.claude-v2:1': { context: 100000, maxOutput: 4096 },
|
|
101
|
+
'anthropic.claude-v2': { context: 100000, maxOutput: 4096 },
|
|
102
|
+
'anthropic.claude-instant-v1': { context: 100000, maxOutput: 4096 },
|
|
103
|
+
|
|
104
|
+
// Meta Llama 3.2
|
|
105
|
+
'meta.llama3-2-1b-instruct-v1:0': { context: 128000, maxOutput: 2048 },
|
|
106
|
+
'meta.llama3-2-3b-instruct-v1:0': { context: 128000, maxOutput: 2048 },
|
|
107
|
+
'meta.llama3-2-11b-instruct-v1:0': { context: 128000, maxOutput: 2048 },
|
|
108
|
+
'meta.llama3-2-90b-instruct-v1:0': { context: 128000, maxOutput: 2048 },
|
|
109
|
+
|
|
110
|
+
// Meta Llama 3.1
|
|
111
|
+
'meta.llama3-1-8b-instruct-v1:0': { context: 128000, maxOutput: 2048 },
|
|
112
|
+
'meta.llama3-1-70b-instruct-v1:0': { context: 128000, maxOutput: 2048 },
|
|
113
|
+
'meta.llama3-1-405b-instruct-v1:0': { context: 128000, maxOutput: 4096 },
|
|
114
|
+
|
|
115
|
+
// Meta Llama 3
|
|
116
|
+
'meta.llama3-8b-instruct-v1:0': { context: 8192, maxOutput: 2048 },
|
|
117
|
+
'meta.llama3-70b-instruct-v1:0': { context: 8192, maxOutput: 2048 },
|
|
118
|
+
|
|
119
|
+
// Meta Llama 2
|
|
120
|
+
'meta.llama2-13b-chat-v1': { context: 4096, maxOutput: 2048 },
|
|
121
|
+
'meta.llama2-70b-chat-v1': { context: 4096, maxOutput: 2048 },
|
|
122
|
+
|
|
123
|
+
// Mistral AI
|
|
124
|
+
'mistral.mistral-7b-instruct-v0:2': { context: 32000, maxOutput: 8192 },
|
|
125
|
+
'mistral.mixtral-8x7b-instruct-v0:1': { context: 32000, maxOutput: 8192 },
|
|
126
|
+
'mistral.mistral-large-2402-v1:0': { context: 32000, maxOutput: 8192 },
|
|
127
|
+
'mistral.mistral-large-2407-v1:0': { context: 128000, maxOutput: 8192 },
|
|
128
|
+
|
|
129
|
+
// Cohere
|
|
130
|
+
'cohere.command-text-v14': { context: 4096, maxOutput: 4096 },
|
|
131
|
+
'cohere.command-light-text-v14': { context: 4096, maxOutput: 4096 },
|
|
132
|
+
'cohere.command-r-v1:0': { context: 128000, maxOutput: 4096 },
|
|
133
|
+
'cohere.command-r-plus-v1:0': { context: 128000, maxOutput: 4096 },
|
|
134
|
+
|
|
135
|
+
// Amazon Titan Text
|
|
136
|
+
'amazon.titan-text-lite-v1': { context: 4096, maxOutput: 4096 },
|
|
137
|
+
'amazon.titan-text-express-v1': { context: 8192, maxOutput: 8192 },
|
|
138
|
+
'amazon.titan-text-premier-v1:0': { context: 32000, maxOutput: 3072 },
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Detect model family from model ID
|
|
143
|
+
*/
|
|
144
|
+
function detectModelFamily(modelId: string): string {
|
|
145
|
+
if (modelId.startsWith('anthropic.')) return 'anthropic';
|
|
146
|
+
if (modelId.startsWith('meta.')) return 'meta';
|
|
147
|
+
if (modelId.startsWith('mistral.')) return 'mistral';
|
|
148
|
+
if (modelId.startsWith('cohere.')) return 'cohere';
|
|
149
|
+
if (modelId.startsWith('ai21.')) return 'ai21';
|
|
150
|
+
if (modelId.startsWith('amazon.')) return 'amazon';
|
|
151
|
+
if (modelId.startsWith('stability.')) return 'stability';
|
|
152
|
+
return 'unknown';
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Detect capabilities from model information
|
|
157
|
+
*/
|
|
158
|
+
function detectCapabilities(model: FoundationModelSummary): Set<ModelCapability> {
|
|
159
|
+
const capabilities = new Set<ModelCapability>();
|
|
160
|
+
const modelId = model.modelId || '';
|
|
161
|
+
const family = detectModelFamily(modelId);
|
|
162
|
+
|
|
163
|
+
// Check for chat capability (text-to-text models)
|
|
164
|
+
if (
|
|
165
|
+
model.inputModalities?.includes('TEXT') &&
|
|
166
|
+
model.outputModalities?.includes('TEXT')
|
|
167
|
+
) {
|
|
168
|
+
// Chat models
|
|
169
|
+
if (
|
|
170
|
+
family === 'anthropic' ||
|
|
171
|
+
family === 'meta' ||
|
|
172
|
+
family === 'mistral' ||
|
|
173
|
+
family === 'cohere' ||
|
|
174
|
+
family === 'ai21' ||
|
|
175
|
+
(family === 'amazon' && modelId.includes('text'))
|
|
176
|
+
) {
|
|
177
|
+
capabilities.add('chat');
|
|
178
|
+
|
|
179
|
+
// Streaming support
|
|
180
|
+
if (model.responseStreamingSupported) {
|
|
181
|
+
capabilities.add('streaming');
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Image generation
|
|
187
|
+
if (
|
|
188
|
+
model.inputModalities?.includes('TEXT') &&
|
|
189
|
+
model.outputModalities?.includes('IMAGE')
|
|
190
|
+
) {
|
|
191
|
+
capabilities.add('image');
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Vision (image understanding)
|
|
195
|
+
if (
|
|
196
|
+
model.inputModalities?.includes('IMAGE') &&
|
|
197
|
+
model.outputModalities?.includes('TEXT')
|
|
198
|
+
) {
|
|
199
|
+
capabilities.add('vision');
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Embeddings
|
|
203
|
+
if (family === 'amazon' && modelId.includes('embed')) {
|
|
204
|
+
capabilities.add('embedding');
|
|
205
|
+
}
|
|
206
|
+
if (family === 'cohere' && modelId.includes('embed')) {
|
|
207
|
+
capabilities.add('embedding');
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Tool calling for supported models
|
|
211
|
+
if (family === 'anthropic' && modelId.includes('claude-3')) {
|
|
212
|
+
capabilities.add('tools');
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return capabilities;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Convert AWS Bedrock model to ModelInfo format
|
|
220
|
+
*/
|
|
221
|
+
function convertAWSModel(model: FoundationModelSummary): ModelInfo | null {
|
|
222
|
+
const modelId = model.modelId;
|
|
223
|
+
if (!modelId) return null;
|
|
224
|
+
|
|
225
|
+
const family = detectModelFamily(modelId);
|
|
226
|
+
const capabilities = detectCapabilities(model);
|
|
227
|
+
|
|
228
|
+
// Determine tier based on model family and name
|
|
229
|
+
let tier: ModelTier = 'efficient';
|
|
230
|
+
if (family === 'anthropic' && modelId.includes('opus')) {
|
|
231
|
+
tier = 'flagship';
|
|
232
|
+
} else if (family === 'anthropic' && modelId.includes('sonnet')) {
|
|
233
|
+
tier = 'efficient';
|
|
234
|
+
} else if (family === 'anthropic' && modelId.includes('haiku')) {
|
|
235
|
+
tier = 'efficient';
|
|
236
|
+
} else if (family === 'meta' && (modelId.includes('405b') || modelId.includes('90b'))) {
|
|
237
|
+
tier = 'flagship';
|
|
238
|
+
} else if (family === 'meta' && (modelId.includes('70b') || modelId.includes('13b'))) {
|
|
239
|
+
tier = 'efficient';
|
|
240
|
+
} else if (family === 'meta' && (modelId.includes('8b') || modelId.includes('7b') || modelId.includes('3b') || modelId.includes('1b'))) {
|
|
241
|
+
tier = 'efficient';
|
|
242
|
+
} else if (family === 'mistral' && modelId.includes('large')) {
|
|
243
|
+
tier = 'flagship';
|
|
244
|
+
} else if (family === 'mistral' && modelId.includes('mixtral')) {
|
|
245
|
+
tier = 'efficient';
|
|
246
|
+
} else if (family === 'mistral' && modelId.includes('7b')) {
|
|
247
|
+
tier = 'efficient';
|
|
248
|
+
} else if (family === 'cohere' && modelId.includes('plus')) {
|
|
249
|
+
tier = 'flagship';
|
|
250
|
+
} else {
|
|
251
|
+
tier = 'efficient';
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Get pricing information
|
|
255
|
+
const pricing = MODEL_PRICING[modelId];
|
|
256
|
+
const contextInfo = MODEL_CONTEXT_WINDOWS[modelId];
|
|
257
|
+
|
|
258
|
+
return {
|
|
259
|
+
provider: 'aws',
|
|
260
|
+
id: modelId,
|
|
261
|
+
name: model.modelName || modelId,
|
|
262
|
+
capabilities,
|
|
263
|
+
tier,
|
|
264
|
+
pricing: pricing ? {
|
|
265
|
+
text: {
|
|
266
|
+
input: pricing.input,
|
|
267
|
+
output: pricing.output,
|
|
268
|
+
},
|
|
269
|
+
} : {},
|
|
270
|
+
contextWindow: contextInfo?.context || 0,
|
|
271
|
+
maxOutputTokens: contextInfo?.maxOutput,
|
|
272
|
+
metadata: {
|
|
273
|
+
modelArn: model.modelArn,
|
|
274
|
+
providerName: model.providerName,
|
|
275
|
+
responseStreamingSupported: model.responseStreamingSupported,
|
|
276
|
+
customizationsSupported: model.customizationsSupported,
|
|
277
|
+
inferenceTypesSupported: model.inferenceTypesSupported,
|
|
278
|
+
inputModalities: model.inputModalities,
|
|
279
|
+
outputModalities: model.outputModalities,
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Main scraper function
|
|
286
|
+
*/
|
|
287
|
+
export async function scrapeAWS(
|
|
288
|
+
outputDir: string,
|
|
289
|
+
options: { region?: string } = {}
|
|
290
|
+
): Promise<void> {
|
|
291
|
+
const { region = process.env.AWS_REGION || 'us-east-1' } = options;
|
|
292
|
+
|
|
293
|
+
console.log('\n=== AWS Bedrock Scraper ===\n');
|
|
294
|
+
console.log(`Using region: ${region}`);
|
|
295
|
+
|
|
296
|
+
// Create Bedrock client
|
|
297
|
+
const client = new BedrockClient({
|
|
298
|
+
region,
|
|
299
|
+
// Credentials are automatically picked up from environment
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
try {
|
|
303
|
+
// List foundation models
|
|
304
|
+
console.log('Fetching models from AWS Bedrock...');
|
|
305
|
+
const command = new ListFoundationModelsCommand({});
|
|
306
|
+
const response = await client.send(command);
|
|
307
|
+
|
|
308
|
+
if (!response.modelSummaries) {
|
|
309
|
+
console.log('✗ No models returned from AWS Bedrock');
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
console.log(`✓ Fetched ${response.modelSummaries.length} AWS Bedrock models`);
|
|
314
|
+
|
|
315
|
+
// Create output directory
|
|
316
|
+
await fs.mkdir(outputDir, { recursive: true });
|
|
317
|
+
|
|
318
|
+
// Save raw data
|
|
319
|
+
await fs.writeFile(
|
|
320
|
+
path.join(outputDir, 'aws-models.json'),
|
|
321
|
+
JSON.stringify({ data: response.modelSummaries }, (key, value) => {
|
|
322
|
+
if (value instanceof Set) {
|
|
323
|
+
return Array.from(value);
|
|
324
|
+
}
|
|
325
|
+
return value;
|
|
326
|
+
}, 2)
|
|
327
|
+
);
|
|
328
|
+
console.log(`✓ Saved raw AWS models to aws-models.json`);
|
|
329
|
+
|
|
330
|
+
// Convert to ModelInfo format
|
|
331
|
+
const modelInfos = response.modelSummaries
|
|
332
|
+
.map(convertAWSModel)
|
|
333
|
+
.filter((m): m is ModelInfo => m !== null);
|
|
334
|
+
|
|
335
|
+
// Save JSON for reference
|
|
336
|
+
await fs.writeFile(
|
|
337
|
+
path.join(outputDir, 'aws-modelinfo.json'),
|
|
338
|
+
JSON.stringify(modelInfos, (key, value) => {
|
|
339
|
+
if (value instanceof Set) {
|
|
340
|
+
return Array.from(value);
|
|
341
|
+
}
|
|
342
|
+
return value;
|
|
343
|
+
}, 2)
|
|
344
|
+
);
|
|
345
|
+
console.log(`✓ Saved ${modelInfos.length} models to JSON`);
|
|
346
|
+
|
|
347
|
+
// Generate TypeScript file
|
|
348
|
+
const srcDir = path.join(__dirname, '../../src/models');
|
|
349
|
+
await writeModelTS(modelInfos, 'awsModels', path.join(srcDir, 'aws.ts'));
|
|
350
|
+
console.log(`✓ Generated TypeScript file: src/models/aws.ts`);
|
|
351
|
+
|
|
352
|
+
console.log('\n✓ AWS Bedrock scraping complete\n');
|
|
353
|
+
} catch (error) {
|
|
354
|
+
console.error('✗ AWS Bedrock scraping failed:', error);
|
|
355
|
+
throw error;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// CLI execution
|
|
360
|
+
if (process.argv[1].endsWith('aws.ts')) {
|
|
361
|
+
const args = process.argv.slice(2);
|
|
362
|
+
const outputDir = args.find((arg) => !arg.startsWith('--')) || path.join(__dirname, '../../data');
|
|
363
|
+
const regionArg = args.find((arg) => arg.startsWith('--region='));
|
|
364
|
+
const region = regionArg ? regionArg.split('=')[1] : undefined;
|
|
365
|
+
|
|
366
|
+
scrapeAWS(outputDir, { region }).catch((error) => {
|
|
367
|
+
console.error('✗ AWS Bedrock scraping failed:', error);
|
|
368
|
+
process.exit(1);
|
|
369
|
+
});
|
|
370
|
+
}
|