language-models 0.1.0 → 0.2.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/.turbo/turbo-build.log +5 -0
- package/.turbo/turbo-test.log +18 -0
- package/README.md +56 -142
- package/data/models.json +18805 -0
- package/dist/aliases.d.ts +5 -1
- package/dist/aliases.d.ts.map +1 -0
- package/dist/aliases.js +40 -4
- package/dist/aliases.js.map +1 -0
- package/dist/data/models.json +18805 -0
- package/dist/index.d.ts +10 -7
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -7
- package/dist/index.js.map +1 -0
- package/dist/models.d.ts +94 -167
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +109 -69803
- package/dist/models.js.map +1 -0
- package/package.json +25 -23
- package/scripts/fetch-models.ts +115 -0
- package/src/aliases.test.ts +319 -0
- package/src/aliases.ts +48 -4
- package/src/index.test.ts +400 -0
- package/src/index.ts +20 -9
- package/src/models.test.ts +392 -0
- package/src/models.ts +174 -0
- package/tsconfig.json +5 -15
- package/vitest.config.ts +4 -14
- package/.editorconfig +0 -10
- package/.gitattributes +0 -4
- package/.releaserc.js +0 -129
- package/LICENSE +0 -21
- package/dist/parser.d.ts +0 -86
- package/dist/parser.js +0 -390
- package/dist/providers.d.ts +0 -1
- package/dist/providers.js +0 -76
- package/dist/types.d.ts +0 -127
- package/dist/types.js +0 -1
- package/eslint.config.js +0 -3
- package/generate/build-models.ts +0 -150
- package/generate/overwrites.ts +0 -12
- package/publish.js +0 -32
- package/roadmap.md +0 -54
- package/src/models.d.ts +0 -170
- package/src/models.js +0 -70434
- package/src/parser.ts +0 -485
- package/src/providers.ts +0 -79
- package/src/types.ts +0 -135
- package/tests/parser.test.ts +0 -11
- package/tests/regex.test.ts +0 -42
- package/tests/selector.test.ts +0 -53
- package/tests/setup.ts +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
/**
|
|
2
|
+
* language-models - Model listing and resolution
|
|
3
|
+
*
|
|
4
|
+
* Lists all available models and resolves aliases to full model IDs.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export { resolve, resolveWithProvider, list, get, search, DIRECT_PROVIDERS, type ModelInfo, type ProviderEndpoint, type ResolvedModel, type DirectProvider } from './models.js';
|
|
9
|
+
export { ALIASES } from './aliases.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,IAAI,EACJ,GAAG,EACH,MAAM,EACN,gBAAgB,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,cAAc,EACpB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
/**
|
|
2
|
+
* language-models - Model listing and resolution
|
|
3
|
+
*
|
|
4
|
+
* Lists all available models and resolves aliases to full model IDs.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
export { resolve, resolveWithProvider, list, get, search, DIRECT_PROVIDERS } from './models.js';
|
|
9
|
+
export { ALIASES } from './aliases.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,OAAO,EACP,mBAAmB,EACnB,IAAI,EACJ,GAAG,EACH,MAAM,EACN,gBAAgB,EAKjB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/models.d.ts
CHANGED
|
@@ -1,170 +1,97 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Model listing and resolution
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Provider endpoint information for direct API access
|
|
6
|
+
*/
|
|
7
|
+
export interface ProviderEndpoint {
|
|
8
|
+
/** Provider's API base URL (e.g., https://api.anthropic.com/v1) */
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
/** Provider's model ID (e.g., claude-opus-4-5-20251101) */
|
|
11
|
+
modelId: string;
|
|
6
12
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
export interface ModelInfo {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
context_length: number;
|
|
18
|
+
pricing: {
|
|
19
|
+
prompt: string;
|
|
20
|
+
completion: string;
|
|
21
|
+
};
|
|
22
|
+
architecture?: {
|
|
23
|
+
modality: string;
|
|
24
|
+
input_modalities: string[];
|
|
25
|
+
output_modalities: string[];
|
|
26
|
+
};
|
|
27
|
+
/** Provider slug (e.g., 'anthropic', 'openai', 'google') */
|
|
28
|
+
provider?: string;
|
|
29
|
+
/** Provider's native model ID for direct API calls */
|
|
30
|
+
provider_model_id?: string;
|
|
31
|
+
/** Provider endpoint info for direct routing */
|
|
32
|
+
endpoint?: ProviderEndpoint;
|
|
14
33
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
34
|
+
/**
|
|
35
|
+
* List all available models
|
|
36
|
+
*/
|
|
37
|
+
export declare function list(): ModelInfo[];
|
|
38
|
+
/**
|
|
39
|
+
* Get a model by exact ID
|
|
40
|
+
*/
|
|
41
|
+
export declare function get(id: string): ModelInfo | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Search models by query string
|
|
44
|
+
* Searches in id and name fields
|
|
45
|
+
*/
|
|
46
|
+
export declare function search(query: string): ModelInfo[];
|
|
47
|
+
/**
|
|
48
|
+
* Resolve a model alias or partial name to a full model ID
|
|
49
|
+
*
|
|
50
|
+
* Resolution order:
|
|
51
|
+
* 1. Check aliases (e.g., 'opus' -> 'anthropic/claude-opus-4.5')
|
|
52
|
+
* 2. Check if it's already a full ID (contains '/')
|
|
53
|
+
* 3. Search for first matching model
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* resolve('opus') // 'anthropic/claude-opus-4.5'
|
|
57
|
+
* resolve('gpt-4o') // 'openai/gpt-4o'
|
|
58
|
+
* resolve('claude-sonnet') // 'anthropic/claude-sonnet-4.5'
|
|
59
|
+
* resolve('llama-70b') // 'meta-llama/llama-3.3-70b-instruct'
|
|
60
|
+
*/
|
|
61
|
+
export declare function resolve(input: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* Providers that support direct SDK access (not via OpenRouter)
|
|
64
|
+
* These providers have special capabilities like MCP, extended thinking, etc.
|
|
65
|
+
*/
|
|
66
|
+
export declare const DIRECT_PROVIDERS: readonly ["openai", "anthropic", "google"];
|
|
67
|
+
export type DirectProvider = typeof DIRECT_PROVIDERS[number];
|
|
68
|
+
/**
|
|
69
|
+
* Result of resolving a model with provider routing info
|
|
70
|
+
*/
|
|
71
|
+
export interface ResolvedModel {
|
|
72
|
+
/** OpenRouter-style model ID (e.g., 'anthropic/claude-opus-4.5') */
|
|
73
|
+
id: string;
|
|
74
|
+
/** Provider slug (e.g., 'anthropic', 'openai', 'google') */
|
|
75
|
+
provider: string;
|
|
76
|
+
/** Provider's native model ID (e.g., 'claude-opus-4-5-20251101') */
|
|
77
|
+
providerModelId?: string;
|
|
78
|
+
/** Whether this provider supports direct SDK routing */
|
|
79
|
+
supportsDirectRouting: boolean;
|
|
80
|
+
/** Full model info if available */
|
|
81
|
+
model?: ModelInfo;
|
|
27
82
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
interface ProviderInfo {
|
|
44
|
-
name: string
|
|
45
|
-
displayName: string
|
|
46
|
-
baseUrl: string
|
|
47
|
-
dataPolicy: DataPolicy
|
|
48
|
-
headquarters?: string // Optional based on examples
|
|
49
|
-
hasChatCompletions: boolean
|
|
50
|
-
hasCompletions: boolean
|
|
51
|
-
isAbortable: boolean
|
|
52
|
-
moderationRequired: boolean
|
|
53
|
-
group: string
|
|
54
|
-
editors: never[] // Assuming these are always empty based on examples
|
|
55
|
-
owners: never[] // Assuming these are always empty based on examples
|
|
56
|
-
isMultipartSupported: boolean
|
|
57
|
-
statusPageUrl: string | null
|
|
58
|
-
byokEnabled: boolean
|
|
59
|
-
isPrimaryProvider: boolean
|
|
60
|
-
icon: Icon
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Represents an entry in the 'providers' array within a Model
|
|
64
|
-
interface ModelProvider {
|
|
65
|
-
name: string
|
|
66
|
-
slug: string
|
|
67
|
-
quantization: string | null
|
|
68
|
-
context: number
|
|
69
|
-
maxCompletionTokens: number | null // Can be null in examples
|
|
70
|
-
pricing: Pricing // Use the common Pricing type
|
|
71
|
-
supportedParameters: string[]
|
|
72
|
-
inputCost: number
|
|
73
|
-
outputCost: number
|
|
74
|
-
throughput?: number // Optional based on examples
|
|
75
|
-
latency?: number // Optional based on examples
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Represents the nested 'features.supportedParameters' object
|
|
79
|
-
interface SupportedParametersFeatures {
|
|
80
|
-
responseFormat?: boolean
|
|
81
|
-
structuredOutputs?: boolean
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Base Model structure (common fields without nested endpoint/providers)
|
|
85
|
-
// This helps avoid circular type definitions initially
|
|
86
|
-
interface ModelBase {
|
|
87
|
-
slug: string
|
|
88
|
-
hfSlug: string | null
|
|
89
|
-
updatedAt: string
|
|
90
|
-
createdAt: string
|
|
91
|
-
hfUpdatedAt: string | null // Assuming string like others, though only null seen
|
|
92
|
-
name: string
|
|
93
|
-
shortName: string
|
|
94
|
-
author: string
|
|
95
|
-
description: string
|
|
96
|
-
modelVersionGroupId: string | null
|
|
97
|
-
contextLength: number
|
|
98
|
-
inputModalities: string[]
|
|
99
|
-
outputModalities: string[]
|
|
100
|
-
hasTextOutput: boolean
|
|
101
|
-
group: string
|
|
102
|
-
instructType: string | null
|
|
103
|
-
defaultSystem: string | null // Assuming string, though only null seen
|
|
104
|
-
defaultStops: string[] // Use string[] as it can contain values
|
|
105
|
-
hidden: boolean
|
|
106
|
-
router: string | null // Assuming string, though only null seen
|
|
107
|
-
warningMessage: string | null
|
|
108
|
-
permaslug: string
|
|
109
|
-
reasoningConfig: ReasoningConfig | null
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Define Endpoint structure, referencing ModelBase for its 'model' property
|
|
113
|
-
interface Endpoint {
|
|
114
|
-
id: string
|
|
115
|
-
name: string
|
|
116
|
-
contextLength: number
|
|
117
|
-
model: ModelBase // Reference the base model structure
|
|
118
|
-
modelVariantSlug: string
|
|
119
|
-
modelVariantPermaslug: string
|
|
120
|
-
providerName: string
|
|
121
|
-
providerInfo: ProviderInfo
|
|
122
|
-
providerDisplayName: string
|
|
123
|
-
providerModelId: string
|
|
124
|
-
providerGroup: string
|
|
125
|
-
isCloaked: boolean
|
|
126
|
-
quantization: string | null
|
|
127
|
-
variant: string
|
|
128
|
-
isSelfHosted: boolean
|
|
129
|
-
canAbort: boolean
|
|
130
|
-
maxPromptTokens: number | null
|
|
131
|
-
maxCompletionTokens: number | null // Endpoint might have different limits
|
|
132
|
-
maxPromptImages: number | null
|
|
133
|
-
maxTokensPerImage: number | null
|
|
134
|
-
supportedParameters: string[]
|
|
135
|
-
isByok: boolean
|
|
136
|
-
moderationRequired: boolean
|
|
137
|
-
dataPolicy: DataPolicy // Data policy specific to the endpoint variant
|
|
138
|
-
pricing: Pricing // Pricing specific to the endpoint variant
|
|
139
|
-
isHidden: boolean
|
|
140
|
-
isDeranked: boolean
|
|
141
|
-
isDisabled: boolean
|
|
142
|
-
supportsToolParameters: boolean
|
|
143
|
-
supportsReasoning: boolean
|
|
144
|
-
supportsMultipart: boolean
|
|
145
|
-
limitRpm: number | null
|
|
146
|
-
limitRpd: number | null
|
|
147
|
-
hasCompletions: boolean
|
|
148
|
-
hasChatCompletions: boolean
|
|
149
|
-
features: {
|
|
150
|
-
supportedParameters?: SupportedParametersFeatures
|
|
151
|
-
}
|
|
152
|
-
providerRegion: string | null // Assuming string, though only null seen
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// --- Final Composed Model Interface ---
|
|
156
|
-
|
|
157
|
-
// Extend ModelBase and add the nested structures
|
|
158
|
-
interface Model extends ModelBase {
|
|
159
|
-
endpoint: Endpoint | null // Endpoint can be null
|
|
160
|
-
sorting: Sorting
|
|
161
|
-
providers: ModelProvider[] // Array can be empty
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// --- The Default Export ---
|
|
165
|
-
|
|
166
|
-
declare const _default: {
|
|
167
|
-
models: Model[]
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export default _default
|
|
83
|
+
/**
|
|
84
|
+
* Resolve a model alias and get full routing information
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* const info = resolveWithProvider('opus')
|
|
88
|
+
* // {
|
|
89
|
+
* // id: 'anthropic/claude-opus-4.5',
|
|
90
|
+
* // provider: 'anthropic',
|
|
91
|
+
* // providerModelId: 'claude-opus-4-5-20251101',
|
|
92
|
+
* // supportsDirectRouting: true,
|
|
93
|
+
* // model: { ... }
|
|
94
|
+
* // }
|
|
95
|
+
*/
|
|
96
|
+
export declare function resolveWithProvider(input: string): ResolvedModel;
|
|
97
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,mEAAmE;IACnE,OAAO,EAAE,MAAM,CAAA;IACf,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE;QACP,MAAM,EAAE,MAAM,CAAA;QACd,UAAU,EAAE,MAAM,CAAA;KACnB,CAAA;IACD,YAAY,CAAC,EAAE;QACb,QAAQ,EAAE,MAAM,CAAA;QAChB,gBAAgB,EAAE,MAAM,EAAE,CAAA;QAC1B,iBAAiB,EAAE,MAAM,EAAE,CAAA;KAC5B,CAAA;IACD,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,sDAAsD;IACtD,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,gDAAgD;IAChD,QAAQ,CAAC,EAAE,gBAAgB,CAAA;CAC5B;AAeD;;GAEG;AACH,wBAAgB,IAAI,IAAI,SAAS,EAAE,CAElC;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAErD;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,CAMjD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAwB7C;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,4CAA6C,CAAA;AAC1E,MAAM,MAAM,cAAc,GAAG,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAA;AAE5D;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,oEAAoE;IACpE,EAAE,EAAE,MAAM,CAAA;IACV,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAA;IAChB,oEAAoE;IACpE,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,wDAAwD;IACxD,qBAAqB,EAAE,OAAO,CAAA;IAC9B,mCAAmC;IACnC,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAiBhE"}
|