@anyllmtoken/modelx-data 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/changes.jsonl +20567 -0
- package/index.ts +141 -0
- package/package.json +19 -0
package/index.ts
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// @anyllmtoken/modelx-data — Model data for all providers across CN and US regions
|
|
2
|
+
//
|
|
3
|
+
// import { getProviders, getAllModels, getChanges, getModel } from "@anyllmtoken/modelx-data";
|
|
4
|
+
|
|
5
|
+
import { providers as _providersUs, allModels as _allModelsUs } from "../../src/data-us";
|
|
6
|
+
import { providers as _providersCn, allModels as _allModelsCn } from "../../src/data-cn";
|
|
7
|
+
import {
|
|
8
|
+
getModel as _getModel,
|
|
9
|
+
getModelsByProvider as _getModelsByProvider,
|
|
10
|
+
getActiveModels as _getActiveModels,
|
|
11
|
+
getModelsByFamily as _getModelsByFamily,
|
|
12
|
+
getModelsByCreator as _getModelsByCreator,
|
|
13
|
+
getProvider as _getProvider,
|
|
14
|
+
getAllProviders as _getAllProviders,
|
|
15
|
+
getProviderIcon as _getProviderIcon,
|
|
16
|
+
} from "../../src/utils";
|
|
17
|
+
import type { Model, ProviderWithModels } from "../../src/types";
|
|
18
|
+
|
|
19
|
+
// ── 类型 ──
|
|
20
|
+
|
|
21
|
+
export type {
|
|
22
|
+
Model,
|
|
23
|
+
ModelData,
|
|
24
|
+
ModelPricing,
|
|
25
|
+
ModelCapabilities,
|
|
26
|
+
ModelModalities,
|
|
27
|
+
Provider,
|
|
28
|
+
ProviderWithModels,
|
|
29
|
+
PricingTier,
|
|
30
|
+
PricingTierRow,
|
|
31
|
+
ModelStatus,
|
|
32
|
+
ModelSource,
|
|
33
|
+
Modality,
|
|
34
|
+
} from "../../src/types";
|
|
35
|
+
|
|
36
|
+
// ── 合并双区域数据 ──
|
|
37
|
+
|
|
38
|
+
function tagRegion<T extends { id: string }>(items: T[], r: string): (T & { region: string })[] {
|
|
39
|
+
return items.map((m) => ({ ...m, region: r }));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const cnProviders = _providersCn.map((p) => ({
|
|
43
|
+
...p,
|
|
44
|
+
models: tagRegion(p.models, "CN"),
|
|
45
|
+
}));
|
|
46
|
+
|
|
47
|
+
const usProviders = _providersUs.map((p) => ({
|
|
48
|
+
...p,
|
|
49
|
+
models: tagRegion(p.models, "US"),
|
|
50
|
+
}));
|
|
51
|
+
|
|
52
|
+
const allProviders = [...usProviders, ...cnProviders];
|
|
53
|
+
|
|
54
|
+
export function getProviders(): ProviderWithModels[] {
|
|
55
|
+
const map = new Map<string, ProviderWithModels>();
|
|
56
|
+
for (const p of allProviders) {
|
|
57
|
+
if (map.has(p.id)) {
|
|
58
|
+
map.get(p.id)!.models.push(...p.models);
|
|
59
|
+
} else {
|
|
60
|
+
map.set(p.id, { ...p, models: [...p.models] });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return [...map.values()];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const _allModels: (Model & { region: string })[] = [
|
|
67
|
+
...tagRegion(_allModelsUs, "US"),
|
|
68
|
+
...tagRegion(_allModelsCn, "CN"),
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
export function getModels(): (Model & { region: string })[] {
|
|
72
|
+
return _allModels;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// ── 查询 ──
|
|
76
|
+
|
|
77
|
+
export function getModel(provider: string, id: string): (Model & { region: string }) | undefined {
|
|
78
|
+
return _getModel(allProviders, _allModels, provider, id) as any;
|
|
79
|
+
}
|
|
80
|
+
export function getModelsByProvider(provider: string): (Model & { region: string })[] {
|
|
81
|
+
return _getModelsByProvider(allProviders, _allModels, provider) as any;
|
|
82
|
+
}
|
|
83
|
+
export function getActiveModels(): (Model & { region: string })[] {
|
|
84
|
+
return _getActiveModels(allProviders, _allModels) as any;
|
|
85
|
+
}
|
|
86
|
+
export function getModelsByFamily(family: string): (Model & { region: string })[] {
|
|
87
|
+
return _getModelsByFamily(allProviders, _allModels, family) as any;
|
|
88
|
+
}
|
|
89
|
+
export function getModelsByCreator(creator: string): (Model & { region: string })[] {
|
|
90
|
+
return _getModelsByCreator(allProviders, _allModels, creator) as any;
|
|
91
|
+
}
|
|
92
|
+
export function getProvider(id: string): ProviderWithModels | undefined {
|
|
93
|
+
const first = allProviders.find((p) => p.id === id);
|
|
94
|
+
if (!first) return undefined;
|
|
95
|
+
// Merge all entries with same id into one
|
|
96
|
+
const all = allProviders.filter((p) => p.id === id);
|
|
97
|
+
return { ...first, models: all.flatMap((p) => p.models) };
|
|
98
|
+
}
|
|
99
|
+
export function getAllProviders(): ProviderWithModels[] {
|
|
100
|
+
// Deduplicate by id, merge models
|
|
101
|
+
const map = new Map<string, ProviderWithModels>();
|
|
102
|
+
for (const p of allProviders) {
|
|
103
|
+
if (map.has(p.id)) {
|
|
104
|
+
map.get(p.id)!.models.push(...p.models);
|
|
105
|
+
} else {
|
|
106
|
+
map.set(p.id, { ...p, models: [...p.models] });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return [...map.values()];
|
|
110
|
+
}
|
|
111
|
+
export function getProviderIcon(id: string): string | undefined {
|
|
112
|
+
return _getProviderIcon(allProviders, id);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// ── 变更日志 ──
|
|
116
|
+
|
|
117
|
+
export interface ChangeEntry {
|
|
118
|
+
ts: string;
|
|
119
|
+
provider: string;
|
|
120
|
+
model: string;
|
|
121
|
+
action: "create" | "update" | "delete";
|
|
122
|
+
commit?: string;
|
|
123
|
+
changes?: Record<string, { from: unknown; to: unknown }>;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const _loadChanges = (): ChangeEntry[] => {
|
|
127
|
+
try {
|
|
128
|
+
const { readFileSync } = require("node:fs") as typeof import("node:fs");
|
|
129
|
+
const { fileURLToPath } = require("node:url") as typeof import("node:url");
|
|
130
|
+
const { resolve, dirname } = require("node:path") as typeof import("node:path");
|
|
131
|
+
const d = typeof __dirname !== "undefined" ? __dirname : dirname(fileURLToPath(import.meta.url));
|
|
132
|
+
const content = readFileSync(resolve(d, "changes.jsonl"), "utf-8");
|
|
133
|
+
return content.trim().split("\n").filter(Boolean).map((l: string) => JSON.parse(l)).reverse();
|
|
134
|
+
} catch {
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export function getChanges(): ChangeEntry[] {
|
|
140
|
+
return _loadChanges();
|
|
141
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@anyllmtoken/modelx-data",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Cross-provider AI model data — specs, pricing, capabilities across 30+ providers",
|
|
5
|
+
"main": "./index.ts",
|
|
6
|
+
"types": "./index.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.ts"
|
|
9
|
+
},
|
|
10
|
+
"files": ["index.ts", "changes.jsonl"],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public",
|
|
14
|
+
"provenance": true
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"prepublishOnly": "cd ../.. && bun run generate && bun run generate:cn"
|
|
18
|
+
}
|
|
19
|
+
}
|