language-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/.editorconfig +10 -0
- package/.gitattributes +4 -0
- package/.releaserc.js +129 -0
- package/LICENSE +21 -0
- package/README.md +165 -0
- package/dist/aliases.d.ts +1 -0
- package/dist/aliases.js +5 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/models.d.ts +170 -0
- package/dist/models.js +69803 -0
- package/dist/parser.d.ts +86 -0
- package/dist/parser.js +390 -0
- package/dist/providers.d.ts +1 -0
- package/dist/providers.js +76 -0
- package/dist/types.d.ts +127 -0
- package/dist/types.js +1 -0
- package/eslint.config.js +3 -0
- package/generate/build-models.ts +150 -0
- package/generate/overwrites.ts +12 -0
- package/package.json +32 -0
- package/publish.js +32 -0
- package/roadmap.md +54 -0
- package/src/aliases.ts +5 -0
- package/src/index.ts +10 -0
- package/src/models.d.ts +170 -0
- package/src/models.js +70434 -0
- package/src/parser.ts +485 -0
- package/src/providers.ts +79 -0
- package/src/types.ts +135 -0
- package/tests/parser.test.ts +11 -0
- package/tests/regex.test.ts +42 -0
- package/tests/selector.test.ts +53 -0
- package/tests/setup.ts +0 -0
- package/tsconfig.json +19 -0
- package/vitest.config.ts +21 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
|
|
2
|
+
import { modelPattern } from '../src'
|
|
3
|
+
|
|
4
|
+
describe('regex', () => {
|
|
5
|
+
const testCases = [
|
|
6
|
+
'frontier(pdf,cost<1,evals>95)',
|
|
7
|
+
'opensource(reasoning,code,throughput,swebench>50)',
|
|
8
|
+
'gpt-4o(pdf,cost<15)',
|
|
9
|
+
'frontier(thread:1234,json)',
|
|
10
|
+
'gemini(reasoning,slack,discord)',
|
|
11
|
+
'claude-3.7-sonnet@vertex:eu(reasoning:high)',
|
|
12
|
+
'gpt-4o(latency,reasoning)',
|
|
13
|
+
'anthropic/claude-3.7-sonnet@vertex:eu(reasoning:high)',
|
|
14
|
+
'gpt-4o@azure:westus(pdf,cost<20)',
|
|
15
|
+
'gemini-2.5-pro@gcp:asia(code,throughput>500)',
|
|
16
|
+
'gemini(slack,discord.sendMessage)',
|
|
17
|
+
'anthropic(reasoning,github,jira.createTicket)',
|
|
18
|
+
'opensource(reasoning,stripe,twilio.sendSMS)',
|
|
19
|
+
'frontier(JSON,Person)',
|
|
20
|
+
'gpt-4o(JSONArray,Product[])',
|
|
21
|
+
'claude(Text)',
|
|
22
|
+
'anthropic(TextArray)',
|
|
23
|
+
'gemini(Markdown)',
|
|
24
|
+
'opensource(Code:TypeScript,code)',
|
|
25
|
+
'r1(output:{address:string,phoneNumber:number},cost)',
|
|
26
|
+
'frontier(dealReviewBenchmark>75)',
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
const invalidTestCases = ['gemini@test@hello(', 'gemini@test@hello(**)', '**gemini@test@hello(**', 'gpt-4o(test', 'gpt-4o)test(', 'gemini)', '(reasoning)']
|
|
30
|
+
|
|
31
|
+
for (const testCase of testCases) {
|
|
32
|
+
it(`should match ${testCase}`, () => {
|
|
33
|
+
expect(modelPattern.test(testCase)).toBe(true)
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
for (const testCase of invalidTestCases) {
|
|
38
|
+
it(`should not match ${testCase}`, () => {
|
|
39
|
+
expect(modelPattern.test(testCase)).toBe(false)
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
})
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
|
|
2
|
+
import { getModel, getModels } from '../src'
|
|
3
|
+
|
|
4
|
+
describe('selector', () => {
|
|
5
|
+
it('should return a model', () => {
|
|
6
|
+
const model = getModel('gemini')
|
|
7
|
+
expect(model).toBeDefined()
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
it('should fail to find a model', () => {
|
|
11
|
+
// Expect an error to be thrown
|
|
12
|
+
const model = getModel('google/gemini-2.0-flash-001:reasoning')
|
|
13
|
+
|
|
14
|
+
expect(model).toBeDefined()
|
|
15
|
+
expect(model?.slug).toBe(undefined)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('should return a model with capabilities', () => {
|
|
19
|
+
const model = getModel('anthropic/claude-3.7-sonnet')
|
|
20
|
+
expect(model).toBeDefined()
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('should return the same model when seed is provided', () => {
|
|
24
|
+
const models = Array(10)
|
|
25
|
+
.fill(0)
|
|
26
|
+
.map((_, i) => getModel('gemini(seed:123)'))
|
|
27
|
+
|
|
28
|
+
// Ensure all models are the same
|
|
29
|
+
expect(models.every((m) => m?.slug === models[0]?.slug)).toBe(true)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('should return a Claude 3.7 Sonnet model with a custom slug', () => {
|
|
33
|
+
const model = getModel('anthropic/claude-3.7-sonnet:thinking')
|
|
34
|
+
expect(model).toBeDefined()
|
|
35
|
+
expect(model?.slug).toBe('anthropic/claude-3.7-sonnet:thinking')
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('should return a Claude 3.7 Sonnet model with reasoning capabilities', () => {
|
|
39
|
+
const model = getModel('anthropic/claude-3.7-sonnet(reasoning)')
|
|
40
|
+
expect(model).toBeDefined()
|
|
41
|
+
expect(model?.slug).toBe('anthropic/claude-3.7-sonnet:thinking')
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('should return multiple models', () => {
|
|
45
|
+
const models = getModels('claude-3.7-sonnet:thinking,r1')
|
|
46
|
+
expect(models.length).toBe(2)
|
|
47
|
+
|
|
48
|
+
// Special case for claude, it supports thinking using a different API
|
|
49
|
+
// structure than other models unfortunately.
|
|
50
|
+
expect(models[0]?.slug).toBe('anthropic/claude-3.7-sonnet:thinking')
|
|
51
|
+
expect(models[1]?.slug).toBe('deepseek/deepseek-r1')
|
|
52
|
+
})
|
|
53
|
+
})
|
package/tests/setup.ts
ADDED
|
File without changes
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "tsconfig/src/base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"emitDeclarationOnly": false,
|
|
8
|
+
"noEmit": false,
|
|
9
|
+
"outDir": "./dist",
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"paths": {
|
|
12
|
+
"@/*": ["./src/*"]
|
|
13
|
+
},
|
|
14
|
+
"allowJs": true,
|
|
15
|
+
"skipLibCheck": true
|
|
16
|
+
},
|
|
17
|
+
"include": ["./src/**/*.ts", "./src/models.js", "./src/models.d.ts"],
|
|
18
|
+
"exclude": ["node_modules", "dist", "**/*.test.ts", "build/**/*.ts", "src/demo.ts"]
|
|
19
|
+
}
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config'
|
|
2
|
+
import { resolve } from 'path'
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
test: {
|
|
6
|
+
include: ['**/*.{test,spec}.{js,ts,jsx,tsx}'],
|
|
7
|
+
environment: 'node',
|
|
8
|
+
},
|
|
9
|
+
resolve: {
|
|
10
|
+
alias: {
|
|
11
|
+
'@payload-config': resolve(__dirname, '../../payload.config.ts'),
|
|
12
|
+
'@': resolve(__dirname, '../..'),
|
|
13
|
+
'@/lib': resolve(__dirname, '../../lib'),
|
|
14
|
+
'@/.velite': resolve(__dirname, '../../.velite'),
|
|
15
|
+
'@/app': resolve(__dirname, '../../app'),
|
|
16
|
+
'@/collections': resolve(__dirname, '../../collections'),
|
|
17
|
+
'@/tasks': resolve(__dirname, '../../tasks'),
|
|
18
|
+
'@/scripts': resolve(__dirname, '../../scripts'),
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
})
|