@anolilab/ai-model-registry 1.3.0 → 2.0.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/CHANGELOG.md +62 -0
- package/LICENSE.md +8 -13
- package/MIGRATION.md +474 -0
- package/README.md +275 -200
- package/dist/icons-sprite.d.ts +1 -1
- package/dist/icons-sprite.js +11 -11
- package/dist/index.d.ts +16 -16
- package/dist/index.js +1 -16
- package/dist/packem_chunks/alibaba.js +1 -0
- package/dist/packem_chunks/amazon-bedrock.js +1 -0
- package/dist/packem_chunks/anthropic.js +1 -0
- package/dist/packem_chunks/api.js +75 -0
- package/dist/packem_chunks/azure-open-ai.js +1 -0
- package/dist/packem_chunks/cerebras.js +1 -0
- package/dist/packem_chunks/chutes.js +1 -0
- package/dist/packem_chunks/cloudflare.js +3 -0
- package/dist/packem_chunks/deep-infra.js +1 -0
- package/dist/packem_chunks/deep-seek.js +1 -0
- package/dist/packem_chunks/fireworks-ai.js +1 -0
- package/dist/packem_chunks/git-hub-copilot.js +1 -0
- package/dist/packem_chunks/git-hub-models.js +1 -0
- package/dist/packem_chunks/google-partner.js +1 -0
- package/dist/packem_chunks/google-vertex.js +1 -0
- package/dist/packem_chunks/google.js +1 -0
- package/dist/packem_chunks/groq.js +1 -0
- package/dist/packem_chunks/hugging-face.js +1 -0
- package/dist/packem_chunks/inception.js +1 -0
- package/dist/packem_chunks/inference.js +1 -0
- package/dist/packem_chunks/meta.js +1 -0
- package/dist/packem_chunks/mistral.js +1 -0
- package/dist/packem_chunks/model-scope.js +1 -0
- package/dist/packem_chunks/morph.js +1 -0
- package/dist/packem_chunks/open-ai.js +1 -0
- package/dist/packem_chunks/open-router.js +1 -0
- package/dist/packem_chunks/providers.js +1 -0
- package/dist/packem_chunks/requesty.js +73 -0
- package/dist/packem_chunks/together-ai.js +1 -0
- package/dist/packem_chunks/upstage.js +1 -0
- package/dist/packem_chunks/v0.js +1 -0
- package/dist/packem_chunks/venice.js +1 -0
- package/dist/packem_chunks/vercel.js +1 -0
- package/dist/packem_chunks/weights-_-biases.js +1 -0
- package/dist/packem_chunks/xai.js +1 -0
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +1 -1
- package/dist/types/alibaba.d.ts +6 -0
- package/dist/types/alibaba.js +0 -0
- package/dist/types/amazon-bedrock.d.ts +6 -0
- package/dist/types/amazon-bedrock.js +0 -0
- package/dist/types/anthropic.d.ts +6 -0
- package/dist/types/anthropic.js +0 -0
- package/dist/types/azure-open-ai.d.ts +6 -0
- package/dist/types/azure-open-ai.js +0 -0
- package/dist/types/cerebras.d.ts +6 -0
- package/dist/types/cerebras.js +0 -0
- package/dist/types/chutes.d.ts +6 -0
- package/dist/types/chutes.js +0 -0
- package/dist/types/cloudflare.d.ts +6 -0
- package/dist/types/cloudflare.js +0 -0
- package/dist/types/deep-infra.d.ts +6 -0
- package/dist/types/deep-infra.js +0 -0
- package/dist/types/deep-seek.d.ts +6 -0
- package/dist/types/deep-seek.js +0 -0
- package/dist/types/fireworks-ai.d.ts +6 -0
- package/dist/types/fireworks-ai.js +0 -0
- package/dist/types/git-hub-copilot.d.ts +6 -0
- package/dist/types/git-hub-copilot.js +0 -0
- package/dist/types/git-hub-models.d.ts +6 -0
- package/dist/types/git-hub-models.js +0 -0
- package/dist/types/google-partner.d.ts +6 -0
- package/dist/types/google-partner.js +0 -0
- package/dist/types/google-vertex.d.ts +6 -0
- package/dist/types/google-vertex.js +0 -0
- package/dist/types/google.d.ts +6 -0
- package/dist/types/google.js +0 -0
- package/dist/types/groq.d.ts +6 -0
- package/dist/types/groq.js +0 -0
- package/dist/types/hugging-face.d.ts +6 -0
- package/dist/types/hugging-face.js +0 -0
- package/dist/types/inception.d.ts +6 -0
- package/dist/types/inception.js +0 -0
- package/dist/types/inference.d.ts +6 -0
- package/dist/types/inference.js +0 -0
- package/dist/types/meta.d.ts +6 -0
- package/dist/types/meta.js +0 -0
- package/dist/types/mistral.d.ts +6 -0
- package/dist/types/mistral.js +0 -0
- package/dist/types/model-scope.d.ts +6 -0
- package/dist/types/model-scope.js +0 -0
- package/dist/types/morph.d.ts +6 -0
- package/dist/types/morph.js +0 -0
- package/dist/types/open-ai.d.ts +6 -0
- package/dist/types/open-ai.js +0 -0
- package/dist/types/open-router.d.ts +6 -0
- package/dist/types/open-router.js +0 -0
- package/dist/types/providers.d.ts +11 -0
- package/dist/types/providers.js +1 -0
- package/dist/types/requesty.d.ts +6 -0
- package/dist/types/requesty.js +0 -0
- package/dist/types/together-ai.d.ts +6 -0
- package/dist/types/together-ai.js +0 -0
- package/dist/types/upstage.d.ts +6 -0
- package/dist/types/upstage.js +0 -0
- package/dist/types/v0.d.ts +6 -0
- package/dist/types/v0.js +0 -0
- package/dist/types/venice.d.ts +6 -0
- package/dist/types/venice.js +0 -0
- package/dist/types/vercel.d.ts +6 -0
- package/dist/types/vercel.js +0 -0
- package/dist/types/weights-_-biases.d.ts +6 -0
- package/dist/types/weights-_-biases.js +0 -0
- package/dist/types/xai.d.ts +6 -0
- package/dist/types/xai.js +0 -0
- package/package.json +7 -2
- package/public/alibaba.json +326 -0
- package/public/amazon-bedrock.json +2141 -0
- package/public/anthropic.json +396 -0
- package/public/api.json +66961 -19318
- package/public/azure-open-ai.json +332 -0
- package/public/cerebras.json +288 -0
- package/public/chutes.json +3220 -0
- package/public/cloudflare.json +3094 -0
- package/public/deep-infra.json +956 -0
- package/public/deep-seek.json +46 -0
- package/public/fireworks-ai.json +14486 -0
- package/public/git-hub-copilot.json +676 -0
- package/public/git-hub-models.json +256 -0
- package/public/google-partner.json +536 -0
- package/public/google-vertex.json +1376 -0
- package/public/google.json +536 -0
- package/public/groq.json +882 -0
- package/public/hugging-face.json +1096 -0
- package/public/inception.json +81 -0
- package/public/inference.json +291 -0
- package/public/meta.json +151 -0
- package/public/mistral.json +2181 -0
- package/public/model-scope.json +37839 -0
- package/public/morph.json +46 -0
- package/public/open-ai.json +606 -0
- package/public/open-router.json +15341 -0
- package/public/providers.json +43 -0
- package/public/requesty.json +13757 -0
- package/public/together-ai.json +641 -0
- package/public/upstage.json +606 -0
- package/public/v0.json +431 -0
- package/public/venice.json +501 -0
- package/public/vercel.json +4071 -0
- package/public/weights-&-biases.json +551 -0
- package/public/xai.json +256 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,65 @@
|
|
|
1
|
+
## @anolilab/ai-model-registry [2.0.0](https://github.com/anolilab/ai-models/compare/@anolilab/ai-model-registry@1.4.0...@anolilab/ai-model-registry@2.0.0) (2026-01-10)
|
|
2
|
+
|
|
3
|
+
### ⚠ BREAKING CHANGES
|
|
4
|
+
|
|
5
|
+
* **ai-model-registry:** All API functions are now async
|
|
6
|
+
|
|
7
|
+
All exported functions now return Promises and must be awaited. This enables
|
|
8
|
+
code splitting, dynamic imports, and better performance by loading provider
|
|
9
|
+
data on-demand.
|
|
10
|
+
|
|
11
|
+
Migration:
|
|
12
|
+
- getAllModels() → await getAllModels()
|
|
13
|
+
- getProviders() → await getProviders()
|
|
14
|
+
- getModelsByProvider(provider) → await getModelsByProvider(provider)
|
|
15
|
+
- getModelById(id) → await getModelById(id)
|
|
16
|
+
- searchModels(criteria) → await searchModels(criteria)
|
|
17
|
+
- getProviderStats() → await getProviderStats()
|
|
18
|
+
|
|
19
|
+
This change enables:
|
|
20
|
+
- Code splitting and dynamic imports for better bundle sizes
|
|
21
|
+
- On-demand loading of provider data
|
|
22
|
+
- Improved tree-shaking capabilities
|
|
23
|
+
- Better scalability as the registry grows
|
|
24
|
+
|
|
25
|
+
Additional changes:
|
|
26
|
+
- Provider-specific JSON files generated (public/{provider-name}.json)
|
|
27
|
+
- New type exports: @anolilab/ai-model-registry/types/{provider-name}
|
|
28
|
+
- api.json still generated but no longer statically imported
|
|
29
|
+
|
|
30
|
+
### Features
|
|
31
|
+
|
|
32
|
+
* add new AI model provider configurations and update package structure ([e2badcb](https://github.com/anolilab/ai-models/commit/e2badcbc204be1a3ff14571c12ad2a3bdcac4afc))
|
|
33
|
+
|
|
34
|
+
### Bug Fixes
|
|
35
|
+
|
|
36
|
+
* **ai-model-registry:** update tests for async API ([6795524](https://github.com/anolilab/ai-models/commit/67955243f292dee0ae35e411e04081e6409a5c6d))
|
|
37
|
+
|
|
38
|
+
### Documentation
|
|
39
|
+
|
|
40
|
+
* **ai-model-registry:** add migration guide for v1 to v2 transition ([e5d9c4b](https://github.com/anolilab/ai-models/commit/e5d9c4bdbb957e184ac04dfe510544c2ed835bff))
|
|
41
|
+
|
|
42
|
+
## @anolilab/ai-model-registry [1.4.0](https://github.com/anolilab/ai-models/compare/@anolilab/ai-model-registry@1.3.0...@anolilab/ai-model-registry@1.4.0) (2026-01-09)
|
|
43
|
+
|
|
44
|
+
### Features
|
|
45
|
+
|
|
46
|
+
* **deps:** update dependencies and improve package configurations ([858afd8](https://github.com/anolilab/ai-models/commit/858afd894ee24e8abe9cbaa5f6d0d00dc76344ae))
|
|
47
|
+
* enhance AI model registry with new models and cost normalization ([b64800b](https://github.com/anolilab/ai-models/commit/b64800b47b7523c54652e0385571689e7b268232))
|
|
48
|
+
* enhance AI model registry with retirement information and update dependencies ([ec66750](https://github.com/anolilab/ai-models/commit/ec66750f8ca504fe12b3ca372b4051f220f97b05))
|
|
49
|
+
|
|
50
|
+
### Bug Fixes
|
|
51
|
+
|
|
52
|
+
* **deps:** update dependency @lobehub/icons-static-svg to ^1.63.0 ([#19](https://github.com/anolilab/ai-models/issues/19)) ([e932ae1](https://github.com/anolilab/ai-models/commit/e932ae18983628ad47abb7538567de6892a129dd))
|
|
53
|
+
* enhance AI model registry with new download scripts and cost formatting improvements ([8a6ff27](https://github.com/anolilab/ai-models/commit/8a6ff27697638865062bf1dbadc5395cd203ebd7))
|
|
54
|
+
* update API and improve output modality parsing ([36d197a](https://github.com/anolilab/ai-models/commit/36d197aaeb7e4495923428d469c27296b0f4b824))
|
|
55
|
+
* update package configurations and enhance README documentation ([4483be1](https://github.com/anolilab/ai-models/commit/4483be12f5a3d7c692e0ad06576e70f681e5e218))
|
|
56
|
+
|
|
57
|
+
### Miscellaneous Chores
|
|
58
|
+
|
|
59
|
+
* add Prettier configuration and ignore files ([490f841](https://github.com/anolilab/ai-models/commit/490f841c983064f2143b14e5ebd6b21960aece5e))
|
|
60
|
+
* **deps:** update dependencies and package configurations ([b5b2005](https://github.com/anolilab/ai-models/commit/b5b20053824074ccf1981bccb38cc7dd4d1dd228))
|
|
61
|
+
* **deps:** update package dependencies and configurations ([1deefef](https://github.com/anolilab/ai-models/commit/1deefef4c1a400b018b687b7c3d4da88f7125ad5))
|
|
62
|
+
|
|
1
63
|
## @anolilab/ai-model-registry [1.3.0](https://github.com/anolilab/ai-models/compare/@anolilab/ai-model-registry@1.2.3...@anolilab/ai-model-registry@1.3.0) (2025-08-14)
|
|
2
64
|
|
|
3
65
|
### Features
|
package/LICENSE.md
CHANGED
|
@@ -233,14 +233,11 @@ Popular AI / LLM Model Brand SVG Logo and Icon Collection
|
|
|
233
233
|
<!-- DEPENDENCIES -->
|
|
234
234
|
|
|
235
235
|
# Licenses of bundled dependencies
|
|
236
|
-
|
|
237
236
|
The published @anolilab/ai-model-registry artifact additionally contains code with the following licenses:
|
|
238
237
|
MIT
|
|
239
238
|
|
|
240
239
|
# Bundled dependencies:
|
|
241
|
-
|
|
242
240
|
## @visulima/string
|
|
243
|
-
|
|
244
241
|
License: MIT
|
|
245
242
|
By: Daniel Bannert
|
|
246
243
|
Repository: git+https://github.com/visulima/visulima.git
|
|
@@ -267,15 +264,14 @@ Repository: git+https://github.com/visulima/visulima.git
|
|
|
267
264
|
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
268
265
|
> SOFTWARE.
|
|
269
266
|
>
|
|
270
|
-
> # Licenses of bundled dependencies
|
|
271
267
|
>
|
|
268
|
+
>
|
|
269
|
+
> # Licenses of bundled dependencies
|
|
272
270
|
> The published @visulima/string artifact additionally contains code with the following licenses:
|
|
273
271
|
> MIT
|
|
274
272
|
>
|
|
275
273
|
> # Bundled dependencies:
|
|
276
|
-
>
|
|
277
274
|
> ## emoji-regex-xs
|
|
278
|
-
>
|
|
279
275
|
> License: MIT
|
|
280
276
|
> By: Steven Levithan
|
|
281
277
|
> Repository: git+https://github.com/slevithan/emoji-regex-xs.git
|
|
@@ -302,10 +298,9 @@ Repository: git+https://github.com/visulima/visulima.git
|
|
|
302
298
|
> > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
303
299
|
> > SOFTWARE.
|
|
304
300
|
>
|
|
305
|
-
>
|
|
301
|
+
> ---------------------------------------
|
|
306
302
|
>
|
|
307
303
|
> ## fastest-levenshtein
|
|
308
|
-
>
|
|
309
304
|
> License: MIT
|
|
310
305
|
> By: Kasper U. Weihe
|
|
311
306
|
> Repository: git+https://github.com/ka-weihe/fastest-levenshtein.git
|
|
@@ -332,10 +327,9 @@ Repository: git+https://github.com/visulima/visulima.git
|
|
|
332
327
|
> > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
333
328
|
> > SOFTWARE.
|
|
334
329
|
>
|
|
335
|
-
>
|
|
330
|
+
> ---------------------------------------
|
|
336
331
|
>
|
|
337
332
|
> ## get-east-asian-width
|
|
338
|
-
>
|
|
339
333
|
> License: MIT
|
|
340
334
|
> By: Sindre Sorhus
|
|
341
335
|
> Repository: sindresorhus/get-east-asian-width
|
|
@@ -350,15 +344,16 @@ Repository: git+https://github.com/visulima/visulima.git
|
|
|
350
344
|
> >
|
|
351
345
|
> > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
352
346
|
>
|
|
353
|
-
> # Licenses of bundled types
|
|
354
347
|
>
|
|
348
|
+
>
|
|
349
|
+
>
|
|
350
|
+
>
|
|
351
|
+
> # Licenses of bundled types
|
|
355
352
|
> The published @visulima/string artifact additionally contains code with the following licenses:
|
|
356
353
|
> MIT
|
|
357
354
|
>
|
|
358
355
|
> # Bundled types:
|
|
359
|
-
>
|
|
360
356
|
> ## fastest-levenshtein
|
|
361
|
-
>
|
|
362
357
|
> License: MIT
|
|
363
358
|
> By: Kasper U. Weihe
|
|
364
359
|
> Repository: git+https://github.com/ka-weihe/fastest-levenshtein.git
|
package/MIGRATION.md
ADDED
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
# Migration Guide: v1 → v2
|
|
2
|
+
|
|
3
|
+
This guide will help you migrate from `@anolilab/ai-model-registry` v1.x to v2.0.0.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Version 2.0.0 introduces a **breaking change**: all API functions are now asynchronous and return Promises. This change enables code splitting, dynamic imports, and better performance by loading provider data on-demand.
|
|
8
|
+
|
|
9
|
+
### What Changed?
|
|
10
|
+
|
|
11
|
+
- All functions are now `async` and return `Promise<T>`
|
|
12
|
+
- Dynamic imports replace static JSON imports
|
|
13
|
+
- Provider-specific JSON files for efficient loading
|
|
14
|
+
- New type exports for provider-specific model IDs
|
|
15
|
+
- Improved tree-shaking and code splitting
|
|
16
|
+
|
|
17
|
+
### What Stayed the Same?
|
|
18
|
+
|
|
19
|
+
- Function names and signatures (except async)
|
|
20
|
+
- Return types (wrapped in Promise)
|
|
21
|
+
- Model schema and data structure
|
|
22
|
+
- Search and filter capabilities
|
|
23
|
+
- TypeScript type definitions
|
|
24
|
+
|
|
25
|
+
## Quick Migration Checklist
|
|
26
|
+
|
|
27
|
+
- [ ] Update all function calls to use `await`
|
|
28
|
+
- [ ] Convert synchronous code to async/await or Promise chains
|
|
29
|
+
- [ ] Update function signatures in your code to handle Promises
|
|
30
|
+
- [ ] Test your application thoroughly
|
|
31
|
+
- [ ] Update any TypeScript types if needed
|
|
32
|
+
|
|
33
|
+
## Step-by-Step Migration
|
|
34
|
+
|
|
35
|
+
### 1. Update Package Version
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install @anolilab/ai-model-registry@^2.0.0
|
|
39
|
+
# or
|
|
40
|
+
yarn add @anolilab/ai-model-registry@^2.0.0
|
|
41
|
+
# or
|
|
42
|
+
pnpm add @anolilab/ai-model-registry@^2.0.0
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 2. Update Function Calls
|
|
46
|
+
|
|
47
|
+
#### Before (v1.x)
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { getAllModels, getModelById, getModelsByProvider, getProviders, getProviderStats, searchModels } from "@anolilab/ai-model-registry";
|
|
51
|
+
|
|
52
|
+
// Synchronous calls
|
|
53
|
+
const providers = getProviders();
|
|
54
|
+
const models = getModelsByProvider("Anthropic");
|
|
55
|
+
const model = getModelById("claude-3-opus-20240229");
|
|
56
|
+
const results = searchModels({ vision: true });
|
|
57
|
+
const allModels = getAllModels();
|
|
58
|
+
const stats = getProviderStats();
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
#### After (v2.0.0)
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { getAllModels, getModelById, getModelsByProvider, getProviders, getProviderStats, searchModels } from "@anolilab/ai-model-registry";
|
|
65
|
+
|
|
66
|
+
// All calls are now async - use await
|
|
67
|
+
const providers = await getProviders();
|
|
68
|
+
const models = await getModelsByProvider("Anthropic");
|
|
69
|
+
const model = await getModelById("claude-3-opus-20240229");
|
|
70
|
+
const results = await searchModels({ vision: true });
|
|
71
|
+
const allModels = await getAllModels();
|
|
72
|
+
const stats = await getProviderStats();
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### 3. Update Function Signatures
|
|
76
|
+
|
|
77
|
+
If you have functions that use the registry, update them to be async:
|
|
78
|
+
|
|
79
|
+
#### Before (v1.x)
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
function getModelInfo(modelId: string) {
|
|
83
|
+
const model = getModelById(modelId);
|
|
84
|
+
|
|
85
|
+
if (model) {
|
|
86
|
+
return {
|
|
87
|
+
cost: model.cost,
|
|
88
|
+
name: model.name,
|
|
89
|
+
provider: model.provider,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### After (v2.0.0)
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
async function getModelInfo(modelId: string) {
|
|
101
|
+
const model = await getModelById(modelId);
|
|
102
|
+
|
|
103
|
+
if (model) {
|
|
104
|
+
return {
|
|
105
|
+
cost: model.cost,
|
|
106
|
+
name: model.name,
|
|
107
|
+
provider: model.provider,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### 4. Update React Components
|
|
116
|
+
|
|
117
|
+
#### Before (v1.x)
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
import { useEffect, useState } from "react";
|
|
121
|
+
import { getAllModels } from "@anolilab/ai-model-registry";
|
|
122
|
+
|
|
123
|
+
function ModelList() {
|
|
124
|
+
const [models, setModels] = useState([]);
|
|
125
|
+
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
const allModels = getAllModels();
|
|
128
|
+
setModels(allModels);
|
|
129
|
+
}, []);
|
|
130
|
+
|
|
131
|
+
return <div>{/* render models */}</div>;
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
#### After (v2.0.0)
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
import { useEffect, useState } from "react";
|
|
139
|
+
import { getAllModels } from "@anolilab/ai-model-registry";
|
|
140
|
+
import type { Model } from "@anolilab/ai-model-registry";
|
|
141
|
+
|
|
142
|
+
function ModelList() {
|
|
143
|
+
const [models, setModels] = useState<Model[]>([]);
|
|
144
|
+
const [loading, setLoading] = useState(true);
|
|
145
|
+
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
async function loadModels() {
|
|
148
|
+
try {
|
|
149
|
+
const allModels = await getAllModels();
|
|
150
|
+
setModels(allModels);
|
|
151
|
+
} catch (error) {
|
|
152
|
+
console.error("Failed to load models:", error);
|
|
153
|
+
} finally {
|
|
154
|
+
setLoading(false);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
loadModels();
|
|
158
|
+
}, []);
|
|
159
|
+
|
|
160
|
+
if (loading) return <div>Loading...</div>;
|
|
161
|
+
return <div>{/* render models */}</div>;
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### 5. Update React Hooks
|
|
166
|
+
|
|
167
|
+
#### Before (v1.x)
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
import { searchModels } from "@anolilab/ai-model-registry";
|
|
171
|
+
import { useMemo } from "react";
|
|
172
|
+
|
|
173
|
+
function useVisionModels() {
|
|
174
|
+
return useMemo(() => searchModels({ vision: true }), []);
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
#### After (v2.0.0)
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
import type { Model } from "@anolilab/ai-model-registry";
|
|
182
|
+
import { searchModels } from "@anolilab/ai-model-registry";
|
|
183
|
+
import { useEffect, useState } from "react";
|
|
184
|
+
|
|
185
|
+
function useVisionModels() {
|
|
186
|
+
const [models, setModels] = useState<Model[]>([]);
|
|
187
|
+
const [loading, setLoading] = useState(true);
|
|
188
|
+
|
|
189
|
+
useEffect(() => {
|
|
190
|
+
async function loadModels() {
|
|
191
|
+
try {
|
|
192
|
+
const visionModels = await searchModels({ vision: true });
|
|
193
|
+
|
|
194
|
+
setModels(visionModels);
|
|
195
|
+
} catch (error) {
|
|
196
|
+
console.error("Failed to load vision models:", error);
|
|
197
|
+
} finally {
|
|
198
|
+
setLoading(false);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
loadModels();
|
|
203
|
+
}, []);
|
|
204
|
+
|
|
205
|
+
return { loading, models };
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### 6. Update Server-Side Code (Node.js, Next.js API Routes)
|
|
210
|
+
|
|
211
|
+
#### Before (v1.x)
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
// Next.js API route
|
|
215
|
+
export default function handler(req, res) {
|
|
216
|
+
const providers = getProviders();
|
|
217
|
+
|
|
218
|
+
res.json({ providers });
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
#### After (v2.0.0)
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
// Next.js API route
|
|
226
|
+
export default async function handler(req, res) {
|
|
227
|
+
try {
|
|
228
|
+
const providers = await getProviders();
|
|
229
|
+
|
|
230
|
+
res.json({ providers });
|
|
231
|
+
} catch (error) {
|
|
232
|
+
res.status(500).json({ error: "Failed to load providers" });
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### 7. Update Promise Chains
|
|
238
|
+
|
|
239
|
+
If you prefer Promise chains over async/await:
|
|
240
|
+
|
|
241
|
+
#### Before (v1.x)
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
const providers = getProviders();
|
|
245
|
+
const models = providers.map((provider) => getModelsByProvider(provider));
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
#### After (v2.0.0)
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
// Using async/await (recommended)
|
|
252
|
+
const providers = await getProviders();
|
|
253
|
+
const models = await Promise.all(providers.map((provider) => getModelsByProvider(provider)));
|
|
254
|
+
|
|
255
|
+
// Or using Promise chains
|
|
256
|
+
getProviders()
|
|
257
|
+
.then((providers) => Promise.all(providers.map((provider) => getModelsByProvider(provider))))
|
|
258
|
+
.then((models) => {
|
|
259
|
+
// Use models
|
|
260
|
+
});
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### 8. Update Error Handling
|
|
264
|
+
|
|
265
|
+
Since functions are now async, errors are thrown asynchronously:
|
|
266
|
+
|
|
267
|
+
#### Before (v1.x)
|
|
268
|
+
|
|
269
|
+
```typescript
|
|
270
|
+
try {
|
|
271
|
+
const model = getModelById("invalid-id");
|
|
272
|
+
// Handle model
|
|
273
|
+
} catch (error) {
|
|
274
|
+
// This won't catch async errors
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
#### After (v2.0.0)
|
|
279
|
+
|
|
280
|
+
```typescript
|
|
281
|
+
try {
|
|
282
|
+
const model = await getModelById("invalid-id");
|
|
283
|
+
// Handle model
|
|
284
|
+
} catch (error) {
|
|
285
|
+
// Properly handles async errors
|
|
286
|
+
console.error("Failed to get model:", error);
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
## New Features in v2.0.0
|
|
291
|
+
|
|
292
|
+
### Provider-Specific Type Exports
|
|
293
|
+
|
|
294
|
+
You can now import type-safe model IDs for specific providers:
|
|
295
|
+
|
|
296
|
+
```typescript
|
|
297
|
+
import type { ProviderName } from "@anolilab/ai-model-registry";
|
|
298
|
+
import type ModelName from "@anolilab/ai-model-registry/types/open-router";
|
|
299
|
+
|
|
300
|
+
// Type-safe provider names
|
|
301
|
+
const provider: ProviderName = "OpenAI"; // Valid
|
|
302
|
+
const invalid: ProviderName = "InvalidProvider"; // TypeScript error
|
|
303
|
+
|
|
304
|
+
// Type-safe model IDs for OpenRouter
|
|
305
|
+
const modelId: ModelName = "meta-llama/llama-3.1-8b-instruct"; // Valid
|
|
306
|
+
const invalidId: ModelName = "invalid-model"; // TypeScript error
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### Dynamic Imports and Code Splitting
|
|
310
|
+
|
|
311
|
+
The new architecture uses dynamic imports, which means:
|
|
312
|
+
|
|
313
|
+
- **Smaller initial bundle**: Only load provider data when needed
|
|
314
|
+
- **Better tree-shaking**: Unused providers won't be included
|
|
315
|
+
- **Improved performance**: Load data on-demand
|
|
316
|
+
|
|
317
|
+
This happens automatically - no code changes needed beyond using `await`.
|
|
318
|
+
|
|
319
|
+
## Common Patterns
|
|
320
|
+
|
|
321
|
+
### Loading Multiple Providers
|
|
322
|
+
|
|
323
|
+
```typescript
|
|
324
|
+
async function loadProviderModels(providerNames: ProviderName[]) {
|
|
325
|
+
const modelsByProvider = await Promise.all(
|
|
326
|
+
providerNames.map(async (provider) => {
|
|
327
|
+
return {
|
|
328
|
+
models: await getModelsByProvider(provider),
|
|
329
|
+
provider,
|
|
330
|
+
}
|
|
331
|
+
}),
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
return modelsByProvider;
|
|
335
|
+
}
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Conditional Loading
|
|
339
|
+
|
|
340
|
+
```typescript
|
|
341
|
+
async function getModelsForProvider(provider?: ProviderName) {
|
|
342
|
+
if (provider) {
|
|
343
|
+
return await getModelsByProvider(provider);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
return await getAllModels();
|
|
347
|
+
}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Error Handling with Fallbacks
|
|
351
|
+
|
|
352
|
+
```typescript
|
|
353
|
+
async function getModelWithFallback(modelId: string) {
|
|
354
|
+
try {
|
|
355
|
+
const model = await getModelById(modelId);
|
|
356
|
+
|
|
357
|
+
if (model)
|
|
358
|
+
return model;
|
|
359
|
+
} catch (error) {
|
|
360
|
+
console.warn("Failed to load model:", error);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// Fallback to searching
|
|
364
|
+
const results = await searchModels({
|
|
365
|
+
/* criteria */
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
return results[0];
|
|
369
|
+
}
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
## Performance Considerations
|
|
373
|
+
|
|
374
|
+
### Caching
|
|
375
|
+
|
|
376
|
+
The library now includes built-in caching, so repeated calls to the same provider won't trigger additional network requests:
|
|
377
|
+
|
|
378
|
+
```typescript
|
|
379
|
+
// First call - loads data
|
|
380
|
+
const models1 = await getModelsByProvider("Anthropic");
|
|
381
|
+
|
|
382
|
+
// Second call - uses cache (no additional load)
|
|
383
|
+
const models2 = await getModelsByProvider("Anthropic");
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### Parallel Loading
|
|
387
|
+
|
|
388
|
+
When loading multiple providers, use `Promise.all` for parallel loading:
|
|
389
|
+
|
|
390
|
+
```typescript
|
|
391
|
+
// Good: Parallel loading
|
|
392
|
+
const [anthropic, openai] = await Promise.all([getModelsByProvider("Anthropic"), getModelsByProvider("OpenAI")]);
|
|
393
|
+
|
|
394
|
+
// Avoid: Sequential loading (slower)
|
|
395
|
+
const anthropic = await getModelsByProvider("Anthropic");
|
|
396
|
+
const openai = await getModelsByProvider("OpenAI");
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
## Troubleshooting
|
|
400
|
+
|
|
401
|
+
### TypeScript Errors
|
|
402
|
+
|
|
403
|
+
If you see TypeScript errors about missing `await`:
|
|
404
|
+
|
|
405
|
+
```typescript
|
|
406
|
+
// Error: 'await' expressions are only allowed within async functions
|
|
407
|
+
const models = await getModelsByProvider("Anthropic");
|
|
408
|
+
|
|
409
|
+
// Fix: Make the function async
|
|
410
|
+
async function loadModels() {
|
|
411
|
+
const models = await getModelsByProvider("Anthropic");
|
|
412
|
+
|
|
413
|
+
return models;
|
|
414
|
+
}
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
### Runtime Errors
|
|
418
|
+
|
|
419
|
+
If you see errors about Promises not being handled:
|
|
420
|
+
|
|
421
|
+
```typescript
|
|
422
|
+
// Error: Unhandled promise rejection
|
|
423
|
+
getModelsByProvider("Anthropic").then((models) => {
|
|
424
|
+
// Use models
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
// Fix: Use async/await or handle errors
|
|
428
|
+
try {
|
|
429
|
+
const models = await getModelsByProvider("Anthropic");
|
|
430
|
+
// Use models
|
|
431
|
+
} catch (error) {
|
|
432
|
+
// Handle error
|
|
433
|
+
}
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### Build Errors
|
|
437
|
+
|
|
438
|
+
If you see build errors related to dynamic imports, ensure your bundler supports dynamic imports:
|
|
439
|
+
|
|
440
|
+
- **Webpack**: Supported by default
|
|
441
|
+
- **Vite**: Supported by default
|
|
442
|
+
- **Rollup**: Supported by default
|
|
443
|
+
- **Next.js**: Supported by default
|
|
444
|
+
|
|
445
|
+
## Breaking Changes Summary
|
|
446
|
+
|
|
447
|
+
| Function | v1.x | v2.0.0 |
|
|
448
|
+
| ------------------------------- | ------------------------------ | --------------------------------------- |
|
|
449
|
+
| `getProviders()` | `ProviderName[]` | `Promise<ProviderName[]>` |
|
|
450
|
+
| `getModelsByProvider(provider)` | `Model[]` | `Promise<Model[]>` |
|
|
451
|
+
| `getModelById(id)` | `Model \| undefined` | `Promise<Model \| undefined>` |
|
|
452
|
+
| `searchModels(criteria)` | `Model[]` | `Promise<Model[]>` |
|
|
453
|
+
| `getAllModels()` | `Model[]` | `Promise<Model[]>` |
|
|
454
|
+
| `getProviderStats()` | `Record<ProviderName, number>` | `Promise<Record<ProviderName, number>>` |
|
|
455
|
+
|
|
456
|
+
## Need Help?
|
|
457
|
+
|
|
458
|
+
If you encounter issues during migration:
|
|
459
|
+
|
|
460
|
+
1. Check the [README.md](./README.md) for the latest API documentation
|
|
461
|
+
2. Review the [examples](#common-patterns) above
|
|
462
|
+
3. Open an issue on [GitHub](https://github.com/anolilab/ai-models/issues)
|
|
463
|
+
|
|
464
|
+
## Benefits of v2.0.0
|
|
465
|
+
|
|
466
|
+
- **Better Performance**: Load data on-demand, reducing initial bundle size
|
|
467
|
+
- **Code Splitting**: Automatic code splitting for better tree-shaking
|
|
468
|
+
- **Scalability**: As the registry grows, your app won't need to load all models upfront
|
|
469
|
+
- **Type Safety**: New provider-specific type exports for better TypeScript support
|
|
470
|
+
- **Caching**: Built-in caching prevents redundant data fetching
|
|
471
|
+
|
|
472
|
+
---
|
|
473
|
+
|
|
474
|
+
**Migration completed?** Great! You're now using the improved v2.0.0 API with better performance and scalability.
|