language-models 2.1.1 → 2.1.3
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 +1 -1
- package/.turbo/turbo-test.log +14 -3
- package/CHANGELOG.md +10 -0
- package/LICENSE +21 -0
- package/README.md +104 -43
- package/package.json +12 -12
package/.turbo/turbo-build.log
CHANGED
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
|
|
2
|
-
> language-models@2.
|
|
3
|
-
> vitest
|
|
2
|
+
> language-models@2.1.1 test /Users/nathanclevenger/projects/primitives.org.ai/packages/language-models
|
|
3
|
+
> vitest
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
DEV v2.1.9 /Users/nathanclevenger/projects/primitives.org.ai/packages/language-models
|
|
7
7
|
|
|
8
|
+
✓ src/aliases.test.ts (48 tests) 8ms
|
|
9
|
+
✓ src/models.test.ts (41 tests) 8ms
|
|
10
|
+
✓ src/index.test.ts (39 tests) 11ms
|
|
11
|
+
|
|
12
|
+
Test Files 3 passed (3)
|
|
13
|
+
Tests 128 passed (128)
|
|
14
|
+
Start at 06:45:30
|
|
15
|
+
Duration 356ms (transform 238ms, setup 0ms, collect 326ms, tests 28ms, environment 0ms, prepare 112ms)
|
|
16
|
+
|
|
17
|
+
PASS Waiting for file changes...
|
|
18
|
+
press h to show help, press q to quit
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# language-models
|
|
2
2
|
|
|
3
|
+
## 2.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Documentation and testing improvements
|
|
8
|
+
- Add deterministic AI testing suite with self-validating patterns
|
|
9
|
+
- Apply StoryBrand narrative to all package READMEs
|
|
10
|
+
- Update TESTING.md with four principles of deterministic AI testing
|
|
11
|
+
- Fix duplicate examples package name conflict
|
|
12
|
+
|
|
3
13
|
## 2.1.1
|
|
4
14
|
|
|
5
15
|
## 2.0.3
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 .org.ai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,79 +1,140 @@
|
|
|
1
1
|
# language-models
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Stop memorizing model IDs. Start shipping.**
|
|
4
|
+
|
|
5
|
+
You're building AI-powered applications, but every provider has different naming conventions. Is it `claude-opus-4-5-20251101` or `anthropic/claude-opus-4.5`? Was it `gpt-4o` or `openai/gpt-4o`? You shouldn't have to care.
|
|
6
|
+
|
|
7
|
+
## The Problem
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
// Without language-models: fragile, provider-specific, constantly breaking
|
|
11
|
+
const model = 'anthropic/claude-3-opus-20240229' // Wait, is this still current?
|
|
12
|
+
const model = 'claude-opus-4-5-20251101' // Or was it this format?
|
|
13
|
+
const model = 'anthropic/claude-opus-4.5' // Which one does OpenRouter want?
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## The Solution
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
// With language-models: simple, memorable, always resolves correctly
|
|
20
|
+
import { resolve } from 'language-models'
|
|
21
|
+
|
|
22
|
+
resolve('opus') // 'anthropic/claude-opus-4.5'
|
|
23
|
+
resolve('sonnet') // 'anthropic/claude-sonnet-4.5'
|
|
24
|
+
resolve('gpt') // 'openai/gpt-4o'
|
|
25
|
+
resolve('llama') // 'meta-llama/llama-4-maverick'
|
|
26
|
+
```
|
|
4
27
|
|
|
5
28
|
## Quick Start
|
|
6
29
|
|
|
30
|
+
**1. Install**
|
|
31
|
+
```bash
|
|
32
|
+
npm install language-models
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**2. Import**
|
|
7
36
|
```typescript
|
|
8
37
|
import { resolve, list, search } from 'language-models'
|
|
38
|
+
```
|
|
9
39
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
resolve('
|
|
14
|
-
resolve('mistral') // 'mistralai/mistral-large-2411'
|
|
15
|
-
|
|
16
|
-
// List all available models
|
|
17
|
-
const models = list()
|
|
40
|
+
**3. Use**
|
|
41
|
+
```typescript
|
|
42
|
+
// Resolve human-friendly aliases to full model IDs
|
|
43
|
+
const modelId = resolve('opus')
|
|
18
44
|
|
|
19
|
-
// Search models
|
|
45
|
+
// Search across 200+ models
|
|
20
46
|
const claudeModels = search('claude')
|
|
47
|
+
|
|
48
|
+
// Get full model catalog with pricing and context info
|
|
49
|
+
const allModels = list()
|
|
21
50
|
```
|
|
22
51
|
|
|
23
|
-
## API
|
|
52
|
+
## API Reference
|
|
24
53
|
|
|
25
54
|
### `resolve(input: string): string`
|
|
26
55
|
|
|
27
|
-
Resolve an alias or partial name to a full model ID.
|
|
56
|
+
Resolve an alias or partial name to a full OpenRouter model ID.
|
|
28
57
|
|
|
29
58
|
```typescript
|
|
30
59
|
resolve('opus') // 'anthropic/claude-opus-4.5'
|
|
31
60
|
resolve('sonnet') // 'anthropic/claude-sonnet-4.5'
|
|
32
61
|
resolve('gpt') // 'openai/gpt-4o'
|
|
33
62
|
resolve('llama') // 'meta-llama/llama-4-maverick'
|
|
34
|
-
resolve('anthropic/claude-opus-4.5') //
|
|
63
|
+
resolve('anthropic/claude-opus-4.5') // Pass-through for full IDs
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### `resolveWithProvider(input: string): ResolvedModel`
|
|
67
|
+
|
|
68
|
+
Get full routing information including provider details for direct SDK access.
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
const info = resolveWithProvider('opus')
|
|
72
|
+
// {
|
|
73
|
+
// id: 'anthropic/claude-opus-4.5',
|
|
74
|
+
// provider: 'anthropic',
|
|
75
|
+
// providerModelId: 'claude-opus-4-5-20251101',
|
|
76
|
+
// supportsDirectRouting: true,
|
|
77
|
+
// model: { name, pricing, context_length, ... }
|
|
78
|
+
// }
|
|
35
79
|
```
|
|
36
80
|
|
|
37
81
|
### `list(): ModelInfo[]`
|
|
38
82
|
|
|
39
|
-
|
|
83
|
+
Get the complete model catalog with pricing, context lengths, and capabilities.
|
|
40
84
|
|
|
41
85
|
### `get(id: string): ModelInfo | undefined`
|
|
42
86
|
|
|
43
|
-
|
|
87
|
+
Fetch a specific model by exact ID.
|
|
44
88
|
|
|
45
89
|
### `search(query: string): ModelInfo[]`
|
|
46
90
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
##
|
|
50
|
-
|
|
51
|
-
|
|
|
52
|
-
|
|
53
|
-
| `opus` | anthropic/claude-opus-4.5 |
|
|
54
|
-
| `sonnet` | anthropic/claude-sonnet-4.5 |
|
|
55
|
-
| `haiku` | anthropic/claude-haiku-4.5 |
|
|
56
|
-
| `
|
|
57
|
-
| `
|
|
58
|
-
| `
|
|
59
|
-
| `gemini
|
|
60
|
-
| `
|
|
61
|
-
| `llama
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
65
|
-
| `
|
|
66
|
-
| `
|
|
67
|
-
| `
|
|
68
|
-
| `
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
91
|
+
Find models matching a search query across IDs and names.
|
|
92
|
+
|
|
93
|
+
## Supported Aliases
|
|
94
|
+
|
|
95
|
+
| You type | You get |
|
|
96
|
+
|----------|---------|
|
|
97
|
+
| `opus` | `anthropic/claude-opus-4.5` |
|
|
98
|
+
| `sonnet` | `anthropic/claude-sonnet-4.5` |
|
|
99
|
+
| `haiku` | `anthropic/claude-haiku-4.5` |
|
|
100
|
+
| `gpt`, `gpt-4o`, `4o` | `openai/gpt-4o` |
|
|
101
|
+
| `o1`, `o3`, `o3-mini` | `openai/o1`, `openai/o3`, `openai/o3-mini` |
|
|
102
|
+
| `gemini`, `flash` | `google/gemini-2.5-flash` |
|
|
103
|
+
| `gemini-pro` | `google/gemini-2.5-pro` |
|
|
104
|
+
| `llama`, `llama-4` | `meta-llama/llama-4-maverick` |
|
|
105
|
+
| `llama-70b` | `meta-llama/llama-3.3-70b-instruct` |
|
|
106
|
+
| `mistral` | `mistralai/mistral-large-2411` |
|
|
107
|
+
| `codestral` | `mistralai/codestral-2501` |
|
|
108
|
+
| `deepseek` | `deepseek/deepseek-chat` |
|
|
109
|
+
| `r1` | `deepseek/deepseek-r1` |
|
|
110
|
+
| `qwen` | `qwen/qwen3-235b-a22b` |
|
|
111
|
+
| `grok` | `x-ai/grok-3` |
|
|
112
|
+
| `sonar` | `perplexity/sonar-pro` |
|
|
113
|
+
|
|
114
|
+
## Direct Provider Routing
|
|
115
|
+
|
|
116
|
+
For providers that support direct SDK access (Anthropic, OpenAI, Google), use `resolveWithProvider` to get the native model ID:
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import { resolveWithProvider, DIRECT_PROVIDERS } from 'language-models'
|
|
120
|
+
|
|
121
|
+
const { provider, providerModelId, supportsDirectRouting } = resolveWithProvider('opus')
|
|
122
|
+
|
|
123
|
+
if (supportsDirectRouting) {
|
|
124
|
+
// Use native SDK with providerModelId
|
|
125
|
+
} else {
|
|
126
|
+
// Route through OpenRouter
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Updating the Model Catalog
|
|
74
131
|
|
|
75
132
|
```bash
|
|
76
133
|
pnpm fetch-models
|
|
77
134
|
```
|
|
78
135
|
|
|
79
|
-
|
|
136
|
+
Fetches the latest models from OpenRouter and updates `data/models.json`.
|
|
137
|
+
|
|
138
|
+
## License
|
|
139
|
+
|
|
140
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "language-models",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "Model listing and resolution for LLM providers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -11,15 +11,6 @@
|
|
|
11
11
|
"types": "./dist/index.d.ts"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
|
-
"scripts": {
|
|
15
|
-
"build": "tsc -p tsconfig.json && cp -r data dist/",
|
|
16
|
-
"dev": "tsc -p tsconfig.json --watch",
|
|
17
|
-
"test": "vitest",
|
|
18
|
-
"typecheck": "tsc --noEmit",
|
|
19
|
-
"lint": "eslint .",
|
|
20
|
-
"clean": "rm -rf dist",
|
|
21
|
-
"fetch-models": "npx tsx scripts/fetch-models.ts"
|
|
22
|
-
},
|
|
23
14
|
"keywords": [
|
|
24
15
|
"ai",
|
|
25
16
|
"llm",
|
|
@@ -28,5 +19,14 @@
|
|
|
28
19
|
"primitives"
|
|
29
20
|
],
|
|
30
21
|
"license": "MIT",
|
|
31
|
-
"dependencies": {}
|
|
32
|
-
|
|
22
|
+
"dependencies": {},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc -p tsconfig.json && cp -r data dist/",
|
|
25
|
+
"dev": "tsc -p tsconfig.json --watch",
|
|
26
|
+
"test": "vitest",
|
|
27
|
+
"typecheck": "tsc --noEmit",
|
|
28
|
+
"lint": "eslint .",
|
|
29
|
+
"clean": "rm -rf dist",
|
|
30
|
+
"fetch-models": "npx tsx scripts/fetch-models.ts"
|
|
31
|
+
}
|
|
32
|
+
}
|